Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
XCOMM $TOG: Imakefile /main/5 1998/08/10 15:51:11 mgreess $
#define IHaveSubdirs
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' 'CXXDEBUGFLAGS=$(CXXDEBUGFLAGS)'
SUBDIRS = dtinfo_start
MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))

View File

@@ -0,0 +1,52 @@
XCOMM $XConsortium: Imakefile /main/5 1996/06/11 17:45:12 cde-hal $
/*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
INCLUDES = -I.
#ifdef AIXArchitecture
LDPOSTLIB=-blibpath:/usr/dt/lib:/X11/lib:/usr/lib/threads:/usr/lib:/lib
#endif
XCOMM something wrong with depend of Xt on IBM
#ifdef AIXArchitecture
DEPLIBS = \
$(DEPDTSVCLIB) \
$(DEPTTLIB) \
$(DEPXMLIB) \
$(DEPXLIB)
#else
DEPLIBS = \
$(DEPDTSVCLIB) \
$(DEPTTLIB) \
$(DEPXMLIB) \
$(DEPXTOOLLIB) \
$(DEPXLIB)
#endif
LOCAL_LIBRARIES = \
$(DTSVCLIB) \
$(TTLIB) \
$(XMLIB) \
$(XTOOLLIB) \
$(XLIB)
PROGRAMS=dtinfo_start
SRCS = dtinfo_start.c
OBJS = dtinfo_start.o
all:: $(OBJS)
LinkSourceFile(dtinfo_start.opnums,$(PROGRAMSRC)/tttypes)
ComplexProgramTarget($(PROGRAMS))

View File

@@ -0,0 +1,622 @@
/* $TOG: dtinfo_start.c /main/9 1999/09/20 13:26:59 mgreess $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*
* This file contains the main program for: dtinfo_start
*/
#include <stdio.h>
#include <stdlib.h>
#include <X11/Intrinsic.h>
#include <Xm/XmP.h>
#include <Xm/XmAll.h>
#include <Dt/EnvControlP.h>
#include <Dt/Action.h>
#include <Dt/DtGetMessageP.h>
#include <Dt/MsgLog.h>
#include <Tt/tt_c.h>
#include "dtinfo_start.h"
#include "dtinfo_start.opnums"
/*
* Operation names, number of arguments and default action names
*/
static const char * LOAD_INFO_LIB_STRING = "DtInfo_LoadInfoLib";
static const int LOAD_INFO_LIB_ARGS = 3;
static const char * LOAD_INFO_LIB_ACTION = "DtInfoStart";
static const char * SHOW_INFO_AT_LOC_STRING = "DtInfo_ShowInfoAtLoc";
static const int SHOW_INFO_AT_LOC_ARGS = 4;
static const char * SHOW_INFO_LIB_SECTION_ACTION = "DtInfoStartAtLoc";
/*
* Static global vars
*/
static Widget top_level;
static XtAppContext app_context;
static const int time_out = 1000; /* milliseconds */
static const int SET_NUM = 1; /* message cat set number */
static const char * name = "DtInfo"; /* ptype name and Xt name */
/*
* Forward declarations for static functions
*/
static int InvokeAction (
char * prog_name,
int op_num,
const char * action_name,
char * exec_host,
char * info_lib,
char * topic);
static void ActionDoneCallback (
DtActionInvocationID id,
XtPointer client_data,
DtActionArg * args,
int num_args,
DtActionStatus status);
static void Exit (
XtPointer client_data,
XtIntervalId id);
static Tt_status ConnectToMessageServer (
char * prog_name);
static void ReceiveMessage (
XtPointer client_data,
int * fd,
XtInputId * id);
static void LogToolTalkError (
DtMsgLogType msg_type,
char * prog_name,
char * function_name,
Tt_status error_num);
static void DieFromToolTalkError (
Widget parent,
char * errfmt,
Tt_status status);
void
main (
int argc,
char ** argv)
{
Display * display;
Arg args[10];
int i = 0;
Tt_status status;
XtSetLanguageProc (NULL, NULL, NULL);
_DtEnvControl (DT_ENV_SET);
XtToolkitInitialize ();
app_context = XtCreateApplicationContext ();
if (!(display = XtOpenDisplay (app_context, NULL, NULL, name,
NULL, NULL, &argc, argv))) {
DtMsgLogMessage (argv[0], DtMsgLogError,
(char *) GETMESSAGE (SET_NUM, 7, "XtOpenDisplay() failed. Perhaps the DISPLAY environment\nvariable is not set or is invalid."));
exit (1);
}
/*
* Create a minimalist application shell - needed by
* DtActionInvoke.
*/
XtSetArg (args[i], XtNallowShellResize, True); i++;
XtSetArg (args[i], XtNmappedWhenManaged, False); i++;
XtSetArg (args[i], XtNheight, 1); i++;
XtSetArg (args[i], XtNwidth, 1); i++;
top_level = XtAppCreateShell (argv[0],
name,
topLevelShellWidgetClass,
display,
args,
i);
XtRealizeWidget (top_level);
/*
* Initialize the desktop
*/
if (DtAppInitialize (app_context, display, top_level, argv[0], name)
== False) {
DtMsgLogMessage (argv[0], DtMsgLogError,
(char *) GETMESSAGE (SET_NUM, 8, "DtAppInitialize() failed. Perhaps the desktop environment\nis not properly installed."));
exit (1);
}
/*
* Connect to the message server
*/
status = ConnectToMessageServer (argv[0]);
if (TT_OK != status) {
char *errfmt;
/*
* An error Message has already been logged.
*/
errfmt = GETMESSAGE (2, 2,
"Could not connect to ToolTalk:\n%s\nExiting ...");
DieFromToolTalkError (top_level, errfmt, status);
}
/*
* Load the datatypes and actions
*/
DtDbLoad();
XtAppMainLoop (app_context);
}
static int
InvokeAction (
char * prog_name,
int op_num,
const char * action_name,
char * exec_host,
char * info_lib,
char * topic)
{
DtActionArg * args;
int num_args = 1;
DtActionInvocationID action_id;
if (op_num == SHOW_INFO_AT_LOC)
num_args = 2;
args = (DtActionArg *) XtCalloc (num_args, sizeof (DtActionArg));
if (!args) {
DtMsgLogMessage (prog_name, DtMsgLogError,
(char *) GETMESSAGE (SET_NUM, 6,
"Cannot invoke an action because malloc(1) failed."));
return (0);
}
args[0].argClass = DtACTION_FILE;
args[0].u.file.name = info_lib;
if (op_num == SHOW_INFO_AT_LOC) {
args[1].argClass = DtACTION_BUFFER;
args[1].u.buffer.name = topic;
args[1].u.buffer.size = strlen (topic) + 1;
args[1].u.buffer.writable = False;
}
action_id = DtActionInvoke (top_level,
(char *) action_name,
args,
num_args,
NULL,
exec_host,
NULL,
True,
(DtActionCallbackProc) ActionDoneCallback,
prog_name);
#if defined(DEBUG)
DtMsgLogMessage (prog_name, DtMsgLogError, "Invoked %s\n", action_name);
#endif
/*
* The following test, comment and code are from:
* $TOP/dtaction/Main.c
*
* "Set up a timer if we didn't get a valid procId --
* since there will be no invocation update in that case."
*/
if (!action_id) {
XtAppAddTimeOut (app_context,
10,
(XtTimerCallbackProc) Exit,
NULL);
}
return (1);
}
/* ARGSUSED */
static void
ActionDoneCallback (
DtActionInvocationID id,
XtPointer client_data,
DtActionArg * args,
int num_args,
DtActionStatus status)
{
#if defined(DEBUG)
char *status_name;
switch (status) {
case DtACTION_DONE:
status_name = "DtACTION_DONE";
break;
case DtACTION_OK:
status_name = "DtACTION_DONE";
break;
case DtACTION_INVOKED:
status_name = "DtACTION_DONE";
break;
case DtACTION_FAILED:
status_name = "DtACTION_DONE";
break;
case DtACTION_CANCELED:
status_name = "DtACTION_DONE";
break;
case DtACTION_INVALID_ID:
status_name = "DtACTION_DONE";
break;
case DtACTION_STATUS_UPDATE:
status_name = "DtACTION_DONE";
break;
default:
status_name = "UNKNOWN";
break;
}
#endif
switch (status) {
case DtACTION_DONE:
case DtACTION_OK:
#if defined(DEBUG)
DtMsgLogMessage ("dtinfo_start", DtMsgLogError,
"Action returned %s\n", status_name);
#endif
XtAppAddTimeOut(app_context, 10 * time_out,
(XtTimerCallbackProc) Exit,
NULL);
case DtACTION_INVOKED:
case DtACTION_FAILED:
case DtACTION_CANCELED:
case DtACTION_INVALID_ID:
case DtACTION_STATUS_UPDATE:
default:
#if defined(DEBUG)
DtMsgLogMessage ("dtinfo_start", DtMsgLogError,
"Action returned %s\n", status_name);
#endif
XtAppAddTimeOut(app_context, 10 * time_out,
(XtTimerCallbackProc) Exit,
NULL);
}
}
static Tt_status
ConnectToMessageServer (
char * prog_name)
{
int mark;
char * procid;
int ttfd;
Tt_status status;
mark = tt_mark();
procid = tt_open();
status = tt_pointer_error (procid);
if (status != TT_OK) {
LogToolTalkError (DtMsgLogError, prog_name,
"tt_open", status);
tt_release (mark);
return (status);
}
status = tt_ptype_declare (name);
if (status != TT_OK) {
LogToolTalkError (DtMsgLogError, prog_name,
"tt_ptype_declare", status);
tt_release (mark);
return (status);
}
ttfd = tt_fd ();
if ((tt_int_error (ttfd)) != TT_OK) {
LogToolTalkError (DtMsgLogError, prog_name,
"tt_fd", status);
tt_release (mark);
return (status);
}
XtAppAddInput (app_context, ttfd, (XtPointer) XtInputReadMask,
ReceiveMessage, (char *) prog_name);
status = tt_session_join (tt_default_session());
if ((tt_int_error (ttfd)) != TT_OK) {
LogToolTalkError (DtMsgLogError, prog_name,
"tt_session_join", status);
tt_release (mark);
return (status);
}
tt_release(mark);
return (TT_OK);
}
/* ARGSUSED */
static void
ReceiveMessage (
XtPointer client_data,
int * fd,
XtInputId * id)
{
static int last_op_num = 0;
int op_num;
int opstatus;
int num_args;
Tt_message message;
const char * action_name;
char * exec_host;
char * locale;
char * topic = NULL;
char * prog_name = (char *) client_data;
static char lang[200];
const char * op_name;
char * info_lib = NULL;
message = tt_message_receive();
/* from tt_message_receive(3), and after examining other TT clients */
if (message == 0) return;
if (tt_pointer_error (message) != TT_OK) {
LogToolTalkError (DtMsgLogError, prog_name,
"tt_message_receive",
tt_pointer_error (message));
exit (1);
}
op_num = tt_message_opnum (message);
switch (op_num) {
case LOAD_INFO_LIB:
op_name = LOAD_INFO_LIB_STRING;
break;
case SHOW_INFO_AT_LOC:
op_name = SHOW_INFO_AT_LOC_STRING;
break;
default: {
/*
* Don't know how I got this message
*/
DtMsgLogMessage (prog_name, DtMsgLogError,
(char *) GETMESSAGE (SET_NUM, 11, "The message operation '%d' is not supported."),
op_num);
tt_message_reject (message);
tt_message_destroy(message);
exit (1);
}
}
/*
* Check the number of arguments
*/
num_args = tt_message_args_count (message);
if ((op_num == LOAD_INFO_LIB && num_args != LOAD_INFO_LIB_ARGS) ||
(op_num == SHOW_INFO_AT_LOC && num_args != SHOW_INFO_AT_LOC_ARGS)) {
DtMsgLogMessage (prog_name, DtMsgLogError,
(char *) GETMESSAGE (SET_NUM, 12, "Message '%s' does not have the required\nnumber of arguments '%d'."),
op_name,
(op_num == LOAD_INFO_LIB) ?
LOAD_INFO_LIB_ARGS : SHOW_INFO_AT_LOC_ARGS);
tt_message_reject (message);
tt_message_destroy(message);
exit (1);
}
/*
* Check for an info lib
*/
info_lib = tt_message_file (message);
if ((tt_ptr_error (info_lib) != TT_OK) || info_lib == NULL) {
/*
* Use DTINFOLIBDEFAULT if it is defined
*/
if ((info_lib = getenv ("DTINFOLIBDEFAULT")) == NULL) {
DtMsgLogMessage (prog_name, DtMsgLogError,
(char *) GETMESSAGE (SET_NUM, 10, "An InfoLib was not provided in the '%s' message\nand the environment variable DTINFOLIBDEFAULT was not defined."),
op_name);
exit (1);
}
}
if ((action_name = tt_message_arg_val (message, 0)) == NULL) {
action_name = (op_num == LOAD_INFO_LIB) ?
LOAD_INFO_LIB_ACTION : SHOW_INFO_LIB_SECTION_ACTION;
DtMsgLogMessage (prog_name, DtMsgLogWarning,
(char *) GETMESSAGE (SET_NUM, 13, "Message '%s' specified a NULL action name.\nAction '%s' will be invoked."),
op_name,
action_name);
}
if ((exec_host = tt_message_arg_val (message, 1)) == NULL) {
DtMsgLogMessage (prog_name, DtMsgLogWarning,
(char *) GETMESSAGE (SET_NUM, 14, "Message '%s' specified a NULL execution host."),
op_name);
}
if ((locale = tt_message_arg_val (message, 2)) == NULL) {
DtMsgLogMessage (prog_name, DtMsgLogWarning,
(char *) GETMESSAGE (SET_NUM, 15, "Message '%s' specified a NULL locale."),
op_name);
}
else {
/*
* Put locale into the environment so that DtActionInvoke
* will propagate it to the dtinfo process.
*/
(void) sprintf (lang, "LANG=%s", locale);
(void) putenv (lang);
}
if (op_num == SHOW_INFO_AT_LOC) {
if ((topic = tt_message_arg_val (message, 3)) == NULL) {
DtMsgLogMessage (prog_name, DtMsgLogError,
(char *) GETMESSAGE (SET_NUM, 16, "Message '%s' specified a NULL topic."),
op_name);
exit (1);
}
}
if (op_num == last_op_num)
{
#if defined(DEBUG)
DtMsgLogMessage("dtinfo_start", DtMsgLogError,
"Received a duplicate tooltalk message: %s",
(op_num == LOAD_INFO_LIB) ?
"LOAD_INFO_LIB" : "SHOW_INFO_AT_LOC" );
#endif
}
else
{
#if defined(DEBUG)
DtMsgLogMessage(
"dtinfo_start", DtMsgLogError,
"Received a tooltalk message: %s\nInvoking action %s",
(op_num==LOAD_INFO_LIB) ? "LOAD_INFO_LIB" : "SHOW_INFO_AT_LOC",
action_name);
#endif
last_op_num = op_num;
opstatus = InvokeAction (prog_name,
op_num,
action_name,
exec_host,
info_lib,
topic);
if (!opstatus) {
tt_message_fail (message);
exit (1);
}
}
tt_message_reply (message);
tt_message_destroy(message);
}
static void
LogToolTalkError (
DtMsgLogType msg_type,
char * prog_name,
char * function_name,
Tt_status error_num)
{
char *message;
message = tt_status_message(error_num);
DtMsgLogMessage (prog_name, msg_type, "%s: %s", function_name, message);
}
#define GETXMSTRING(s, m, d) XmStringCreateLocalized(GETMESSAGE(s,m,d))
static void
ExitCB (Widget dialog, XtPointer client_data, XtPointer call_data)
{
exit((int) client_data);
}
static void
DieFromToolTalkError(Widget parent, char *errfmt, Tt_status status)
{
Arg args[10];
Widget dialog, dialogShell;
char *errmsg, *statmsg, *title;
XmString xms_errmsg, xms_ok, xms_title;
int n;
if (! tt_is_err(status)) return;
statmsg = tt_status_message(status);
errmsg = XtMalloc(strlen(errfmt) + strlen(statmsg) + 2);
sprintf(errmsg, errfmt, statmsg);
xms_ok = GETXMSTRING(2, 3, "OK");
xms_errmsg = XmStringCreateLocalized(errmsg);
xms_title = GETXMSTRING(2, 1, "Dtinfo: Error");
n = 0;
XtSetArg(args[n], XmNautoUnmanage, False); n++;
XtSetArg(args[n], XmNokLabelString, xms_ok); n++;
XtSetArg(args[n], XmNdialogTitle, xms_title); n++;
XtSetArg(args[n], XmNmessageString, xms_errmsg); n++;
XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
dialog = XmCreateErrorDialog(parent, "DtinfoStartError", args, n);
XtAddCallback(dialog, XmNokCallback, ExitCB, (XtPointer) status);
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
/*
* Disable the frame menu from dialog since we don't want the user
* to be able to close dialogs with the frame menu
*/
dialogShell = XtParent(dialog);
n = 0;
XtSetArg(args[n], XmNmwmDecorations, MWM_DECOR_ALL | MWM_DECOR_MENU); n++;
XtSetValues(dialogShell, args, n);
XtManageChild(dialog);
XtRealizeWidget(dialogShell);
XtFree(errmsg);
XmStringFree(xms_ok);
XmStringFree(xms_errmsg);
XmStringFree(xms_title);
while (TRUE)
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll);
}
/* ARGSUSED */
static void
Exit (
XtPointer client_data,
XtIntervalId id)
{
/*
* The following code to determine if DtActionInvoke
* resulted in the posting a dialog is from:
* $TOP/dtaction/Main.c
*/
if (top_level->core.num_popups == 0)
exit(0);
XtAppAddTimeOut (app_context,
time_out,
(XtTimerCallbackProc) Exit,
NULL);
}

View File

@@ -0,0 +1,34 @@
/* $XConsortium: dtinfo_start.h /main/4 1996/09/14 14:52:13 drk $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*
*/
#ifndef _dtinfo_start_h_
#define _dtinfo_start_h_
/*
* macro to get message catalog strings
*/
#ifndef NO_MESSAGE_CATALOG
# ifdef __ultrix
# define _CLIENT_CAT_NAME "dtinfo_start.cat"
# else /* __ultrix */
# define _CLIENT_CAT_NAME "dtinfo_start"
# endif /* __ultrix */
extern char *_DtGetMessage (char *filename, int set_num, int message_num, char *message);
# define GETMESSAGE(set, number, string)\
(_DtGetMessage(_CLIENT_CAT_NAME, set, number, string))
#else /* NO_MESSAGE_CATALOG */
# define GETMESSAGE(set, number, string)\
string
#endif /* NO_MESSAGE_CATALOG */
#endif /* _dtinfo_start_h_ */

View File

@@ -0,0 +1,95 @@
$ $TOG: dtinfo_start.msg /main/2 1999/09/20 13:27:31 mgreess $
$
$ (c) Copyright 1996 Digital Equipment Corporation.
$ (c) Copyright 1996 Hewlett-Packard Company.
$ (c) Copyright 1996 International Business Machines Corp.
$ (c) Copyright 1996 Sun Microsystems, Inc.
$ (c) Copyright 1996 Novell, Inc.
$ (c) Copyright 1996 FUJITSU LIMITED.
$ (c) Copyright 1996 Hitachi.
$
$ ******************************************************************************
$
$set 1
$ The messages in this set will only appear in the users
$ "errorlog" file.
$
$ ******************************************************************************
$
$ Messages 1-5: These messages result from an error in a tt_* function
$ call.
$
1 The ttsession(1) process is not running and the ToolTalk\n\
service cannot restart it.
2 The current default process identifier is out of date or invalid.
3 The specified ToolTalk session is out of date or invalid.
$
$ Message 4: Do not localize the word DtInfo_Start.
$
4 The process type 'DtInfo_Start' is not the\n\
name of an installed process type.
5 The error number is not recognized.
6 Cannot invoke an action because malloc(1) failed.
$
$ Message 7: Do not localize the word DISPLAY. Do not localize the
$ word XtOpenDisplay().
$
7 XtOpenDisplay() failed. Perhaps the DISPLAY environment\n\
variable is not set or is invalid.
$
$ Message 8: Do not localize the word DtAppInitialize().
$
8 DtAppInitialize() failed. Perhaps the desktop environment\n\
is not properly installed.
$
$ Message 9: Do NOT localize the word DTINFOLIBDEFAULT
$
9 An InfoLib was not provided in the '%s' message.\n\
The value of the environment variable DTINFOLIBDEFAULT\n\
(%s) will be used for the InfoLib.
$
$ Message 10: Do NOT localize the word DTINFOLIBDEFAULT
$
10 An InfoLib was not provided in the '%s' message\n\
and the environment variable DTINFOLIBDEFAULT was not defined.
$
$ Messages 11-16: These message are the result of the dtinfo_start
$ getting an error while trying to parse a ToolTalk message.
$
$ Do NOT localize the word NULL
$
11 The message operation '%d' is not supported.
12 Message '%s' does not have the required\n\
number of arguments '%d'.
13 Message '%s' specified a NULL action name.\n\
Action '%s' will be invoked.
14 Message '%s' specified a NULL execution host.
15 Message '%s' specified a NULL locale.
16 Message '%s' specified a NULL topic.
$set 2
$ *****************************************************************************
$ **
$ ** Message set for DieFromToolTalkError Dialog
$ **
$ *****************************************************************************
$ These are the messages for the ToolTalk error dialog
$ "-NEW"
1 Dtinfo: Error
$ "-NEW"
2 "Could not connect to ToolTalk:\n%s\n"
$ "-NEW"
3 OK