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,85 @@
/* $TOG: ActIndicator.c /main/5 1998/07/30 12:11:42 mgreess $ */
/******************************************************************************
*
* File Name: Indicator.c
*
* This file defines the API for interacting with the activity indicator.
*
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Novell, Inc.
*
*****************************************************************************/
#include <X11/Intrinsic.h>
#include <Dt/DtP.h>
#include <Dt/IndicatorM.h>
#include <Tt/tttk.h>
/******** Public Function Declarations ********/
extern void _DtSendActivityNotification( int ) ;
extern void _DtSendActivityDoneNotification( void ) ;
/******** End Public Function Declarations ********/
/*
* _DtSendActivityNotification()
*
* This function provides the client with a means for broadcasting
* notification that an activity has been started. For the present
* time, this will enable the activity indicator for upto a specified
* number of seconds.
*/
void
_DtSendActivityNotification(
int duration )
{
Tt_message msg;
Tt_status status;
msg = tt_pnotice_create(TT_SESSION, "DtActivity_Beginning");
status = tt_ptr_error(msg);
if (status != TT_OK) {
return;
}
status = tt_message_send(msg);
if (status != TT_OK) {
return;
}
tt_message_destroy(msg);
}
/*
* _DtSendActivityDoneNotification()
*
* This function provides the client with a means for broadcasting
* notification that an activity which had earlier been started, is
* now down.
*/
void
_DtSendActivityDoneNotification( void )
{
Tt_message msg;
Tt_status status;
msg = tt_pnotice_create(TT_SESSION, "DtActivity_Began");
status = tt_ptr_error(msg);
if (status != TT_OK) {
return;
}
status = tt_message_send(msg);
if (status != TT_OK) {
return;
}
tt_message_destroy(msg);
}

View File

@@ -0,0 +1,294 @@
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/* -*-C-*-
*******************************************************************************
*
* File: ChkpntClient.c
* Description: CDE client-side checkpoint protocol functions. Private API
* functions for use by the CDE client program.
* Created: Mon Sep 6 09:00:00 1993
* Language: C
*
* $TOG: ChkpntClient.c /main/7 1998/04/09 17:49:06 mgreess $
*
* (C) Copyright 1993, Hewlett-Packard, all rights reserved.
*
*******************************************************************************
*/
#define NUMPROPERTIES 8
#define INVALID_TIME ((Time) -1)
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include "Dt/ChkpntP.h"
#include "DtSvcLock.h"
static struct {
Display *display; /* Display pointer */
Window window; /* Window id for the program */
char *pname; /* Actual name of the program */
Atom aSelection; /* Atom for root selection */
Atom *aProperty; /* Atom array for window props */
int maxprops; /* Size of above array */
Atom aChkpntMsg; /* Atom for Checkpoint message */
Boolean bChkpnt; /* Should I do checkpointing ? */
} dtcp_info; /* Data structure for this client*/
static DtChkpntMsg dtcp_msg; /* Message structure union */
/*
* myCheckClientEvent --- Helper Boolean function to pass to XCheckIfEvent()
* Checks for PropertyNotify & SelectionNotify events in the event queue.
*/
static Bool myCheckClientEvent(Display *display, XEvent *event, char *args)
{
Boolean onMyWindow;
/* Only check the client window events */
_DtSvcProcessLock();
onMyWindow = (event->xany.window == dtcp_info.window);
_DtSvcProcessUnlock();
if (!onMyWindow)
return(False);
switch(event->type)
{
case PropertyNotify:
case SelectionNotify:
return(True);
break;
default:
break;
}
return (False);
}
/*
* myDtChkpntMsgSend --- Helper function: Send a checkpoint message to the listener
*/
static myDtChkpntMsgSend(char *message, char *type)
{
static long msgcount = 0; /* Running count of messages */
static int propnum = 0; /* Which property are we using ? */
static Time oldtime = INVALID_TIME; /* Recycled from old PropertyNotify events */
Time timestamp= INVALID_TIME;
char buf_msgcount[32];
char buf_seconds[128];
struct timeval time_val;
struct timezone time_zone;
XTextProperty tp;
Status status;
Bool bool;
XEvent event;
/* Check to see if checkpoint is actually on */
_DtSvcProcessLock();
if (dtcp_info.bChkpnt == False) {
_DtSvcProcessUnlock();
return(0);
}
/* Fill the message list. ("pname" and "window" were filled at init) */
dtcp_msg.record.type = type;
sprintf(buf_msgcount, "%ld", msgcount);
dtcp_msg.record.count = buf_msgcount; /* Running message count */
gettimeofday(&time_val, &time_zone);
sprintf(buf_seconds,"%lf",time_val.tv_sec + (time_val.tv_usec/1000000.0 ));
dtcp_msg.record.seconds = buf_seconds; /* Info from gettimeofday()*/
dtcp_msg.record.message = message; /* Actual message string */
/*
* We maintain a list of properties and use them round robin -- hoping to
* never run out.
* The listener should then track the message count to see if messages are
* getting dropped.
*/
/* Fill the window property with necessary information */
status = XStringListToTextProperty(dtcp_msg.array,DT_PERF_CHKPNT_MSG_SIZE, &tp);
/* Hang the property on the window */
if ( !( (status == Success) || (status > 0) )) {
_DtSvcProcessUnlock();
return(0);
}
XSetTextProperty(dtcp_info.display, dtcp_info.window,
&tp, dtcp_info.aProperty[propnum]);
XFree(tp.value);
if (oldtime != INVALID_TIME) { /* Valid timestamp to be recycled */
timestamp = oldtime;
}
else { /* Check event queue */
bool = XCheckIfEvent(dtcp_info.display, &event,
myCheckClientEvent, NULL);
if (bool == True) {
if (event.type == PropertyNotify)
timestamp = event.xproperty.time;
else timestamp = event.xselection.time;
}
else { /* Synthesize time by generating a PropertyNotify */
XChangeProperty(dtcp_info.display, dtcp_info.window,
dtcp_info.aProperty[propnum], XA_STRING,
8, PropModeAppend,
(unsigned char *) NULL, 0);
XFlush(dtcp_info.display);
loop:
XWindowEvent(dtcp_info.display, dtcp_info.window,
PropertyChangeMask, &event);
if (event.type == PropertyNotify) {
timestamp = event.xproperty.time;
}
else goto loop;
}
}
/*
* Send the checkpoint message: do a ConvertSelection()
*/
/* Note: Currently listener makes no use of the "aChkpntMsg" info */
XConvertSelection(dtcp_info.display,dtcp_info.aSelection,
dtcp_info.aChkpntMsg, dtcp_info.aProperty[propnum],
dtcp_info.window, timestamp);
XFlush(dtcp_info.display);
/*
* Toss SelectionNotify and PropertyNotify events from the event queue
*/
oldtime = INVALID_TIME;
do {
bool = XCheckIfEvent(dtcp_info.display, &event,
myCheckClientEvent, NULL);
if (event.type == PropertyNotify) /* Save timestamp for recycling */
oldtime = event.xproperty.time;
else oldtime = event.xselection.time;
} while(bool == True);
/*
* Increment the property and message counters
*/
if (++propnum >= dtcp_info.maxprops)
propnum = 0;
msgcount++;
_DtSvcProcessUnlock();
return(1);
}
/*
* _DtPerfChkpntInit --- Initialize the checkpointing mechanism
*/
_DtPerfChkpntInit(Display *display,
Window parentwin,
char *prog_name,
Boolean bChkpnt)
{
static char winstring[32]; /* Storage for window id */
Window tmpwin;
char propname[80]; /* Temp buffer for property name */
Display *tmpdisplay;
int i;
/*
* Fill the dtcp_info structure
*/
_DtSvcProcessLock();
dtcp_info.display = display;
dtcp_info.pname = prog_name;
dtcp_info.bChkpnt = bChkpnt;
dtcp_info.aChkpntMsg = XA_STRING;
/* Pre-compute Atom names and save them away in the dtcp_info structure */
dtcp_info.aSelection = XInternAtom(dtcp_info.display,
DT_PERF_CHKPNT_SEL, False);
dtcp_info.maxprops = NUMPROPERTIES;
dtcp_info.aProperty = (Atom *) malloc(dtcp_info.maxprops * sizeof(Atom));
for (i= 0; i < dtcp_info.maxprops; i++) {
sprintf(propname, "%s_%x", DT_PERF_CLIENT_CHKPNT_PROP, i);
dtcp_info.aProperty[i] = XInternAtom(dtcp_info.display,
propname, False);
}
/*
* Check to see if listener is available
*/
tmpwin = XGetSelectionOwner(dtcp_info.display, dtcp_info.aSelection);
if (tmpwin == None) { /* No listener */
dtcp_info.bChkpnt = False;
_DtSvcProcessUnlock();
return(0);
}
/*
* Create a permanent window for hanging messages on
*/
tmpdisplay = display;
tmpdisplay = XOpenDisplay(""); /* Temporary display connection */
XSetCloseDownMode(tmpdisplay, RetainPermanent);
dtcp_info.window = XCreateSimpleWindow(tmpdisplay, parentwin,
1, 1, 100, 100, 1,
BlackPixel(display,DefaultScreen(display)),
WhitePixel(display,DefaultScreen(display)));
{ /* Hang a name on the permanent window => helps debugging */
char *buffer;
char *array[2];
XTextProperty text_prop;
buffer = malloc(strlen(prog_name) + 8);
sprintf(buffer, "DtPerf %s", prog_name);
array[0] = buffer;
array[1] = "";
XStringListToTextProperty(array, 1, &text_prop);
XSetWMName(tmpdisplay, dtcp_info.window, &text_prop);
XFree(text_prop.value);
if (buffer) free(buffer);
}
XCloseDisplay(tmpdisplay);
/*
* Pre-fill the message structure entries for "pname" and "window"
*/
dtcp_msg.record.pname = prog_name;
sprintf(winstring, "%lx", (long) dtcp_info.window);
dtcp_msg.record.window = winstring;
/*
* Express interest in Property change events
*/
XSelectInput(dtcp_info.display, dtcp_info.window, PropertyChangeMask);
/* Inform listener that you are ready to send messages */
myDtChkpntMsgSend("Begin checkpoint delivery", DT_PERF_CHKPNT_MSG_INIT);
_DtSvcProcessUnlock();
return(1);
} /* DtChkpntInit() */
/*
* _DtPerfChkpntMsgSend --- Send a checkpoint message to the listener
*/
_DtPerfChkpntMsgSend(char *message)
{
myDtChkpntMsgSend(message, DT_PERF_CHKPNT_MSG_CHKPNT);
}
/*
* myDtPerfChkpntEnd --- End the checkpointing message delivery
*/
_DtPerfChkpntEnd()
{
myDtChkpntMsgSend("End checkpoint delivery", DT_PERF_CHKPNT_MSG_END);
return(1);
}

View File

@@ -0,0 +1,199 @@
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/* -*-C-*-
*******************************************************************************
*
* File: ChkpntListen.c
* Description: CDE listener-side checkpoint protocol functions. Internal API
* functions for use by the CDE checkpoint listener.
* Created: Mon Sep 6 09:00:00 1993
* Language: C
*
* $XConsortium: ChkpntListen.c /main/6 1996/08/28 15:14:40 drk $
*
* (C) Copyright 1993, Hewlett-Packard, all rights reserved.
*
*******************************************************************************
*/
#define INVALID_TIME ((Time) -1)
#include <stdio.h>
#include <string.h>
#include "Dt/ChkpntP.h"
#include "DtSvcLock.h"
static struct {
Display *display; /* Display pointer */
Window window; /* Window id for the program */
Atom aSelection; /* Atom for root selection */
Boolean bListen; /* Should I do listening ? */
} dtsvc_info;
/* _DtPerfChkpntListenInit(): Start the Checkpoint listener */
#ifdef _NOPROTO
_DtPerfChkpntListenInit(display, parentwin)
Display *display; /* Current display */
Window parentwin; /* Parent of window associated with listener */
#else
_DtPerfChkpntListenInit(Display *display, Window parentwin)
#endif
{
Time timestamp = INVALID_TIME;
Window tmpwin;
Bool bsuccess = False;
_DtSvcProcessLock();
dtsvc_info.display = display;
dtsvc_info.window = XCreateSimpleWindow(display, parentwin,
1, 1, 100, 100, 1,
BlackPixel(display,DefaultScreen(display)),
WhitePixel(display,DefaultScreen(display)));
dtsvc_info.bListen = True;
/*
* Assert ownership over the appropriate root window selection
*/
dtsvc_info.aSelection = XInternAtom(display, DT_PERF_CHKPNT_SEL, False);
if (XGetSelectionOwner(dtsvc_info.display, dtsvc_info.aSelection) == None) {
if (timestamp == INVALID_TIME) { /* Generate a valid timestamp */
XEvent event;
Atom aProperty;
char propname[80]; /* Temp buffer for property name */
sprintf(propname, "%s_%x", DT_PERF_CLIENT_CHKPNT_PROP, 0);
aProperty = XInternAtom(dtsvc_info.display, propname,False);
XSelectInput(dtsvc_info.display,
dtsvc_info.window, PropertyChangeMask);
XChangeProperty(dtsvc_info.display, dtsvc_info.window,
aProperty, XA_STRING, 8,
PropModeAppend, (unsigned char *) NULL, 0);
XFlush(dtsvc_info.display);
loop:
XWindowEvent(dtsvc_info.display, dtsvc_info.window,
PropertyChangeMask, &event);
if (event.type == PropertyNotify) {
timestamp = event.xproperty.time;
}
else goto loop;
}
XSetSelectionOwner(dtsvc_info.display, dtsvc_info.aSelection,
dtsvc_info.window, timestamp);
tmpwin = XGetSelectionOwner(dtsvc_info.display, dtsvc_info.aSelection);
if ( tmpwin == dtsvc_info.window)
bsuccess = True;/* We are now the listener! */
}
if (bsuccess == False) {
fprintf(stderr,
"\t** Chkpnt listener: Cannot gain ownership of root selection **\n");
fprintf(stderr,
"\t** Chkpnt listener: Selection is owned by window: %lx **\n",
(long) tmpwin);
dtsvc_info.bListen = False;
_DtSvcProcessUnlock();
return(0);
}
/* Express interests in Events on this window */
XSelectInput(dtsvc_info.display, dtsvc_info.window,
SelectionRequest | SelectionClear);
_DtSvcProcessUnlock();
return(1);
}
/* Helper Boolean function to pass to XCheckIfEvent() */
static Bool myCheckSelectionEvent(Display *display, XEvent *event, char *args)
{
_DtSvcProcessLock();
if (event->xany.window != dtsvc_info.window) { /* Only listener window events*/
_DtSvcProcessUnlock();
return(False);
}
else switch(event->type) { /* Selection stuff ? */
case SelectionClear:
case SelectionRequest:
_DtSvcProcessUnlock();
return (True);
break;
default:
_DtSvcProcessUnlock();
return (False);
break;
}
}
/*
* _DtPerfChkpntMsgReceive() Non blocking fetch from message queue
*/
Bool _DtPerfChkpntMsgReceive(DtChkpntMsg *dtcp_msg, Bool bBlock)
{
XEvent event;
Bool bool=True;
XTextProperty tp;
int i;
static char **Stringlist;
static int numfields = 0;
_DtSvcProcessLock();
if (dtsvc_info.bListen == False) {
_DtSvcProcessUnlock();
return(False);
}
if (numfields) { /* Free the storage from last time around */
XFreeStringList(Stringlist);
numfields = 0;
}
if (bBlock == True)
XIfEvent(dtsvc_info.display, &event, myCheckSelectionEvent, NULL);
else
bool = XCheckIfEvent(dtsvc_info.display, &event,
myCheckSelectionEvent, NULL);
if (bool == True) {
switch (event.type) {
case SelectionRequest: /* Message received from a client */
/* Is this a Checkpoint request ?*/
if (event.xselectionrequest.selection == dtsvc_info.aSelection){
/* Correct selection, now fetch the property */
/*
* Note: Need to handle errors if the client is dead
* and the property no longer exists.
*/
XGetTextProperty(dtsvc_info.display,
event.xselectionrequest.requestor,
&tp,
event.xselectionrequest.property);
XDeleteProperty (dtsvc_info.display,
event.xselectionrequest.requestor,
event.xselectionrequest.property);
XTextPropertyToStringList(&tp, &Stringlist, &numfields);
XFree(tp.value);
for (i = 0; i < DT_PERF_CHKPNT_MSG_SIZE; i++)
dtcp_msg->array[i] = (Stringlist)[i];
/* End? Destroy the, RetainPermanent client window */
if (!strcmp(dtcp_msg->record.type, DT_PERF_CHKPNT_MSG_END))
XDestroyWindow(dtsvc_info.display,
event.xselectionrequest.requestor);
}
break;
/* */
case SelectionClear: /* We no longer own the selection */
default:
fprintf(stderr,"\t** Chkpnt listener: Warning - loss of Selection ownership **\n");
bool = False;
break;
}
}
_DtSvcProcessUnlock();
return(bool);
}

View File

@@ -0,0 +1,111 @@
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/* -*-C-*-
**************************************************************************
*
* File: Chkpnt.h
* Description: CDE Private header file. Private API for sending checkpoint
* messages between compliant clients and the checkpoint service
* provider. This API is designed for use by performance
* measurement programs.
*
* Created: Mon Sep 6 09:00 1993
* Language: C
*
* $XConsortium: ChkpntP.h /main/4 1995/10/26 15:18:33 rswiston $
*
* (C) Copyright 1993, Hewlett-Packard, all rights reserved.
*
**************************************************************************
*/
#ifndef _Dt_Perf_Checkpoint_P_h
#define _Dt_Perf_Checkpoint_P_h
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Intrinsic.h>
/*************************************************************************/
/************* Data types ************************************************/
/*************************************************************************/
/* The following definition is ONLY meant for union that follows */
typedef struct {
char *pname; /* Client program name */
char *window; /* Window Id for client */
char *type; /* Type of message */
char *count; /* Running count of messages */
char *seconds; /* Time in seconds from gettimeofday() */
char *message; /* Actual message */
} _DtChkpntMsgFormat;
#define DT_PERF_CHKPNT_MSG_SIZE (sizeof(_DtChkpntMsgFormat) / sizeof(char *))
/* Use the following union for actual message declaration */
typedef union {
_DtChkpntMsgFormat record;
char *array[DT_PERF_CHKPNT_MSG_SIZE];
} DtChkpntMsg;
#define DT_PERF_CHKPNT_MSG_INIT "Init"
#define DT_PERF_CHKPNT_MSG_CHKPNT "Chkpnt"
#define DT_PERF_CHKPNT_MSG_END "End"
/*************************************************************************/
/************* Atom Names ************************************************/
/*************************************************************************/
/* Selection for ICCCM style interaction of client and listener*/
/* This selection is owned by the listener */
#define DT_PERF_CHKPNT_SEL "_DT_PERF_CHKPNT_SEL"
/* Properties attached to the client: Used for message transmission */
#define DT_PERF_CLIENT_CHKPNT_PROP "_DT_PERF_CHKPNT_PROP"
/*************************************************************************/
/************* Client Functions ******************************************/
/*************************************************************************/
/* Note: It is expected that users will invoke the following functions within
#ifdef DT_PERFORMANCE directives. The DT_PERFORMANCE flag should be set,
in the build environment, for the performance-test-enabled builds.
*/
/* Initialize the checkpointing mechanism */
extern _DtPerfChkpntInit(
Display *display, /* Display pointer */
Window parentwin, /* Parent window id */
char *prog_name, /* Name of the client program (argv[0]) */
Boolean bChkpnt /* Boolean: True or False */
);
/* Send a checkpoint message to the listener */
extern _DtPerfChkpntMsgSend(
char *message /* Acual message for transmission */
);
/* End the checkpointing message delivery */
extern _DtPerfChkpntEnd(
);
/*************************************************************************/
/************* Listener Service Functions ********************************/
/*************************************************************************/
/* Initialize the listener */
extern _DtPerfChkpntListenInit(
Display *display, /* Current display */
Window parentwin /* Parent of window associated with listener */
);
/* Fetch a message from message queue */
extern Bool _DtPerfChkpntMsgReceive(
DtChkpntMsg *dtcp_msg, /* Above message available as a structure */
Bool bBlock /* Block until a message is received ? */
);
#endif /*_Dt_Perf_Checkpoint_h*/
/* Do not add anything after this endif. */

View File

@@ -0,0 +1,416 @@
/*
* File: CmdUtility.c $XConsortium: CmdUtility.c /main/4 1995/10/26 15:18:41 rswiston $
* Language: C
*
* (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#ifdef __apollo
#include "/sys5/usr/include/unistd.h"
#else
#include <unistd.h>
#endif
#include <limits.h>
#include <sys/stat.h>
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Dt/Utility.h>
#include <Dt/DtNlUtils.h>
#define _SINGLE "\'"
#define _DOUBLE "\""
/******** Static Function Declarations ********/
static void SkipWhiteSpace(
String string,
int *position) ;
static void FillWord(
char *string,
char *word,
int *position) ;
static void GetWordWithQuotes(
String string,
String word,
int *position) ;
/******** End Static Function Declarations ********/
/*****************************************************************************
*
* SkipWhiteSpace - takes a string and in index ("position") into the
* string and advances "position" until a non-whitespace character is
* encountered.
*
* A "whitespace" character is defined by "isspace".
*
* PARAMETERS:
*
* String string; - The string to search.
*
* int *position; - MODIFIED: Set to the location of the first
* non-whitespace character.
*
*****************************************************************************/
static void
SkipWhiteSpace(
String string,
int *position )
{
string += (*position);
while (
#ifdef NLS16
(!is_multibyte || (mblen (string, MB_CUR_MAX) == 1)) &&
#endif
isspace ((u_char)*string)) {
string++;
(*position)++;
}
}
/*****************************************************************************
*
* FillWord - parses "string" for a complete argument and puts the
* result in "word".
*
* The algorithm was derived by empirical observation and checking the
* (poorly written) Bourne Shell tutorial. A BNF for the shell meta
* characters ", ', and \ was not availble.
*
* The algorithm - until the end of the word is found:
*
* For each character "c":
* If c = \, remove the \ and pass on the next char.
*
* If c = ' or ", must save this in "qchar" and loop until the
* ending quote is found:
* c = the next char
* If c = qchar, found the ending quote, exit this loop
* If c = \
* If qchar = double quote and c2 = next char
* if c2 = \, ", $, or `, remove c and pass on c2
* otherwise, pass on both c and c2
* If qchar = single quote, and c2 = next char:
* if c2 = ', pass on c, remove the ' and exit this loop
* (the ' cannot be escaped)
* otherwise, pass on both c and c2
* Othewise, pass on c
*
* If c = white space, found the end of the word, return
* Otherwise, pass on the char
*
*
* PARAMETERS:
*
* char *string; - The string to search.
*
* char *word; - MODIFIED: Points to the beginning of the word.
*
* int *position - MODIFIED: Starts at the beginning of the string
* and gets advanced past "word".
*
*****************************************************************************/
static void
FillWord(
char *string,
char *word,
int *position )
{
char *qchar;
int len, i;
Boolean found = False;
Boolean done = False;
int j = 0;
char *pbeg = string;
while ((*string != '\0') && (!found)) {
/*
* Check for multibyte chars. The assumption here is that if
* is_multibyte is true and "string" points to a multi-byte char,
* then that entire char should be copied to "word".
*/
#ifdef NLS16
if (is_multibyte && ((len = mblen (string, MB_CUR_MAX)) > 1))
for (i=0; i < len; i++, j++, string++)
word[j] = *string;
else
#endif
{
switch (*string) {
case '\\':
/* Remove the slash and add the following character. */
string++;
#ifdef NLS16
if (is_multibyte && ((len = mblen (string, MB_CUR_MAX)) > 1))
for (i=0; i < len; i++, j++, string++)
word[j] = *string;
else
#endif
word[j++] = *(string)++;
break;
case '\'':
case '\"':
qchar = _DOUBLE;
if (*string == '\'') qchar = _SINGLE;
string++;
/* Search for the ending quote. */
done = False;
while ((!done) && (*string != '\0')) {
#ifdef NLS16
if (is_multibyte && ((len = mblen (string, MB_CUR_MAX)) > 1))
for (i=0; i < len; i++, j++, string++)
word[j] = *string;
else
#endif
{
if (*string == *qchar) {
done = True;
string++;
break;
}
if (*string == '\\') {
/* Must follow the rules of the single or double
* quote - which ever "qchar" points to.
*/
if (!strcmp (qchar, _DOUBLE)) {
if ((DtStrcspn (string+1, "\"\\$`")) == 0) {
/* Skip past the '\', but fill in the
* following character.
*/
string++;
}
else
/* Want to pass on both the '\' and the
* following char.
*/
word[j++] = *(string)++;
/* The '\' is skipped. Fill in the next char. */
#ifdef NLS16
if (is_multibyte && ((len = mblen (string, MB_CUR_MAX)) > 1))
for (i=0; i < len; i++, j++, string++)
word[j] = *string;
else
#endif
word[j++] = *(string)++;
/* The \ and following char are now skipped. */
}
else if (!strcmp (qchar, _SINGLE)) {
/* Must be working on a _SINGLE quoted word. */
if ((DtStrcspn (string+1, "\'")) == 0) {
/*
* Have \', which passes on the \, skips
* the single quote and ends the word. An
* assumption here is that the char following
* the '\' was a single byte single quote
* and there is no need for checking multi-byte.
*/
word[j++] = *(string)++;
/* Now skip the quote. */
string++;
done = True;
break;
}
else {
/*
* Need to pass on both chars. Pass on the
* first char here.
*/
word[j++] = *(string)++;
/*
* The '\' is skipped if present. Fill in the
* next char.
*/
#ifdef NLS16
if (is_multibyte && ((len = mblen (string, MB_CUR_MAX)) > 1))
for (i=0; i < len; i++, j++, string++)
word[j] = *string;
else
#endif
/* Pass on what ever char is there. */
word[j++] = *(string)++;
}
}
}
else
/* This char was not escaped, just add it. */
word[j++] = *(string)++;
}
}
break;
case ' ':
case '\t':
/* Found the end of the word. */
found = True;
string++;
break;
default: {
word[j++] = *(string)++;
}
}
}
}
word [j] = '\0';
*position = *position + (string - pbeg);
}
/*****************************************************************************
*
* GetWordWithQuotes - takes the strings "string" and "word" and an index
* into "string" and fills "word" with one word from "string".
*
* A word is defined in the function "FillWord".
*
* Note that if an ending quote is not found, "position" will be advanced to
* the end of the string.
*
* PARAMETERS:
*
* String string; - String containing the word to be extracted.
*
* String word; - MODIFIED - contains the next word in "string".
*
* int *position; - MODIFIED - starts at beginning of word, ends
* at end of word.
*
*****************************************************************************/
static void
GetWordWithQuotes(
String string,
String word,
int *position )
{
int len = strlen(string);
SkipWhiteSpace (string, position);
if ((*position) >= len) {
word[0] = '\0';
return;
}
string += (*position);
FillWord (string, word, position);
}
/*****************************************************************************
*
* _DtCmdStringToArrayOfStrings - takes a string and an array of pointers
* to strings and breaks the string into whitespace separated words.
*
* A "word" is a sequence of characters that has no whitespace with
* the following exception:
*
* - A word may contain contain whitespace if it is delimited
* by a pair of matching single or double qotes.
*
* "Whitespace" is a tab or blank character.
*
*
* NOTES:
*
* - The space for the "words" is malloc'd and must be free'd by
* the caller.
*
* - "theArray" is NULL terminated.
*
* PARAMETERS:
*
* char theString[]; - The string to parse.
*
* char *theArray[]; - MODIFIED: gets filled with pointers to
* the words that are parsed.
*
*****************************************************************************/
void
_DtCmdStringToArrayOfStrings(
char theString[],
char *theArray[] )
{
int len, i, position;
char *tmp;
tmp = (char *) XtMalloc (1 + strlen (theString));
len=strlen(theString);
for (position=0, i=0; (position <= len) &&
(theString[position] != '\0'); ) {
(void) strcpy (tmp, "");
GetWordWithQuotes (theString, tmp, &position);
/* Check word to see if it contains only trailing blanks. */
if (tmp[0] == '\0')
{
if (position < len)
{
/*
* This parameter is empty, such as "" or '' but we are
* not at the end of the line. Consequently, put an
* empty string in "theArray".
*/
theArray[i] = XtNewString ("");
}
else
{
/*
* Must be at the end of the line.
*/
theArray[i] = (char *) NULL;
break;
}
}
else
theArray[i] = XtNewString (tmp);
i++;
}
/* Null terminate the array of string pointers. */
theArray[i]=NULL;
XtFree ((char *) tmp);
}
/******************************************************************************
*
* _DtCmdFreeStringVector - takes an array of pointers to strings and
* frees the malloc'd space for the strings.
*
* This does NOT free the string vector itself; It assumes that
* stringv is a static i.e. char *stringv[N].
*
* PARAMETERS:
*
* char **stringv; - MODIFIED: Each string in the array is freed.
*
*****************************************************************************/
void
_DtCmdFreeStringVector(
char **stringv )
{
char **pch;
for (pch = stringv; *pch != NULL; pch++) {
XtFree (*pch);
*pch = NULL;
}
}

View File

@@ -0,0 +1,29 @@
/* $XConsortium: Collate.h /main/3 1995/10/26 15:18:49 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/* Hp DT's version of an 8.0 include file; needed for Fnmatch */
#ifndef DtCOLLATE_INCLUDED
#define DtCOLLATE_INCLUDED
#define MASK077 077
#define ENDTABLE 0377 /* end mark of 2 to 1 character */
struct col_21tab {
unsigned char ch1; /* first char of 2 to 1 */
unsigned char ch2; /* second char of 2 to 1 */
unsigned char seqnum; /* sequence number */
unsigned char priority; /* priority */
};
struct col_12tab {
unsigned char seqnum; /* seqnum of second char of 1 to 2 */
unsigned char priority; /* priority of 1 to 2 char */
};
#endif /* DtCOLLATE_INCLUDED */

View File

@@ -0,0 +1,36 @@
/*
* File: CommandM.h $XConsortium: CommandM.h /main/3 1995/10/26 15:18:58 rswiston $
* Language: C
*
* (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef _Dt_CommandM_h
#define _Dt_CommandM_h
/*
* Command Invoker execution window types. Note that a success or
* failure notification will be sent for each request. For
* failures, the only data returned is an error message.
*/
#define DtNO_STDIO "NO_STDIO"
#define DtTERMINAL "TERMINAL"
#define DtPERM_TERMINAL "PERM_TERMINAL"
#define DtOUTPUT_ONLY "OUTPUT_ONLY"
#define DtSHARED_OUTPUT "SHARED_OUTPUT"
/*
* When the session manager starts, it needs a window type (NO-STDIO),
* but if a failure occurs, it does NOT want an error message, but
* instead wants to receive the execution host and the execution
* string. The following define is for this type of request.
*/
#define DtSTART_SESSION "START-SESSION"
#endif /* _Dt_CommandM_h */
/* Do not add anything after this endif. */

View File

@@ -0,0 +1,156 @@
/*
* File: Connect.h $XConsortium: Connect.h /main/3 1995/10/26 15:19:09 rswiston $
* Language: C
*
* (c) Copyright 1990, Hewlett-Packard Company, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef _Dt_connect_h
#define _Dt_connect_h
#include <Dt/DtP.h>
#include <bms/connect.h>
#define DtGetShortHostname Xegetshorthostname
#define DtGetHostname Xegethostname
/*
DESCRIPTION:
These functions are similiar to gethostname(2), however
DtGetHostname always returns a full domain-qualified name
and DtGetShortHostname returns a simple name.
SYNOPSIS:
status = DtGet[Short]Hostname (hostname, size)
int status; Returns 0 on success, -1 on failure.
[Actually it returns what gethostname(2)
returns, which is ambiguous in the
HP-UX manual.]
char *hostname; The hostname is returned here.
int size; The name is truncated to "size - 1" and
is null-terminated.
*/
#define DtGetcwd Xegetcwd
/*
DESCRIPTION:
This function is similar to getcwd except it first checks $PWD.
It only calls getcwd if $PWD is not set.
SYNOPSIS:
cwd = DtGetcwd (buf, size)
char *cwd; Pointer to the returned value. (Typically
the same value as 'buf' that is passed in.)
char *buf; Pointer to memory allocated by the caller.
Buf must be large enough to hold the string.
int size; Size of buf in bytes.
*/
#define DtIsLocalHostP XeIsLocalHostP
/*
DESCRIPTION:
Tests whether a passed-in hostname identifies the host on which
the function is being executed. This handles all combinations of
simple and domain-qualified names for either the hostname passed
in or the one defined on the local host.
WARNING: Returns BOOLEAN, not INT. DONT TREAT IT AS AN INT!
SYNOPSIS:
status = XeIsLocalHostP (hostname);
Boolean status; Returns TRUE if "hostname" identifies the
local host, FALSE otherwise.
char *hostname; The hostname (either simple or domain-
qualified) to test.
*/
#define DtIsSameHostP XeIsSameHostP
/*
DESCRIPTION:
Compares two hostnames to see if they specify the same host.
This handles combinations of simple and domain-qualified names.
This function canonicalizes both names and then compares them.
WARNING: Returns BOOLEAN, not INT. DONT TREAT IT AS AN INT!
SYNOPSIS:
status = DtIsSameHostP (host1, host2);
Boolean status; Returns TRUE if host1 and host2 identify
the same host, FALSE otherwise.
char *host1, *host2; The two hostnames (either simple or
domain-qualified) to compare.
*/
#define DtCreateContextString XeCreateContextString
/*
DESCRIPTION:
DtCreateContextString takes the three parts of a context and
puts them into a single string, in the form "host:/dir/file".
A NEW STRING, OWNED BY THE CALLER, is returned.
SYNOPSIS:
context_string = DtCreateContextString (host, dir, file);
DtString context_string; The returned context. The memory is owned
by the caller. "NULL" is returned if the
context cannot be created.
DtString host; The name of the host.
DtString dir; The directory.
DtString file; The name of the file.
*/
#define DtEliminateDots XeEliminateDots
/*
DESCRIPTION:
This routine removes /./'s and /../'s from a path. It will
OVERWRITE the path IT WAS PASSED. If there are too many /../'s
in the path this function will return NULL, so you better keep
a pointer to the path if you hope to reclaim it.
This function does not handle "host:/directory/file", shell
variables, or other exotic animals.
SYNOPSIS:
fixed_path = DtEliminateDots (path);
DtString fixed_path; A pointer to the same path that was passed in
(though now it is fixed up) or NULL if problems
were encountered.
DtString path; The path that needs fixing up.
*/
#define DtParseFileString XeParseFileString
#endif /* _Dt_connect_h */
/* Do not add anything after this endif. */

View File

@@ -0,0 +1,36 @@
/* $XConsortium: DataTypes.h /main/3 1995/10/26 15:19:20 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/* -*-C-*-
*******************************************************************************
*
* File: DataTypes.h
* Description: This file defines data types that are used throughout the
* DT code.
*
* Common Desktop Environment (CDE)
*
* (c) Copyright 1993 Hewlett-Packard Company
* (c) Copyright 1993 International Business Machines Corp.
* (c) Copyright 1993 Sun Microsystems, Inc.
*
*
* Disclaimer: This file could change between the 10/93 snapshot and the
* final release of CDE 1.0
*
*******************************************************************************
*/
#ifndef _Dt_DataTypes_h
#define _Dt_DataTypes_h
#include <X11/Intrinsic.h>
typedef XtPointer Pointer;
#endif /* _Dt_DataTypes_h */
/* Do not add anything after this endif. */

113
cde/lib/DtSvc/DtUtil2/Dt.ad Normal file
View File

@@ -0,0 +1,113 @@
!######################################################################
!#
!# Dt
!#
!# Common Desktop Environment (Cde)
!#
!# Global Defaults for Cde Desktop
!#
!# (c) Copyright 1993, 1994 Hewlett-Packard Company
!# (c) Copyright 1993, 1994 International Business Machines Corp.
!# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
!# (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary
!# of Novell, Inc.
!#
!# $XConsortium: Dt.ad /main/3 1995/10/26 15:19:31 rswiston $
!#
!######################################################################
*foregroundThreshold: 70
!########
!#
!# Help system specific resources
!#
!#
!# Window Sizes
!#
!# These resources set the window sizes for the Help windows.
!# These resources are complex because they have to override
!# the standard widget resources.
!#
*DtHelpDialog*onHelpDialog.rows: %|nls-30-#23#|
*DtHelpDialog*onHelpDialog.columns: %|nls-31-#69#|
*DtHelpQuickDialog.printShell.printForm.printerField.columns: %|nls-32-#10#|
*DtHelpQuickDialog.printShell.printForm.copiesField.columns: %|nls-33-#4#|
*DtHelpDialog.printShell.printForm.printerField.columns: %|nls-32-#10#|
*DtHelpDialog.printShell.printForm.copiesField.columns: %|nls-33-#4#|
*DtHelpDialog.historyShell*historyTopicList.visibleItemCount: %|nls-34-#5#|
*DtHelpDialog.historyShell*historyVolumeList.visibleItemCount: %|nls-35-#5#|
*DtHelpDialog.searchShell*searchForm.srchWord.columns: %|nls-36-#20#|
*DtHelpDialog.searchShell*resultList.visibleItemCount: %|nls-37-#12#|
*DtHelpDialog.searchShell*fileSelectShell*selList.visibleItemCount: %|nls-38-#12#|
!#
!# Display Area Colors
!#
!# These resources set the colors for the display area (where
!# actual help text is displayed). The resources are complex
!# because they have to override the standard color resources
!# in all cases.
!#
*XmDialogShell.DtHelpDialog*DisplayArea.background: White
*XmDialogShell*XmDialogShell.DtHelpDialog*DisplayArea.background: White
*XmDialogShell.DtHelpDialog*DisplayArea.foreground: Black
*XmDialogShell*XmDialogShell.DtHelpDialog*DisplayArea.foreground: Black
*XmDialogShell.DtHelpQuickDialog*DisplayArea.background: White
*XmDialogShell*XmDialogShell.DtHelpQuickDialog*DisplayArea.background: White
*XmDialogShell.DtHelpQuickDialog*DisplayArea.foreground: Black
*XmDialogShell*XmDialogShell.DtHelpQuickDialog*DisplayArea.foreground: Black
!########
!#
!# Menu Accelerators
!#
!# The following resources establish keyboard accelerators
!# for the most frequently accessed menu commands.
!#
!########
*DtHelpDialog*searchMenu.keyword.acceleratorText: %|nls-1-#Ctrl+K#|
*DtHelpDialog*searchMenu.keyword.accelerator: %|nls-2-#Ctrl<Key>k#|
*DtHelpDialog*navigateMenu.backTrack.acceleratorText: %|nls-3-#Ctrl+B#|
*DtHelpDialog*navigateMenu.backTrack.accelerator: %|nls-4-#Ctrl<Key>b#|
*DtHelpDialog*navigateMenu.homeTopic.acceleratorText: %|nls-7-#Ctrl+H#|
*DtHelpDialog*navigateMenu.homeTopic.accelerator: %|nls-8-#Ctrl<Key>h#|
*DtHelpDialog*fileMenu.close.acceleratorText: %|nls-9-#Alt+F4#|
*DtHelpDialog*fileMenu.close.accelerator: %|nls-10-#Alt<Key>f4#|
*DtHelpDialog*fileMenu.print.acceleratorText: %|nls-21-#Ctrl+P#|
*DtHelpDialog*fileMenu.print.accelerator: %|nls-22-#Ctrl<Key>p#|
*DtHelpDialog*editMenu.copy.acceleratorText: %|nls-23-#Ctrl+C#|
*DtHelpDialog*editMenu.copy.accelerator: %|nls-24-#Ctrl<Key>c#|
!########
!#
!# Non-ISO-8859-1 font resources.
!#
!# The following resources establish fonts used for help information
!# written using a non-ISO-8859-1 code set. The default is to be
!# empty.
!#
!########
%|nls-39-#non iso-8859-1 fonts#|
!#################################################################
!#
!# Cde File Selection dialog global resources
!#
!#################################################################
*XmFileSelectionBox.fileFilterStyle: XmFILTER_HIDDEN_FILES
*XmFileSelectionBox.pathMode: XmPATH_MODE_RELATIVE
*XmFileSelectionBox.resizePolicy: XmRESIZE_GROW
*XmFileSelectionBox*dirTextLabelString: %|nls-14-#Enter path ...#|
*XmFileSelectionBox*applyLabelString: %|nls-15-#Update#|
*XmFileSelectionBox*selectionLabelString: %|nls-16-#Enter file name:#|
*XmFileSelectionBox*dirListLabelString: %|nls-17-#Folders#|
!########################### eof ###################

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,71 @@
/* $TOG: DtGetMessage.c /main/10 1998/07/30 12:12:25 mgreess $ */
/*
* (c) Copyright 1995 Digital Equipment Corporation.
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
* (c) Copyright 1995 FUJITSU LIMITED.
* (c) Copyright 1995 Hitachi.
*/
/******************************************************************************
*
* File Name: DtGetMessage.c
*
* Contains the function for getting localized strings.
*
*****************************************************************************/
#ifndef NO_MESSAGE_CATALOG
#include <stdio.h>
#include <string.h>
#include <nl_types.h>
#include "DtSvcLock.h"
/*****************************************************************************
*
* Function: Dt11GetMessage
*
* Parameters:
*
* char *filename - Filename to open.
*
* int set - The message catalog set number.
*
* int n - The message number.
*
* char *s - The default message if the message is not
* retrieved from a message catalog.
*
* Returns: the string for set 'set' and number 'n'.
*
*****************************************************************************/
char *
Dt11GetMessage(
char *filename,
int set,
int n,
char *s)
{
char *msg;
static int first = 1;
static nl_catd nlmsg_fd;
static char *nlmsg_filename = NULL;
_DtSvcProcessLock();
if ( NULL == nlmsg_filename || 0 != strcmp(nlmsg_filename, filename) )
{
nlmsg_fd = catopen(filename, NL_CAT_LOCALE);
if (nlmsg_filename)
{
free(nlmsg_filename);
nlmsg_filename = NULL;
}
nlmsg_filename = strdup(filename);
}
msg=catgets(nlmsg_fd,set,n,s);
_DtSvcProcessUnlock();
return (msg);
}
#endif

View File

@@ -0,0 +1,47 @@
/* $TOG: DtGetMessageP.h /main/5 1998/07/30 12:14:37 mgreess $
*
* (c) Copyright 1995 Digital Equipment Corporation.
* (c) Copyright 1995 Hewlett-Packard Company.
* (c) Copyright 1995 International Business Machines Corp.
* (c) Copyright 1995 Sun Microsystems, Inc.
* (c) Copyright 1995 Novell, Inc.
* (c) Copyright 1995 FUJITSU LIMITED.
* (c) Copyright 1995 Hitachi.
*
* DtGetMessage.h - Interfaces for the DtSvc library's private message
* catalog APIs
*/
#ifndef _DtGetMessage_h
#define _DtGetMessage_h
#ifdef __cplusplus
extern "C" {
#endif
/*
* External declarations
*/
extern char *Dt11GetMessage (
char *filename,
int set,
int number,
char *string);
/*
* Dt11GETMESSAGE macro
*/
#ifndef NO_MESSAGE_CATALOG
# define _MESSAGE_CAT_NAME "dt"
# define Dt11GETMESSAGE(set, number, string)\
Dt11GetMessage(_MESSAGE_CAT_NAME, set, number, string)
#else
# define Dt11GETMESSAGE(set, number, string)\
string
#endif
#ifdef __cplusplus
}
#endif
#endif /* _DtGetMessage_h */

View File

@@ -0,0 +1,717 @@
/* $TOG: DtNlUtils.c /main/10 1999/10/15 12:07:23 mgreess $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/*****************************************************************************/
/* */
/* This file contains the Dt versions of common string functions, which */
/* have not yet been provided by the HP-UX platform. */
/* These functions know how to handle multi-byte strings. */
/* */
/*****************************************************************************/
#include <string.h>
#include <Dt/DtNlUtils.h>
#include "DtSvcLock.h"
/*
* Globals
*/
Boolean _DtNl_is_multibyte = False;
#ifdef NLS16
/*
* Dt nls initialization function.
* will see if multibyte characters are
* supported for the locale. If multibyte characters are not supported,
* then all of our string utilites simply call the standard libc function.
*/
void
Dt_nlInit( void )
{
char * bc;
static Boolean first = True;
_DtSvcProcessLock();
if (!first) {
_DtSvcProcessUnlock();
return;
}
first = False;
_DtSvcProcessUnlock();
if (MB_CUR_MAX > 1)
_DtNl_is_multibyte = True;
else
_DtNl_is_multibyte = False;
}
/*
* Dt version of strtok(s1, s2).
* Returns a pointer to the span of characters in s1 terminated by
* one of the characters in s2. Only s1 can be multibyte.
*/
char *
Dt_strtok(
char *s1,
char *s2 )
{
static char *ptr;
char * return_ptr;
int len;
int offset;
/* Use standard libc function, if no multibyte */
if (!_DtNl_is_multibyte)
return(strtok(s1, s2));
/*
* If this is the first call, save the string pointer, and bypass
* any leading separators.
*/
if (s1)
ptr = s1 + Dt_strspn(s1, s2);
/* A Null string pointer has no tokens */
if (ptr == NULL)
return(NULL);
/* Find out where the first terminator is */
if ((len = Dt_strcspn(ptr, s2)) <= 0)
{
/* No tokens left */
return(NULL);
}
/* Keep track of where the token started */
return_ptr = ptr;
/* Null out the terminator; we need to know how many bytes are
* occupied by the terminator, so that we can skip over it to
* the next character.
*/
/*
* We have to take care of the case when mblen() returns -1.
*/
offset = mblen(ptr + len, MB_CUR_MAX);
if( offset == -1 )
offset = 1;
*(ptr + len) = '\0';
ptr += (len + offset);
/*
* In preparation for the next pass, skip any other occurrances of
* the terminator characters which were joined with the terminator
* we first encountered.
*/
len = Dt_strspn(ptr, s2);
ptr += len;
return(return_ptr);
}
char *
Dt_strtok_r(
char *s1,
char *s2,
char **ptr )
{
char * return_ptr;
int len;
int offset;
/* Use standard libc function, if no multibyte */
if (!_DtNl_is_multibyte)
return((char*) strtok_r(s1, s2, ptr));
/*
* If this is the first call, save the string pointer, and bypass
* any leading separators.
*/
if (s1)
*ptr = s1 + Dt_strspn(s1, s2);
/* A Null string pointer has no tokens */
if (*ptr == NULL)
return(NULL);
/* Find out where the first terminator is */
if ((len = Dt_strcspn(*ptr, s2)) <= 0)
{
/* No tokens left */
return(NULL);
}
/* Keep track of where the token started */
return_ptr = *ptr;
/* Null out the terminator; we need to know how many bytes are
* occupied by the terminator, so that we can skip over it to
* the next character.
*/
/*
* We have to take care of the case when mblen() returns -1.
*/
offset = mblen(*ptr + len, MB_CUR_MAX);
if( offset == -1 )
offset = 1;
*(*ptr + len) = '\0';
*ptr += (len + offset);
/*
* In preparation for the next pass, skip any other occurrances of
* the terminator characters which were joined with the terminator
* we first encountered.
*/
len = Dt_strspn(*ptr, s2);
*ptr += len;
return(return_ptr);
}
/*
* Dt version of strspn(s1, s2).
* Returns the span of characters in s1 contained in s2.
* Only s1 can be multibyte.
*/
int
Dt_strspn(
char *s1,
char *s2 )
{
wchar_t s1char, s2char;
int s1len, s2len;
int i;
int count;
char * ptr;
Boolean match;
/* Use the standard libc function, if multibyte is not present */
if (!_DtNl_is_multibyte)
return(strspn(s1, s2));
/* A Null string has no spans */
if (s1 == NULL)
return(0);
count = 0;
while (*s1)
{
/* Extract the next character from s1; may be multibyte */
if ((s1len = mbtowc(&s1char, s1, MB_CUR_MAX)) < 0)
return(0);
s1 += s1len;
/*
* Compare this character against all the chars in s2. Keep
* working through s1, until a character is found in s1 which
* is not contained in s2.
*/
ptr = s2;
match = False;
while (*ptr)
{
/* Extract the next character from s2; cannot be multibyte */
s2char = *ptr++;
/* If a match is found, keep processing s1 */
if (s1char == s2char)
{
match = True;
count += s1len;
break;
}
}
/*
* If we made it here because all of s2 was searched, and a match
* was not found against s1, then we are done.
*/
if (!match)
return(count);
}
return(count);
}
/*
* Dt version of strcspn(s1, s2).
* Returns the span of characters in s1 not contained in s2.
* Only s1 can be multibyte.
*/
int
Dt_strcspn(
char *s1,
char *s2 )
{
wchar_t s1char, s2char;
int s1len, s2len;
int i;
int count;
char * ptr;
/* Use the standard libc function, if multibyte is not present */
if (!_DtNl_is_multibyte)
return(strcspn(s1, s2));
/* An empty string has no spans */
if (s1 == NULL)
return(0);
count = 0;
while (*s1)
{
/* Extract the next character from s1; may be multibyte */
if ((s1len = mbtowc(&s1char, s1, MB_CUR_MAX)) < 0)
return(0);
s1 += s1len;
/*
* Compare this character against all the chars in s2. Keep
* working through s1, until a character is found in s1 which
* is contained in s2.
*/
ptr = s2;
while (*ptr)
{
/* Extract the next character from s2; cannot be multibyte */
s2char = *ptr++;
/* If a match occurs, then we are done */
if (s1char == s2char)
return(count);
}
/*
* If we've made it here, then we searched all of s2, and none of
* its components matched s1; continue with the next character
* in s1.
*/
count += s1len;
}
return(count);
}
/*
* Dt version of strchr(s, c).
* Returns a pointer to the first occurance of 'c' in 's'.
*/
char *
Dt_strchr(
char *s,
char c )
{
wchar_t schar;
int i;
int slen;
wchar_t wc;
char foo[2];
if (s == NULL)
return(NULL);
/* Use standard libc function if multibyte is not enabled */
if (!_DtNl_is_multibyte)
return(strchr(s, c));
foo[0] = c;
foo[1] = '\0';
mbtowc(&wc, foo, 2);
do
{
/* Extract next char from 's'; may be multibyte */
if ((slen = mbtowc(&schar, s, MB_CUR_MAX)) < 0)
return(NULL);
s += slen;
/* If we match 'c', then return a pointer to this character */
if (schar == wc)
return (s - slen);
} while (slen > 0);
/* No match was found */
return(NULL);
}
/*
* Dt version of strrchr(s, c).
* Returns a pointer to the last occurance of 'c' in 's'.
*/
char *
Dt_strrchr(
char *s,
char c )
{
wchar_t schar;
int i;
int slen;
char * last = NULL;
wchar_t wc;
char foo[2];
if (s == NULL)
return(NULL);
/* Use standard libc function if multibyte is not enabled */
if (!_DtNl_is_multibyte)
return(strrchr(s, c));
foo[0] = c;
foo[1] = '\0';
mbtowc(&wc, foo, 2);
do
{
/* Extract next char from 's'; may be multibyte */
if ((slen = mbtowc(&schar, s, MB_CUR_MAX)) < 0)
return(NULL);
s += slen;
/* If we match 'c', keep track of it, and keep looking */
if (schar == wc)
last = s - slen;
} while (slen > 0);
return(last);
}
/*
* Dt equivalent of s[strlen(s) - 1]
* Returns the last character in the string 's'.
*/
void
Dt_lastChar(
char *s,
char **cptr,
int *lenptr )
{
int len = 0;
if ((s == NULL) || (*s == '\0'))
{
*lenptr = 0;
*cptr = NULL;
return;
}
/* Use the easy method, if possible */
if (!_DtNl_is_multibyte)
{
*cptr = s + strlen(s) - 1;
*lenptr = 1;
return;
}
/* Move through the string, keeping a ptr to the last character found */
while (*s)
{
/*
* We have to take care of the case when mbtowc() returns -1
*/
len = mbtowc(NULL, s, MB_CUR_MAX);
if ( len == -1 )
len = 1;
s += len;
}
/* Backup to the character before the NULL */
*lenptr = mblen(s-len, MB_CUR_MAX);
*cptr = s - len;
}
/*
* Dt equivalent of strlen()
* Returns the number of characters (not bytes) in a string
*/
int
Dt_charCount(
char *s )
{
int count = 0;
int len;
if (s == NULL)
return(0);
if (!_DtNl_is_multibyte)
return(strlen(s));
/* Move through the string, counting each character present */
while (*s)
{
len = mblen(s, MB_CUR_MAX);
/* if invalid character, still count it and continue */
if (len == -1)
len = 1;
s += len;
count++;
}
return(count);
}
/******************************************************************************
*
* _Dt_NextChar(s)
* return a pointer to the next multi-byte character after the character
* pointed to by "s". If "s" does not point to a valid multi-byte
* character advance one byte.
*
******************************************************************************/
char *
_Dt_NextChar(char *s)
{
int len=1;
if (_DtNl_is_multibyte || (MB_CUR_MAX > 1))
len = mblen ( s, MB_CUR_MAX);
/*
* If "s" did not point to a vaild multi-byte character,
* move ahead one byte.
*/
if ( len == -1 )
len = 1;
return s + len;
}
/******************************************************************************
*
* _Dt_PrevChar(start,s)
* return a pointer to the multi-byte character preceding the
* character pointed to by "s". If "s" does not point to a valid
* multi-byte character retreat one byte. "start" should point to
* a character preceding "s" in the multi-byte string.
*
******************************************************************************/
char *
_Dt_PrevChar(const char *start, char *s)
{
char *p;
int len;
if ( !_DtNl_is_multibyte || (MB_CUR_MAX == 1) )
return (s - 1);
/*
* Check if "*s" is a valid multi-byte character.
* if not just return the previous byte.
*/
if ( mblen(s,MB_CUR_MAX) < 0 )
return (s - 1);
/*
* "start" must be less than "s" ; if not return
* (s-1)
*/
if ( start >= s )
return (s - 1);
/*
* Check that "start" points to a valid multi-byte character.
* otherwise return "s-1"
*/
if ( mblen(start,MB_CUR_MAX) < 0 )
return (s-1);
/*
* Starting from "start" traverse the string until we find
* the character preceding "s".
*/
/*
* We have to take care of the case when mblen() returns -1.
*/
for (p = (char *)start;
p + (len = (mblen(p,MB_CUR_MAX) == -1 ? 1 : mblen(p,MB_CUR_MAX))) < s;
p += len)
/* NULL STATEMENT */;
/*
* We should always find a multi-byte character preceding "s" if
* "*s" is a valid multi-byte char and not the first character of
* the text.
*/
/* myassert(p < s); */
return p;
}
/*
* Dt mult-byte equivalent of isspace()
*/
int
_Dt_isspace(char *s)
{
if ( !_DtNl_is_multibyte || MB_CUR_MAX == 1 )
return isspace((u_char)*s);
if ( mblen(s,MB_CUR_MAX) == 1 )
return isspace((u_char)*s);
else
return 0;
}
/*
* Dt mult-byte equivalent of isdigit()
*/
int
_Dt_isdigit(char *s)
{
if ( !_DtNl_is_multibyte || MB_CUR_MAX == 1 )
return isdigit(*s);
if ( mblen(s,MB_CUR_MAX) == 1 )
return isdigit(*s);
else
return 0;
}
/*
* Dt equivalent of &(s[n])
* Returns a pointer to the indicated character
*/
char *
_DtGetNthChar(
char *s,
int n )
{
int count;
int len;
if ((s == NULL) || (n < 0) || (n > Dt_charCount(s)))
return(NULL);
count = 0;
while ((count < n) && (*s))
{
if (_DtNl_is_multibyte)
len = mblen(s, MB_CUR_MAX);
else
len = 1;
/*
* We have to take care of the case when mblen() returns -1.
*/
if ( len == -1 )
len = 1;
s += len;
count++;
}
return(s);
}
/*
* multibyte version of strpbrk().
* Only cs can be multibyte.
*/
char *
_dt_strpbrk(
char *cs,
char *ct)
{
int len;
size_t i;
if(MB_CUR_MAX == 1)
return(strpbrk(cs, ct));
while(*cs) {
len = mblen(cs, MB_CUR_MAX);
if(len < 1)
len = 1;
if(len == 1) {
for(i = 0; i < strlen(ct); i++) {
if(*cs == *(ct + i))
return(cs);
}
}
cs += len;
}
return(NULL);
}
/*
* returns 1 if a character before s2 in s1 is single-byte,
* returns 0 if it is multi-byte.
*/
int
_is_previous_single(
char *s1,
char *s2)
{
int n = 1;
if(MB_CUR_MAX == 1)
return(1);
while(*s1) {
if(s1 == s2) {
if(n > 1)
return(0);
else
return(1);
}
n = mblen(s1, MB_CUR_MAX) > 1 ? mblen(s1, MB_CUR_MAX) : 1;
s1 += n;
}
return(1);
}
#else
char *
_DtGetNthChar(
char *s,
int n )
{
if ((s == NULL) || (n < 0) || (n > strlen(s)))
return(NULL);
return (s + n);
}
char *
_dt_strpbrk(
char *cs,
char *ct)
{
return(strpbrk(cs, ct));
}
int
_is_previous_single(
char *s1,
char *s2)
{
return(1);
}
#endif /* NLS16 */

View File

@@ -0,0 +1,105 @@
/* $XConsortium: DtNlUtils.h /main/4 1996/06/21 17:22:30 ageorge $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/**************************************************************************/
/* */
/* Public include file for Dt localization functions. */
/* */
/**************************************************************************/
#ifdef NLS16
#include <stdlib.h>
#include <locale.h>
#include <string.h>
#include <limits.h>
#include <nl_types.h>
#include <langinfo.h>
#endif
#include <X11/Intrinsic.h>
#ifdef NLS16
#define is_multibyte _DtNl_is_multibyte
extern Boolean _DtNl_is_multibyte;
extern void Dt_nlInit( void ) ;
extern char * Dt_strtok(
char *s1,
char *s2) ;
extern char * Dt_strtok_r(
char *s1,
char *s2,
char **ptr) ;
extern int Dt_strspn(
char *s1,
char *s2) ;
extern int Dt_strcspn(
char *s1,
char *s2) ;
extern char * Dt_strchr(
char *s,
char c) ;
extern char * Dt_strrchr(
char *s,
char c) ;
extern void Dt_lastChar(
char *s,
char **cptr,
int *lenptr) ;
extern int Dt_charCount(
char *s) ;
extern char * _Dt_NextChar(char *s);
extern char * _Dt_PrevChar(const char *start,char *s);
extern int _Dt_isspace(char *s);
extern int _Dt_isdigit(char *s);
#define DtNlInitialize() (Dt_nlInit())
#define DtStrtok(s1, s2) (Dt_strtok(s1, s2))
#define DtStrtok_r(s1, s2, ptr) (Dt_strtok_r(s1, s2, ptr))
#define DtStrspn(s1, s2) (Dt_strspn(s1, s2))
#define DtStrcspn(s1, s2) (Dt_strcspn(s1, s2))
#define DtStrchr(s1, c) (Dt_strchr(s1, c))
#define DtStrrchr(s1, c) (Dt_strrchr(s1, c))
#define DtLastChar(s1, cp, lp) (Dt_lastChar(s1, cp, lp))
#define DtCharCount(s1) (Dt_charCount(s1))
#define DtNextChar(s) (is_multibyte?_Dt_NextChar(s):((s)+1))
#define DtPrevChar(st,s) (is_multibyte?_Dt_PrevChar(st,s):((s)-1))
#define DtIsspace(s) (is_multibyte?_Dt_isspace(s):isspace(*(s)))
#define DtIsdigit(s) (is_multibyte?_Dt_isdigit(s):isdigit(*(s)))
#else /* NLS16 */
#define DtNlInitialize()
#define DtStrtok(s1, s2) (strtok(s1, s2))
#define DtStrtok_r(s1, s2, ptr) (strtok_r(s1, s2, ptr))
#define DtStrspn(s1, s2) (strspn(s1, s2))
#define DtStrcspn(s1, s2) (strcspn(s1, s2))
#define DtStrchr(s1, c) (strchr(s1, c))
#define DtStrrchr(s1, c) (strrchr(s1, c))
#define DtLastChar(s1, cp, lp) {(*cp = s1 + strlen(s1) - 1); *lp = 1;}
#define DtCharCount(s1) (strlen(s1))
#define DtNextChar(s) ((s)+1)
#define DtPrevChar(st,s) ((s)-1)
#define DtIsspace(s) (isspace(*s))
#define DtIsdigit(s) (isdigit(*s))
#endif /* NLS16 */
extern char * _DtGetNthChar(
char *s,
int n) ;
extern char * _dt_strpbrk(
char *cs,
char *ct);
extern int _is_previous_single(
char *s1,
char *s2);

123
cde/lib/DtSvc/DtUtil2/DtP.h Normal file
View File

@@ -0,0 +1,123 @@
/*
* File: DtP.h $TOG: DtP.h /main/7 1998/07/30 12:12:49 mgreess $
* Language: C
*/
#ifndef _DtP_h
#define _DtP_h
#include <X11/Xmd.h> /* for protocol typedefs */
#include <X11/Intrinsic.h>
#include <Dt/DtPStrings.h>
#include <Dt/DtGetMessageP.h>
#include <bms/sbport.h>
#include <bms/bms.h>
#ifdef __cplusplus
extern "C" {
#endif
/*********************************
*
* Miscellaneous Data Types
*
*********************************/
#define DtChar XeChar
#define DtString XeString
/*********************************
*
* Initalization
*
*********************************/
#define DtToolClass XeToolClass
/*********************************
*
* Global variables (defined in DtUtil.c)
*
*********************************/
extern Display * _DtDisplay;
extern char * _DtApplicationName;
extern char * _DtApplicationClass;
extern char * _DtToolClass;
extern XtAppContext _DtAppContext;
extern XrmDatabase _DtResourceDatabase;
extern Widget _DtInitTtContextWidget;
extern XtAppContext * _DtInitAppContextp;
extern void _DtAddToResource( Display *, const char * );
extern void _DtAddResString( Display *, const char *, unsigned int);
extern char * _DtGetResString( Display *dpy, unsigned int);
#define _DT_ATR_RESMGR (1 << 0)
#define _DT_ATR_PREFS (1 << 1)
/*
DESCRIPTION:
Add strings to XA_RESOURCE_MANAGER property on the default root
window. Correctly merges resource specifications with the same
name and different values. The new value overwrites the old.
_DtAddToResource() may be used where you would have used xrdb to
add a resource.
SYNOPSIS:
void _DtAddToResource(dpy,data)
Display *dpy; The application's display structure.
char *data; The string to be added to the
XA_RESOURCE_MANAGER property.
*/
extern char *_DtCreateDtDirs( Display * );
/*
DESCRIPTION:
Creates the directories needed for dt to operate in. When an
application saves its state inside a file, it should call this
routine to set up the directories before saving any files. The
routine constructs the path to which all save files should be saved
to when responding the the WM_SAVE_YOURSELF message issued by the
session manager. The routine returns the path to save to. It also
allocates the memory for the path so when you are done with it you
should free() it.
WARNING: If it can't create the directory it returns NULL
SYNOPSIS:
dirName = _DtCreateDtDirs (display);
char *dirName; The path to save to.
Display *display; The application's display structure.
*/
/*
* The following string globals are available for use by any DT
* component. They represent the button labels in most dialogs,
* and will be automatically localized by DtInitialize().
*/
extern const char * _DtOkString;
extern const char * _DtCancelString;
extern const char * _DtHelpString;
extern const char * _DtApplyString;
extern const char * _DtCloseString;
#ifdef __cplusplus
}
#endif
/* Do not add anything after this endif. */
#endif /* _DtP_h */

View File

@@ -0,0 +1,65 @@
/*
* File: DtPStrings.h $XConsortium: DtPStrings.h /main/5 1995/12/14 11:02:36 barstow $
* Language: C
*/
#ifndef _DtPStrings_h
#define _DtPStrings_h
/*
* DT applications should use this name to look up DT-global
* resources instead of argv[0].
*/
#define DtDT_PROG_NAME "dt"
/*
* DT applications should use this class name to look up DT-global
* resources.
*/
#define DtDT_PROG_CLASS "Dt"
/*
* The following string constants define the standard DT configuration
* directories.
*/
#define DtPERSONAL_CONFIG_DIRECTORY ".dt"
#define DtSM_SESSION_DIRECTORY "sessions"
#define DtSM_SESSION_DISPLAY_DIRECTORY "display"
#define DtCURRENT_DT_VERSION "3.0"
/*
* If you change the following two #defines, you must also change the
* related one below (DtDB_DIRS_DEFAULT).
*/
#define DtPERSONAL_DB_DIRECTORY ".dt/types"
#define DtPERSONAL_TMP_DIRECTORY ".dt/tmp"
/*
* Names for the message log files
*/
#define DtERRORLOG_FILE "errorlog"
#define DtOLD_ERRORLOG_FILE "errorlog.old"
#define DtOLDER_ERRORLOG_FILE "errorlog.older"
/*
* Strings for default types and icons
*/
#define DtDEFAULT_DATA_FT_NAME "DATA"
/*
* The following string constants define the resource name,
* resource class and default values for the action bitmaps.
*/
#define DtACTION_ICON_RESOURCE_NAME "actionIcon"
#define DtACTION_ICON_RESOURCE_CLASS "ActionIcon"
#define DtACTION_ICON_DEFAULT "Dtactn"
/*
* The following string constants define the resource name,
* resource class and default values for the Dt tmp directory path.
*/
#define DtACTION_DTTMPDIR_RESOURCE_NAME "dtTmpDir"
#define DtACTION_DTTMPDIR_RESOURCE_CLASS "DtTmpDir"
#define DtACTION_DTTMPDIR_DEFAULT ".dt/tmp"
/* Do not add anything after this endif. */
#endif /* _DtPStrings_h */

View File

@@ -0,0 +1,205 @@
/* $TOG: DtUtil.c /main/10 1998/07/30 12:13:08 mgreess $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/******************************************************************************
*
* File Name: DtUtil.c
*
* Contains the DT functions used by an application to connect to the
* underlying communications mechanism.
*
*****************************************************************************/
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <netdb.h>
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Xm/Xm.h>
#include <Dt/DtP.h>
#include <Dt/UserMsg.h>
#include <Dt/DtNlUtils.h>
#include <Dt/EnvControlP.h>
#include "DtSvcLock.h"
/*****************************************
*
* External functions not defined in header files.
*
*****************************************/
/******** End Public Function Declarations ********/
/******** Static Function Declarations ********/
static Boolean DtBigInitialize(
Display *display,
Widget widget,
char *name,
char *toolClass,
XtAppContext app_context) ;
static void InitButtonLabels( void ) ;
static void DtGlobalsInitialize(
Display *display,
char *name,
char *toolClass) ;
/******** End Static Function Declarations ********/
/*****************************************
*
* Global variables
*
*****************************************/
XrmDatabase _DtResourceDatabase = NULL; /* This Dt global indicates which
Xrm database should be read for
resources. */
XtAppContext _DtAppContext = NULL; /* This Dt global keeps track of the
app-context, if one has been
specified. Note that libXv does
not yet support multiple app-
contexts. */
XtAppContext *_DtInitAppContextp = NULL;
Widget _DtInitTtContextWidget = NULL;
Display *_DtDisplay = NULL; /* This global variable is saved
when a client invokes "DtInitialize"
It is used later to get resources
when the DT databases are loaded.*/
char *_DtApplicationName = NULL; /* This global variable is the
client's "ApplicationName". */
char *_DtApplicationClass = NULL; /* This global variable is the
client's "ApplicationClass". */
char *_DtToolClass = NULL; /* Tool class passed to _DtInit...() */
/* Localizable button labels */
const char * _DtOkString = NULL;
const char * _DtCancelString = NULL;
const char * _DtHelpString = NULL;
const char * _DtApplyString = NULL;
const char * _DtCloseString = NULL;
/*********************************************
*
* Initialization Functions
*
*********************************************/
Boolean
DtAppInitialize(
XtAppContext app_context,
Display *display,
Widget widget,
char *name,
char *toolClass )
{
Boolean result;
_DtSvcAppLock(app_context);
result = DtBigInitialize (display, widget, name, toolClass, app_context);
_DtSvcAppUnlock(app_context);
return (result);
}
Boolean
DtInitialize(
Display *display,
Widget widget,
char *name,
char *toolClass )
{
Boolean result;
_DtSvcDisplayToAppContext(display);
_DtSvcAppLock(app);
result = DtBigInitialize (display, widget, name, toolClass, NULL);
_DtSvcAppUnlock(app);
return (result);
}
static Boolean
DtBigInitialize(
Display *display,
Widget widget,
char *name,
char *toolClass,
XtAppContext app_context )
{
static Boolean initialized = False;
/* Initialization can only be performed once. */
_DtSvcProcessLock();
if (initialized) {
_DtSvcProcessUnlock();
return (False);
}
/* Preserve the pre-Dt environ and add Dt-specifics to environ */
(void) _DtEnvControl (DT_ENV_SET);
/* Initialize a bunch of miscellaneous things. */
DtNlInitialize();
InitButtonLabels();
DtGlobalsInitialize (display, name, toolClass);
if ( XmIsGadget(widget) )
_DtInitTtContextWidget = XtParent(widget);
else
_DtInitTtContextWidget = widget;
if (app_context)
_DtAppContext = app_context;
else
_DtAppContext = XtWidgetToApplicationContext(_DtInitTtContextWidget);
_DtInitAppContextp = &_DtAppContext;
initialized = TRUE;
_DtSvcProcessUnlock();
return (initialized);
}
/* Initialize the global button labels */
static void
InitButtonLabels( void )
{
_DtOkString = XtNewString(Dt11GETMESSAGE(28, 1, "OK"));
_DtCancelString = XtNewString(Dt11GETMESSAGE(28, 2, "Cancel"));
_DtHelpString = XtNewString(Dt11GETMESSAGE(28, 3, "Help"));
_DtApplyString = XtNewString(Dt11GETMESSAGE(28, 4, "Apply"));
_DtCloseString = XtNewString(Dt11GETMESSAGE(28, 5, "Close"));
}
static void
DtGlobalsInitialize(
Display *display,
char *name,
char *toolClass )
{
_DtResourceDatabase = XtDatabase (display);
DtProgName = name;
_DtToolClass = XtNewString(toolClass);
XeToolClass = XtNewString (toolClass);
/*
* Save the application name and application class.
*/
_DtDisplay = display;
XtGetApplicationNameAndClass (display,
&_DtApplicationName,
&_DtApplicationClass);
}

View File

@@ -0,0 +1,223 @@
/* $TOG: DtosP.h /main/4 1998/01/21 16:37:29 mgreess $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifdef REV_INFO
#ifndef lint
static char SCCSID[] = "OSF/Motif: @(#)_DtosP.h 4.16 91/09/12";
#endif /* lint */
#endif /* REV_INFO */
/******************************************************************************
*******************************************************************************
*
* (c) Copyright 1989, 1990, 1991 OPEN SOFTWARE FOUNDATION, INC.
* (c) Copyright 1989, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
* (c) Copyright 1987, 1988, 1989, 1990, 1991 HEWLETT-PACKARD COMPANY
* ALL RIGHTS RESERVED
*
* THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED
* AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND
* WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR
* ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE
* AVAILABLE TO ANY OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE
* SOFTWARE IS HEREBY TRANSFERRED.
*
* THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT
* NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY OPEN SOFTWARE
* FOUNDATION, INC. OR ITS THIRD PARTY SUPPLIERS
*
* OPEN SOFTWARE FOUNDATION, INC. AND ITS THIRD PARTY SUPPLIERS,
* ASSUME NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE ANY OF ITS
* SOFTWARE . OSF SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
* KIND, AND OSF EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE.
*
* Notice: Notwithstanding any other lease or license that may pertain to,
* or accompany the delivery of, this computer software, the rights of the
* Government regarding its use, reproduction and disclosure are as set
* forth in Section 52.227-19 of the FARS Computer Software-Restricted
* Rights clause.
*
* (c) Copyright 1989, 1990, 1991 Open Software Foundation, Inc. Unpublished - all
* rights reserved under the Copyright laws of the United States.
*
* RESTRICTED RIGHTS NOTICE: Use, duplication, or disclosure by the
* Government is subject to the restrictions as set forth in subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software clause
* at DFARS 52.227-7013.
*
* Open Software Foundation, Inc.
* 11 Cambridge Center
* Cambridge, MA 02142
* (617)621-8700
*
* RESTRICTED RIGHTS LEGEND: This computer software is submitted with
* "restricted rights." Use, duplication or disclosure is subject to the
* restrictions as set forth in NASA FAR SUP 18-52.227-79 (April 1985)
* "Commercial Computer Software- Restricted Rights (April 1985)." Open
* Software Foundation, Inc., 11 Cambridge Center, Cambridge, MA 02142. If
* the contract contains the Clause at 18-52.227-74 "Rights in Data General"
* then the "Alternate III" clause applies.
*
* (c) Copyright 1989, 1990, 1991 Open Software Foundation, Inc.
* ALL RIGHTS RESERVED
*
*
* Open Software Foundation is a trademark of The Open Software Foundation, Inc.
* OSF is a trademark of Open Software Foundation, Inc.
* OSF/Motif is a trademark of Open Software Foundation, Inc.
* Motif is a trademark of Open Software Foundation, Inc.
* DEC is a registered trademark of Digital Equipment Corporation
* DIGITAL is a registered trademark of Digital Equipment Corporation
* X Window System is a trademark of the Massachusetts Institute of Technology
*
*******************************************************************************
******************************************************************************/
#ifndef __DtosP_h
#define __DtosP_h
#ifndef NO_MEMMOVE
# ifndef X_NOT_STDC_ENV
# include <stdlib.h> /* Needed for MB_CUR_MAX, mbtowc, mbstowcs and mblen */
# endif
#else
# define memmove( p1, p2, p3 ) bcopy( p2, p1, p3 )
#endif
#ifdef BOGUS_MB_MAX /* some systems don't properly set MB_[CUR|LEN]_MAX */
# undef MB_LEN_MAX
# define MB_LEN_MAX 1 /* temp fix for ultrix */
# undef MB_CUR_MAX
# define MB_CUR_MAX 1 /* temp fix for ultrix */
#endif /* BOGUS_MB_MAX */
/**********************************************************************/
/* here we duplicate Xtos.h, since we can't include this private file */
#ifdef INCLUDE_ALLOCA_H
# include <alloca.h>
#endif
#ifdef CRAY
# define WORD64
#endif
/* stolen from server/include/os.h */
#ifndef NO_ALLOCA
/*
* os-dependent definition of local allocation and deallocation
* If you want something other than XtMalloc/XtFree for ALLOCATE/DEALLOCATE
* LOCAL then you add that in here.
*/
# if defined(__HIGHC__)
# if HCVERSION < 21003
# define ALLOCATE_LOCAL(size) alloca((int)(size))
#pragma on(alloca);
# else /* HCVERSION >= 21003 */
# define ALLOCATE_LOCAL(size) _Alloca((int)(size))
# endif /* HCVERSION < 21003 */
# define DEALLOCATE_LOCAL(ptr) /* as nothing */
# endif /* defined(__HIGHC__) */
# ifdef __GNUC__
# define alloca __builtin_alloca
# define ALLOCATE_LOCAL(size) alloca((int)(size))
# define DEALLOCATE_LOCAL(ptr) /* as nothing */
# else /* ! __GNUC__ */
/*
* warning: mips alloca is unsuitable, do not use.
*/
# if defined(vax) || defined(sun) || defined(apollo) || defined(stellar)
/*
* Some System V boxes extract alloca.o from /lib/libPW.a; if you
* decide that you don't want to use alloca, you might want to fix it here.
*/
char *alloca();
# define ALLOCATE_LOCAL(size) alloca((int)(size))
# define DEALLOCATE_LOCAL(ptr) /* as nothing */
# endif /* who does alloca */
# endif /* __GNUC__ */
#endif /* NO_ALLOCA */
#ifndef ALLOCATE_LOCAL
# define ALLOCATE_LOCAL(size) XtMalloc((unsigned long)(size))
# define DEALLOCATE_LOCAL(ptr) XtFree((XtPointer)(ptr))
#endif /* ALLOCATE_LOCAL */
/* End of Xtos.h */
/*****************/
/*
* Default Icon Search Paths
*
* The following are default starter values for XMICONSEARCHPATH and
* XMICONBMSEARCHPATH, respectively. Code elsewhere must ensure that paths
* into the user's home directory occur in front of these paths in the
* environment variables. Note the apparently redundant use of ANSI C string
* constant concatenation; this is necessary in order to avoid the sequence of
* characters % B %, which form an SCCS id keyword.
*/
#define DTPMSYSDEFAULT \
CDE_CONFIGURATION_TOP "/appconfig/icons/%L/%B" "%M.pm:" \
CDE_CONFIGURATION_TOP "/appconfig/icons/%L/%B" "%M.bm:" \
CDE_CONFIGURATION_TOP "/appconfig/icons/%L/%B:" \
\
CDE_CONFIGURATION_TOP "/appconfig/icons/C/%B" "%M.pm:" \
CDE_CONFIGURATION_TOP "/appconfig/icons/C/%B" "%M.bm:" \
CDE_CONFIGURATION_TOP "/appconfig/icons/C/%B:" \
\
CDE_INSTALLATION_TOP "/appconfig/icons/%L/%B" "%M.pm:" \
CDE_INSTALLATION_TOP "/appconfig/icons/%L/%B" "%M.bm:" \
CDE_INSTALLATION_TOP "/appconfig/icons/%L/%B:" \
\
CDE_INSTALLATION_TOP "/appconfig/icons/C/%B" "%M.pm:" \
CDE_INSTALLATION_TOP "/appconfig/icons/C/%B" "%M.bm:" \
CDE_INSTALLATION_TOP "/appconfig/icons/C/%B"
#define DTBMSYSDEFAULT \
CDE_CONFIGURATION_TOP "/appconfig/icons/%L/%B" "%M.bm:" \
CDE_CONFIGURATION_TOP "/appconfig/icons/%L/%B" "%M.pm:" \
CDE_CONFIGURATION_TOP "/appconfig/icons/%L/%B:" \
\
CDE_CONFIGURATION_TOP "/appconfig/icons/C/%B" "%M.bm:" \
CDE_CONFIGURATION_TOP "/appconfig/icons/C/%B" "%M.pm:" \
CDE_CONFIGURATION_TOP "/appconfig/icons/C/%B:" \
\
CDE_INSTALLATION_TOP "/appconfig/icons/%L/%B" "%M.bm:" \
CDE_INSTALLATION_TOP "/appconfig/icons/%L/%B" "%M.pm:" \
CDE_INSTALLATION_TOP "/appconfig/icons/%L/%B:" \
\
CDE_INSTALLATION_TOP "/appconfig/icons/C/%B" "%M.bm:" \
CDE_INSTALLATION_TOP "/appconfig/icons/C/%B" "%M.pm:" \
CDE_INSTALLATION_TOP "/appconfig/icons/C/%B"
#ifdef __cplusplus
extern "C" {
#endif
/******** Private Function Declarations ********/
/******** End Private Function Declarations ********/
#ifdef __cplusplus
} /* Close scope of 'extern "C"' declaration which encloses file. */
#endif
#endif /* __DtosP_h */
/* DON'T ADD ANYTHING AFTER THIS #endif */

View File

@@ -0,0 +1,39 @@
/* $XConsortium: DtpadM.h /main/3 1995/10/26 15:20:56 rswiston $ */
/************************************<+>*************************************
****************************************************************************
**
** File: DtpadM.h
**
** Project: HP-DT "dtpad" text editor
**
** Description: Defines for the tool class and messages for the
** dtpad text editor
**
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Novell, Inc.
**
**
**
****************************************************************************
************************************<+>*************************************/
#ifndef _DtpadM_h
#define _DtpadM_h
#define DTPAD_TOOL_CLASS "DTPAD"
/*
* Request Messages which the editor understands
*/
#define DTPAD_RUN_SESSION_MSG "RUN_SESSION"
#define DTPAD_OPEN_FILE_MSG "OPEN_FILE"
/*
* Notification Messages which the Editor sends
*/
#define DTPAD_DONE "DONE"
#endif /*_DtpadM_h*/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,102 @@
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/****************************<+>*************************************
**
** File: EnvControlI.h
**
** RCS: $TOG: EnvControlI.h /main/6 1998/07/30 12:14:02 mgreess $
**
** Project: DT Runtime Library -- Private header
**
** Description: Defines structures, and parameters used
** for communication with the environment
**
** (c) Copyright 1992-94 by Hewlett-Packard Company
**
****************************<+>*************************************/
/*******************************************************************
The environment variables
*******************************************************************/
#define BIN_PATH_ENVIRON "PATH"
#define NLS_PATH_ENVIRON "NLSPATH"
#define SYSTEM_APPL_PATH_ENVIRON "XFILESEARCHPATH"
#define PM_PATH_ENVIRON "XMICONSEARCHPATH"
#define BM_PATH_ENVIRON "XMICONBMSEARCHPATH"
/*******************************************************************
The default DT path strings, architecture-dependent
*******************************************************************/
#define BIN_PATH_STRING CDE_INSTALLATION_TOP "/bin"
#define NLS_PATH_STRING CDE_INSTALLATION_TOP "/lib/nls/msg/%L/%N.cat:" \
CDE_INSTALLATION_TOP "/lib/nls/msg/C/%N.cat"
#if defined(sun)
#define X_BIN_PATH_STRING "/usr/openwin/bin"
#else
#define X_BIN_PATH_STRING "/usr/bin/X11"
#endif
/*
* Some notes on the behavior and use of the XFILESEARCHPATH component, as
* defined through the SYSTEM_APPL_PATH_STRING definition below:
*
* Its precedence in the lookup of X resources is fairly low--it can
* be overridden by XRM resources, by resources specified in
* the user's $HOME/.Xdefaults-<hostname> file, and by resources
* found using the $XUSERFILESEARCHPATH setting.
*
* The order of pathnames in the XFILESEARCHPATH is such that the first
* match satisfies the lookup, and the lookup stops there.
*
* We place the pathname components in our XFILESEARCHPATH such that
* the lookup goes, from first match attempt to last match attempt, as
* follows:
*
* - Custom resources: /etc/../$LANG
* - Custom resources: /etc/../C
* - Factory defaults: /opt/../$LANG --shipped with every localized system
* - Factory defaults: /opt/../C --shipped with every system
*
* These resources are used ONLY for the DT components themselves
* (not, for example, for MIT client resources).
*
* The CDE vendors retain the right to alter, remove, append to, and
* ignore any settings in the factory defaults locations. The vendors
* will not modify the settings in the "custom resources" locations.
*
*/
#define SYSTEM_APPL_PATH_STRING CDE_CONFIGURATION_TOP "/app-defaults/%L/%N:" \
CDE_CONFIGURATION_TOP "/app-defaults/C/%N:" \
CDE_INSTALLATION_TOP "/app-defaults/%L/%N:" \
CDE_INSTALLATION_TOP "/app-defaults/C/%N"
/**********************************************************************
* Data representation of the user's DT environment
**********************************************************************/
typedef struct environStruct {
char * pmPath;
char * binPath;
char * nlsPath;
char * sysApplPath;
char * bmPath;
} _environStruct;
/**********************************************************************
* Miscellaneous
**********************************************************************/
#define BV_BINPATH (1<<0)
#define BV_SYSAPPLPATH (1<<1)
#define BV_NLSPATH (1<<2)
#define BV_PMPATH (1<<3)
#define BV_BMPATH (1<<4)
#define MAX_ENV_STRING (2*BUFSIZ)
/**************************** eof **********************/

View File

@@ -0,0 +1,65 @@
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/****************************<+>*************************************
**
** File: EnvControlP.h
**
** RCS: $TOG: EnvControlP.h /main/6 1998/07/30 12:13:45 mgreess $
** Project: DT Runtime Library
**
** Description: Defines structures, and parameters used
** for communication with the environment
**
** (c) Copyright 1990 by Hewlett-Packard Company
**
****************************<+>*************************************/
/******** Public Function Declarations ********/
#ifdef __cplusplus
extern "C" {
#endif
extern int _DtEnvControl(
int mode) ;
extern int _DtWsmSetBackdropSearchPath(
Screen *screen,
char *backdropDir,
Boolean useMultiColorIcons) ;
/******** End Public Function Declarations ********/
/**********************************************************************
* Command parameters to the function, which double as result codes.
* If the invocation is successful, the same is returned;
* else DT_ENV_NO_OP is returned.
DT_ENV_SET
Sets the DT environment.
DT_ENV_RESTORE_PRE_DT
Restores the pre-DT application environment
DT_ENV_RESTORE_POST_DT
Reinstalls the DT environment after a restoring pre-DT
environment
DT_ENV_NO_OP
Does nothing
DT_ENV_SET_BIN
Sets the DT environment PLUS sets the PATH= variable to
where the DT files live.
**********************************************************************/
#define DT_ENV_SET 0
#define DT_ENV_RESTORE_PRE_DT 1
#define DT_ENV_RESTORE_POST_DT 2
#define DT_ENV_NO_OP 3
#define DT_ENV_SET_BIN 4
#ifdef __cplusplus
}
#endif
/**************************** eof **********************/

View File

@@ -0,0 +1,41 @@
/* $XConsortium: FileM.h /main/3 1995/10/26 15:21:35 rswiston $ */
/************************************<+>*************************************
****************************************************************************
**
** File: FileM.h
**
** Project: DT
**
** Description: Defines for the tool class and messages for the
** File Manager.
**
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Novell, Inc.
**
**
**
****************************************************************************
************************************<+>*************************************/
#ifndef _FileM_h
#define _FileM_h
#define FILE_MANAGER_TOOL_CLASS "FILEMGR"
#define FILE_MANAGER_CLASS_NAME "Dtfile"
#define FILE_MANAGER_RUN_SESSION_MSG "RUN_SESSION"
#define FILE_MANAGER_SHOW_HOME_MSG "SHOW_HOME_FOLDER"
#define FILE_MANAGER_SHOW_DIRECTORY_MSG "SHOW_FOLDER"
#define FILE_MANAGER_SHOW_TOOLS_MSG "SHOW_TOOLS"
#define SHOW_TRASH_MSG "SHOW_TRASH"
#define REMOVE_TRASH_MSG "REMOVE_TRASH"
#define EMPTY_TRASH_MSG "EMPTY_TRASH"
#endif /*_FileM_h*/
/* DON'T ADD ANYTHING AFTER THIS #endif */

View File

@@ -0,0 +1,220 @@
/*
* File: FileUtil.c $XConsortium: FileUtil.c /main/6 1996/11/01 10:06:23 drk $
* Language: C
*
* (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include <sys/types.h> /* stat(2) */
#include <sys/stat.h> /* stat(2) */
#include <sys/param.h> /* MAXPATHLEN */
#include <errno.h> /* errno(2) */
#ifdef __hpux
#include <ndir.h> /* opendir(), directory(3C) */
#else
#if defined(sun) || defined(USL) || defined(sco) || defined(__uxp__)
#include <dirent.h> /* opendir(), directory(3C) */
#else
#include <sys/dir.h>
#endif /* sun || USL */
#endif /* __hpux */
#include <X11/Xlib.h>
#include <X11/Intrinsic.h> /* Xt stuff */
#include <X11/StringDefs.h> /* Cardinal */
#include <Dt/DtNlUtils.h>
#include <Dt/ActionUtilP.h>
#include <Tt/tt_c.h>
/******************
*
* Function Name: _DtCreateDirs
*
* Description:
*
* This function is passed a directory path to create and the mode
* for the directory. It will create any of the parent directories
* on the path that do not already exist.
*
* This function may fail if any of the directories on the path already
* exist and are not writable. If some component of the path already
* exists and is not a directory, a failure will be returned.
*
* If some component of the path exists as a directory but does not have
* the specified mode, this will NOT cause a failure to be returned.
* This implies that if this function is called to create a writeable
* directory, it is possible for the function to return successfully
* but the directory may not actually be writable.
*
* Synopsis:
*
* status = _DtCreateDirs (path, mode);
*
* int status; Returns 0 on success and -1 on failure.
* char *path; The directory path to create.
* int mode; The file mode for setting any directories
* that are created.
*
******************/
int
_DtCreateDirs(
char *path,
int mode )
{
struct stat st_buf;
int st_status;
int ret_status;
char *parent_path;
char *temp_s;
/* If the path already exist, make sure it is a directory. */
if ((st_status = stat (path, &st_buf)) == 0) {
if (S_ISDIR (st_buf.st_mode))
ret_status = 0;
else
ret_status = -1;
}
/* If we can't stat it, make sure it is simply because some component
of the path doesn't exist. */
else if (errno != ENOENT)
ret_status = -1;
else {
/* Some component of the path doesn't exist. Recursively make the
parent of the current directory, then make the current directory. */
parent_path = XtNewString (path);
if ((temp_s = DtStrrchr (parent_path, '/')) != NULL) {
*temp_s = '\0';
(void) _DtCreateDirs (parent_path, mode);
}
XtFree (parent_path);
/* If no error has been encountered, now make the final directory
in the path. */
if ((ret_status = mkdir (path, S_IFDIR)) == 0)
(void) chmod (path, mode);
}
return (ret_status);
}
/******************
*
* Function Name: _DtIsOpenableDirContext
*
* Description:
*
* This function takes a path as an argument and determines whether
* the path is a directory that can be opened. This function returns
* "1" if the path is an openable directory and "0" if it is not.
* In addition, if the calling function passes in another pointer,
* we will return the internal representation for the path.
*
* The path can be in the Softbench "context" form of "host:/path/dir".
*
* Synopsis:
*
* status = _DtIsOpenableDirContext (cpath, ret_ptr)
*
* int status; Returns 1 for openable directories,
* 0 otherwise.
* char *cpath; The directory name to test.
* char ** ret_ptr; Where to place internal format.
*
******************/
int
_DtIsOpenableDirContext(
char *path,
char **ret_path )
{
char *real_path = NULL;
char * tmp_real_path;
DIR *dirp;
int ret_status;
Tt_status status;
char * host;
char * filename;
char * netfile;
if (ret_path)
*ret_path = NULL;
host = _DtHostString(path);
filename = _DtPathname(path);
if (host)
{
netfile = tt_host_file_netfile(host, filename);
if ((status = tt_ptr_error(netfile)) == TT_OK)
{
tmp_real_path = tt_netfile_file(netfile);
status = tt_ptr_error(real_path);
tt_free(netfile);
}
if (status != TT_OK) {
real_path = NULL;
} else {
real_path = XtNewString(tmp_real_path);
tt_free(tmp_real_path);
}
XtFree(filename);
XtFree(host);
}
else
real_path = filename;
if (real_path && ((dirp = opendir (real_path)) != NULL))
{
closedir (dirp);
ret_status = 1;
if (ret_path)
*ret_path = real_path;
}
else
{
ret_status = 0;
if (real_path)
XtFree(real_path);
}
return (ret_status);
}
/******************
*
* Function Name: _DtIsOpenableDir
*
* Description:
*
* This function takes a path as an argument and determines whether
* the path is a directory that can be opened. This function returns
* "1" if the path is an openable directory and "0" if it is not.
*
* The path can be in the Softbench "context" form of "host:/path/dir".
*
* Synopsis:
*
* status = _DtIsOpenableDir (cpath)
*
* int status; Returns 1 for openable directories,
* 0 otherwise.
* char *cpath; The directory name to test.
*
******************/
int
_DtIsOpenableDir(
char *path )
{
return (_DtIsOpenableDirContext(path, NULL));
}

View File

@@ -0,0 +1,147 @@
/*
* File: FileUtil.h $XConsortium: FileUtil.h /main/4 1995/10/26 15:21:50 rswiston $
* Language: C
*
* (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef _FileUtil_h
#define _FileUtil_h
extern int _DtCreateDirs( char *path,
int mode) ;
/******************
*
* Function Name: _DtCreateDirs
*
* Description:
*
* This function is passed a directory path to create and the mode
* for the directory. It will create any of the parent directories
* on the path that do not already exist.
*
* This function may fail if any of the directories on the path already
* exist and are not writable. If some component of the path already
* exists and is not a directory, a failure will be returned.
*
* If some component of the path exists as a directory but does not have
* the specified mode, this will NOT cause a failure to be returned.
* This implies that if this function is called to create a writeable
* directory, it is possible for the function to return successfully
* but the directory may not actually be writable.
*
* Synopsis:
*
* status = _DtCreateDirs (path, mode);
*
* int status; Returns 0 on success and -1 on failure.
* char *path; The directory path to create.
* int mode; The file mode for setting any directories
* that are created.
*
******************/
extern int _DtIsOpenableDir( char *path) ;
/******************
*
* Function Name: _DtIsOpenableDir
*
* Description:
*
* This function takes a path as an argument and determines whether
* the path is a directory that can be opened. This function returns
* "1" if the path is an openable directory and "0" if it is not.
*
* The path can be in the Softbench "context" form of "host:/path/dir".
*
* Synopsis:
*
* status = _DtIsOpenableDir (cpath)
*
* int status; Returns 1 for openable directories,
* 0 otherwise.
* char *cpath; The directory name to test.
*
******************/
extern int
_DtIsOpenableDirContext(
char *path,
char **ret_path ) ;
/******************
*
* Function Name: _DtIsOpenableDirContext
*
* Description:
*
* This function takes a path as an argument and determines whether
* the path is a directory that can be opened. This function returns
* "1" if the path is an openable directory and "0" if it is not.
* In addition, if the calling function passes in another pointer,
* we will return the internal representation for the path.
*
* The path can be in the Softbench "context" form of "host:/path/dir".
*
* Synopsis:
*
* status = _DtIsOpenableDirContext (cpath, ret_ptr)
*
* int status; Returns 1 for openable directories,
* 0 otherwise.
* char *cpath; The directory name to test.
* char ** ret_ptr; Where to place internal format.
*
******************/
extern char * _DtReaddirLstat(
char *dir_name,
DIR *dirp,
struct stat *st_buf) ;
/******************
*
* Function Name: _DtReaddirLstat
*
* Description:
*
* This function reads the next entry out of a directory that has
* been opened with opendir and returns lstat information on it.
* For more information on reading a directory, see directory(3C).
* For more information on lstat information, see stat(2).
*
* This function returns a pointer to the full pathname of the directory
* entry. This memory is owned by this function and must not be
* freed. If the caller wants to keep the filename, it must make its
* own copy. When the end of the directory is encountered, NULL is
* returned.
*
* Synopsis:
*
* dir_entry = _DtReaddirLstat (dir_name, dirp, st_buf);
*
* char *dir_entry; The name of the current entry within the
* directory.
*
* char *dir_name; The full path name of the directory.
*
* DIR *dirp; A pointer to the directory [obtained from
* opendir(3C)].
*
* struct stat *st_buf; The lstat(2) information.
*
******************/
#endif /* _FileUtil_h */
/* DON'T ADD ANYTHING AFTER THIS #endif */

View File

@@ -0,0 +1,69 @@
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/****************************<+>*************************************
**
** File: GetDispRes.c
**
** RCS: $XConsortium: GetDispRes.c /main/4 1995/10/26 15:22:04 rswiston $
**
** Project: HP DT Runtime Library
**
** Description: Get the display resolution of a particular display
** and screen.
**
** (c) Copyright 1992 by Hewlett-Packard Company
**
********************************************************************/
#include <stdio.h>
#include <X11/Xlib.h>
#include "GetDispRes.h"
/******************************<->*************************************
*
* _DtGetDisplayResolution(DISPLAY, screen)
*
* Description:
* -----------
* This function determines whether a display is HIGH, MEDIUM, or
* LOW display resolution.
*
* Inputs:
* -------
* Pointer to the DISPLAY and a screen number
*
* Outputs:
* -------
* One of four types of resolution: HIGH_RES_DISPLAY,
* MED_RES_DISPLAY,
* LOW_RES_DISPLAY,
* NO_RES_DISPLAY (if below min for LOW)
*
* Comments:
* --------
* Algorithm only uses XWidthOfScreen to make the determination.
*
******************************<->***********************************/
int
_DtGetDisplayResolution(Display *disp, int screen)
{
int screenWidth = XDisplayWidth(disp, screen);
if (screenWidth >= _DT_HIGH_RES_MIN) {
return(HIGH_RES_DISPLAY);
}
if (screenWidth >= _DT_MED_RES_MIN) {
return(MED_RES_DISPLAY);
}
if (screenWidth >= _DT_LOW_RES_MIN) {
return(LOW_RES_DISPLAY);
}
return(NO_RES_DISPLAY);
}
/************** eof ******************/

View File

@@ -0,0 +1,47 @@
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/****************************<+>*************************************
**
** File: EnvControl.h
**
** RCS: $XConsortium: GetDispRes.h /main/4 1995/10/26 15:22:11 rswiston $
** Project: HP DT Runtime Library
**
** Description: Defines structures, and parameters used
** for communication with the environment
**
** (c) Copyright 1992 by Hewlett-Packard Company
**
****************************<+>*************************************/
/******** Function Declarations ********/
int _DtGetDisplayResolution(
Display *disp,
int screen) ;
/******** End Function Declarations ********/
/**********************************************************************
* Resolution threshold values (width of screen in pixels)
**********************************************************************/
#define _DT_HIGH_RES_MIN 1176
#define _DT_MED_RES_MIN 851
#define _DT_LOW_RES_MIN 512
/**********************************************************************
* Resolution types of a given screen
**********************************************************************/
#define NO_RES_DISPLAY 0
#define LOW_RES_DISPLAY 1
#define VGA_RES_DISPLAY 2
#define MED_RES_DISPLAY 3
#define HIGH_RES_DISPLAY 4
#define ALL_RES_DISPLAY 5
/**************************** eof **********************/

View File

@@ -0,0 +1,111 @@
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/************************************<+>*************************************
****************************************************************************
**
** File: GetEmbed.c
**
** RCS: $XConsortium: GetEmbed.c /main/5 1996/05/20 16:09:08 drk $
** Project: DT Workspace Manager
**
** Description: Get workspace embedded clients property.
**
** (c) Copyright 1990, 1993 by Hewlett-Packard Company
**
****************************************************************************
************************************<+>*************************************/
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <Dt/Wsm.h>
#include <Dt/WsmP.h>
#include <Xm/Xm.h>
#include <Xm/AtomMgr.h>
/*************************************<->*************************************
*
* int _DtGetEmbeddedClients (display, root, ppEmbeddedClients,
* pNumEmbeddedClients)
*
*
* Description:
* -----------
* Get the contents of the _DT_WORKSPACE_EMBEDDED_CLIENTS property
* from a root window. This is a array of top-level windows that are
* embedded in the front panel of the window manager. They would
* not be picked up ordinarily by a session manager in a normal
* search for top-level windows because they are reparented to
* the front panel which itself is a top-level window.
*
*
* Inputs:
* ------
* display - display
* root - root window to get info from
* ppEmbeddedClients - pointer to a pointer (to be returned)
* pNumEmbeddedClients - pointer to a number (to be returned)
*
* Outputs:
* -------
* *ppEmbeddedClients - pointer to a array of window IDs (top-level
* windows for embedded clients)
* (NOTE: This should be freed using XFree)
* *pNumEmbeddedClients- number of window IDs in array
* Return - Success if property fetched ok.
* Failure returns are from XGetWindowProperty
*
* Comments:
* --------
* Use XFree to free the returned data.
*
*************************************<->***********************************/
int
_DtGetEmbeddedClients(
Display *display,
Window root,
Atom **ppEmbeddedClients,
unsigned long *pNumEmbeddedClients )
{
Atom actualType;
int actualFormat;
unsigned long leftover;
int rcode;
Atom property;
*ppEmbeddedClients = NULL;
property = XmInternAtom (display,
_XA_DT_WORKSPACE_EMBEDDED_CLIENTS, False);
if ((rcode=XGetWindowProperty(display,
root,
property,
0L,
(long)BUFSIZ,
False,
property,
&actualType,
&actualFormat,
pNumEmbeddedClients,
&leftover,
(unsigned char **)ppEmbeddedClients))==Success)
{
if (actualType != property)
{
/* wrong type, force failure */
*pNumEmbeddedClients = 0;
rcode = BadValue;
if (actualType != None)
{
XFree ((char *) *ppEmbeddedClients);
}
}
}
return(rcode);
}

View File

@@ -0,0 +1,75 @@
/* $XConsortium: GetMessage.c /main/5 1996/06/21 17:22:13 ageorge $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/*************************************<+>*************************************
*****************************************************************************
**
** File: GetMessage.c
**
** Project: DT
**
** Description: This file contains the library source code to get
** a localized message.
**
**
** (c) Copyright 1992 by Hewlett-Packard Company
**
*
****************************************************************************
************************************<+>*************************************/
#include <stdio.h>
#include <nl_types.h>
#include "DtSvcLock.h"
#if !defined(NL_CAT_LOCALE)
#define NL_CAT_LOCALE 0
#endif
/*****************************************************************************
*
* Function: _DtGetMessage
*
* Parameters:
*
* char *filename - Filename to open.
*
* int set - The message catalog set number.
*
* int n - The message number.
*
* char *s - The default message if the message is not
* retrieved from a message catalog.
*
* Returns: the string for set 'set' and number 'n'.
*
*****************************************************************************/
char *
_DtGetMessage(
char *filename,
int set,
int n,
char *s )
{
char *msg;
char *lang;
nl_catd catopen();
char *catgets();
static int first = 1;
static nl_catd nlmsg_fd;
_DtSvcProcessLock();
if ( first )
{
first = 0;
nlmsg_fd = catopen(filename, NL_CAT_LOCALE);
}
msg=catgets(nlmsg_fd,set,n,s);
_DtSvcProcessUnlock();
return (msg);
}

View File

@@ -0,0 +1,270 @@
/* $XConsortium: Hash.c /main/4 1995/10/26 15:22:41 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/***********************************************************
Copyright 1987, 1988, 1990 by Digital Equipment Corporation, Maynard,
Massachusetts, and the Massachusetts Institute of Technology, Cambridge,
Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#include "HashP.h"
/******** Static Function Declarations ********/
static unsigned int GetTableIndex(
register DtHashTable tab,
register DtHashKey key,
#if NeedWidePrototypes
register int new) ;
#else
register Boolean new) ;
#endif /* NeedWidePrototypes */
static void ExpandHashTable(
register DtHashTable tab) ;
/******** End Static Function Declarations ********/
typedef unsigned long Signature;
typedef struct _DtHashTableRec {
unsigned int mask; /* size of hash table - 1 */
unsigned int rehash; /* mask - 2 */
unsigned int occupied; /* number of occupied entries */
unsigned int fakes; /* number occupied by DTHASHfake */
DtHashEntryType *types; /* lookup methods for key */
unsigned short numTypes; /* number of lookup methods */
Boolean keyIsString; /* whether the hash key is a string */
DtHashEntry *entries; /* the entries */
}DtHashTableRec;
static DtHashEntryRec DtHashfake; /* placeholder for deletions */
#define HASH(tab,sig) ((sig) & tab->mask)
#define REHASHVAL(tab, idx) ((((idx) % tab->rehash) + 2) | 1)
#define REHASH(tab,idx,rehash) ((idx + rehash) & tab->mask)
#define KEY(tab, entry) \
((* (tab->types[entry->hash.type]->hash.getKeyFunc) ) \
(entry, tab->types[entry->hash.type]->hash.getKeyClientData))
#define RELEASE_KEY(tab, entry, key) \
{\
if (tab->types[entry->hash.type]->hash.releaseKeyProc) \
(* (tab->types[entry->hash.type]->hash.releaseKeyProc)) \
(entry, key); \
}
static unsigned int
GetTableIndex(
register DtHashTable tab,
register DtHashKey key,
#if NeedWidePrototypes
register int new)
#else
register Boolean new)
#endif /* NeedWidePrototypes */
{
register DtHashEntry *entries = tab->entries;
register int len, idx, i, rehash = 0;
register char c;
register Signature sig = 0;
register DtHashEntry entry;
String s1, s2;
DtHashKey compKey;
if (tab->keyIsString) {
s1 = (String)key;
for (s2 = (char *)s1; c = *s2++; )
sig = (sig << 1) + c;
len = s2 - s1 - 1;
}
else
sig = (Signature)key;
idx = HASH(tab, sig);
while (entry = entries[idx]) {
if (entries[idx] == &DtHashfake) {
if (new)
return idx;
else
goto nomatch;
}
if (tab->keyIsString) {
compKey = KEY(tab, entry);
for (i = len, s1 = (String)key, s2 = (String) compKey;
--i >= 0; ) {
if (*s1++ != *s2++)
goto nomatch;
}
}
else {
if ((compKey = KEY(tab, entry)) != key)
s2 = " ";
else
s2 = "";
}
if (*s2) {
nomatch:
RELEASE_KEY(tab, entry, compKey);
if (!rehash)
rehash = REHASHVAL(tab, idx);
idx = REHASH(tab, idx, rehash);
continue;
}
else
RELEASE_KEY(tab, entry, compKey);
break;
}
return idx;
}
void
_DtRegisterHashEntry(
register DtHashTable tab,
register DtHashKey key,
register DtHashEntry entry )
{
unsigned int idx;
if ((tab->occupied + (tab->occupied >> 2)) > tab->mask)
ExpandHashTable(tab);
idx = GetTableIndex(tab, key, True);
if (tab->entries[idx] == &DtHashfake)
tab->fakes--;
tab->occupied++;
tab->entries[idx] = entry;
}
void
_DtUnregisterHashEntry(
register DtHashTable tab,
register DtHashEntry entry )
{
register int idx, rehash;
register DtHashEntry *entries = tab->entries;
DtHashKey key = KEY(tab, entry);
idx = GetTableIndex(tab, key, False);
RELEASE_KEY(tab, entry, key);
entries[idx] = &DtHashfake;
tab->fakes++;
tab->occupied--;
}
static void
ExpandHashTable(
register DtHashTable tab )
{
unsigned int oldmask;
register DtHashEntry *oldentries, *entries;
register int oldidx, newidx, rehash, len;
register DtHashEntry entry;
register DtHashKey key;
oldmask = tab->mask;
oldentries = tab->entries;
tab->fakes = 0;
if ((tab->occupied + (tab->occupied >> 2)) > tab->mask) {
tab->mask = (tab->mask << 1) + 1;
tab->rehash = tab->mask - 2;
}
entries = tab->entries = (DtHashEntry *) XtCalloc(tab->mask+1, sizeof(DtHashEntry));
for (oldidx = 0; oldidx <= oldmask; oldidx++) {
if ((entry = oldentries[oldidx]) && entry != &DtHashfake) {
newidx = GetTableIndex(tab, key = KEY(tab, entry), True);
RELEASE_KEY(tab, entry, key);
entries[newidx] = entry;
}
}
XtFree((char *)oldentries);
}
DtHashEntry
_DtEnumerateHashTable(
register DtHashTable tab,
register DtHashEnumerateFunc enumFunc,
register XtPointer clientData )
{
register unsigned int i;
for (i = 0; i <= tab->mask; i++)
if (tab->entries[i] &&
tab->entries[i] != &DtHashfake &&
((*enumFunc) (tab->entries[i], clientData)))
return tab->entries[i];
return NULL;
}
DtHashEntry
_DtKeyToHashEntry(
register DtHashTable tab,
register DtHashKey key )
{
register int idx, rehash, len;
register DtHashEntry entry, *entries = tab->entries;
if (!key) return NULL;
idx = GetTableIndex(tab, key, False);
return entries[idx];
}
DtHashTable
_DtAllocHashTable(DtHashEntryType *hashEntryTypes,
Cardinal numHashEntryTypes,
#if NeedWidePrototypes
int keyIsString)
#else
Boolean keyIsString)
#endif /* NeedWidePrototypes */
{
register DtHashTable tab;
tab = (DtHashTable) XtMalloc(sizeof(struct _DtHashTableRec));
tab->types = hashEntryTypes;
tab->numTypes = numHashEntryTypes;
tab->keyIsString = keyIsString;
tab->mask = 0x7f;
tab->rehash = tab->mask - 2;
tab->entries = (DtHashEntry *) XtCalloc(tab->mask+1, sizeof(DtHashEntry));
tab->occupied = 0;
tab->fakes = 0;
return tab;
}
void
_DtFreeHashTable(
DtHashTable hashTable )
{
XtFree((char *)hashTable->entries);
XtFree((char *)hashTable);
}

View File

@@ -0,0 +1,159 @@
/* $XConsortium: HashP.h /main/4 1995/10/26 15:22:50 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifdef REV_INFO
#ifndef lint
static char SCCSID[] = "OSF/Motif: @(#)_HashP.h 4.16 91/09/12";
#endif /* lint */
#endif /* REV_INFO */
/******************************************************************************
*******************************************************************************
*
* (c) Copyright 1989, 1990, 1991 OPEN SOFTWARE FOUNDATION, INC.
* (c) Copyright 1989, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
* (c) Copyright 1987, 1988, 1989, 1990, 1991 HEWLETT-PACKARD COMPANY
* ALL RIGHTS RESERVED
*
* THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED
* AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND
* WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR
* ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE
* AVAILABLE TO ANY OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE
* SOFTWARE IS HEREBY TRANSFERRED.
*
* THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT
* NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY OPEN SOFTWARE
* FOUNDATION, INC. OR ITS THIRD PARTY SUPPLIERS
*
* OPEN SOFTWARE FOUNDATION, INC. AND ITS THIRD PARTY SUPPLIERS,
* ASSUME NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE ANY OF ITS
* SOFTWARE . OSF SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
* KIND, AND OSF EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE.
*
* Notice: Notwithstanding any other lease or license that may pertain to,
* or accompany the delivery of, this computer software, the rights of the
* Government regarding its use, reproduction and disclosure are as set
* forth in Section 52.227-19 of the FARS Computer Software-Restricted
* Rights clause.
*
* (c) Copyright 1989, 1990, 1991 Open Software Foundation, Inc. Unpublished - all
* rights reserved under the Copyright laws of the United States.
*
* RESTRICTED RIGHTS NOTICE: Use, duplication, or disclosure by the
* Government is subject to the restrictions as set forth in subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software clause
* at DFARS 52.227-7013.
*
* Open Software Foundation, Inc.
* 11 Cambridge Center
* Cambridge, MA 02142
* (617)621-8700
*
* RESTRICTED RIGHTS LEGEND: This computer software is submitted with
* "restricted rights." Use, duplication or disclosure is subject to the
* restrictions as set forth in NASA FAR SUP 18-52.227-79 (April 1985)
* "Commercial Computer Software- Restricted Rights (April 1985)." Open
* Software Foundation, Inc., 11 Cambridge Center, Cambridge, MA 02142. If
* the contract contains the Clause at 18-52.227-74 "Rights in Data General"
* then the "Alternate III" clause applies.
*
* (c) Copyright 1989, 1990, 1991 Open Software Foundation, Inc.
* ALL RIGHTS RESERVED
*
*
* Open Software Foundation is a trademark of The Open Software Foundation, Inc.
* OSF is a trademark of Open Software Foundation, Inc.
* OSF/Motif is a trademark of Open Software Foundation, Inc.
* Motif is a trademark of Open Software Foundation, Inc.
* DEC is a registered trademark of Digital Equipment Corporation
* DIGITAL is a registered trademark of Digital Equipment Corporation
* X Window System is a trademark of the Massachusetts Institute of Technology
*
*******************************************************************************
******************************************************************************/
#ifndef __HashP_h
#define __HashP_h
#include <X11/Intrinsic.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* the structure is used as a common header part for different
* users of the hash functions in order to locate the key
*/
typedef XtPointer DtHashKey;
typedef DtHashKey (*DtGetHashKeyFunc)();
typedef Boolean (*DtHashEnumerateFunc)();
typedef void (*DtReleaseKeyProc)();
typedef struct _DtHashEntryPartRec {
unsigned int type:16;
unsigned int flags:16;
}DtHashEntryPartRec, *DtHashEntryPart;
typedef struct _DtHashEntryRec {
DtHashEntryPartRec hash;
}DtHashEntryRec, *DtHashEntry;
typedef struct _DtHashEntryTypePartRec {
unsigned int entrySize;
DtGetHashKeyFunc getKeyFunc;
XtPointer getKeyClientData;
DtReleaseKeyProc releaseKeyProc;
}DtHashEntryTypePartRec, *DtHashEntryTypePart;
typedef struct _DtHashEntryTypeRec {
DtHashEntryTypePartRec hash;
}DtHashEntryTypeRec, *DtHashEntryType;
typedef struct _DtHashTableRec *DtHashTable;
/******** Private Function Declarations for Hash.c ********/
extern void _DtRegisterHashEntry(
register DtHashTable tab,
register DtHashKey key,
register DtHashEntry entry) ;
extern void _DtUnregisterHashEntry(
register DtHashTable tab,
register DtHashEntry entry) ;
extern DtHashEntry _DtEnumerateHashTable(
register DtHashTable tab,
register DtHashEnumerateFunc enumFunc,
register XtPointer clientData) ;
extern DtHashEntry _DtKeyToHashEntry(
register DtHashTable tab,
register DtHashKey key) ;
extern DtHashTable _DtAllocHashTable(
DtHashEntryType *hashEntryTypes,
Cardinal numHashEntryTypes,
#if NeedWidePrototypes
int keyIsString) ;
#else
Boolean keyIsString) ;
#endif /* NeedWidePrototypes */
extern void _DtFreeHashTable(
DtHashTable hashTable) ;
/******** End Private Function Declarations ********/
#ifdef __cplusplus
} /* Close scope of 'extern "C"' declaration which encloses file. */
#endif
#endif /* HashP_h */
/* DON'T ADD ANYTHING AFTER THIS #endif */

View File

@@ -0,0 +1,344 @@
/* $XConsortium: HourGlass.c /main/5 1996/06/21 17:22:09 ageorge $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/************************************<+>*************************************
****************************************************************************
**
** File: HourGlass.c
**
** Project: dt Dt Utility function
**
** Description: This module contains a simple function for
** creating an hourglass cursor.
**
** (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
**
**
**
****************************************************************************
************************************<+>*************************************/
/*****************************************************************************
*
* (c) Copyright 1989,1990 OPEN SOFTWARE FOUNDATION, INC.
* (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY
* ALL RIGHTS RESERVED
*
* THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED
* AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND
* WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR
* ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE
* AVAILABLE TO ANY OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE
* SOFTWARE IS HEREBY TRANSFERRED.
*
* THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT
* NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY OPEN SOFTWARE
* FOUNDATION, INC. OR ITS THIRD PARTY SUPPLIERS
*
* OPEN SOFTWARE FOUNDATION, INC. AND ITS THIRD PARTY SUPPLIERS,
* ASSUME NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE ANY OF ITS
* SOFTWARE . OSF SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
* KIND, AND OSF EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE.
*
* Notice: Notwithstanding any other lease or license that may pertain to,
* or accompany the delivery of, this computer software, the rights of the
* Government regarding its use, reproduction and disclosure are as set
* forth in Section 52.227-19 of the FARS Computer Software-Restricted
* Rights clause.
*
* (c) Copyright 1989,1990 Open Software Foundation, Inc. Unpublished - all
* rights reserved under the Copyright laws of the United States.
*
* RESTRICTED RIGHTS NOTICE: Use, duplication, or disclosure by the
* Government is subject to the restrictions as set forth in subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software clause
* at DFARS 52.227-7013.
*
* Open Software Foundation, Inc.
* 11 Cambridge Center
* Cambridge, MA 02142
* (617)621-8700
*
* RESTRICTED RIGHTS LEGEND: This computer software is submitted with
* "restricted rights." Use, duplication or disclosure is subject to the
* restrictions as set forth in NASA FAR SUP 18-52.227-79 (April 1985)
* "Commercial Computer Software- Restricted Rights (April 1985)." Open
* Software Foundation, Inc., 11 Cambridge Center, Cambridge, MA 02142. If
* the contract contains the Clause at 18-52.227-74 "Rights in Data General"
* then the "Alternate III" clause applies.
*
* (c) Copyright 1989,1990 Open Software Foundation, Inc.
* ALL RIGHTS RESERVED
*
*
* Open Software Foundation is a trademark of The Open Software
* Foundation, Inc.
*
* OSF is a trademark of Open Software Foundation, Inc.
* OSF/Motif is a trademark of Open Software Foundation, Inc.
* Motif is a trademark of Open Software Foundation, Inc.
* DEC is a registered trademark of Digital Equipment Corporation
* DIGITAL is a registered trademark of Digital Equipment Corporation
* X Window System is a trademark of the Massachusetts Institute of Technology
*
*****************************************************************************
*************************************<+>*************************************/
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include "DtSvcLock.h"
#define time32_width 32
#define time32_height 32
#define time32_x_hot 15
#define time32_y_hot 15
static unsigned char time32_bits[] = {
0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
0x8c, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
0x8c, 0x00, 0x00, 0x31, 0x0c, 0x7f, 0xfe, 0x30, 0x0c, 0xfe, 0x7f, 0x30,
0x0c, 0xfc, 0x3f, 0x30, 0x0c, 0xf8, 0x1f, 0x30, 0x0c, 0xe0, 0x07, 0x30,
0x0c, 0x80, 0x01, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x60, 0x06, 0x30,
0x0c, 0x18, 0x18, 0x30, 0x0c, 0x04, 0x20, 0x30, 0x0c, 0x02, 0x40, 0x30,
0x0c, 0x01, 0x80, 0x30, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x80, 0x01, 0x32,
0x4c, 0xc0, 0x03, 0x32, 0x4c, 0xf0, 0x1f, 0x32, 0x4c, 0xff, 0xff, 0x32,
0xcc, 0xff, 0xff, 0x33, 0x8c, 0xff, 0xff, 0x31, 0xfe, 0xff, 0xff, 0x7f,
0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
#define time32m_width 32
#define time32m_height 32
static unsigned char time32m_bits[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xcf, 0x00, 0x00, 0xf3, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
0xce, 0x00, 0x00, 0x73, 0x8e, 0x7f, 0xfe, 0x71, 0x0e, 0xff, 0xff, 0x70,
0x0e, 0xfe, 0x7f, 0x70, 0x0e, 0xfc, 0x3f, 0x70, 0x0e, 0xf8, 0x1f, 0x70,
0x0e, 0xe0, 0x07, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0x78, 0x1e, 0x70,
0x0e, 0x1c, 0x38, 0x70, 0x0e, 0x06, 0x60, 0x70, 0x0e, 0x03, 0xc0, 0x70,
0x8e, 0x01, 0x80, 0x71, 0xce, 0x00, 0x00, 0x73, 0x6e, 0x80, 0x01, 0x76,
0x6e, 0xc0, 0x03, 0x76, 0x6e, 0xf0, 0x1f, 0x76, 0x6e, 0xff, 0xff, 0x76,
0xee, 0xff, 0xff, 0x77, 0xcf, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
#define time16_x_hot 7
#define time16_y_hot 7
#define time16_width 16
#define time16_height 16
static unsigned char time16_bits[] = {
0x00, 0x00, 0xfe, 0x7f, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x24, 0x24,
0x44, 0x22, 0x84, 0x21, 0x84, 0x21, 0x44, 0x22, 0x24, 0x24, 0x14, 0x28,
0x94, 0x29, 0xd4, 0x2b, 0xfe, 0x7f, 0x00, 0x00};
#define time16m_width 16
#define time16m_height 16
static unsigned char time16m_bits[] = {
0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff};
/******** Public Function Declarations ********/
extern Cursor _DtGetHourGlassCursor(
Display *dpy) ;
extern void _DtTurnOnHourGlass(
Widget w) ;
extern void _DtTurnOffHourGlass(
Widget w) ;
/******** End Public Function Declarations ********/
/*************************************<->*************************************
*
* Cursor _DtGetHourGlassCursor ()
*
*
* Description:
* -----------
* Builds and returns the appropriate Hourglass cursor
*
*
* Inputs:
* ------
* dpy = display
*
* Outputs:
* -------
* Return = cursor.
*
* Comments:
* --------
* None. (None doesn't count as a comment)
*
*************************************<->***********************************/
Cursor
_DtGetHourGlassCursor(
Display *dpy )
{
unsigned char *bits;
unsigned char *maskBits;
unsigned int width;
unsigned int height;
unsigned int xHotspot;
unsigned int yHotspot;
Pixmap pixmap;
Pixmap maskPixmap;
XColor xcolors[2];
int scr;
unsigned int cWidth;
unsigned int cHeight;
int useLargeCursors = 0;
static Cursor waitCursor=0;
_DtSvcProcessLock();
if (waitCursor != 0) {
_DtSvcProcessUnlock();
return(waitCursor);
}
if (XQueryBestCursor (dpy, DefaultRootWindow(dpy),
32, 32, &cWidth, &cHeight))
{
if ((cWidth >= 32) && (cHeight >= 32))
{
useLargeCursors = 1;
}
}
if (useLargeCursors)
{
width = time32_width;
height = time32_height;
bits = time32_bits;
maskBits = time32m_bits;
xHotspot = time32_x_hot;
yHotspot = time32_y_hot;
}
else
{
width = time16_width;
height = time16_height;
bits = time16_bits;
maskBits = time16m_bits;
xHotspot = time16_x_hot;
yHotspot = time16_y_hot;
}
pixmap = XCreateBitmapFromData (dpy,
DefaultRootWindow(dpy), (char*) bits,
width, height);
maskPixmap = XCreateBitmapFromData (dpy,
DefaultRootWindow(dpy), (char*) maskBits,
width, height);
xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
XQueryColors (dpy,
DefaultColormapOfScreen(DefaultScreenOfDisplay
(dpy)), xcolors, 2);
waitCursor = XCreatePixmapCursor (dpy, pixmap, maskPixmap,
&(xcolors[0]), &(xcolors[1]),
xHotspot, yHotspot);
XFreePixmap (dpy, pixmap);
XFreePixmap (dpy, maskPixmap);
_DtSvcProcessUnlock();
return (waitCursor);
}
/*************************************<->*************************************
*
* void DtSetHourGlass
*
*
* Description:
* -----------
* sets the window cursor to an hourglass
*
*
* Inputs:
* ------
* w = Widget
*
* Outputs:
* -------
* None
*
* Comments:
* --------
* None. (None doesn't count as a comment)
*
*************************************<->***********************************/
void
_DtTurnOnHourGlass(
Widget w )
{
Cursor cursor;
cursor = _DtGetHourGlassCursor(XtDisplay(w));
XDefineCursor(XtDisplay(w), XtWindow(w), cursor);
XFlush(XtDisplay(w));
}
/*************************************<->*************************************
*
* void _DtTurnOffHourGlass
*
*
* Description:
* -----------
* Removed the hourglass cursor from a window
*
*
* Inputs:
* ------
* w = Widget
*
* Outputs:
* -------
* None
*
* Comments:
* --------
* None. (None doesn't count as a comment)
*
*************************************<->***********************************/
void
_DtTurnOffHourGlass(
Widget w )
{
XUndefineCursor(XtDisplay(w), XtWindow(w));
XFlush(XtDisplay(w));
}

View File

@@ -0,0 +1,72 @@
/* $XConsortium: HourGlass.h /main/4 1995/10/26 15:23:08 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/************************************<+>*************************************
****************************************************************************
**
** File: HourGlass.h
**
** Project: DT
**
** Description: Public include file for HourGlass Library.
**
**
** (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
**
**
**
****************************************************************************
************************************<+>*************************************/
#ifndef _hourglass_h
#define _hourglass_h
/* _DtGetHourGlassCursor -
*
* Builds and returns the appropriate HourGlass cursor.
*/
extern Cursor _DtGetHourGlassCursor(
Display *dpy) ;
/* _DtTurnOnHourGlass -
*
* Gets and displays an hourglass cursor in the window of the widget
* which is passed in to the funciton.
*/
extern void _DtTurnOnHourGlass(
Widget w) ;
/* Widget widget;
*
* widget is the toplevel shell of the window you want
* the hourglass cursor to appear in.
*/
/* _DtTurnOffHourGlass -
*
* Removes the hourglass cursor from the window of the widget
* which is passed in to the funciton.
*/
extern void _DtTurnOffHourGlass(
Widget w) ;
/* Widget widget;
*
* widget is the toplevel shell of the window you want
* to remove hourglass cursor from.
*/
#endif /* _hourglass_h */
/* DON'T ADD ANYTHING AFTER THIS #endif */

View File

@@ -0,0 +1,118 @@
/* $XConsortium: IconFile.h /main/4 1995/10/26 15:23:17 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifdef REV_INFO
#ifndef lint
static char SCCSID[] = "OSF/Motif: @(#)_IconFile.h 4.16 91/09/12";
#endif /* lint */
#endif /* REV_INFO */
/******************************************************************************
*******************************************************************************
*
* (c) Copyright 1989, 1990, 1991 OPEN SOFTWARE FOUNDATION, INC.
* (c) Copyright 1989, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
* (c) Copyright 1987, 1988, 1989, 1990, 1991 HEWLETT-PACKARD COMPANY
* ALL RIGHTS RESERVED
*
* THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED
* AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND
* WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR
* ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE
* AVAILABLE TO ANY OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE
* SOFTWARE IS HEREBY TRANSFERRED.
*
* THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT
* NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY OPEN SOFTWARE
* FOUNDATION, INC. OR ITS THIRD PARTY SUPPLIERS
*
* OPEN SOFTWARE FOUNDATION, INC. AND ITS THIRD PARTY SUPPLIERS,
* ASSUME NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE ANY OF ITS
* SOFTWARE . OSF SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
* KIND, AND OSF EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE.
*
* Notice: Notwithstanding any other lease or license that may pertain to,
* or accompany the delivery of, this computer software, the rights of the
* Government regarding its use, reproduction and disclosure are as set
* forth in Section 52.227-19 of the FARS Computer Software-Restricted
* Rights clause.
*
* (c) Copyright 1989, 1990, 1991 Open Software Foundation, Inc. Unpublished - all
* rights reserved under the Copyright laws of the United States.
*
* RESTRICTED RIGHTS NOTICE: Use, duplication, or disclosure by the
* Government is subject to the restrictions as set forth in subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software clause
* at DFARS 52.227-7013.
*
* Open Software Foundation, Inc.
* 11 Cambridge Center
* Cambridge, MA 02142
* (617)621-8700
*
* RESTRICTED RIGHTS LEGEND: This computer software is submitted with
* "restricted rights." Use, duplication or disclosure is subject to the
* restrictions as set forth in NASA FAR SUP 18-52.227-79 (April 1985)
* "Commercial Computer Software- Restricted Rights (April 1985)." Open
* Software Foundation, Inc., 11 Cambridge Center, Cambridge, MA 02142. If
* the contract contains the Clause at 18-52.227-74 "Rights in Data General"
* then the "Alternate III" clause applies.
*
* (c) Copyright 1989, 1990, 1991 Open Software Foundation, Inc.
* ALL RIGHTS RESERVED
*
*
* Open Software Foundation is a trademark of The Open Software Foundation, Inc.
* OSF is a trademark of Open Software Foundation, Inc.
* OSF/Motif is a trademark of Open Software Foundation, Inc.
* Motif is a trademark of Open Software Foundation, Inc.
* DEC is a registered trademark of Digital Equipment Corporation
* DIGITAL is a registered trademark of Digital Equipment Corporation
* X Window System is a trademark of the Massachusetts Institute of Technology
*
*******************************************************************************
******************************************************************************/
#ifndef __DtIconFile_h
#define __DtIconFile_h
#include <Xm/Xm.h>
#include <Xm/IconFile.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* values for icon magnitude
*/
#define DtUNSPECIFIED 0
#define DtLARGE 1
#define DtMEDIUM 2
#define DtSMALL 3
#define DtTINY 4
/******** Public Function Declarations for XmWrap.c ********/
extern String _DtGetIconFileName(
Screen *screen,
String imageInstanceName,
String imageClassName,
String hostPrefix,
unsigned int size) ;
/******** End Public Function Declarations ********/
#ifdef __cplusplus
} /* Close scope of 'extern "C"' declaration which encloses file. */
#endif
#endif /* __DtIconFile_h */
/* DON'T ADD ANYTHING AFTER THIS #endif */

View File

@@ -0,0 +1,142 @@
XCOMM $TOG: Imakefile /main/14 1998/04/22 14:18:31 mgreess $
#define DoNormalLib NormalLibDtSvc
#define DoSharedLib SharedLibDtSvc
#define DoDebugLib DebugLibDtSvc
#define DoProfileLib ProfileLibDtSvc
#define LibName DtSvc
#define SoRev SODTSVCREV
#define IncSubdir Dt
#define LibCreate NO
#include <Threads.tmpl>
#ifndef DtSvcDefines
# define DtSvcDefines -DXK_MISCELLANY -DMULTIBYTE
#endif
DEFINES = DtSvcDefines \
-DCDE_INSTALLATION_TOP=\"$(CDE_INSTALLATION_TOP)\" \
-DCDE_CONFIGURATION_TOP=\"$(CDE_CONFIGURATION_TOP)\"
INCLUDES = -I. -I../include
#ifdef SunArchitecture
EXTRA_INCLUDES = -I$(DTHELPSRC)
EXTRA_SRCS = SunDtHelp.c
EXTRA_OBJS = SunDtHelp.o
#endif
HEADERS = \
ChkpntP.h \
Collate.h \
CommandM.h \
Connect.h \
DataTypes.h \
DtNlUtils.h \
DtP.h \
DtPStrings.h \
DtosP.h \
DtpadM.h \
EnvControlI.h \
EnvControlP.h \
FileM.h \
FileUtil.h \
GetDispRes.h \
DtGetMessageP.h \
HashP.h \
HourGlass.h \
IconFile.h \
Indicator.h \
IndicatorM.h \
Info.h \
LocaleXlate.h \
Lock.h \
Message.h \
Msg.h \
MsgP.h \
MsgCatP.h \
MsgLog.h \
MsgLogI.h \
Service.h \
Setlocale.h \
SharedProcs.h \
SmCreateDirs.h \
Spc.h \
SvcTT.h \
Unistd.h \
UserMsg.h \
Utility.h \
UtilityP.h \
XlationSvc.h
SRCS = \
$(EXTRA_SRCS) \
ChkpntClient.c \
ChkpntListen.c \
DtEnvMap.c \
DtNlUtils.c \
EnvControl.c \
FileUtil.c \
GetDispRes.c \
GetMessage.c \
HourGlass.c \
Info.c \
SharedProcs.c \
SmCreateDirs.c \
UErrNoBMS.c \
Utility.c \
ActIndicator.c \
CmdUtility.c \
DtGetMessage.c \
DtUtil.c \
GetEmbed.c \
Hash.c \
PrintXErr.c \
XmWrap.c \
addToRes.c \
lock.c \
SvcTT.c \
MsgCat.c \
MsgLog.c \
LocaleXlate.c \
XlationSvc.c
/* WARNING!!!!
* Any .o's added to this list need to be added to DTUTIL2_OBJS
* and SHARED_DTUTIL2_OBJS in the DtSvc Imakefile.
*/
OBJS = \
$(EXTRA_OBJS) \
ChkpntClient.o \
ChkpntListen.o \
DtEnvMap.o \
DtNlUtils.o \
EnvControl.o \
FileUtil.o \
GetDispRes.o \
GetMessage.o \
HourGlass.o \
Info.o \
SharedProcs.o \
SmCreateDirs.o \
UErrNoBMS.o \
Utility.o \
ActIndicator.o \
CmdUtility.o \
DtGetMessage.o \
DtUtil.o \
GetEmbed.o \
Hash.o \
PrintXErr.o \
XmWrap.o \
addToRes.o \
lock.o \
SvcTT.o \
MsgCat.o \
MsgLog.o \
LocaleXlate.o \
XlationSvc.o
#include <Library.tmpl>
SubdirLibraryRule($(OBJS))
DependTarget()

View File

@@ -0,0 +1,42 @@
/* $XConsortium: Indicator.h /main/4 1995/10/26 15:23:41 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/*
********************************************************************************
*
* File: Indicator.h
* Description: Public header for Activity Indicator
*
* (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
*
********************************************************************************
*/
#ifndef _Indicator_h
#define _Indicator_h
extern void _DtSendActivityNotification( int ) ;
/* int duration; Maximum activation time for the indicator */
/*
* _DtSendActivityNotification() provides the application with the means for
* notifying the world that an activity has been started, and may take upto
* 'duration' seconds. For now, the workspace manager will enable the
* activity indicator for upto the indicated duration of time; the time is
* in units of seconds.
*/
extern void _DtSendActivityDoneNotification( void ) ;
/*
* _DtSendActivityDoneNotification() provides the application with the means for
* notifying the world that an activity which had earlier been started, is
* now complete.
*/
#endif /* _Indicator_h */
/* DON'T ADD STUFF AFTER THIS #endif */

View File

@@ -0,0 +1,37 @@
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/*****************************<+>*************************************
*********************************************************************
**
** File: IndicatorM.h
**
** RCS: $XConsortium: IndicatorM.h /main/3 1995/10/26 15:23:53 rswiston $
** Project: DT
**
** Description: Defines indicator messages
**
** (c) Copyright 1990 by Hewlett-Packard Company
**
*********************************************************************
*****************************<+>*************************************/
#ifndef _IndicatorM_h
#define _IndicatorM_h
/*
* BMS Messaging definitions
*/
/* _DtMessage for turning on the activity indicator */
#define DtACTIVITY_NOTIFICATION "ACTIVITY_NOTIFICATION"
/* _DtMessage for turning off the activity indicator */
#define DtACTIVITY_DONE_NOTIFICATION "ACTIVITY_DONE_NOTIFICATION"
#endif /* _IndicatorM_h */
/* Do not add anything after this endif. */

View File

@@ -0,0 +1,144 @@
/* $XConsortium: Info.c /main/1 1996/03/25 19:10:11 barstow $
*
* (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 <stdlib.h>
#include <sys/param.h> /* MAXHOSTNAMELEN */
#include <Tt/tt_c.h>
#include <Dt/Info.h>
#include <Dt/Connect.h>
/*
* External declaration for Xegethostname
*/
extern int Xegetshorthostname (char * hostname, unsigned int size);
/*
* Static variables
*/
static const char * DTINFOLIBDEFAULT_NAME = "DTINFOLIBDEFAULT";
static const char * DTINFOLIBDEFAULT_DEFAULT = "cde";
static const char * SHOW_INFO_OP_NAME = "DtInfo_ShowInfoAtLoc";
static const char * SHOW_INFO_DEFAULT_ACTION = "DtInfoStartAtLoc";
static const char * LOCALE_NAME = "LANG";
static const char * DEFAULT_LOCALE = "C";
static const char * STRING_ARG_TYPE = "string";
/*
* Forward declarations for static functions
*/
static DtInfoShowStatus ConnectToMessageServer ();
/*
* Public functions
*/
DtInfoShowStatus
DtInfoShowTopic (
const char * info_lib, /* the InfoLib */
const char * locator) /* the generalized locator
format */
{
Tt_message message;
Tt_status status;
DtInfoShowStatus ret_val;
const char * file = info_lib;
const char * locale;
char host[MAXHOSTNAMELEN];
/*
* Check the arguments
*/
if (!locator)
return (DtINFO_SHOW_BAD_LOCATOR);
if ((ret_val = ConnectToMessageServer ()) != DtINFO_SHOW_OK)
return (ret_val);
if (!file) {
if ((file = getenv (DTINFOLIBDEFAULT_NAME)) == NULL)
file = DTINFOLIBDEFAULT_DEFAULT;
}
if ((locale = getenv (LOCALE_NAME)) == NULL)
locale = DEFAULT_LOCALE;
message = tt_message_create ();
status = tt_ptr_error (message);
if (status != TT_OK)
return (DtINFO_SHOW_MSG_CREATE_FAIL);
/*
* Initialize message
*/
tt_message_class_set (message, TT_REQUEST);
tt_message_scope_set (message, TT_SESSION);
tt_message_address_set (message, TT_PROCEDURE);
tt_message_session_set (message, tt_default_session());
tt_message_op_set (message, SHOW_INFO_OP_NAME);
tt_message_file_set (message, info_lib);
/*
* Add the arguments
*/
tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE,
SHOW_INFO_DEFAULT_ACTION);
if ((Xegetshorthostname (host, MAXHOSTNAMELEN)) != 0)
tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE, NULL);
else
tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE, host);
tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE, locale);
tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE, locator);
/*
* Send it
*/
status = tt_message_send (message);
if (status != TT_OK)
return (DtINFO_SHOW_MSG_SEND_FAIL);
return (DtINFO_SHOW_OK);
}
static DtInfoShowStatus
ConnectToMessageServer ()
{
char * procid;
Tt_status status;
procid = tt_default_procid ();
status = tt_ptr_error (procid);
if (status == TT_OK) {
tt_free (procid);
}
if ((status == TT_ERR_NOMP) || (status == TT_ERR_PROCID)) {
procid = tt_open ();
status = tt_ptr_error (procid);
if (status != TT_OK) {
return (DtINFO_SHOW_TT_OPEN_FAIL);
}
}
return (DtINFO_SHOW_OK);
}

View File

@@ -0,0 +1,37 @@
/* $XConsortium: Info.h /main/2 1996/03/26 15:05:44 barstow $
*
* (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 _dt_info_h_
#define _dt_info_h_
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
DtINFO_SHOW_OK,
DtINFO_SHOW_BAD_LOCATOR, /* the locator argument is NULL */
DtINFO_SHOW_TT_OPEN_FAIL, /* tt_open() failed */
DtINFO_SHOW_MSG_CREATE_FAIL, /* tt_message_create() failed */
DtINFO_SHOW_MSG_SEND_FAIL /* tt_message_send() failed */
} DtInfoShowStatus;
extern DtInfoShowStatus DtInfoShowTopic (
const char * info_lib, /* The InfoLib to browse */
const char * locator); /* The locator in Generalized Locator
Format */
#ifdef __cplusplus
}
#endif
#endif /* _dt_info_h_ */

View File

@@ -0,0 +1,724 @@
/* $TOG: LocaleXlate.c /main/14 1999/10/14 15:58:52 mgreess $ */
/************************************<+>*************************************
****************************************************************************
$FILEBEG$: LocaleXlate.c
$PROJECT$: CDE 1.0
$COMPONENT$: DtLcx service
$1LINER$: Locale translation routines
$COPYRIGHT$:
(c) Copyright 1993, 1994 Hewlett-Packard Company
(c) Copyright 1993, 1994 International Business Machines Corp.
(c) Copyright 1993, 1994 Sun Microsystems, Inc.
(c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of Novell, Inc.
$END$
****************************************************************************
************************************<+>*************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(sun)
#include <sys/utsname.h>
#endif
#include <limits.h>
#define X_INCLUDE_PWD_H
#define XOS_USE_XT_LOCKING
#include <X11/Xos_r.h> /* for getpw... */
#include <sys/param.h> /* MAXPATHLEN */
#include <sys/utsname.h> /* for uname */
#include <unistd.h>
/* for Xrm */
#include <X11/Intrinsic.h>
#include <X11/Xresource.h>
#include "XlationSvc.h"
/*=================================================================
$SHAREDBEG$: This is the header file that should appear in all
DtLcx topics
=======================================================$SKIP$======*/
/*$INCLUDE$*/
#include "LocaleXlate.h"
/*$END$*/
/*========================================================*/
/*================ Introductory Info =====================*/
/*========================================================*/
#if DOC
/*========================================================*/
$INTROBEG$: _DtLcx family
$1LINER$: Translate locale and codeset strings to/from any platform
$SUMMARY$:
The _DtLcx family of routines enables the translation of a
locale string from any platform into a standard locale string,
and from standard locale string to the locale string of any platform.
This is useful because each platform, and in fact within
version ranges of some platforms, different strings are used
that have the same meaning. This becomes a problem as soon as
any of these strings is stored in a file. If the file is
opened on a platform for which the string has no meaning,
that functionality supported by using the string is lost.
With the _DtLcx service, the string can be translated into
a string appropriate to the current platform.
Standard locale strings are based on the XoJIG proposed strings,
but with a slightly altered syntax to adhere to the constraints
of the translation database.
The following are the current set of standard strings:
_DtLcx uses the _DtXlate translation database services,
but the _DtLcx routines provide a high-level interface to
the _DtXlate routines tuned to locales. They allow any
component of a locale to be translated individually.
The _DtLcxOpenAllDbs() routine opens all the predefined
locale translation databases that can be found. These
may are the following:
/usr/dt/config/svc/<platform>.lcx
/etc/dt/config/svc/<platform>.lcx
$HOME/.dt/config/svc/<platform>.lcx
Alternatively, the DTLCXSEARCHPATH directory may be used
to specify a colon separated search path. Relative paths
in the search path are relative to the current working
directory.
One of the nice features of the _DtLcx service is that
the translation database is designed for extension. So
if new locales need to be supported, a system admin
or user can add the specifications to the appropriate
file and it will be immediately accessible.
/*=$END$================================================*/
#endif
#if DOC
/*========================================================*/
$INTROBEG$: _DtLcx translation table syntax
$1LINER$: translation table syntax for _DtLcx
$SUMMARY$:
BNF Syntax of Locale Translation Specification
==============================================
For the full syntax of translation specifications,
see the _DtXlate documentation.
<stdvalue> ::= <langterr>[.<codeset>[.<modifier>]]
<langterr> ::= <identifier> | <matchall>
<codeset> ::= <identifier> | <matchall>
<modifier> ::= <identifier> | <matchall>
<opvalue> ::= (<vischars>|<metachar>)+ | '"'(<anychar>|<metachar>)+'"'
Semantics of the Translation Specification
==========================================
For a full description of translation table semantics,
refer to the _DtXlatedocumentation.
<operations> : a CDE-standardized identifier for the operation(s) to
which the value applies. The operation(s) need not be supported by every
platform, but CDE must have standardized an identifier for the operation
in order for it to be used. More than one identifer may be included by
concatenating them using the ',' separator, eg. "iconv1,iconv3".
_DtLcx defines a number of standard operation strings that use
locales. Users of _DtLcx should use the constants beginning
_DtLCX_OPER... to specify a particular operation.
<stdvalue> : a sequence of one or more '.'-separated CDE-standardizd
identifiers or matchall characters. This represents the canonical
string used as a standard representation of a semantic value that
may vary in different situations.
<langterr> : a CDE-standardized identifier for a language and territory
for which the operation is valid. The language and territory must be
supported or irrelvant for the operations, as qualified for platform
and version, e.g. en_US. The identifier need not be the identifier
used on any actual platform to specify language and territory.
<codeset> : a CDE-standardized identifier for a codeset for which the
operation is valid. The codeset must be supported or irrelvant for
the operations, as qualified for platform and version, e.g. iso88591.
The identifier need not be the identifier used on any actual platform
to specify codeset.
<modifier> : a CDE-standardized identifier for a locale modifier.
The modifier must be supported or irrelvant for the operations,
as qualified for platform and version. The identifier need not be
the identifier used on any actual platform to specify modifiers.
<opvalue> : can be used in three ways. When a straight translation,
it is string that is matched against a query locale value to determine
the standard value of the locale. When a OpToStd translation,
the string is a regular expression that is matched against the
query string. When a StdToOp translation, the string is a
replacement value for the std value and may contain subexpression
replacement specifiers.
$EXAMPLE$:
These are some example specs:
HP-UX.900-999.setlocale.=.en_US.HP-ROMAN8: american
HP-UX.900-999.setlocale.=.en_US.ISO-8859-1: american.iso88591
HP-UX.900-999.setlocale.=.nl_NL.HP-ROMAN8: dutch
HP-UX.900-999.setlocale.=.nl_NL.ISO-8859-1: dutch.iso88591
/*=$END$================================================*/
#endif
#if DOC
/*========================================================*/
$INTROBEG$: _DtLcx example usage
$1LINER$: Examples of how to _DtLcx
$EXAMPLE$:
#include <LocaleXlate.h>
main()
{
_DtXlateDb db = NULL;
int ret;
char plat[_DtPLATFORM_MAX_LEN];
int execver;
int compver;
char * val = NULL;
char * str = NULL;
char * val1 = NULL;
char * val2 = NULL;
char * val3 = NULL;
ret = _DtLcxOpenAllDbs(&db);
ret = _DtXlateGetXlateEnv(db,plat,&execver,&compver);
printf("Platform: %s\nExec Ver: %d\nComp Ver: %d\n",
plat,execver,compver);
ret = _DtLcxXlateStdToOp(db,plat,compver,DtLCX_OPER_SETLOCALE,
str="en_US.hp-roman8",NULL,NULL,NULL,&val);
if (ret==0) printf("setlocale(%s) xlation=%s\n", str, val);
else printf("no xlation\n", val);
ret = _DtLcxXlateStdToOp(db,plat,compver,DtLCX_OPER_SETLOCALE,
str="en_US.?",NULL,NULL,NULL,&val);
if (ret==0) printf("setlocale(%s) xlation=%s\n", str, val);
else printf("no xlation\n", val);
ret = _DtLcxXlateOpToStd(db,plat,execver,DtLCX_OPER_SETLOCALE,
str="american",&val,&val1,&val2,&val3);
if (ret==0) printf("setlocale(%s) xlation=%s; %s; %s; %s\n",
str, val,val1,val2,val3);
else printf("no xlation\n", val,val1,val2,val3);
ret = _DtLcxXlateOpToStd(db,plat,execver,DtLCX_OPER_SETLOCALE,
str="dutch@fold",&val,&val1,&val2,&val3);
if (ret==0) printf("setlocale(%s) xlation=%s; %s; %s; %s\n",
str, val,val1,val2,val3);
ret = _DtLcxCloseDb(&db);
}
/*=$END$================================================*/
#endif
/*========================================================*/
/*====================== Constants =======================*/
/*========================================================*/
/*=============== private =================*/
/* A "random" number used to ensure that the Db has been initalized */
#define PATH_SEPARATOR ':'
#define EOS '\0'
#define DIR_SLASH '/'
#define DIR_SLASH_STR "/"
#define MATCHALL_STR "?"
#define DOT_STR "."
/*=============== internal =================*/
#define DTLCXSEARCHPATH "DTLCXSEARCHPATH"
#ifndef CDE_CONFIGURATION_TOP
#define CDE_CONFIGURATION_TOP "/etc/dt"
#endif
#ifndef CDE_INSTALLATION_TOP
#define CDE_INSTALLATION_TOP "/usr/dt"
#endif
#ifndef CDE_USER_TOP
#define CDE_USER_TOP ".dt"
#endif
#define DtLCX_USER_PATH s_LcxUserPath
#define DtLCX_INSTALL_AND_CONFIG_PATHS s_LcxInstallAndConfigPaths
#define _DtLCX_INSTALL_DB_DIR CDE_INSTALLATION_TOP "/config/svc/"
/* This is the file type of a _DtLcx file */
#define _DtLCX_DATABASE_TYPE ".lcx"
/* This is the name of the fallback _DtLcx file */
#define _DtLCX_DATABASE_FALLBACK ("dtcomplete" _DtLCX_DATABASE_TYPE)
/* This is the name of the CDE standard _DtLcx file */
#define _DtLCX_DATABASE_CDE ("CDE" _DtLCX_DATABASE_TYPE)
/*========================================================*/
/*====================== Variables =======================*/
/*========================================================*/
static char s_LcxUserPath[] = CDE_USER_TOP "/config/svc";
static char s_LcxInstallAndConfigPaths[] =
CDE_INSTALLATION_TOP "/config/svc:"
CDE_CONFIGURATION_TOP "/config/svc:";
/*========================================================*/
/*================== Private routines ====================*/
/*========================================================*/
#if DOC
/*========================================================*/
/*
$PFUNBEG$: GetHomeDirPath()
$1LINER$: Retrieves path to current user's home directory
$SUMMARY$:
Looks for first the HOME and then USER environment
variables. If these are not set, uses the password
info to get the user's home directory.
$ARGS$:
outptr: pts to string allocated by caller to hold the home dir path
Generally, the string should be at least MAXPATHLEN+1 in size.
max: maximum number of bytes allowed (including ending bytes).
$RETURNS$:
*/
/*================================================$SKIP$==*/
#endif
static
void GetHomeDirPath(
char * outptr,
unsigned int max)
{ /*$CODE$*/
int uid;
char * ptr = NULL;
_Xgetpwparams pwd_buf;
struct passwd * pwd_ret;
if((ptr = (char *)getenv("HOME")) == NULL)
{
if((ptr = (char *)getenv("USER")) != NULL)
pwd_ret = _XGetpwnam(ptr, pwd_buf);
else
{
uid = getuid();
pwd_ret = _XGetpwuid(uid, pwd_buf);
}
if (pwd_ret != NULL)
ptr = pwd_ret->pw_dir;
else
ptr = NULL;
}
if (ptr && strlen(ptr))
{
strncpy(outptr, ptr, max-1);
outptr[max-1] = '\0';
}
else outptr[0] = '\0' ;
} /*$END$*/
/*========================================================*/
/*================ Public DtLcx routines =================*/
/*========================================================*/
#if DOC
/*========================================================*/
$FUNBEG$: _DtLcxOpenAllDbs()
$1LINER$: Open and merge all locale translation databases that can be found
$SUMMARY$:
DtLcxOpenAllDbs() locates all translation databases
named "<platform>.lcx" present in the DTLCXSEARCHPATH
directories. If none exist, the file "dtcomplete.lcx"
is tried in those directories. Finally, the database "CDE.lcx"
is merged into those databases already loaded.
The <platform> string is taken from uname(2), which is the
same string returned by the command 'uname -s'. For example,
on HP-UX platforms, the string is "HPUX", so the translation
databases to be loaded must be named "HPUX.lcx".
By default, the search paths are:
DTLCXSEARCHPATH = "/usr/dt/config/svc:" \
"/etc/dt/config/svc:" \
"$HOME/.dt/config/svc"
Alternatively, the DTLCXSEARCHPATH directory may be used
to specify a colon separated search path. Relative paths
in the search path are relative to the current working
directory.
$ARGS$:
$RETURNS$:
Returns the return value of _DtXlateOpenAllDbs()
/*================================================$SKIP$==*/
#endif
int _DtLcxOpenAllDbs(
_DtXlateDb * ret_db)
{ /*$CODE$*/
char * paths;
char * dbPaths;
struct utsname names;
int ret = 0;
int globRet = -1;
int len;
char lcxfile[100];
char homePath[MAXPATHLEN];
_DtXlateDb cde_db = NULL;
#define MAXSHORTFNAMELEN 14
/* get host specifics and generate platform-specific lcx file name */
uname(&names);
len = MAXSHORTFNAMELEN - strlen(_DtLCX_DATABASE_TYPE);
strncpy(lcxfile,names.sysname,len);
lcxfile[len-1] = EOS;
strcat(lcxfile,_DtLCX_DATABASE_TYPE); /* e.g. HP-UX.lcx */
/* get paths for LCX */
paths = getenv(DTLCXSEARCHPATH);
if (NULL != paths && paths[0] != EOS)
{
dbPaths = strdup(paths);
}
else
{
const char *slash;
char *end;
/* no DTLCXSEARCHPATH; build a default path */
GetHomeDirPath(homePath, MAXPATHLEN);
end = homePath + strlen(homePath);
_DtMBStrrchr(homePath,DIR_SLASH,-1,&slash);
if ((end - 1) != slash && end < homePath + MAXPATHLEN - 2 )
{
*end++ = DIR_SLASH;
*end = EOS;
}
if (end < homePath + MAXPATHLEN - strlen(DtLCX_USER_PATH) - 1)
strcat(homePath,DtLCX_USER_PATH);
dbPaths = malloc(sizeof(char) *
(strlen(homePath)+strlen(DtLCX_INSTALL_AND_CONFIG_PATHS)+5));
if (dbPaths)
sprintf(dbPaths,"%s:%s",DtLCX_INSTALL_AND_CONFIG_PATHS,homePath);
}
/* open all dbs of filename found in paths */
globRet = _DtXlateOpenAllDbs(dbPaths,lcxfile, ret_db);
if (globRet != 0)
{ /* on failure */
/* open all dbs of the fallback filename found in paths */
globRet = _DtXlateOpenAllDbs(dbPaths,_DtLCX_DATABASE_FALLBACK, ret_db);
}
/* merge in the CDE standard translations database */
ret = _DtXlateOpenAllDbs(dbPaths,_DtLCX_DATABASE_CDE, &cde_db);
if (ret == 0)
{
globRet = 0;
_DtXlateMergeDbs(&cde_db,ret_db); /* cde_db get's closed by the merge */
}
else
_DtXlateCloseDb(&cde_db);
if(dbPaths) free(dbPaths);
return globRet;
} /*$END$*/
#if DOC
/*========================================================*/
$FUNBEG$: _DtLcxCloseDb()
$1LINER$: Close an open locale translation database
$SUMMARY$:
_DtLcxCloseDb() releases all memory associated with
the translation database. Further use of the database
object is an error.
$ARGS$:
$RETURNS$:
0: database was valid and has been closed
-1: invalid database pointer
$DEF$:
int _DtLcxCloseDb(
_DtXlateDb * io_db)
$NOTE$: the current implementation is a macro call to
_DtXlateCloseDb().
/*================================================$SKIP$==*/
#endif
#if DOC
/*========================================================*/
/*
$FUNBEG$: _DtLcxXlateOpToStd()
$1LINER$: Translate an operation-specific locale to a standard locale
$SUMMARY$:
_DtLcxXlateOpToStd() is designed to allow a locale string
that is specific to some platform, version, and operation to be
translated to a CDE standard locale. For example, a locale
string stored in a file on systemA and recovered by an application
on systemB can be translated into a CDE standard locale by the
application on system B.
The xlationDb is the database to use for the translation.
It must have been opened with a call to _DtLcxOpenAllDbs().
The platform and version arguments can be used to specify
systemA if the information is known. The platform value
should be one of _DtPLATFORM_xxx. If platform is unknown,
use _DtPLATFORM_UNKNOWN, and if version is unknown, use -1.
The operation is an optional argument. If the operation is known
from which the opValue originated or for which it was intended
for use on systemA, the operation may be specified using the
appropriate DtLCX_OPER_xxx constant. If the operation is unknown,
it should be NULL.
The opValue is the systemA locale string recovered by the
application on systemB and which should be translated. It is
an error if it is NULL.
Zero or more of the ret_xxx arguments may be NULL values.
If they are NULL, that value is not determined. For
non-NULL ret_xxx arguments, the string value of each
is allocated using malloc() and the pointer is assigned
at the location pointed to by the argument. The caller
function should free the memory wth free() when it is
no longer needed. The ret_xxx arguments have the following
values.
The ret_stdLocale points to a caller-owned string with
the CDE standard equivalent to opValue. This value is the '.'-
separated concatenation of the <langterr> and <codeset> fields
of the specification. If <langterr> or <codeset> is the matchall
character, that value and the '.' separator are dropped.
The ret_stdLangTerr points to a caller-owned string with
the CDE standard equivalent of the opValue's language and
territory. If <langterr> or <codeset> in the translation
specification is the matchall character, the value is the
empty string.
The ret_stdCodeset points to a caller-owned string with
the CDE standard equivalent of the opValue's codeset.
If <codeset> in the translation specification is the matchall
character, the value is the empty string.
The ret_stdModifier points to a caller-owned string with
the CDE standard equivalent of the opValue's modifier.
If <modifier> in the translation specification is the matchall
character or not present, the value is the empty string.
$ARGS$:
xlation_db: a translation database
platform: the platform string (see _DtXlateGetXlateEnv())
version: the version number (see _DtXlateGetXlateEnv())
operation: the operation of interest, e.g. "setlocale"
opValue: the operation-specific value pattern
ret_stdLocale: location where ptr to standard locale string is stored
ret_stdLangTerr:location where ptr to standard lang+terr string is stored
ret_stdCodeset: location where ptr to standard codeset string is stored
ret_stdModifier:location where ptr to standard modifier string is stored
$RETURNS$:
Return values are those of _DtXlateOpToStd()
*/
/*================================================$SKIP$==*/
#endif
int _DtLcxXlateOpToStd(
const _DtXlateDb xlationDb,
const char * platform,
const int version,
const char * operation,
const char * opValue,
char * * ret_stdLocale,
char * * ret_stdLangTerr,
char * * ret_stdCodeset,
char * * ret_stdModifier)
{ /*$CODE$*/
int ret;
char * stdValue = NULL;
Boolean freeStdValue = True;
int scanned = 0;
char langterr[50];
char codeset[50];
char mod[50];
/* do the translation */
ret = _DtXlateOpToStdValue(xlationDb,platform,version,operation,opValue,
&stdValue,NULL);
/* std locale string syntax: langterr.codeset.modifier */
/* parse into the desire chunks */
if (ret == 0 && stdValue)
scanned = sscanf(stdValue,"%[^.].%[^.].%s",langterr,codeset,mod);
/* locale string is just the std value */
if ( ret_stdLocale )
{ *ret_stdLocale = stdValue; freeStdValue = False; }
if ( ret_stdLangTerr)
{ *ret_stdLangTerr = ( scanned >= 1 ? strdup(langterr) : NULL); }
if ( ret_stdCodeset )
{ *ret_stdCodeset = ( scanned >= 2 ? strdup(codeset) : NULL); }
if ( ret_stdModifier )
{ *ret_stdModifier = ( scanned >= 3 ? strdup(mod) : NULL); }
if (freeStdValue && NULL != stdValue) free(stdValue);
return ret;
} /*$END$*/
#if DOC
/*========================================================*/
$FUNBEG$: _DtLcxXlateStdToOp()
$1LINER$: Translate a standard locale to an operation-specific one
$SUMMARY$:
_DtLcxXlateStdToOp() is designed to allow a locale string
that is the CDE standard locale to be translated to the appropriate
string for some platform, version, and operation. For example, a
CDE locale string stored in a file on systemA and recovered by an
application on systemB can be translated into a platform- and
operation-specific locale by the application on system B.
_DtLcxXlateStdToOp() takes a number of query qualifiers
and determines the best translation that matches them. The
routine allocates memory for the resulting operation-specific
locale using malloc() and stores the pointer to it at the
location pointed to by ret_opValue. If the query qualifiers
do not uniquely identify a translation specification, the
specification used is chosen at random from those that match.
[Random selection is an artifact of using XrmEnumerateDatabase()
to process the contents of the table--entries are not presented
to the processing routine in a pre-specified order.]
The xlationDb is the database to use for the translation.
It must have been opened with a call to _DtLcxOpenAllDbs().
The platform and version arguments are optional. If the desired
platform is the current one for the executing application,
use _DtPLATFORM_CURRENT, and if version is the current one
for the application, use -1.
The operation is a required argument, and should be selected
from the DtLCX_OPER_xxx constants.
The stdLocale is the CDE standard locale string, such as the
one recovered using _DtLcxXlateOpToStd(). The value is
the '.'-separated concatenation of the <langterr>, <codeset>,
and <modifier> fields, or it may be NULL. The stdLocale string
alone *or* any combination of stdLangTerr, stdCodeset, and
stdModifier strings may be specified for the translation, but
not both.
The stdLangTerr, stdCodeset, and stdModifier are the CDE strings,
such as the one recovered using _DtLcxXlateOpToStd(). The
strings are valid across CDE platforms and across operations.
The stdLangTerr, stdCodeset, or stdModifier string may be used
alone *or* in any combination with each other, but not with the
stdLocale string. The values may also be NULL.
$ARGS$:
xlationDb: a translation database
platform: the platform string (see _DtXlateGetXlateEnv())
version: the version number (see _DtXlateGetXlateEnv())
operation: the operation of interest, e.g. "setlocale"
stdValue: the standard value pattern
stdLocale: standard locale strin
stdLangTerr: standard lang+terr string
stdCodeset: standard codeset string
stdModifier: standard modifier string
ret_opValue: location where ptr to translated string is stored
$RETURNS$:
-1: if all stdXxx strings have NULL values
plus the return values are those of _DtXlateStdToOp()
/*================================================$SKIP$==*/
#endif
int _DtLcxXlateStdToOp(
const _DtXlateDb xlationDb,
const char * platform,
const int version,
const char * operation,
const char * stdLocale,
const char * stdLangTerr,
const char * stdCodeset,
const char * stdModifier,
char * * ret_opValue)
{ /*$CODE$*/
#define DTLCXXLATE_STDTOOP_BUFSIZE 256
char stdValueBuf[DTLCXXLATE_STDTOOP_BUFSIZE];
char *stdValue = stdValueBuf;
char empty = EOS;
char * matchall = MATCHALL_STR;
char * dot = DOT_STR;
char * sepLC = &empty;
char * sepCM = &empty;
int retval;
if (stdLocale)
{
if (strlen(stdLocale) >= DTLCXXLATE_STDTOOP_BUFSIZE)
stdValue = malloc(strlen(stdLocale) + 1);
else
stdValue = stdValueBuf;
stdValue[0] = EOS;
strcpy(stdValue, stdLocale);
}
else
{
int need = 0;
int bytes_needed = 0;
#define NEED_LANGTERR 0x01
#define NEED_CODESET 0x02
#define NEED_MODIFIER 0x04
if (stdLangTerr) need = NEED_LANGTERR;
if (stdCodeset) need = NEED_LANGTERR | NEED_CODESET;
if (stdModifier) need = NEED_LANGTERR | NEED_CODESET | NEED_MODIFIER;
if (need == 0) return -1; /* RETURN: need a pattern */
/* only include matchalls for those that are needed */
/* This is needed because of the manner of scoring matches.
If unnecessary matchall's are present, that can detract
from the score. */
if (need & NEED_LANGTERR)
{ stdLangTerr = (stdLangTerr ? stdLangTerr : matchall); }
if (need & (NEED_LANGTERR | NEED_CODESET))
{ stdCodeset = (stdCodeset ? stdCodeset : matchall); sepLC = dot; }
if (need & (NEED_LANGTERR | NEED_CODESET | NEED_MODIFIER))
{ stdModifier = (stdModifier ? stdModifier : matchall); sepCM = dot; }
bytes_needed =
strlen(stdLangTerr) + strlen(sepLC) + strlen(stdCodeset) +
strlen(sepCM) + strlen(stdModifier) + 1;
if (bytes_needed > DTLCXXLATE_STDTOOP_BUFSIZE)
stdValue = malloc(bytes_needed);
else
stdValue = stdValueBuf;
/* generate the std value string */
stdValue[0] = EOS;
sprintf(stdValue,
"%s%s%s%s%s",
stdLangTerr, sepLC, stdCodeset, sepCM, stdModifier);
}
retval = _DtXlateStdToOpValue(
xlationDb,platform,version,operation,
stdValue, ret_opValue,NULL);
if (stdValue && stdValue != stdValueBuf) free(stdValue);
return retval;
} /*$END$*/

View File

@@ -0,0 +1,90 @@
/* $XConsortium: LocaleXlate.h /main/4 1995/10/26 12:29:54 rswiston $ */
/************************************<+>*************************************
****************************************************************************
**
** File: LocaleXlate.h
**
** Project: DtLcx
**
** Description: locale translation services
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of Novell, Inc.
**
**
****************************************************************************
************************************<+>*************************************/
#ifndef _DtLCX_XLATE_LOCALE_I
#define _DtLCX_XLATE_LOCALE_I
#include "XlationSvc.h" /* FIX: move to <> */
#ifdef __cplusplus
extern "C" {
#endif
#if DOC
/*========================================================*/
$CONSTBEG$: _DtLCX_OPER_xxx
$1LINER$: Constants for specifying operations
$SUMMARY$:
The _DtLCX_OPER_xxx are constants that produce strings
used in the translation specifications when specifying
the operation of a translation.
The operation string name must be identical both in the
source code and in the translation table.
These constants should be used whenever referencing
operations as part of a translation.
/*================================================$SKIP$==*/
#endif
/* $DEF$, Operation constants */
#define DtLCX_OPER_STD "standard"
#define DtLCX_OPER_ICONV1 "iconv1"
#define DtLCX_OPER_ICONV3 "iconv3"
#define DtLCX_OPER_NLLANGINFO_CODESET "nl_langinfo(CODESET)"
#define DtLCX_OPER_SETLOCALE "setlocale"
#define DtLCX_OPER_MULTIBYTE "multibyte"
#define DtLCX_OPER_CCDF "ccdf"
#define DtLCX_OPER_XLFD "xlfd"
#define DtLCX_OPER_MIME "mime"
#define DtLCX_OPER_INTERCHANGE_CODESET "interchangeCodeset"
/*$END$*/
/* Functions */
#define _DtLcxCloseDb(io_db) _DtXlateCloseDb(io_db)
int _DtLcxOpenAllDbs(
_DtXlateDb * ret_db);
int _DtLcxXlateOpToStd(
const _DtXlateDb xlationDb,
const char * platform,
const int version,
const char * operation,
const char * opValue,
char * * ret_stdLocale,
char * * ret_stdLangTerr,
char * * ret_stdCodeset,
char * * ret_stdModifier);
int _DtLcxXlateStdToOp(
const _DtXlateDb xlationDb,
const char * platform,
const int version,
const char * operation,
const char * stdLocale,
const char * stdLangTerr,
const char * stdCodeset,
const char * stdModifier,
char * * ret_opValue);
#ifdef __cplusplus
}
#endif
#endif /*_DtLCX_XLATE_LOCALE_I*/
/********* do not put anything below this line ********/

View File

@@ -0,0 +1,123 @@
/*
* File: Lock.h $XConsortium: Lock.h /main/4 1995/10/26 15:24:02 rswiston $
* Language: C
*
* (c) Copyright 1990, Hewlett-Packard Company, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef _Dt_lock_h
#define _Dt_lock_h
/*
GENERAL DESCRIPTION:
The DT lock facility provides simple exclusive locking. It
(as of 6/19/90) is based on the X11 selection-ownership
mechanism, though users of Dt locking do not need to be aware of
this.
X11 server grabs are judiciously used to guarantee atomicity of
operations. If a process which holds a lock dies (or closes its
X11 server connection for some other reason), the lock will be
automatically released.
Locks are identified by a string. There is no mechanism to
allocate unique lock strings to clients; users must take care to
choose a string that will not be easily duplicated by some other
client.
SAMPLE CODE:
#define MY_LOCK "MYAPP_MY_LOCK"
...
if (_DtGetLock (display, MY_LOCK)) {
<do whatever it is I want to do>
_DtReleaseLock (display, MY_LOCK);
}
else {
<do the alternative>
}
*/
extern int _DtGetLock (
Display *display,
char *lock_name);
/*
DESCRIPTION:
_DtGetLock attempts to get the specified lock. If nobody holds
the lock, _DtGetLock will obtain the lock and return 1. If
somebody else already holds the lock, the lock will not be
disturbed and _DtGetLock will return 0.
If the process which owns a lock dies (or closes its X11 server
connection), the lock will be automatically released. To
explicitly release a lock, use _DtReleaseLock.
SYNOPSIS:
success = _DtGetLock (display, lock);
int success; Returns 1 if the lock is obtained,
0 if not.
Display *display; The X11 server connection which will
hold the lock.
char *lock; The string which names the lock.
*/
extern void _DtReleaseLock (
Display *display,
char *lock_name);
/*
DESCRIPTION:
_DtReleaseLock releases a lock obtained by _DtGetLock.
WARNING!! It is perfectly legal for one process to release
a lock held by another process. By convention you should only
release locks previously obtained by your process from _DtGetLock
unless you are playing God and know what you are doing.
SYNOPSIS:
(void) _DtReleaseLock (display, lock);
Display *display; The X11 server connection which holds
the lock.
char *lock; The string which names the lock.
*/
extern int _DtTestLock (
Display *display,
char *lock_name);
/*
DESCRIPTION:
_DtTestLock returns a status indicating whether anybody holds the
specified lock.
SYNOPSIS:
status = _DtTestLock (display, lock);
int success; Returns 1 if anybody holds the lock,
0 otherwise.
Display *display; The X11 server connection.
char *lock; The string which names the lock.
*/
#endif /* _Dt_lock_h */
/* Do not add anything after this endif. */

View File

@@ -0,0 +1,92 @@
/*
* File: Message.h $XConsortium: Message.h /main/5 1996/03/01 16:36:42 drk $
* Language: C
*
* (c) Copyright 1990, Hewlett-Packard Company, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef _Dt_message_h
#define _Dt_message_h
#include <Dt/DataTypes.h>
#include <Dt/DtP.h>
#include <Dt/Service.h>
/* This header file is a modifed version of <Xv/Message.h> that
* provides compatibility between the BMS messaging and the new
* ICCCM messaging used in DT.
*
* The following symbols that were defined in <Xv/Message.h> are
* no longer available. Any code that depended on them will have
* to be rewritten:
*
* DtServerDeathFn
* DtCloseMsgServerConnect
* DtAddFailNotificationCallback
* DtStatusResponse
* DtUniqueRequestId
* DtSendFailNotification
* DtSendMsg
*/
/**********************************
*
* Message Format
*
**********************************/
/*
* DT messages have the following format:
*
* Request message: <request> [args ...]
* Reply message: <SUCCESS | FAILURE> [args ...]
* Notify message: <notification> [args ...]
*
* The following fields in BMS messages are no longer supported:
*
* DT_MSG_SENDER
* DT_MSG_REQUEST_ID
* DT_MSG_TOOL
* DT_MSG_HOST
* DT_MSG_DIR
* DT_MSG_FILE
*/
#define DT_MSG_TYPE 0
#define DT_MSG_COMMAND 0
#define DT_MSG_DATA_1 1
#define DT_MSG_DATA_2 2
#define DT_MSG_DATA_3 3
#define DT_MSG_DATA_4 4
#define DT_MSG_DATA_5 5
#define DT_MSG_DATA_6 6
#define DT_MSG_DATA_7 7
#define DT_MSG_DATA_8 8
#define DT_MSG_DATA_9 9
#define DT_MSG_DATA_10 10
#define DT_MSG_DATA_11 11
#define DT_MSG_DATA_12 12
#define DT_MSG_DATA_13 13
#define DT_MSG_DATA_14 14
#define DT_MSG_DATA_15 15
#define DT_MSG_DATA_16 16
#define DT_MSG_DATA_17 17
#define DT_MSG_DATA_18 18
#define DT_MSG_DATA_19 19
#define DT_MSG_DATA_20 20
#define DtDONT_CARE_FIELD "*"
/*
If a particular message does not require a value in one of the
fields, use DtDONT_CARE_FIELD for the value of the field.
*/
#endif /*_Dt_message_h*/
/* Do not add anything after this endif. */

View File

@@ -0,0 +1,33 @@
/*
* Msg.h -- Header file for DT messaging library
*
* $XConsortium: Msg.h /main/5 1996/03/01 16:36:15 drk $
*
* (C) Copyright 1993, Hewlett-Packard, all rights reserved.
*/
#ifndef _DT_MSG_H
#define _DT_MSG_H
#include <X11/Intrinsic.h>
#include <Dt/DataTypes.h>
/*
* _DtMessage handle definitions
*/
typedef struct _DtMsgHandle *DtMsgHandle;
/*
* Return values
*/
#define dtmsg_NO_LISTENERS (102)
#define dtmsg_SUCCESS (1)
#define dtmsg_FAIL (-1)
#define dtmsg_NO_SERVICE (-102)
#define dtmsg_WRONG_FORMAT (-103)
#define dtmsg_ANOTHER_PROVIDER (-104)
#define dtmsg_LOST_SERVICE (-105)
#define DtMsgContext Pointer
#endif /* not defined _DT_MSG_H */
/***** END OF FILE ****/

View File

@@ -0,0 +1,134 @@
/*
* (c) Copyright 1995 Digital Equipment Corporation.
* (c) Copyright 1995 Hewlett-Packard Company.
* (c) Copyright 1995 International Business Machines Corp.
* (c) Copyright 1995 Sun Microsystems, Inc.
* (c) Copyright 1995 Novell, Inc.
* (c) Copyright 1995 FUJITSU LIMITED.
* (c) Copyright 1995 Hitachi.
*
* MsgCat.c - public interfaces for the Cached Message Catalog Service
*
* $TOG: MsgCat.c /main/4 1999/07/02 14:02:03 mgreess $
*
*/
#include <stdio.h>
#include <string.h>
#include <nl_types.h>
#include <Dt/MsgCatP.h>
#include <DtSvcLock.h>
typedef struct _dt_msg_cache
{
char ***cached_msgs;
int nmsgs_per_set;
int nsets;
nl_catd catd;
struct _dt_msg_cache *next;
} _DtMsgCache;
static _DtMsgCache *catalog_message_caches = NULL;
static _DtMsgCache *get_msg_cache(nl_catd catd)
{
#define INITIAL_NMSGS_PER_SET 300
#define INITIAL_NSETS 50
_DtMsgCache *c;
for (c=catalog_message_caches; NULL!=c; c=c->next)
if (catd == c->catd) return c;
c = (_DtMsgCache*) XtMalloc(sizeof(_DtMsgCache));
c->cached_msgs = NULL;
c->nmsgs_per_set = INITIAL_NMSGS_PER_SET;
c->nsets = INITIAL_NSETS;
c->catd = catd;
c->next = catalog_message_caches;
catalog_message_caches = c;
return c;
}
/*
* Wrapper around catgets -- this makes sure the message string is saved
* in a safe location; so repeated calls to catgets() do not overwrite
* the catgets() internal buffer. This has been a problem on HP systems.
*/
char *_DtCatgetsCached(nl_catd catd, int set, int num, char *dflt)
{
char *message;
#if !defined(hpV4)
message = catgets(catd, set, num, dflt);
#else
_DtMsgCache *c;
char **setptr;
int i, multiplier;
int size;
/* convert to a zero based index */
int setIdx = set - 1;
int numIdx = num - 1;
_DtSvcProcessLock();
c = get_msg_cache(catd);
if (NULL == c)
{
message = catgets(catd, set, num, dflt);
return message;
}
if (NULL == c->cached_msgs)
{
size = sizeof(char**) * c->nsets;
c->cached_msgs = (char***) XtMalloc(size);
memset((char*) c->cached_msgs, 0, size);
}
else if (setIdx >= c->nsets)
{
for (multiplier=2; setIdx > multiplier*c->nsets; multiplier++) {}
size = sizeof(char**) * c->nsets;
c->cached_msgs =
(char***) XtRealloc((char*) c->cached_msgs, multiplier*size);
memset((char*) (c->cached_msgs + size), 0, multiplier*size);
c->nsets *= multiplier;
}
if (NULL == c->cached_msgs[setIdx])
{
size = sizeof(char*) * c->nmsgs_per_set;
c->cached_msgs[setIdx] = (char**) XtMalloc(size);
memset((char*) c->cached_msgs[setIdx], 0, size);
}
else if (numIdx >= c->nmsgs_per_set)
{
for (multiplier=2; numIdx > multiplier*c->nsets; multiplier++) {}
size = sizeof(char*) * c->nmsgs_per_set;
for (i=0; i<c->nmsgs_per_set; i++)
{
if (NULL != c->cached_msgs[i])
{
c->cached_msgs[i] =
(char**) XtRealloc((char*)c->cached_msgs[i], multiplier*size);
memset((char*) (c->cached_msgs[i] + size), 0, multiplier*size);
}
}
c->nmsgs_per_set *= multiplier;
}
setptr = c->cached_msgs[setIdx];
if (NULL == setptr[numIdx])
setptr[numIdx] = strdup(catgets(catd, set, num, dflt));
message = setptr[numIdx];
_DtSvcProcessUnlock();
#endif /* hpV4 */
return message;
}

View File

@@ -0,0 +1,31 @@
/*
* (c) Copyright 1995 Digital Equipment Corporation.
* (c) Copyright 1995 Hewlett-Packard Company.
* (c) Copyright 1995 International Business Machines Corp.
* (c) Copyright 1995 Sun Microsystems, Inc.
* (c) Copyright 1995 Novell, Inc.
* (c) Copyright 1995 FUJITSU LIMITED.
* (c) Copyright 1995 Hitachi.
*
* MsgCat.h - Public interfaces for the Cached Message Catalog Service
*
* $TOG: MsgCatP.h /main/1 1998/04/22 14:19:24 mgreess $
*
*/
#ifndef _Dt_MsgCat_h
#define _Dt_MsgCat_h
#include <nl_types.h>
#ifdef __cplusplus
extern "C" {
#endif
extern char *_DtCatgetsCached(nl_catd catd, int set, int num, char *dflt);
#ifdef __cplusplus
}
#endif
#endif /* _Dt_MsgCat_h */

View File

@@ -0,0 +1,448 @@
/*
* (c) Copyright 1995 Digital Equipment Corporation.
* (c) Copyright 1995 Hewlett-Packard Company.
* (c) Copyright 1995 International Business Machines Corp.
* (c) Copyright 1995 Sun Microsystems, Inc.
* (c) Copyright 1995 Novell, Inc.
* (c) Copyright 1995 FUJITSU LIMITED.
* (c) Copyright 1995 Hitachi.
*
* MsgLog.c - public interfaces for the Message Logging Service
*
* NOTE: the cpp define MSGLOG_CLIENT_ONLY is not defined when this
* file is compiled for the DtSvc library. MSGLOG_CLIENT_ONLY
* is only defined when an application intends to use these
* routines directly because the application does not to build
* in a dependecy to the DtSvc library (e.g. dtexec).
*
* $TOG: MsgLog.c /main/21 1998/10/26 17:23:21 mgreess $
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#define X_INCLUDE_PWD_H
#define X_INCLUDE_TIME_H
#define XOS_USE_XT_LOCKING
#include <X11/Xos_r.h>
#include <sys/param.h>
#include <limits.h>
#include <Dt/DtPStrings.h>
#ifndef MSGLOG_CLIENT_ONLY
# include <Dt/UserMsg.h>
# include <DtSvcLock.h>
#endif /* MSGLOG_CLIENT_ONLY */
#include <Dt/DtGetMessageP.h>
#include <Dt/MsgLog.h>
#include <Dt/MsgLogI.h>
#define MAX_DATE_TIME_STRING 256
/*
* Static variables
*/
static char * information_string = NULL;
static char * stderr_string = NULL;
static char * debug_string = NULL;
static char * warning_string = NULL;
static char * error_string = NULL;
static char * unknown_string = NULL;
#ifndef MSGLOG_CLIENT_ONLY
static DtMsgLogHandler saved_msglog_handler = NULL;
#endif /* MSGLOG_CLIENT_ONLY */
/*
* Static constants
*/
static const char * LOGFILE_NAME = DtERRORLOG_FILE;
static const char * TMP_DIR = "/tmp";
static const char * OPEN_FLAG = "a+";
static const int SET_NUM = 50;
#ifdef CDE_LOGFILES_TOP
static const char * CDE_VAR_TMP_DIR = CDE_LOGFILES_TOP ;
#else
static const char * CDE_VAR_TMP_DIR = "/var/dt/tmp";
#endif
/*
* Static function forward declarations
*/
static char * get_file_name (
const char * type,
FILE ** fp,
const char * format,
... );
static char * check_possible_files (
const char * type,
FILE ** fp );
static void initialize_message_strings (void);
/*
* initialize_message_string -
*
* Modified: initializes the static message string variables
*
*/
static void initialize_message_strings (void)
{
information_string = strdup (Dt11GETMESSAGE (SET_NUM, 1, "INFORMATION"));
stderr_string = strdup (Dt11GETMESSAGE (SET_NUM, 2, "STDERR"));
debug_string = strdup (Dt11GETMESSAGE (SET_NUM, 3, "DEBUG"));
warning_string = strdup (Dt11GETMESSAGE (SET_NUM, 4, "WARNING"));
error_string = strdup (Dt11GETMESSAGE (SET_NUM, 5, "ERROR"));
unknown_string = strdup (Dt11GETMESSAGE (SET_NUM, 6, "UNKNOWN"));
}
/*
* get_file_name - given a sprintf-like format and a variable
* list of args, create a filename and open the file.
*
* Modified:
*
* fp - set to the opened file or NULL if the open
* fails
*
* Returns: a filename or NULL if the filename cannot be opened
* with mode 'type'.
*/
static char * get_file_name (
const char * type,
FILE ** fp, /* MODIFIED */
const char * format,
... )
{
char *file, *rtn;
va_list args;
file = malloc(MAXPATHLEN+1);
if (! file) return;
Va_start (args, format);
(void) vsprintf (file, format, args);
va_end (args);
if ((*fp = fopen (file, type)) == NULL)
return (NULL);
rtn = strdup (file);
free(file);
return rtn;
}
/*
* check_possible_files - generates possible filenames to use for
* the message logging.
*
* The first one of the following files that is append'able is
* returned:
*
* o $HOME/DtPERSONAL_CONFIG_DIRECTORY/LOGFILE_NAME
*
* o CDE_VAR_TMP_DIR/$DTUSERSESSION/LOGFILE_NAME
*
* o TMP_DIR/<login_name_from_passwd_file>/LOGFILE_NAME
*
* Note: #2 is only checked if $DTUSERSESSION is defined
*
* Modified:
*
* fp - set to the opened file or NULL if the open
* fails
*
* Returns: a filename if one if found that is append'able or NULL
* if such a file cannot be determined.
*/
static char * check_possible_files (
const char * type,
FILE ** fp ) /* MODIFIED */
{
char * file;
char * env;
_Xgetpwparams pwd_buf;
struct passwd * pwd_ret;
if ((file = get_file_name (type,
fp,
"%s/%s/%s",
getenv("HOME"),
DtPERSONAL_CONFIG_DIRECTORY,
LOGFILE_NAME)) != NULL)
return (file);
if ((env = getenv ("DTUSERSESSION")) != NULL) {
if ((file = get_file_name (type,
fp,
"%s/%s/%s",
CDE_VAR_TMP_DIR,
env,
LOGFILE_NAME)) != NULL)
return (file);
}
if ((env = getenv ("LOGNAME")) != NULL) {
if ((file = get_file_name (type,
fp,
"%s/%s.%s",
TMP_DIR,
env,
LOGFILE_NAME)) != NULL)
return (file);
}
if ((env = getenv ("USER")) != NULL) {
if ((file = get_file_name (type,
fp,
"%s/%s.%s",
TMP_DIR,
env,
LOGFILE_NAME)) != NULL)
return (file);
}
if ((pwd_ret = _XGetpwuid (getuid(), pwd_buf)) != NULL) {
if ((file = get_file_name (type,
fp,
"%s/%s.%s",
TMP_DIR,
pwd_ret->pw_name,
LOGFILE_NAME)) != NULL)
return (file);
}
return (NULL);
}
/*
* DtMsgLogMessage -
*
* Returns: 0 if the message is successfully logged or 1 if an
* error occurs and the message is not logged.
*/
void DtMsgLogMessage (
const char * program_name,
DtMsgLogType msg_type,
const char * format,
... )
{
va_list args;
FILE * fp = NULL;
char * file = NULL;
time_t now;
char * msg_string; /* temp msg type string */
int num_bytes;
char buf[MAX_DATE_TIME_STRING];
#ifdef NLS16
char * tmp_format;
#endif
_Xctimeparams ctime_buf;
char * result;
_Xltimeparams localtime_buf;
struct tm * current_time;
Va_start (args, format);
#ifndef MSGLOG_CLIENT_ONLY
_DtSvcProcessLock();
if (saved_msglog_handler != NULL) {
(*saved_msglog_handler) (program_name ? program_name :
DtProgName,
msg_type,
format,
args);
_DtSvcProcessUnlock();
va_end (args);
return;
}
_DtSvcProcessUnlock();
#endif /* MSGLOG_CLIENT_ONLY */
if (!information_string) {
#ifndef MSGLOG_CLIENT_ONLY
_DtSvcProcessLock();
#endif /* MSGLOG_CLIENT_ONLY */
if (!information_string)
initialize_message_strings ();
#ifndef MSGLOG_CLIENT_ONLY
_DtSvcProcessUnlock();
#endif /* MSGLOG_CLIENT_ONLY */
}
/*
* Need to get a copy of the string in case another
* thread calls catgets and puts a different
* string in catgets's static buffer before
* msg_string is output
*/
switch (msg_type) {
case DtMsgLogInformation:
msg_string = information_string;
break;
case DtMsgLogStderr:
msg_string = stderr_string;
break;
case DtMsgLogDebug:
msg_string = debug_string;
break;
case DtMsgLogWarning:
msg_string = warning_string;
break;
case DtMsgLogError:
msg_string = error_string;
break;
default:
msg_string = unknown_string;
break;
}
now = time ((time_t)0);
/*
* Write to stderr if a log file cannot be determined
* or if it isn't writeable.
*/
if ((fp = DtMsgLogOpenFile (OPEN_FLAG, &file)) == NULL)
fp = stderr;
#ifdef NLS16
current_time = _XLocaltime(&now, localtime_buf);
/*
* Need to save format because the next call to catgets
* may overwrite it on some platforms (if format itself
* is the result of a call to catgets).
*/
tmp_format = strdup ((char *) format);
(void) strftime (buf,
MAX_DATE_TIME_STRING,
Dt11GETMESSAGE (48, 1, "%a %b %d %H:%M:%S %Y\n"),
current_time);
num_bytes = fprintf (fp, "*** %s(%d): %s: PID %d: %s",
msg_string, msg_type,
#ifndef MSGLOG_CLIENT_ONLY
program_name ? program_name : DtProgName,
#else
program_name ? program_name : "",
#endif /* MSGLOG_CLIENT_ONLY */
getpid(), buf);
#else
result = _XCtime(&now, ctime_buf);
num_bytes = fprintf (fp, "*** %s(%d): %s: PID %ld: %s",
msg_string, msg_type,
#ifndef MSGLOG_CLIENT_ONLY
program_name ? program_name : DtProgName,
#else
program_name ? program_name : "",
#endif /* MSGLOG_CLIENT_ONLY */
(long)getpid(), result);
#endif
#ifdef NLS16
num_bytes += vfprintf (fp, tmp_format, args);
free (tmp_format);
#else
num_bytes += vfprintf (fp, format, args);
#endif
va_end (args);
fprintf (fp, "\n*** [%d]\n\n", num_bytes);
if (fp != stderr) {
(void) fflush (fp);
(void) fclose(fp);
}
if (file)
free (file);
}
#ifndef MSGLOG_CLIENT_ONLY
/*
* DtMsgLogSetHandler - caches an alternate message logging
* handler
*
* Modified:
*
* saved_msglog_handler - set to the given handler
*
* Returns: if handler is NULL, the default handler is restored;
* returns a pointer to the previous handler
*
*/
DtMsgLogHandler DtMsgLogSetHandler (
DtMsgLogHandler handler )
{
DtMsgLogHandler previous_handler;
_DtSvcProcessLock();
if (handler == NULL) {
if (saved_msglog_handler) {
previous_handler = saved_msglog_handler;
saved_msglog_handler = NULL;
return (previous_handler);
}
else {
saved_msglog_handler = NULL;
return (DtMsgLogHandler) DtMsgLogMessage;
}
}
if (saved_msglog_handler)
previous_handler = saved_msglog_handler;
else
previous_handler = (DtMsgLogHandler) DtMsgLogMessage;
saved_msglog_handler = handler;
_DtSvcProcessUnlock();
return (previous_handler);
}
#endif /* MSGLOG_CLIENT_ONLY */
/*
* DtMsgLogOpenFile - opens the logfile
*
* Returns: returns a pointer to the opened logfile; if a logfile
* cannot be opened, stderr is returned
*
* Modified:
*
* fp - is set to the opened file
*
* filename_return - will be set to the filename if it
* if it is not NULL and a file is opened. If filename_return
* is not NULL and and a file is opened, the calling function
* should free the space allocated for the filename.
*/
FILE * DtMsgLogOpenFile (
const char * type,
char ** filename_return) /* MODIFIED */
{
FILE * fp = NULL;
char * pch;
pch = check_possible_files (type, &fp);
if (filename_return)
*filename_return = pch;
else if (pch)
free (pch);
if (!fp)
fp = stderr;
return (fp);
}

View File

@@ -0,0 +1,64 @@
/*
* (c) Copyright 1995 Digital Equipment Corporation.
* (c) Copyright 1995 Hewlett-Packard Company.
* (c) Copyright 1995 International Business Machines Corp.
* (c) Copyright 1995 Sun Microsystems, Inc.
* (c) Copyright 1995 Novell, Inc.
* (c) Copyright 1995 FUJITSU LIMITED.
* (c) Copyright 1995 Hitachi.
*
* MsgLog.h - Public header file for the Message Logging Service
*
* $XConsortium: MsgLog.h /main/5 1995/07/14 13:22:57 drk $
*
*/
#ifndef _Dt_MsgLog_h
#define _Dt_MsgLog_h
#include <stdio.h> /* needed for FILE */
#ifdef __cplusplus
extern "C" {
#endif
# include <stdarg.h>
/*
* Type declarations
*/
typedef enum {
DtMsgLogInformation,
DtMsgLogStderr,
DtMsgLogDebug,
DtMsgLogWarning,
DtMsgLogError
} DtMsgLogType;
typedef void (*DtMsgLogHandler) (
const char * program_name,
DtMsgLogType msg_type,
const char * format,
va_list args );
/*
* Function declarations
*/
extern void DtMsgLogMessage (
const char * program_name,
DtMsgLogType msg_type,
const char * format,
... );
extern DtMsgLogHandler DtMsgLogSetHandler (
DtMsgLogHandler handler );
extern FILE * DtMsgLogOpenFile (
const char * type,
char ** filename_return); /* MODIFIED */
#ifdef __cplusplus
}
#endif
#endif /* _Dt_MsgLog_h */

View File

@@ -0,0 +1,43 @@
/*
* (c) Copyright 1995 Digital Equipment Corporation.
* (c) Copyright 1995 Hewlett-Packard Company.
* (c) Copyright 1995 International Business Machines Corp.
* (c) Copyright 1995 Sun Microsystems, Inc.
* (c) Copyright 1995 Novell, Inc.
* (c) Copyright 1995 FUJITSU LIMITED.
* (c) Copyright 1995 Hitachi.
*
* MsgLogI.h - Private header file for the Message Logging Service
*
* $XConsortium: MsgLogI.h /main/4 1995/07/14 13:23:02 drk $
*
*/
#ifndef _Dt_MsgLogI_h
#define _Dt_MsgLogI_h
# include <stdarg.h>
# define Va_start(a,b) va_start(a,b)
/*
* Account for the various macros on different systems which indicate that
* stdarg.h has been included. Code in this file only checks for
* _STDARG_INCLUDED. If a given system defines another macro that means the
* same thing -- then define _STDARG_INCLUDED here.
*
* System Macro Indicating stdarg.h has been included
* -------- ---------------------------------------------
* HPUX _STDARG_INCLUDED
* AIX _H_STDARG
* SOLARIS _STDARG_H
*/
#ifdef _H_STDARG
#define _STDARG_INCLUDED
#endif
#ifdef _STDARG_H
#define _STDARG_INCLUDED
#endif
#endif /* _Dt_MsgLogI_h */

View File

@@ -0,0 +1,160 @@
#ifndef _DT_MSG_P_H
#define _DT_MSG_P_H
/*
* MsgP.h -- Private header file for DT messaging library
*
* $XConsortium: MsgP.h /main/3 1995/10/26 15:24:51 rswiston $
* $XConsortium: MsgP.h /main/3 1995/10/26 15:24:51 rswiston $
*
* (C) Copyright 1993, Hewlett-Packard, all rights reserved.
*/
#include <Dt/Msg.h>
/*
* Definitions
*/
/* max property size (bytes) */
#define DT_MSG_MAX_PROP_SIZE (32768)
/* atom names */
#define DT_MSG_XA_REQUEST "_DT_REQUEST"
#define DT_MSG_XA_NOTIFY "_DT_NOTIFY"
#define DT_MSG_XA_BROADCAST_REGISTRY "_DT_BROADCAST_REGISTRY"
/*
* _DtMessage handle
*/
typedef struct _DtMsgHandle {
char * pchName; /* handle "name" */
Atom atom; /* Selection/Broadcast atom */
Widget widget; /* Widget registering this handle */
char * pchPropName; /* property name */
Atom property; /* atomized property name */
/* other data */
struct _DtMsgServiceContext *
service_data; /* service data assoc w/ handle */
struct _DtMsgBroadcastData *
broadcast_data; /* broadcast data assoc w/ handle */
} DtMsgHandle;
/*
* _DtMessage handle accessor "functions"
*/
#define DtMsgH_Name(h) ((h)->pchName)
#define DtMsgH_Widget(h) ((h)->widget)
#define DtMsgH_Atom(h) ((h)->atom)
#define DtMsgH_SvcData(h) ((h)->service_data)
#define DtMsgH_BcData(h) ((h)->broadcast_data)
#define DtMsgH_PropertyName(h) ((h)->pchPropName)
#define DtMsgH_PropertyAtom(h) ((h)->property)
#define DtMsgH_Shandle(h) ((h)->service_data->handle)
#define DtMsgH_RequestProc(h) ((h)->service_data->request_proc)
#define DtMsgH_ReceiveCD(h) ((h)->service_data->receive_client_data)
#define DtMsgH_LoseProc(h) ((h)->service_data->lose_proc)
#define DtMsgH_LoseCD(h) ((h)->service_data->lose_client_data)
#define DtMsgH_RegistryAtom(h) ((h)->broadcast_data->aRegistry)
#define DtMsgH_SharedWindow(h) ((h)->broadcast_data->winShared)
#define DtMsgH_SharedWidget(h) ((h)->broadcast_data->wShared)
#define DtMsgH_Listener(h) ((h)->broadcast_data->wListener)
#define DtMsgH_BreceiveProc(h) ((h)->broadcast_data->Breceive_proc)
#define DtMsgH_BclientData(h) ((h)->broadcast_data->Bclient_data)
#define DtMsgH_Bprops(h) ((h)->broadcast_data->props)
#define DtMsgH_BnumProps(h) ((h)->broadcast_data->numProps)
#define DtMsgH_BsizeProps(h) ((h)->broadcast_data->sizeProps)
#define DtMsgH_Breceivers(h) ((h)->broadcast_data->pReceivers)
#define DtMsgH_BnumReceivers(h) ((h)->broadcast_data->numReceivers)
#define DtMsgH_BsizeReceivers(h) ((h)->broadcast_data->sizeReceivers)
#define DtMsgH_BSenderInit(h) ((h)->broadcast_data->bSenderInitialized)
/*
* Service context data
* (for client that offers a service)
*/
typedef struct _DtMsgServiceContext {
DtMsgHandle handle;
DtMsgReceiveProc request_proc;
DtMsgStatusProc lose_proc;
Pointer receive_client_data;
Pointer lose_client_data;
} DtMsgServiceContext;
/*
* Request context data
* (for client that makes a service request)
*/
typedef struct _DtMsgRequestContext {
DtMsgHandle handle;
DtMsgReceiveProc reply_proc;
Pointer client_data;
} DtMsgRequestContext;
/*
* Reply message context data
* (for client replying to a request)
*/
typedef struct _DtMsgReplyMessageContext {
DtMsgHandle handle;
Window window;
Atom target;
Atom property;
} DtMsgReplyMessageContext;
/*
* Broadcast sender data
*/
/* number of props to allocate per memory request */
#define DT_MSG_PROP_INC_AMT 10
typedef struct _DtMsgBroadcastPerReceiverData {
Widget widget; /* widget of receiver */
Atom * propsUnread; /* list of props */
int numPropsUnread; /* number of props */
int sizePropsUnread; /* amt of space allocated */
} DtMsgBroadcastPerReceiverData;
typedef struct _DtMsgBroadcastData {
Atom aRegistry; /* registry atom name */
Window winShared; /* shared window */
Widget wShared; /* shared widget */
Widget wListener; /* child of shared window */
DtMsgReceiveProc Breceive_proc; /* broadcast receive proc */
Pointer Bclient_data; /* broadcast client data */
Boolean bSenderInitialized; /* true if ready for send */
Atom * props; /* props to use for messages */
int numProps; /* number of message props */
int sizeProps; /* number of props allocated */
DtMsgBroadcastPerReceiverData * pReceivers; /* rcvr data */
int numReceivers; /* number of receivers */
int sizeReceivers; /* amt of rcvr space allocated */
} DtMsgBroadcastData;
/*
* Broadcast _DtMessage Registry definitions
*/
/* registry entry size, in words */
#define DT_MSG_REGISTRY_ENTRY_SIZE 2
/* offsets within each registry entry */
#define DT_MSG_REGISTRY_NAME_OFFSET 0
#define DT_MSG_REGISTRY_WINDOW_OFFSET 1
/* Macros to compute offset */
#define MSG_GROUP_NAME(R, i) \
(R[((i)*DT_MSG_REGISTRY_ENTRY_SIZE)+DT_MSG_REGISTRY_NAME_OFFSET])
#define MSG_GROUP_WINDOW(R, i) \
(R[((i)*DT_MSG_REGISTRY_ENTRY_SIZE)+DT_MSG_REGISTRY_WINDOW_OFFSET])
#endif /* not defined _DT_MSG_P_H */
/***** END OF FILE ****/

View File

@@ -0,0 +1,257 @@
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/* Copyright Massachusetts Institute of Technology 1985, 1986, 1987 */
/*
* $TOG: PrintXErr.c /main/7 1998/04/10 07:46:38 mgreess $
*/
/* ** (c) Copyright Hewlett-Packard Company, 1990.*/
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*Lifted from xlib code. How to print a reasonably complete message */
/*and NOT exit.*/
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*$TOG: PrintXErr.c /main/7 1998/04/10 07:46:38 mgreess $*/
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
int
_DtPrintDefaultError(
Display *dpy,
XErrorEvent *event,
char *msg )
{
_DtPrintDefaultErrorSafe(dpy, event, msg, BUFSIZ);
}
#define _DTP_STRNCAT(s1, s2, nb, ec) \
{ \
strncat((s1),(s2),(nb)); \
(nb)-=strlen(s2); \
if (0>=(nb)) return (ec); \
}
int
_DtPrintDefaultErrorSafe(
Display *dpy,
XErrorEvent *event,
char *msg,
int bytes)
{
char buffer[BUFSIZ];
char fpBuf[BUFSIZ];
char *fp;
char mesg[BUFSIZ];
char number[32];
char *mtype = "XlibMessage";
int nbytes = bytes-1;
register _XExtension *ext = (_XExtension *)NULL;
memset(msg, 0, bytes);
{
XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
_DTP_STRNCAT(msg, mesg, nbytes, event->error_code);
_DTP_STRNCAT(msg, ": ", nbytes, event->error_code);
_DTP_STRNCAT(msg, buffer, nbytes, event->error_code);
_DTP_STRNCAT(msg, "\n ", nbytes, event->error_code);
}
{
XGetErrorDatabaseText(
dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ);
if (strlen(mesg) < BUFSIZ-10)
fp = fpBuf;
else
fp = malloc(strlen(mesg) + 10);
(void) sprintf(fp, mesg, event->request_code);
_DTP_STRNCAT(msg, fp, nbytes, event->error_code);
if (fp != fpBuf) free(fp);
}
{
if (event->request_code < 128)
{
sprintf(number, "%d", event->request_code);
XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
}
else
{
for (ext = dpy->ext_procs;
ext && (ext->codes.major_opcode != event->request_code);
ext = ext->next)
;
if (ext)
{
strncpy(buffer, ext->name, BUFSIZ-1);
buffer[BUFSIZ-1] = '\0';
}
else
buffer[0] = '\0';
}
_DTP_STRNCAT(msg, " (", nbytes, event->error_code);
_DTP_STRNCAT(msg, buffer, nbytes, event->error_code);
_DTP_STRNCAT(msg, ")\n ", nbytes, event->error_code);
}
{
if (event->request_code >= 128)
{
XGetErrorDatabaseText(
dpy, mtype, "MinorCode", "Request Minor code %d", mesg, BUFSIZ);
if (strlen(mesg) < BUFSIZ-10)
fp = fpBuf;
else
fp = malloc(strlen(mesg) + 10);
(void) sprintf(fp, mesg, event->minor_code);
_DTP_STRNCAT(msg, fp, nbytes, event->error_code);
if (fp != fpBuf) free(fp);
if (ext)
{
if (strlen(ext->name) < BUFSIZ-10)
fp = fpBuf;
else
fp = malloc(strlen(ext->name) + 10);
sprintf(fp, "%s.%d", ext->name, event->minor_code);
XGetErrorDatabaseText(dpy, "XRequest", fp, "", buffer, BUFSIZ);
if (fp != fpBuf) free(fp);
}
_DTP_STRNCAT(msg, "\n (", nbytes, event->error_code);
_DTP_STRNCAT(msg, buffer, nbytes, event->error_code);
_DTP_STRNCAT(msg, ")", nbytes, event->error_code);
}
}
if (event->error_code >= 128)
{
/* kludge, try to find the extension that caused it */
buffer[0] = '\0';
for (ext = dpy->ext_procs; ext; ext = ext->next)
{
if (ext->error_string)
(*ext->error_string)(dpy, event->error_code, &ext->codes,
buffer, BUFSIZ);
if (buffer[0])
break;
}
if (buffer[0])
{
if (strlen(buffer) < BUFSIZ-10)
sprintf(buffer,
"%s.%d",
ext->name,
event->error_code - ext->codes.first_error);
}
else
strcpy(buffer, "Value");
XGetErrorDatabaseText(dpy, mtype, buffer, "Value 0x%x", mesg, BUFSIZ);
if (*mesg)
{
if (strlen(mesg) < BUFSIZ-10)
fp = fpBuf;
else
fp = malloc(strlen(mesg) + 10);
(void) sprintf(fp, mesg, event->resourceid);
_DTP_STRNCAT(msg, fp, nbytes, event->error_code);
_DTP_STRNCAT(msg, "\n ", nbytes, event->error_code);
if (fp != fpBuf) free(fp);
}
}
else if ((event->error_code == BadWindow) ||
(event->error_code == BadPixmap) ||
(event->error_code == BadCursor) ||
(event->error_code == BadFont) ||
(event->error_code == BadDrawable) ||
(event->error_code == BadColor) ||
(event->error_code == BadGC) ||
(event->error_code == BadIDChoice) ||
(event->error_code == BadValue) ||
(event->error_code == BadAtom))
{
if (event->error_code == BadValue)
XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
mesg, BUFSIZ);
else if (event->error_code == BadAtom)
XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
mesg, BUFSIZ);
else
XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
mesg, BUFSIZ);
if (strlen(mesg) < BUFSIZ-10)
fp = fpBuf;
else
fp = malloc(strlen(mesg) + 10);
(void) sprintf(fp, mesg, event->resourceid);
_DTP_STRNCAT(msg, fp, nbytes, event->error_code);
_DTP_STRNCAT(msg, "\n ", nbytes, event->error_code);
if (fp != fpBuf) free(fp);
}
{
XGetErrorDatabaseText(
dpy, mtype, "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ);
if (strlen(mesg) < BUFSIZ-10)
fp = fpBuf;
else
fp = malloc(strlen(mesg) + 10);
(void) sprintf(fp, mesg, event->serial);
_DTP_STRNCAT(msg, fp, nbytes, event->error_code);
_DTP_STRNCAT(msg, "\n ", nbytes, event->error_code);
if (fp != fpBuf) free(fp);
}
{
XGetErrorDatabaseText(
dpy, mtype, "CurrentSerial", "Current Serial #%d", mesg, BUFSIZ);
if (strlen(mesg) < BUFSIZ-10)
fp = fpBuf;
else
fp = malloc(strlen(mesg) + 10);
(void) sprintf(fp, mesg, dpy->request);
_DTP_STRNCAT(msg, fp, nbytes, event->error_code);
_DTP_STRNCAT(msg, "\n ", nbytes, event->error_code);
if (fp != fpBuf) free(fp);
}
if (event->error_code == BadImplementation) return 0;
return 1;
}

View File

@@ -0,0 +1,130 @@
/*
* File: Service.h $XConsortium: Service.h /main/3 1995/10/26 15:27:03 rswiston $
* Language: C
*
* (C) Copyright 1993, Hewlett-Packard, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef _Dt_Service_h
#define _Dt_Service_h
/************* DATA TYPES *****************************************/
/* Many of the data types are standard DT types. */
#include <Dt/DataTypes.h>
/* Built on ICCC-based messaging library */
#include <Dt/Msg.h>
/* Specific messaging data types */
typedef struct _DtSvcHandle * DtSvcHandle;
typedef DtMsgContext DtSvcMsgContext;
/************* MESSAGE DEFINITIONS *********************************/
#define DT_SVC_MSG_SUCCESS "SUCCESS"
#define DT_SVC_MSG_FAIL "FAIL"
#define DT_SVC_MSG_REQUEST "REQUEST"
#define DT_SVC_MSG_NOTIFY "NOTIFY"
/************* CALLBACK PROTOTYPES ******************************
*/
typedef void (*DtSvcReceiveProc) ();
/*
DtSvcHandle service,
DtSvcMsgContext reply_context,
Pointer client_data,
String * message_fields,
int num_fields);
*/
/*
* service A handle for the service.
*
* reply_context Opaque context information for the request that
* was received. This data is needed when
* generating a reply to a request.
*
* client_data A pointer to the data that was specified when
* the callback was registered.
*
* message_fields A pointer to an array of strings that is the
* contents of the request. (See note 2.)
*
* num_fields The number of fields in the message_fields
* array.
*/
typedef void (*DtSvcMessageProc) ();
/*
DtSvcHandle service,
Pointer client_data,
String * message_fields,
int num_fields);
*/
/*
* service A handle for the service.
*
* client_data A pointer to the data that was specified when
* the callback was registered.
*
* message_fields A pointer to an array of strings that is the
* contents of the message. (See note 2.)
*
* num_fields The number of fields in the message_fields
* array.
*/
typedef void (*DtSvcStatusProc) ();
/*
DtSvcHandle service,
int status,
Pointer client_data);
*/
/*
* service Handle to the service whose status is being
* reported.
*
* status The status of the service being started.
*
* client_data Pointer to the data that was registered when
* the callback was registered.
*/
/************* CONSTANTS ******************************************
*/
/* The following are types of reply messages.
*/
#define DT_SVC_SUCCESS 1 /* The request succeeded. */
#define DT_SVC_FAIL -1 /* The service failed to carry
* out the request.
*/
#define DT_SVC_DELIVERY_FAIL -2 /* The request could not be
* delivered to the service for
* some reason. For example,
* the service may not be running
* and cannot be invoked.
*/
/* The following are types of status.
*/
#define DT_SVC_START 1 /* The service was started. */
#define DT_SVC_NO_START -1 /* The service failed to start.
*/
#define DT_SVC_LOST -2 /* The service was lost. Another
provider took over ownership
for this service. */
#endif /*_Dt_Service_h*/
/* Do not add anything after this endif. */

View File

@@ -0,0 +1,346 @@
/* $XConsortium: Setlocale.h /main/3 1995/10/26 15:27:34 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/* Hp DT's version of an 8.0 include file; needed for Fnmatch */
#ifndef DtSETLOCALE_INCLUDED /* allow multiple inclusions */
#define DtSETLOCALE_INCLUDED
#ifdef _NAMESPACE_CLEAN
#define _1kanji __1kanji
#define _2kanji __2kanji
#define _downshift __downshift
#define _upshift __upshift
#endif /* _NAMESPACE_CLEAN */
#include <locale.h>
#include <limits.h>
#include <nl_types.h>
#include <langinfo.h>
#include <Dt/Collate.h>
#ifdef sco /* XPG4isms comming soon */
#ifndef _NL_DIRECT
#define _NL_DIRECT
typedef int nl_direct;
#endif
#ifndef _NL_ORDER
#define _NL_ORDER
typedef int nl_order;
#endif
#ifndef _NL_MODE
#define _NL_MODE
typedef int nl_mode;
#endif
#ifndef _NL_OUTDGT
#define _NL_OUTDGT
typedef int nl_outdgt;
#endif
#ifndef MAXLNAMELEN
#define MAXLNAMELEN 14
#endif
#endif
struct _era_data { /* defines an Emperor/Era time period */
short start_year; /* starting date of era */
unsigned short start_month;
unsigned short start_day;
short end_year; /* ending date of era */
unsigned short end_month;
unsigned short end_day;
short origin_year; /* time axis origin for era (one of start_year or end_year) */
short offset; /* offset from 0 for 1st year of era */
short signflag; /* adjusts sign of (year - origin_year) value */
unsigned short reserved;
unsigned char *name; /* name of era */
unsigned char *format; /* instead of nl_langinfo(ERA_FMT) */
};
extern int __nl_langid[]; /* langid of currently loaded language */
extern unsigned char *__ctype; /* pointer to ctype table */
extern unsigned char *_1kanji; /* pointer to 1st of 2 kanji table */
extern unsigned char *_2kanji; /* pointer to 2nd of 2 kanji table */
extern unsigned char *_upshift; /* pointer to up shift table */
extern unsigned char *_downshift; /* pointer to down shift table */
#ifdef EUC
extern unsigned char *__e_cset; /* pointer to expanded char set table */
extern unsigned char *__ein_csize; /* pointer to expanded in_csize table */
extern unsigned char *__eout_csize; /* pointer to expanded out_csize table*/
#endif /* EUC */
extern struct _era_data *_nl_era[]; /* array of era info str pointer */
extern int _nl_radix; /* radix character */
extern int _sh_low; /* lowest char in shift table domain */
extern int _sh_high; /* highest char in shift table domain */
extern int __nl_char_size; /* size of characters */
#ifdef EUC
extern int __nl_code_scheme;/* flag for char code scheme */
extern int __cs_SBYTE; /* flag for 1 byte char code scheme */
extern int __cs_HP15; /* flag for HP15 char code scheme */
extern int __cs_EUC; /* flag for EUC char code scheme */
extern unsigned char __in_csize[]; /* input char size */
extern unsigned char __out_csize[]; /* output char size */
extern unsigned int __euc_template[]; /* euc process code template */
#endif /* EUC */
extern nl_direct _nl_direct; /* direction flag */
extern int _nl_context; /* directionality context flag */
extern nl_order _nl_order; /* order flag */
extern nl_mode _nl_mode; /* mode flag; Latin or non-Latin */
extern nl_outdgt _nl_outdigit; /* digit output : ascii or alt digit */
extern int _nl_space_alt; /* value of alternative space */
extern unsigned char *_nl_dgt_alt; /* buffer for alt digit string */
extern unsigned char *_nl_punct_alt; /* buffer for alt punctuation string */
extern unsigned char *_nl_pascii; /* buffer for ascii punctuation string */
extern unsigned char *_nl_dascii; /* buffer for ascii digits string */
extern int _nl_map21; /* non-zero if 2-to-1 mappings */
extern int _nl_onlyseq; /* true if only 1-to-1 char w no pri */
extern int _nl_collate_on; /* true if collation table loaded */
extern int _nl_mb_collate; /* true if collation is multibyte */
extern unsigned char *_seqtab; /* dictionary sequence number table */
extern unsigned char *_pritab; /* 1to2/2to1 flag + priority table */
extern struct col_21tab *_tab21; /* 2-to-1 mapping table */
extern struct col_12tab *_tab12; /* 1-to-2 mapping table */
extern unsigned char *__errptr; /* pointer to an area _errlocale() can use as a buffer */
extern struct lconv *_lconv;
extern unsigned char *__category_name[];
extern unsigned char **__nl_info; /* pointers to locale langinfo strings */
extern unsigned char *__C_langinfo[];/* default langinfo strings for the C locale */
#define _NL_MAX_MSG ERA_FMT /* last nl_langinfo item */
/***************************************************************************
The remainder of this file includes structures for the language files.
The files are built by buildlang(1M).
The structure of the files is as follows :
----------------------------------
| Table Header (A) |
----------------------------------
| Category/Modifier Structures(B)|
==================================
| LC_ALL Table Header (C) |
- - - - - - - - -
| LC_ALL Data |
----------------------------------
| LC_COLLATE Table Header (D) |
- - - - - - - - -
| LC_COLLATE Data |
----------------------------------
| LC_CTYPE Table Header (E) |
- - - - - - - - -
| LC_CTYPE Data |
----------------------------------
| LC_MONETARY Table Header (F)
- - - - - - - - -
| LC_MONETARY Data |
----------------------------------
| LC_NUMERIC Table Header (G) |
- - - - - - - - -
| LC_NUMERIC Data |
----------------------------------
| LC_TIME Table Header (H) |
- - - - - - - - -
| LC_TIME Data |
----------------------------------
*****************************************************************************/
/* Category Id's */
/* Table Header (A) */
struct table_header {
unsigned int size; /* size of table header and category
structure. (A) + (B) */
unsigned short nl_langid; /* _nl_langid */
unsigned char lang[3*MAXLNAMELEN+2+1]; /* language name */
unsigned short cat_no; /* number of categories defined */
unsigned short mod_no; /* number of modifiers defined */
unsigned short rev_flag; /* true if HP defined */
unsigned char rev_str[36]; /* Revision String */
unsigned short codeset; /* 0 if 1 byte, 1 if 2 byte */
unsigned int reserved1;
unsigned int reserved2;
unsigned int reserved3;
};
/* Category/Modifier Structure (B)
Catinfotype structure describes a category/modifier table
There is one structure for each category and modifier defined.
These entries follow the table header */
struct catinfotype
{
int size; /* size of category table */
int address; /* address of category table -
offset from the beginning of
the category tables () */
short catid; /* category id */
unsigned char mod_name[MAXLNAMELEN+1]; /* name of modifier */
short mod_addr; /* address of category table
for modifier - offset from
beginning of file */
};
/* Below are the category headers for each of the defined categories
All addresses are offset from the beginning of the category information */
/* LC_ALL Table (C) */
struct all_header {
unsigned short yes_addr; /* msg_index[YESSTR] */
unsigned short no_addr; /* msg_index[NOSTR] */
unsigned short direct_addr; /* msg_index[DIRECTION] */
/* _nl_direct */
unsigned short context_addr; /* _nl_context */
};
/* LC_COLLATE Tables (D) */
struct col_header {
unsigned int seqtab_addr; /* _seqtab */
unsigned int pritab_addr; /* _pritab */
unsigned short nl_map21; /* not an address */
unsigned short nl_onlyseq; /* not an address */
unsigned int tab21_addr;
unsigned int tab12_addr;
};
/* LC_CTYPE Tables (E) */
struct ctype_header {
unsigned int _sh_high; /* _sh_high */
int _sh_low; /* _sh_low */
unsigned int _ctype_addr; /* __ctype */
unsigned int kanji1_addr; /* _1kanji */
unsigned int kanji2_addr; /* _2kanji */
unsigned int upshift_addr; /* _upshift */
unsigned int downshift_addr; /* _downshift */
unsigned short byte_char_addr; /* msg_index[BYTES_CHAR] */
unsigned short alt_punct_addr; /* msg_index[ALT_PUNCT] */
/* _nl_punct_alt[] */
/* _nl_space_alt */
#ifdef EUC
unsigned int io_csize_addr; /* __io_csize[] */
unsigned int e_cset_addr; /* __e_cset */
unsigned int ein_csize_addr; /* __ein_csize */
unsigned int eout_csize_addr; /* __eout_csize */
#endif /* EUC */
};
/* LC_MONETARY Tables (F) */
struct monetary_header {
unsigned short int_frac_digits; /* _lconv->short_frac_digits */
unsigned short frac_digits; /* _lconv->frac_digits */
unsigned short p_cs_precedes; /* _lconv->p_cs_precedes */
unsigned short p_sep_by_space; /* _lconv->p_sep_by_space */
unsigned short n_cs_precedes; /* _lconv->n_cs_precedes */
unsigned short n_sep_by_space; /* _lconv->n_sep_by_space */
unsigned short p_sign_posn; /* _lconv->p_sign_posn */
unsigned short n_sign_posn; /* _lconv->n_sign_posn */
unsigned short curr_symbol_lconv; /* _lconv->currency_symbol */
unsigned short curr_symbol_li; /* msg_index[CRNCYSTR] */
unsigned short mon_decimal_point; /* _lconv->mon_decimal_point */
unsigned short int_curr_symbol; /* _lconv->short_curr_symbol */
unsigned short mon_thousands_sep; /* _lconv->mon_thousands_sep */
unsigned short mon_grouping; /* _lconv->mon_grouping */
unsigned short positive_sign; /* _lconv->positive_sign */
unsigned short negative_sign; /* _lconv->negative_sign */
};
/* LC_NUMERIC Tables (G) */
struct numeric_header {
unsigned short grouping; /* _lconv->grouping */
unsigned short decimal_point; /* _lconv->decimal_point */
/* msg_index[RADIXCHAR] */
/* _nl_radix */
unsigned short thousands_sep; /* _lconv->thousands_sep */
/* msg_index[THOUSEP] */
unsigned short alt_digit_addr; /* msg_index[ALT_DIGIT] */
};
/* LC_TIME Tables (H) */
struct time_header {
unsigned short d_t_fmt; /* msg_index[D_T_FMT] */
unsigned short d_fmt; /* msg_index[D_FMT] */
unsigned short t_fmt; /* msg_index[T_FMT] */
unsigned short day_1; /* msg_index[DAY_1] */
unsigned short day_2; /* msg_index[DAY_2] */
unsigned short day_3; /* msg_index[DAY_3] */
unsigned short day_4; /* msg_index[DAY_4] */
unsigned short day_5; /* msg_index[DAY_5] */
unsigned short day_6; /* msg_index[DAY_6] */
unsigned short day_7; /* msg_index[DAY_7] */
unsigned short abday_1; /* msg_index[ABDAY_1] */
unsigned short abday_2; /* msg_index[ABDAY_2] */
unsigned short abday_3; /* msg_index[ABDAY_3] */
unsigned short abday_4; /* msg_index[ABDAY_4] */
unsigned short abday_5; /* msg_index[ABDAY_5] */
unsigned short abday_6; /* msg_index[ABDAY_6] */
unsigned short abday_7; /* msg_index[ABDAY_7] */
unsigned short mon_1; /* msg_index[MON_1] */
unsigned short mon_2; /* msg_index[MON_2] */
unsigned short mon_3; /* msg_index[MON_3] */
unsigned short mon_4; /* msg_index[MON_4] */
unsigned short mon_5; /* msg_index[MON_5] */
unsigned short mon_6; /* msg_index[MON_6] */
unsigned short mon_7; /* msg_index[MON_7] */
unsigned short mon_8; /* msg_index[MON_8] */
unsigned short mon_9; /* msg_index[MON_9] */
unsigned short mon_10; /* msg_index[MON_10] */
unsigned short mon_11; /* msg_index[MON_11] */
unsigned short mon_12; /* msg_index[MON_12] */
unsigned short abmon_1; /* msg_index[ABMON_1] */
unsigned short abmon_2; /* msg_index[ABMON_2] */
unsigned short abmon_3; /* msg_index[ABMON_3] */
unsigned short abmon_4; /* msg_index[ABMON_4] */
unsigned short abmon_5; /* msg_index[ABMON_5] */
unsigned short abmon_6; /* msg_index[ABMON_6] */
unsigned short abmon_7; /* msg_index[ABMON_7] */
unsigned short abmon_8; /* msg_index[ABMON_8] */
unsigned short abmon_9; /* msg_index[ABMON_9] */
unsigned short abmon_10; /* msg_index[ABMON_10] */
unsigned short abmon_11; /* msg_index[ABMON_11] */
unsigned short abmon_12; /* msg_index[ABMON_12] */
unsigned short am_str; /* msg_index[AM_STR] */
unsigned short pm_str; /* msg_index[PM_STR] */
unsigned short year_unit; /* msg_index[YEAR_UNIT] */
unsigned short mon_unit; /* msg_index[MON_UNIT] */
unsigned short day_unit; /* msg_index[DAY_UNIT] */
unsigned short hour_unit; /* msg_index[HOUR_UNIT] */
unsigned short min_unit; /* msg_index[MIN_UNIT] */
unsigned short sec_unit; /* msg_index[SEC_UNIT] */
unsigned short era_fmt; /* msg_index[ERA_FMT] */
unsigned short era_count; /* number of era entries */
unsigned short era_names; /* address of era name and format strings */
unsigned short era_addr; /* address of era data structure entries */
unsigned short reserved; /* address of era data structure entries */
};
#endif /* DtSETLOCALE_INCLUDED */

View File

@@ -0,0 +1,345 @@
/* $XConsortium: SharedProcs.c /main/7 1996/08/28 17:19:21 drk $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/*************************************<+>*************************************
*****************************************************************************
**
** File: SharedProcs.c
**
** Project: DT
**
** Description: Contains the set of functions which are of general
** use to all DT clients.
**
**
****************************************************************************
************************************<+>*************************************/
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <time.h>
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/VendorSEP.h>
#include <Xm/MessageB.h>
#include <Xm/RowColumn.h>
#include <Xm/MwmUtil.h>
#include <Xm/Protocols.h>
#include <X11/ShellP.h>
#include <X11/Shell.h>
#include <X11/Xatom.h>
#include <Dt/DtP.h>
#include <Dt/Connect.h>
#include <Dt/DtNlUtils.h>
#include "SharedProcs.h"
/* Defines */
#define RW_ALL S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH
/******** Static Function Declarations ********/
/******** End Static Function Declarations ********/
/************************************************************************
*
* _DtStripSpaces
*
* Strip all leading and trailing spaces.
*
************************************************************************/
String
_DtStripSpaces(
String string )
{
int i;
String space;
if (string == NULL)
return (string);
/* Strip off leading spaces first */
i = 0;
while (
#ifdef NLS16
(!is_multibyte || (mblen(string + i, MB_CUR_MAX) == 1)) &&
#endif
isspace((u_char)string[i]))
{
i++;
}
/* Copy over the leading spaces */
strcpy(string, string + i);
/* Drop out, if the string is now empty */
if ((i = strlen(string) - 1) < 0)
return(string);
/* Strip off trailing spaces */
#ifdef NLS16
if (!is_multibyte)
{
#endif
/* No multibyte; simply work back through the string */
while ((i >= 0) && (isspace((u_char)string[i])))
i--;
string[i + 1] = '\0';
#ifdef NLS16
}
else
{
/* Work forward, looking for a trailing space of spaces */
int len;
i = 0;
space = NULL;
while (string[i])
{
if (((len = mblen(string + i, MB_CUR_MAX)) == 1) && isspace((u_char)string[i]))
{
/* Found a space */
if (space == NULL)
space = string + i;
}
else if (space)
space = NULL;
/* if there is an invalid character, treat as a valid one-byte */
if (len == -1)
len = 1;
i += len;
}
if (space)
*space = '\0';
}
#endif
return (string);
}
/************************************************************************
*
* _DtMessage
* Create and display an error message.
*
************************************************************************/
void
_DtMessage(
Widget w,
char *title,
char *message_text,
XtPointer helpIdStr,
void (*helpCallback)() )
{
_DtMessageDialog(w, title, message_text, helpIdStr, False,
NULL, _DtMessageOK, _DtMessageClose, helpCallback, True,
ERROR_DIALOG);
}
/************************************************************************
*
* Generic warning/error dialog creation function.
*
************************************************************************/
Widget
_DtMessageDialog(
Widget w,
char *title,
char *message_text,
XtPointer helpIdStr,
Boolean cancel_btn,
void (*cancel_callback)(),
void (*ok_callback)(),
void (*close_callback)(),
void (*help_callback)(),
Boolean deleteOnClose,
int dialogType )
{
Widget message;
Widget widget;
XmString message_string;
XWindowAttributes attributes;
Arg args[10];
XmString okString, cancelString, helpString;
okString = XmStringCreateLocalized((Dt11GETMESSAGE(28,1, "OK")));
cancelString = XmStringCreateLocalized((Dt11GETMESSAGE(28,2, "Cancel")));
helpString = XmStringCreateLocalized((Dt11GETMESSAGE(28,3, "Help")));
XtSetArg (args[0], XmNautoUnmanage, False);
XtSetArg (args[1], XmNcancelLabelString, cancelString);
XtSetArg (args[2], XmNokLabelString, okString);
XtSetArg (args[3], XmNhelpLabelString, helpString);
XtSetArg (args[4], XmNuseAsyncGeometry, True);
/* Search up to get the topmost shell */
while (XtParent (w) != NULL && !(XtIsSubclass (w, shellWidgetClass)))
w = XtParent (w);
switch (dialogType)
{
case ERROR_DIALOG:
message = XmCreateErrorDialog(w, title, args, 5);
break;
case WARNING_DIALOG:
message = XmCreateWarningDialog(w, title, args, 5);
break;
case QUESTION_DIALOG:
message = XmCreateQuestionDialog(w, title, args, 5);
break;
}
if (XtWindow (w) != 0)
XGetWindowAttributes(XtDisplay (w), XtWindow (w), &attributes);
else
attributes.map_state = IsUnmapped;
if (attributes.map_state == IsUnmapped)
{
XtSetArg(args[0], XmNx, (WidthOfScreen(XtScreen (w)) - 350) / 2);
XtSetArg(args[1], XmNy, (HeightOfScreen(XtScreen (w)) - 200) / 2);
XtSetArg(args[2], XmNdefaultPosition, False);
XtSetValues(message, args, 3);
}
/* Adjust the decorations and title for the dialog shell of the dialog */
XtSetArg(args[0], XmNtitle, title);
XtSetArg(args[1], XmNmwmFunctions, MWM_FUNC_MOVE);
XtSetArg(args[2], XmNmwmDecorations, MWM_DECOR_BORDER | MWM_DECOR_TITLE);
XtSetValues(XtParent (message), args, 3);
widget = XmMessageBoxGetChild(message, XmDIALOG_CANCEL_BUTTON);
if (!cancel_btn)
XtUnmanageChild(widget);
else if (cancel_callback)
{
XtAddCallback(widget, XmNactivateCallback, cancel_callback,
(caddr_t) message);
XtSetArg(args[0], XmNcancelButton, widget);
XtSetValues(message, args, 1);
}
widget = XmMessageBoxGetChild(message, XmDIALOG_OK_BUTTON);
XtSetArg(args[0], XmNmarginWidth, 10);
XtSetArg(args[1], XmNmarginHeight, 2);
XtSetValues(widget, args, 2);
XtAddCallback(widget, XmNactivateCallback, ok_callback, (caddr_t) message);
widget = XmMessageBoxGetChild(message, XmDIALOG_HELP_BUTTON);
if (helpIdStr != NULL)
{
if (help_callback)
{
XtAddCallback(widget, XmNactivateCallback, help_callback,
(caddr_t) helpIdStr);
}
XtSetValues(widget, args, 2);
}
else
XtUnmanageChild(widget);
widget = XmMessageBoxGetChild(message, XmDIALOG_MESSAGE_LABEL);
message_string = XmStringCreateLocalized(message_text);
XtSetArg(args[0], XmNlabelString, message_string);
XtSetValues(widget, args, 1);
XmStringFree(message_string);
XtManageChild(message);
if (deleteOnClose)
{
if (close_callback == NULL)
close_callback = _DtMessageClose;
XtAddEventHandler(XtParent (message), StructureNotifyMask, True,
(XtEventHandler)close_callback, message);
}
XmStringFree(okString);
XmStringFree(cancelString);
XmStringFree(helpString);
return(message);
}
/************************************************************************
*
* _DtMessageOK
* Close the error message box.
*
************************************************************************/
/* ARGSUSED */
void
_DtMessageOK(
Widget w,
XtPointer client_data,
XtPointer call_data )
{
XtUnmanageChild(client_data);
}
/************************************************************************
*
* _DtMessageClose
* Close the error message box.
*
************************************************************************/
void
_DtMessageClose(
Widget w,
XtPointer client_data,
XEvent *event )
{
if (event->type == UnmapNotify)
{
XtRemoveEventHandler(XtParent(client_data), StructureNotifyMask,
True, (XtEventHandler)_DtMessageClose, client_data);
XtUnmanageChild(client_data);
XtDestroyWidget(w);
}
}

View File

@@ -0,0 +1,80 @@
/* $XConsortium: SharedProcs.h /main/4 1995/10/26 15:28:07 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/************************************<+>*************************************
****************************************************************************
**
** File: SharedProcs.h
**
** Project: SUI
**
** Description: Public include file for some shared functions.
**
**
** (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
**
**
**
****************************************************************************
************************************<+>*************************************/
#ifndef _SharedProcs_h
#define _SharedProcs_h
/******** Public Function Declarations ********/
extern String _DtStripSpaces(
String string) ;
extern void _DtMessage(
Widget w,
char *title,
char *message_text,
XtPointer helpIdStr,
void (*helpCallback)()) ;
extern Widget _DtMessageDialog(
Widget w,
char *title,
char *message_text,
XtPointer helpIdStr,
Boolean cancel_btn,
void (*cancel_callback)(),
void (*ok_callback)(),
void (*close_callback)(),
void (*help_callback)(),
Boolean deleteOnClose,
int dialogType) ;
extern void _DtMessageOK(
Widget w,
XtPointer client_data,
XtPointer call_data) ;
extern void _DtMessageClose(
Widget w,
XtPointer client_data,
XEvent *event) ;
/******** End Public Function Declarations ********/
/* _DtMessage Dialog build defines */
#define ERROR_DIALOG 1
#define WARNING_DIALOG 2
#define QUESTION_DIALOG 3
/* Flag which can be used to prevent error dialogs from being posted */
extern Boolean messageDisplayEnabled;
/* Flag controlling whether dialogs are auto-positioned */
extern Boolean disableDialogAutoPlacement;
/* Generic overlay for all dialog 'Rec' structures */
typedef struct
{
Widget shell;
} GenericRecord;
#endif /* _SharedProcs_h */
/* DON'T ADD ANYTHING AFTER THIS #endif */

View File

@@ -0,0 +1,366 @@
/* $TOG: SmCreateDirs.c /main/9 1997/02/24 09:23:16 barstow $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/******************************************************************************
*
* File Name: SmCreateDirs.c
*
*****************************************************************************/
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <X11/Intrinsic.h>
#include <Dt/DtNlUtils.h>
#include <Dt/DtPStrings.h>
#include <Dt/WsmP.h>
/******** Private Function Declarations ********/
static int
GetShortHostname (
char*,
unsigned int);
static char *
GetSessionDirProperty (
Display *display);
static char *
GetDisplayName (
Display *display);
/*************************************<->*************************************
*
* _DtCreateDtDirs (display)
*
* 1. Creates ~/.dt, ~/.dt/types, ~/.dt/tmp and either
* ~/.dt/sessions or ~/.dt/<display_name>
*
* 2. Returns the name of the session directory
*
* Outputs:
* -------
* Returns the session directory or NULL if malloc fails or ~/.dt
* cannot be created
*
*************************************<->***********************************/
char *
_DtCreateDtDirs(
Display *display )
{
char *tmpPath;
Boolean needSessionsDir = False;
Boolean useOldSession = False;
struct stat buf;
int status;
char *home;
char *sessionDir;
char *displayName;
/*
* Sanity check - make sure there's an existing display
*/
if(!display)
return(NULL);
if ((home =getenv("HOME")) == NULL)
home = "";
tmpPath = (char *) XtMalloc((MAXPATHLEN + 1) * sizeof(char));
if(tmpPath == NULL)
return(NULL);
/*
* If the $HOME/.dt directory does not exist, create it
*/
strcpy(tmpPath, home);
strcat(tmpPath, "/" DtPERSONAL_CONFIG_DIRECTORY);
status = stat(tmpPath, &buf);
if (status == -1) {
status = mkdir(tmpPath, 0000);
if (status == -1) {
XtFree(tmpPath);
return(NULL);
}
(void)chmod(tmpPath, 0755);
}
/*
* Create the personal DB directory if it does not exist.
*/
strcpy(tmpPath, home);
strcat(tmpPath, "/" DtPERSONAL_DB_DIRECTORY);
if ((status = stat (tmpPath, &buf)) == -1) {
if ((status = mkdir (tmpPath, 0000)) != -1)
(void) chmod (tmpPath, 0755);
}
/*
* Create the personal tmp dir if it does not exist.
*/
strcpy(tmpPath, home);
strcat(tmpPath, "/" DtPERSONAL_TMP_DIRECTORY);
if ((status = stat (tmpPath, &buf)) == -1) {
if ((status = mkdir (tmpPath, 0000)) != -1)
(void) chmod (tmpPath, 0755);
}
/*
* The creation of the session directory is tricky:
*
* For CDE 1.0 sessions, if a display-specific directory exists,
* it will take precedence. CDE 1.0 does not support the selection
* of a session.
*
* However, for newer CDE implementations, if a specific session
* was selected, the specified session will be used. If no session
* was selected, the CDE 1.0 mechanism will be used.
*
* If a CDEnext session is being used, the session directory will
* be on a property on the root window.
*
* Must check for this property and use it if is set.
*/
if ((sessionDir = GetSessionDirProperty (display)) != NULL) {
if (!strcmp (sessionDir, DtSM_SESSION_DIRECTORY)) {
/*
* Need to create a DtSM_SESSION_DIRECTORY dir if it
* does not exist.
*/
needSessionsDir = True;
} else if (!strcmp (sessionDir, DtSM_SESSION_DISPLAY_DIRECTORY)) {
/*
* Create a directory for a display-specific session if necessary
*/
if ((displayName = GetDisplayName (display)) != NULL) {
strcpy (tmpPath, home);
strcat (tmpPath, "/" DtPERSONAL_CONFIG_DIRECTORY);
strcat (tmpPath, "/");
strcat (tmpPath, displayName);
free(displayName); /* CDExc22771 */
if ((status = stat (tmpPath, &buf)) == -1) {
if ((status = mkdir (tmpPath, 0000)) != -1)
(void) chmod (tmpPath, 0755);
else
useOldSession = True;
}
}
else {
/*
* Something's wrong with the display, use the fallback
*/
useOldSession = True;
}
} else {
/*
* The property contains an unrecognized value, fallback to
* other session selection algorithm.
*/
useOldSession = True;
}
XFree (sessionDir);
}
else
useOldSession = True;
if (useOldSession) {
/*
* Check for a display dependent directory. If one exists,
* it will be used.
*
* This is done for backward compatibility - THE DISPLAY
* DEPENDENT DIR TAKES PRECEDENT.
*/
if ((displayName = GetDisplayName (display)) != NULL) {
strcpy (tmpPath, home);
strcat (tmpPath, "/" DtPERSONAL_CONFIG_DIRECTORY);
strcat (tmpPath, "/");
strcat (tmpPath, displayName);
free(displayName); /* CDExc22771 */
if ((status = stat(tmpPath, &buf)) != 0)
/*
* The display directory does not exist
*/
needSessionsDir = True;
}
else
needSessionsDir = True;
}
if(needSessionsDir)
{
/*
* If we don't have an old style directory - we check for a sessions
* directory, and create it if it doesn't exist
*/
strcpy (tmpPath, home);
strcat (tmpPath, "/" DtPERSONAL_CONFIG_DIRECTORY);
strcat (tmpPath, "/" DtSM_SESSION_DIRECTORY);
if ((status = stat(tmpPath, &buf)) == -1) {
if ((status = mkdir(tmpPath, 0000)) == -1) {
XtFree(tmpPath);
return(NULL);
}
(void)chmod(tmpPath, 0755);
}
}
return(tmpPath);
}
/*------------------------------------------------------------------------+*/
static int
GetShortHostname(
char *buffer,
unsigned int bufsize )
{
char * ptr;
int status;
if (status = gethostname(buffer, bufsize))
return status; /* failed gethostname */
if (ptr = strstr(buffer, (char *)"."))
*ptr = NULL; /* delete domain name if there is one */
return 0;
}
/*------------------------------------------------------------------------+*/
/*
* GetSessionDirProperty -
*/
static char *
GetSessionDirProperty (
Display *display)
{
int propStatus;
Atom actualType;
int actualFormat;
unsigned long nitems;
unsigned long leftover;
char *property = NULL;
Atom tmpAtom;
tmpAtom = XInternAtom(display, _XA_DT_RESTORE_DIR, False);
propStatus = XGetWindowProperty (display, RootWindow(display, 0),
(Atom) tmpAtom, 0L,
1000000L, False,
AnyPropertyType, &actualType,
&actualFormat, &nitems, &leftover,
(unsigned char **)&property);
if (propStatus == Success && actualType != None &&
actualFormat == 8 && nitems != 0)
return(property);
if (property)
XFree(property);
return (NULL);
}
/*------------------------------------------------------------------------+*/
/*
* GetDisplayName -
*/
static char *
GetDisplayName (
Display *display)
{
char *tmpPath;
char hostName[101], displayName[101];
char *pch, *tmpNumber = NULL;
char *returnPath;
/*
* Create the display name and append it to the current path.
*/
(void)strcpy(hostName, display->display_name);
(void)strcpy(displayName, display->display_name);
/*
* If this is run to unix or local get the host name - otherwise
* just use what we have
*/
/*
* Strip host name to nothing but the unqualified (short) host name
*/
if (pch = DtStrchr(hostName, ':'))
*pch = '\0';
if (pch = DtStrchr(hostName, '.'))
*pch = '\0';
if((!strcmp(hostName, "unix")) || (!strcmp(hostName, "local"))
|| (!strcmp(hostName, "")))
{
/*
* host name is local - get the real name
*/
(void) GetShortHostname(hostName, 25);
}
/*
* Strip screen off of display name
*/
if (tmpNumber = DtStrchr(displayName, ':'))
if (pch = DtStrchr(tmpNumber, '.'))
*pch = '\0';
/*
* Strip it down to 14 chars (actually, 14 bytes or less)
*/
if((strlen(tmpNumber) + strlen(hostName)) > (size_t)14)
{
size_t tnLen;
int lastChLen;
char *lastCh;
/* Pare display number to at most 12 bytes */
while ((tnLen = strlen(tmpNumber)) > (size_t)12)
{
/* Remove the last character, an try again */
DtLastChar(tmpNumber, &lastCh, &lastChLen);
*lastCh = '\0';
}
/* Pare down host name, if necessary */
while ((strlen(hostName) + tnLen) > (size_t)14)
{
/* Remove the last character, and try again */
DtLastChar(hostName, &lastCh, &lastChLen);
*lastCh = '\0';
}
}
strcat (hostName, tmpNumber);
returnPath = strdup (hostName);
return (returnPath);
}

View File

@@ -0,0 +1,51 @@
/* $XConsortium: SmCreateDirs.h /main/4 1995/10/26 15:28:38 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/*************************************<+>*************************************
*****************************************************************************
**
** File: SmCreateDirs.h
**
** Description: Header file for SmCreateDirs.c
** -----------
**
*******************************************************************
** (c) Copyright Hewlett-Packard Company, 1990. All rights are
** reserved. Copying or other reproduction of this program
** except for archival purposes is prohibited without prior
** written consent of Hewlett-Packard Company.
********************************************************************
**
**
**
*****************************************************************************
*************************************<+>*************************************/
#ifndef _SmCreateDirs_h
#define _SmCreateDirs_h
/*
* include statements
*/
/*
* define statements
*/
/*
* typedef statements
*/
/*
* Function definitions
*/
extern char * _DtCreateDtDirs(Display *display) ;
#endif /* _SmCreateDirs_h */
/* Do not add anything after this endif. */

View File

@@ -0,0 +1,29 @@
/*
* File: Spc.h $XConsortium: Spc.h /main/3 1995/10/26 15:28:51 rswiston $
* Language: C
*
* (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef _Dt_SPC_h
#define _Dt_SPC_h
#include <bms/spc.h>
/*
* For definitions of any of the following, look in <bms/spc.h>.
*/
#define DtSPCOpen XeSPCOpen
#define DtSPCClose XeSPCClose
#define DtSPCSpawn XeSPCSpawn
#define DtSPCAddInput XeSPCAddInput
#define DtSPCRegisterTerminator XeSPCRegisterTerminator
#define DtSPCErrorNumber XeSPCErrorNumber
#endif /* #ifdef _Dt_SPC_h */

View File

@@ -0,0 +1,148 @@
/* $XConsortium: SunDtHelp.c /main/6 1996/08/22 10:39:25 rswiston $
*
* (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.
*/
/*
*+SNOTICE
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement bertween
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
* Sun's specific written approval. This documment and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*+ENOTICE
*/
#include <stdio.h>
#include <dlfcn.h>
#include "Help.h"
#include "DtSvcLock.h"
#pragma weak DtCreateHelpDialog = _DtCreateHelpDialog
#pragma weak DtCreateHelpQuickDialog = _DtCreateHelpQuickDialog
#pragma weak DtHelpQuickDialogGetChild = _DtHelpQuickDialogGetChild
#pragma weak DtHelpReturnSelectedWidgetId = _DtHelpReturnSelectedWidgetId
typedef Widget (*SUNWWidgetProc)();
typedef int (*SUNWIntProc)();
typedef struct _SUNWHelpProcList {
SUNWWidgetProc DtCreateHelpDialogSym;
SUNWWidgetProc DtCreateHelpQuickDialogSym;
SUNWWidgetProc DtHelpQuickDialogGetChildSym;
SUNWIntProc DtHelpReturnSelectedWidgetIdSym;
} SUNWHelpProcList;
static SUNWHelpProcList *pmySUNWProcList = NULL;
int SUNWDtHelpdlopen()
{
void *libDtHelpHandle = NULL;
_DtSvcProcessLock();
pmySUNWProcList = (SUNWHelpProcList *)malloc(sizeof(SUNWHelpProcList));
libDtHelpHandle = dlopen("libDtHelp.so.1", RTLD_LAZY | RTLD_GLOBAL);
if (libDtHelpHandle == NULL) {
char *my_err_msg;
my_err_msg = dlerror();
printf("%s\n", my_err_msg);
_DtSvcProcessUnlock();
return(FALSE);
}
pmySUNWProcList->DtCreateHelpDialogSym = (SUNWWidgetProc)
dlsym(libDtHelpHandle, "DtCreateHelpDialog");
pmySUNWProcList->DtCreateHelpQuickDialogSym = (SUNWWidgetProc)
dlsym(libDtHelpHandle, "DtCreateHelpQuickDialog");
pmySUNWProcList->DtHelpQuickDialogGetChildSym = (SUNWWidgetProc)
dlsym(libDtHelpHandle, "DtHelpQuickDialogGetChild");
pmySUNWProcList->DtHelpReturnSelectedWidgetIdSym = (SUNWIntProc)
dlsym(libDtHelpHandle, "DtHelpReturnSelectedWidgetId");
_DtSvcProcessUnlock();
return(TRUE);
}
Widget _DtCreateHelpDialog(
Widget parent,
char *name,
ArgList al,
Cardinal ac)
{
int status;
_DtSvcProcessLock();
status = pmySUNWProcList || SUNWDtHelpdlopen();
_DtSvcProcessUnlock();
if (!status)
return(NULL);
return ((*pmySUNWProcList->DtCreateHelpDialogSym)(parent, name, al, ac));
}
Widget _DtCreateHelpQuickDialog(
Widget parent,
char *name,
ArgList al,
Cardinal ac)
{
int status;
_DtSvcProcessLock();
status = pmySUNWProcList || SUNWDtHelpdlopen();
_DtSvcProcessUnlock();
if (!status)
return(NULL);
return ((*pmySUNWProcList->DtCreateHelpQuickDialogSym)(parent, name, al, ac));
}
Widget _DtHelpQuickDialogGetChild(
Widget widget,
unsigned char child )
{
int status;
_DtSvcProcessLock();
status = pmySUNWProcList || SUNWDtHelpdlopen();
_DtSvcProcessUnlock();
if (!status)
return(NULL);
return ((*pmySUNWProcList->DtHelpQuickDialogGetChildSym)(widget, child));
}
int _DtHelpReturnSelectedWidgetId(
Widget parent,
Cursor cursor,
Widget *widget)
{
int status;
_DtSvcProcessLock();
status = pmySUNWProcList || SUNWDtHelpdlopen();
_DtSvcProcessUnlock();
if (!status)
return(NULL);
return ((*pmySUNWProcList->DtHelpReturnSelectedWidgetIdSym)(parent, cursor,
widget));
}

View File

@@ -0,0 +1,64 @@
/* $XConsortium: SvcTT.c /main/3 1995/10/26 15:30:18 rswiston $ */
/*%% */
/*%% RESTRICTED CONFIDENTIAL INFORMATION: */
/*%% */
/*%% The information in this document is subject to special */
/*%% restrictions in a confidential disclosure agreement between */
/*%% HP, IBM, Sun, USL, SCO and Univel. Do not distribute this */
/*%% document outside HP, IBM, Sun, USL, SCO, or Univel without */
/*%% Sun's specific written approval. This document and all copies */
/*%% and derivative works thereof must be returned or destroyed at */
/*%% Sun's request. */
/*%% */
/* (c) Copyright 1993, 1994 Hewlett-Packard Company */
/* (c) Copyright 1993, 1994 International Business Machines Corp. */
/* (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
/* (c) Copyright 1993, 1994 Novell, Inc. */
/*%% */
#include <sys/time.h>
#include <Dt/SvcTT.h>
/*
* Ensure that there is a valid ToolTalk connection open.
* If none is open, creates one and adds it to the XtAppContext
* of widget. Returns
* TT_OK Success.
* TT_ERR_NOMP ToolTalk could not be initialized.
* TT_ERR_POINTER widget was null.
*/
Tt_status
_DtSvcInitToolTalk(
Widget widget
)
{
char *procid;
Tt_status status;
int fd;
XtAppContext ctxt;
procid = tt_default_procid();
status = tt_ptr_error( procid );
if (status == TT_OK) {
tt_free( procid );
}
if ((status == TT_ERR_NOMP) || (status == TT_ERR_PROCID)) {
if (widget == 0) {
return TT_ERR_POINTER;
}
procid = tt_open(); /* do not tt_free(); Xt will pass it back */
status = tt_ptr_error( procid );
if (status != TT_OK) {
return status;
}
fd = tt_fd();
status = tt_int_error( fd );
if (status != TT_OK) {
return status;
}
ctxt = XtWidgetToApplicationContext( widget );
XtAppAddInput( ctxt, fd, (XtPointer)XtInputReadMask,
tttk_Xt_input_handler, procid );
}
return TT_OK;
}

View File

@@ -0,0 +1,24 @@
/* $XConsortium: SvcTT.h /main/3 1995/10/26 15:30:33 rswiston $ */
/*%% */
/*%% RESTRICTED CONFIDENTIAL INFORMATION: */
/*%% */
/*%% The information in this document is subject to special */
/*%% restrictions in a confidential disclosure agreement between */
/*%% HP, IBM, Sun, USL, SCO and Univel. Do not distribute this */
/*%% document outside HP, IBM, Sun, USL, SCO, or Univel without */
/*%% Sun's specific written approval. This document and all copies */
/*%% and derivative works thereof must be returned or destroyed at */
/*%% Sun's request. */
/*%% */
/*%% Copyright 1994 Sun Microsystems, Inc. All rights reserved. */
/*%% */
#ifndef _DT_SVCTT_H
#define _DT_SVCTT_H
#include <Tt/tttk.h>
extern Tt_status _DtSvcInitToolTalk(
Widget widget
);
#endif

View File

@@ -0,0 +1,225 @@
/* $TOG: UErrNoBMS.c /main/9 1998/04/09 17:50:11 mgreess $ */
/*
* (c) Copyright 1995 Digital Equipment Corporation.
* (c) Copyright 1987, 1988, 1989, 1990, 1993, 1994, 1995 Hewlett-Packard Company
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
* (c) Copyright 1995 FUJITSU LIMITED.
* (c) Copyright 1995 Hitachi.
*/
/*************************************<+>*************************************
*****************************************************************************
**
** File: UErrNoBMS.c
**
** Project: DT
**
** Description: This file contains the CDE 1.0 message logging functions
**
****************************************************************************
************************************<+>*************************************/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <Dt/MsgLog.h>
#include <Dt/MsgLogI.h>
#include <Dt/UserMsg.h>
#define MESSAGE_BUFFER 2048
static char * errno_string(
unsigned int errn, char *buff) ;
static void log_message(
char *progName,
char *help,
char *message,
DtSeverity severity,
int errnoset);
static char *
errno_string(
unsigned int errn, char *buff)
{
char * s;
switch (errn) {
/* These are all in POSIX 1003.1 and/or X/Open XPG3 */
/* ---------------------------------------------------- */
case EPERM : s = "EPERM"; break;
case ENOENT : s = "ENOENT"; break;
case ESRCH : s = "ESRCH"; break;
case EINTR : s = "EINTR"; break;
case EIO : s = "EIO"; break;
case ENXIO : s = "ENXIO"; break;
case E2BIG : s = "E2BIG"; break;
case ENOEXEC : s = "ENOEXEC";break;
case EBADF : s = "EBADF"; break;
case ECHILD : s = "ECHILD"; break;
case EAGAIN : s = "EAGAIN"; break;
case ENOMEM : s = "ENOMEM"; break;
case EACCES : s = "EACCES"; break;
case EFAULT : s = "EFAULT"; break;
case ENOTBLK : s = "ENOTBLK";break;
case EBUSY : s = "EBUSY"; break;
case EEXIST : s = "EEXIST"; break;
case EXDEV : s = "EXDEV"; break;
case ENODEV : s = "ENODEV"; break;
case ENOTDIR : s = "ENOTDIR";break;
case EISDIR : s = "EISDIR"; break;
case EINVAL : s = "EINVAL"; break;
case ENFILE : s = "ENFILE"; break;
case EMFILE : s = "EMFILE"; break;
case ENOTTY : s = "ENOTTY"; break;
case ETXTBSY : s = "ETXTBSY";break;
case EFBIG : s = "EFBIG"; break;
case ENOSPC : s = "ENOSPC"; break;
case ESPIPE : s = "ESPIPE"; break;
case EROFS : s = "EROFS"; break;
case EMLINK : s = "EMLINK"; break;
case EPIPE : s = "EPIPE"; break;
case ENOMSG : s = "ENOMSG"; break;
case EIDRM : s = "EIDRM"; break;
case EDEADLK : s = "EDEADLK";break;
case ENOLCK : s = "ENOLCK"; break;
#ifndef _AIX
case ENOTEMPTY : s = "ENOTEMPTY"; break;
#endif
case ENAMETOOLONG : s = "ENAMETOOLONG"; break;
case ENOSYS : s = "ENOSYS"; break;
default : s = NULL; break;
}
if (s)
sprintf(buff, "%s (%d)",s,errn);
else
sprintf(buff, "(%d)",errn);
return (buff);
}
/*
* This function calls the CDE message logging service.
*/
static void
log_message(
char *progName,
char *help,
char *message,
DtSeverity severity,
int errnoset )
{
char * errmsg = NULL;
char * errname = NULL;
char format[25];
DtMsgLogType msg_type;
char buff[40];
(void) strcpy (format, "%s");
if (help)
(void) strcat (format, "\n %s");
if (errnoset) {
unsigned int errn;
if (errnoset == TRUE) /* Use "errno" from <errno.h> ? */
errn = errno; /* --- yep. */
else
errn = errnoset; /* No, not the magic value, use parm */
errname = errno_string(errn, buff);
if (!(errmsg = strerror(errn)))
errmsg = "unknown";
}
/*
* Must map the old message types to the new
*/
switch (severity) {
case DtError:
DtFatalError:
DtInternalError:
msg_type = DtMsgLogError; break;
case DtIgnore:
DtInformation:
msg_type = DtMsgLogInformation; break;
case DtWarning:
msg_type = DtMsgLogWarning; break;
default:
msg_type = DtMsgLogError;
}
if (errmsg)
(void) strcat (format, "\n [%s] %s");
if (help) {
if (errmsg)
DtMsgLogMessage (progName, msg_type, format, message, help,
errname, errmsg);
else
DtMsgLogMessage (progName, msg_type, format, message, help);
} else {
if (errmsg)
DtMsgLogMessage (progName, msg_type, format, message, errname, errmsg);
else
DtMsgLogMessage (progName, msg_type, format, message);
}
}
void
_DtSimpleError(
char *progName,
DtSeverity severity,
char *help,
char *format,
... )
{
va_list args;
char *message = (char*) malloc(MESSAGE_BUFFER);
if (NULL == message) return;
Va_start(args, format);
#if defined(USE_SNPRINTF)
(void) vsnprintf(message, MESSAGE_BUFFER, format, args);
#else
(void) vsprintf(message, format, args);
#endif
va_end(args);
log_message(progName, help, message, severity, FALSE);
if (message) free(message);
}
void
_DtSimpleErrnoError(
char *progName,
DtSeverity severity,
char *help,
char *format,
... )
{
va_list args;
char *message = (char*) malloc(MESSAGE_BUFFER);
if (NULL == message) return;
Va_start(args, format);
#if defined(USE_SNPRINTF)
(void) vsnprintf(message, MESSAGE_BUFFER, format, args);
#else
(void) vsprintf(message, format, args);
#endif
va_end(args);
log_message(progName, help, message, severity, TRUE);
if (message) free(message);
}

View File

@@ -0,0 +1,17 @@
/* $XConsortium: Unistd.h /main/3 1995/10/26 15:31:10 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/* Hp DT's version of an 8.0 include file; needed for Fnmatch */
#ifndef DtUNISTD_INCLUDED
#define DtUNISTD_INCLUDED
# define FNM_PATHNAME 01 /* flag for pathname matching */
# define _FNM_PERIOD 02 /* flag for explicitly matching leading '.'s */
# define _FNM_UAE 04 /* flag for csh pattern matching */
#endif /* DtUNISTD_INCLUDED */

View File

@@ -0,0 +1,107 @@
/* $TOG: UserMsg.h /main/6 1998/04/09 17:50:49 mgreess $ */
/*
* (c) Copyright 1995 Digital Equipment Corporation.
* (c) Copyright 1988, 1993, 1994, 1995 Hewlett-Packard Company
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
* (c) Copyright 1995 FUJITSU LIMITED.
* (c) Copyright 1995 Hitachi.
*/
/* -*-C-*-
********************************************************************************
*
* File: usermsg.h
* Description: Header for error logging routines
* Status: Experimental (Do Not Distribute)
*
********************************************************************************
*/
#ifndef _usermsg_h
#define _usermsg_h
#include <X11/Intrinsic.h>
#ifndef __STDC__
# ifndef const
# define const
# endif
#endif
#include <bms/XeUserMsg.h>
typedef enum {
DtIgnore,
DtInformation,
DtWarning,
DtError,
DtFatalError,
DtInternalError
} DtSeverity;
extern void _DtSimpleError(
char *progName,
DtSeverity severity,
char *help,
char *format,
...) ;
extern void _DtSimpleErrnoError(
char *progName,
DtSeverity severity,
char *help,
char *format,
...) ;
#define DtProgName XeProgName
extern _DtPrintDefaultError(
Display *dpy,
XErrorEvent *event,
char *msg );
#define _DTPRINTDEFAULTERROR_BUFSIZE 1024
extern _DtPrintDefaultErrorSafe(
Display *dpy,
XErrorEvent *event,
char *msg,
int bytes);
/*
DESCRIPTION:
Supply the standard Xerror output to a buffer (instead of stederr)
so client can do what it wants with it. Also don't exit. Allow
client to decide what to do.
An appropriate thing to do would be to pass the buffer to
DtSimpleError() and return. ie. In your error callback:
{
char errmsg[1024];
int ret ;
ret = _DtPrintDefaultError (style.display, rep, errmsg);
DtSimpleError(DtWarning, "><An X Error has occurred...continuing" ,
errmsg, NULL);
return ret;
}
SYNOPSIS:
int _DtPrintDefaultError (dpy, event, msg)
Display *dpy; The application's display structure.
XErrorEvent *event; Error event returned to error callback.
char *msg; Buffer returning the formatted text of
the error message. It won't be more than
1024 bytes.
*/
#endif /* _usermsg_h */
/* DON'T ADD STUFF AFTER THIS #endif */

View File

@@ -0,0 +1,216 @@
/*
* File: Utility.c $XConsortium: Utility.c /main/5 1996/06/21 17:20:20 ageorge $
* Language: C
*
* (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include <stdio.h>
#include <sys/types.h>
#ifdef __hpux
#include <ndir.h>
#else
#if defined(sun) || defined(USL) || defined(sco) || defined(__uxp__)
#include <dirent.h>
#else
#include <sys/dir.h>
#endif
#endif
#include <ctype.h>
#ifdef NLS16
#include <limits.h>
#endif
#include <sys/stat.h>
#include <sys/param.h> /* MAXPATHLEN, MAXHOSTNAMELEN */
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Dt/DtP.h>
#include <Dt/Connect.h>
#include <Dt/FileUtil.h>
#include <Dt/DtNlUtils.h>
#include <Dt/Utility.h>
#include <Dt/UtilityP.h>
#include "DtSvcLock.h"
#include <string.h>
#define TRUE 1
#define FALSE 0
/******** Static Function Declarations ********/
static char * RemapSpecialDisplayName(
char *dispInfo) ;
/******** End Static Function Declarations ********/
/******************
*
* Function Name: _DtVectorizeInPlace
*
* Description:
*
* A "string vector" is an array of pointers to strings. The
* end of the array is marked with a null pointer. This function
* takes a long string and creates a string vector from it by
* allocating the array of pointers, breaking the string up into
* sub-strings (based on a specified separator character), and
* making the array elements point to the sub-strings;
*
* NOTE that it does this "in place". If you don't want the original
* string disturbed, be sure to make a copy of it before calling
* this function.
*
* The memory for the array of pointers is owned by the caller.
* It can be safely freed (though this doesn't free the sub-strings).
*
* Synopsis:
*
* svector = _DtVectorizeInPlace (string, separator);
*
* char **svector; The string vector that was created. The
* memory is owned by the caller.
* char *string; A pointer to the string to be vectorized.
* THIS STRING WILL BE ALTERED.
* char separtor; The separator character which marks the
* ends of the sub-strings.
*
******************/
char * *
_DtVectorizeInPlace(
char *string,
char separator )
{
/* LOCAL VARIABLES */
char **vector, **next_string, *nextc;
int num_pieces;
/* CODE */
/* Count the elements in the string and allocate an appropriate size
vector. There is one more element than separator characters. */
num_pieces = 1;
nextc = string;
while (nextc = DtStrchr(nextc, separator))
{
num_pieces++;
nextc++;
}
vector = (char **) XtMalloc ((Cardinal)(sizeof(char *) * (num_pieces + 1)));
/* Set the first element of the vector to point to the start of
the string. */
*vector = string;
next_string = vector + 1;
nextc = string;
/* Parse out each component, terminating it with a NULL */
while (nextc = DtStrchr(nextc, separator))
{
*nextc = '\0';
nextc++;
*next_string = nextc;
next_string++;
}
/* The last pointer in the vector must be set to NULL. */
*next_string = NULL;
return (vector);
}
/******************
*
* Function Name: _DtFreeStringVector
*
* Description:
*
* A "string vector" is an array of pointers to strings.
*
* Synopsis:
*
* _DtFreeStringVector (stringv);
*
* char **stringv; The string vector which is freed.
*
* NOTE: this function assumes that "stringv" was created by
* "_DtVectorizeInPlace".
*
******************/
void
_DtFreeStringVector(
char **stringv )
{
/* CODE */
if (stringv)
{
if (stringv[0])
XtFree ((char *)stringv[0]);
XtFree ((char *)stringv);
}
}
/*
* Functions for mapping a display pointer into a display name. It
* special cases 'local:' and 'unix:', and maps these into the real
* host name.
*/
static char *
RemapSpecialDisplayName(
char *dispInfo )
{
static char * localHost = NULL;
char * name;
_DtSvcProcessLock();
if (localHost == NULL)
{
localHost = XtMalloc((Cardinal)30);
DtGetShortHostname(localHost, 30);
}
_DtSvcProcessUnlock();
name = XtMalloc((Cardinal)(strlen(localHost) + strlen(dispInfo) + 1));
(void)strcpy(name, localHost);
(void)strcat(name, dispInfo);
return(name);
}
/*
* Move here from DragUtil.c because the function is useful and DragUtil.c
* is going away.
*/
char *
_DtGetDisplayName(
Display *display )
{
char * name = DisplayString(display);
if (strncmp("unix:", name, 5) == 0)
return(RemapSpecialDisplayName(name+4));
else if (strncmp("local:", name, 6) == 0)
return(RemapSpecialDisplayName(name+5));
else if (strncmp(":", name, 1) == 0)
return(RemapSpecialDisplayName(name));
return(XtNewString(name));
}

View File

@@ -0,0 +1,118 @@
/*
* File: Utility.h $XConsortium: Utility.h /main/4 1995/10/26 15:31:55 rswiston $
* Language: C
*
* (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef _Dt_Utility_h
#define _Dt_Utility_h
/******************************************************************************
*
* _DtVectorizeInPlace() takes a string which is made up a group of
* components, separated by a common separator character, and breaks
* the string up into the separate components. To reduce the amount of
* memory used (and to reduce memory fragmentation), the string is simply
* searched for each occurrence of the separator, and the separator is then
* replaced by a NULL character. Pointers to the individual components are
* returned as a NULL-terminated array of pointers.
*
* The passed-in string should be malloc'ed space, since the string will
* eventually be freed when the application frees the returned array. If
* you don't want the original string modified, then a copy should be made,
* before calling this function.
*
* The application is responsible for freeing up this memory, and should do
* so by calling _DtFreeStringVector().
*
* Parameters:
*
* string A NULL-terminated string, which is to be vectorized.
*
* separator The character which separates the components within
* the string.
*
*****************************************************************************/
extern char ** _DtVectorizeInPlace( char * string,
char separator );
/******************************************************************************
*
* _DtFreeStringVector will free up the vectorized string array returned by
* a call to _DtVectorizeInPlace(). Both the array used to return the
* vectorized strings, and the original string itself will be freed up.
*
* Parameters:
*
* stringVector The array to be freed; originally obtained by a call
* to _DtVectorizeInPlace().
*
*****************************************************************************/
extern void _DtFreeStringVector( char ** stringVector );
/*****************************************************************************
* DtCmd String Utility routines.
*
*****************************************************************************
*
* _DtCmdStringToArrayOfStrings - takes a string and an array of pointers
* to strings and breaks the string into whitespace separated words.
*
* A "word" is a sequence of characters that has no whitespace with
* the following exception:
*
* - A word may contain contain whitespace if it is delimited
* by a pair of matching single or double qotes.
*
* "Whitespace" is a tab or blank character.
*
*
* NOTES:
*
* - The space for the "words" is malloc'd and must be free'd by
* the caller.
* - _DtCmdFreeStringVector() should be used to free up string vectors
* created by _DtCmdStringToArrayOfStrings().
*
* - "theArray" is NULL terminated.
*
* PARAMETERS:
*
* char theString[]; - The string to parse.
*
* char *theArray[]; - MODIFIED: gets filled with pointers to
* the words that are parsed.
*
*****************************************************************************/
/******************************************************************************
*
* _DtCmdFreeStringVector - takes an array of pointers to strings and
* frees the malloc'd space for the strings.
*
* This does NOT free the string vector itself; It assumes that
* stringv is a static i.e. char *stringv[N].
*
* PARAMETERS:
*
* char **stringv; - MODIFIED: Each string in the array is freed.
*
*****************************************************************************/
extern void _DtCmdStringToArrayOfStrings(
char theString[],
char *theArray[]) ;
extern void _DtCmdFreeStringVector(
char **stringv) ;
#endif /* _Dt_Utility_h */
/* DON'T ADD ANYTHING AFTER THIS #endif */

View File

@@ -0,0 +1,20 @@
/*
* File: UtilityP.h $XConsortium: UtilityP.h /main/4 1995/10/26 15:32:08 rswiston $
* Language: C
*
* (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef _Dt_UtilityP_h
#define _Dt_UtilityP_h
extern char * _DtGetDisplayName( Display * display );
#endif /* _Dt_UtilityP_h */
/* DON'T ADD ANYTHING AFTER THIS #endif */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,176 @@
/* $XConsortium: XlationSvc.h /main/6 1996/08/22 09:07:18 rswiston $ */
/************************************<+>*************************************
****************************************************************************
**
** File: XlationSvc.h
**
** Project: DtXlate
**
** Description: table-based translation services
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of Novell, Inc.
**
****************************************************************************
************************************<+>*************************************/
#ifndef _DtXLATE_XLATION_SVC_I
#define _DtXLATE_XLATION_SVC_I
#include <sys/utsname.h> /* for UTSLEN, SYS_NMLN */
#ifdef __cplusplus
extern "C" {
#endif
/*=================================================================
$SHAREDBEG$: This header appears in all appropriate DtXlate topics
$INCLUDE$
#include <XlationSvc.h>
=$END$==========================================================*/
#if DOC
/*========================================================*/
$TYPEBEG$: _DtXlateDb
$1LINER$: An opaque object used to represent translation dbs
$SUMMARY$:
_DtXlateDb is the type of a translation database object.
The database object must be opened before use and closed
after use. The definition of the object is opaque to users.
$ARGS$:
/*================================================$SKIP$==*/
#endif
/*$DEF$*/
typedef struct __DtXlateDbRec * _DtXlateDb;
/*$END$*/
#if DOC
/*========================================================*/
$CONSTBEG$: _DtXLATE_OPER_xxx
$1LINER$: Constants for specifying operations
$SUMMARY$:
The _DtXLATE_OPER_xxx are constants that produce strings
used in the translation specifications when specifying
the operation of a translation.
The operation string name must be identical both in the
source code and in the translation table.
These constants should be used whenever referencing
operations as part of a translation.
/*================================================$SKIP$==*/
#endif
/* $DEF$, Operation constants */
#define _DtXLATE_OPER_VERSION "version"
/*$END$*/
#if DOC
/*========================================================*/
$CONSTBEG$: _DtPLATFORM_xxx
$1LINER$: Constants for specifying platforms strings
$SUMMARY$:
The _DtPLATFORM_xxx are constants that produce strings
used in the translation specifications and when performing
a translation using the API. Recall that the platform name must
be an exact match if specified as translation criteria.
These names are the same strings returned by 'uname(1) -s'
and uname(2):utsname.sysname.
The operation string name must be identical both in the
source code and in the translation table.
These constants should be used whenever referencing
platforms as part of a translation.
/*================================================$SKIP$==*/
#endif
/* $DEF$, Platform constants */
#if defined(SVR4) || defined(_AIX)
#define _DtPLATFORM_MAX_LEN SYS_NMLN
#else
#if defined(SYS_NMLN)
#define _DtPLATFORM_MAX_LEN SYS_NMLN
#else
#define _DtPLATFORM_MAX_LEN UTSLEN
#endif
#endif
#define _DtPLATFORM_UNKNOWN ((const char *)0)
#define _DtPLATFORM_CURRENT ((const char *)0)
#define _DtPLATFORM_CDE "CDE"
#define _DtPLATFORM_HPUX "HP-UX"
#define _DtPLATFORM_AIX "AIX"
#define _DtPLATFORM_SUNOS "SunOS"
#define _DtPLATFORM_SOLARIS "Solaris" /* verify */
#define _DtPLATFORM_USL "USL" /* verify */
#define _DtPLATFORM_SCO "SCO" /* verify */
#define _DtPLATFORM_XENIX "Xenix" /* verify */
/*$END$*/
/* Functions */
int _DtXlateOpenDb(
const char * databaseName,
_DtXlateDb * ret_db);
int _DtXlateOpenAndMergeDbs(
const char * databaseName,
_DtXlateDb * io_db);
int _DtXlateMergeDbs(
_DtXlateDb * io_dbToMerge,
_DtXlateDb * io_mergeIntoDb);
int _DtXlateOpenAllDbs(
const char * searchPaths,
const char * databaseName,
_DtXlateDb * ret_db);
int _DtXlateCloseDb(
_DtXlateDb * io_db);
int _DtXlateStdToOpValue(
_DtXlateDb db,
const char * platform,
const int version,
const char * operation,
const char * stdValue,
char * * ret_opValue,
void * ret_reserved);
int _DtXlateOpToStdValue(
_DtXlateDb db,
const char * platform,
const int version,
const char * operation,
const char * opValue,
char * * ret_stdValue,
void * ret_reserved);
int _DtXlateGetXlateEnv(
_DtXlateDb db,
char * ret_AppExecEnvPlatform,
int * ret_AppExecEnvVersion,
int * ret_XlateCompiledForOSVersion);
/* Non DtXlate functions currently in XlationSvc.c */
int _DtMBStrrchr (
const char * s1,
int value,
int max_len,
const char * * ret_ptr );
int _DtMBStrchr (
const char * s1,
int value,
int max_len,
const char * * ret_ptr );
#ifdef __cplusplus
}
#endif
#endif /*_DtXLATE_XLATION_SVC_I*/
/********* do not put anything below this line ********/

View File

@@ -0,0 +1,218 @@
/* $TOG: XmWrap.c /main/10 1998/09/21 10:57:11 mgreess $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include <Xm/XmP.h>
#include <Xm/IconFile.h>
#ifdef DtUse_XmFunctions
/* Prototypes for internal functions we steal from <Xm/ImageCachI.h>. */
extern Boolean _XmInstallImage(
XImage *image,
char *image_name,
int hot_x,
int hot_y) ;
extern Boolean _XmGetImage(
Screen *screen,
char *image_name,
XImage **image) ;
extern Boolean _XmCachePixmap(
Pixmap pixmap,
Screen *screen,
char *image_name,
Pixel foreground,
Pixel background,
int depth,
Dimension width,
Dimension height) ;
#endif
/************************************************************************
*
* _DtGetPixmapByDepth
* Public wrapper around __DtGetPixmap with parameter order changed.
*
************************************************************************/
Pixmap
_DtGetPixmapByDepth(
Screen *screen,
char *image_name,
Pixel foreground,
Pixel background,
int depth)
{
return(XmGetPixmapByDepth(screen, image_name,
foreground, background, depth));
}
/************************************************************************
*
* _DtGetPixmap
* Create a pixmap of screen depth, using the image referenced
* by the name and the foreground and background colors
* specified. Ensure that multiple pixmaps of the same attributes
* are not created by maintaining a cache of the pixmaps.
*
************************************************************************/
Pixmap
_DtGetPixmap(
Screen *screen,
char *image_name,
Pixel foreground,
Pixel background )
{
return (XmGetPixmap(screen, image_name, foreground, background));
}
/************************************************************************
*
* _DtGetMask
*
************************************************************************/
Pixmap
_DtGetMask(
Screen *screen,
char *image_name)
{
return XmeGetMask( screen, image_name );
}
/************************************************************************
*
* __DtInstallPixmap
* Install a pixmap into the pixmap cache. This is used to add
* cached pixmaps which have no image associated with them.
*
************************************************************************/
Boolean
__DtInstallPixmap(
Pixmap pixmap,
Screen *screen,
char *image_name,
Pixel foreground,
Pixel background )
{
#ifdef DtUse_XmFunctions
return _XmCachePixmap(pixmap, screen, image_name, foreground, background,
0, 0, 0);
#else
XtWarning("__DtInstallPixmap: unsupported interface");
return False;
#endif
}
/************************************************************************
*
* _DtDestroyPixmap
* Locate a pixmap in the cache and decrement its reference count.
* When the reference count is at zero, free the pixmap.
*
************************************************************************/
Boolean
_DtDestroyPixmap(
Screen *screen,
Pixmap pixmap )
{
return XmDestroyPixmap( screen, pixmap );
}
/************************************************************************
*
* _DtInstallImage
* Add the provided image for the image set and return an
* tile id to be used for further referencing. Keep the
* allocation of the image_set array straight.
*
************************************************************************/
Boolean
_DtInstallImage(
XImage *image,
char *image_name,
int hot_x,
int hot_y)
{
#ifdef DtUse_XmFunctions
return _XmInstallImage(image, image_name, hot_x, hot_y);
#else
XtWarning("_DtInstallImage: unsupported interface");
return False;
#endif
}
/************************************************************************
*
* _DtUninstallImage
* Remove an image from the image set.
* Return a boolean (True) if the uninstall succeeded. Return
* a boolean (False) if an error condition occurs.
*
************************************************************************/
Boolean
_DtUninstallImage(
XImage *image )
{
return XmUninstallImage( image );
}
XImage *
_DtGetImage(
Screen *screen,
char *image_name,
XImage **image)
{
Boolean result;
#ifdef DtUse_XmFunctions
if( (result=_XmGetImage(screen, image_name, image)) == False )
return False;
else
return *image;
#else
XtWarning("_DtGetImage: unsupported interface");
return False;
#endif
}
/*
* see if this pixmap is in the cache. If it is then return all the
* gory details about it
*/
/*ARGSUSED*/
Boolean
__DtGetPixmapData(
Screen *screen,
Pixmap pixmap,
char **image_name,
int *depth,
Pixel *foreground,
Pixel *background,
int *hot_x,
int *hot_y,
unsigned int *width,
unsigned int *height)
{
return XmeGetPixmapData(screen, pixmap, image_name, depth, foreground,
background, hot_x, hot_y, width, height);
}
String
_DtGetIconFileName(
Screen *screen,
String imageInstanceName,
String imageClassName,
String hostPrefix,
unsigned int size)
{
return XmGetIconFileName(screen, imageInstanceName, imageClassName,
hostPrefix, size);
}
void
_DtFlushIconFileCache(String path)
{
XmeFlushIconFileCache(path);
}

View File

@@ -0,0 +1,582 @@
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
/*Add a string to the XA_RESOURCE_MANAGER*/
/*
* COPYRIGHT 1987
* DIGITAL EQUIPMENT CORPORATION
* MAYNARD, MASSACHUSETTS
* ALL RIGHTS RESERVED.
*
* THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
* SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
* DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR
* ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
*
* IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT RIGHTS,
* APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN ADDITION TO THAT
* SET FORTH ABOVE.
*
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Digital Equipment Corporation not be
* used in advertising or publicity pertaining to distribution of the software
* without specific, written prior permission.
*/
/*Lifted from xrdb(1X)*/
/* -*-C-*-
*******************************************************************************
*
* File: addToResource.c
* RCS: $TOG: addToRes.c /main/8 1999/10/14 16:01:17 mgreess $
* Description: Source code for adding strings to RESOURCE_PROPERTY on
default root window
* Author: DEC, Robert Williams
* Created: Thu Apr 26 14:42:08 PDT 1990
* Modified: Kim Dronesen
* Language: C
* Package: N/A
* Status: Experimental (Do Not Distribute)
*
* (C) Copyright 1990, Hewlett-Packard, all rights reserved.
*
*******************************************************************************
*/
/*$TOG: addToRes.c /main/8 1999/10/14 16:01:17 mgreess $ */
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xos.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <Dt/DtP.h>
#include <Dt/SessionM.h>
#include "DtSvcLock.h"
/****************************************/
/* Global variables */
/****************************************/
typedef struct _Entry {
char *tag, *value;
int lineno;
Bool usable;
} Entry;
typedef struct _Buffer {
char *buff;
int room, used;
Bool freebuff;
} Buffer;
typedef struct _Entries {
Entry *entry;
int room, used;
} Entries;
#define INIT_BUFFER_SIZE 10000
#define INIT_ENTRY_SIZE 500
/******** Public Function Declarations ********/
static Buffer * _DtAllocBuffer(const char **buff);
static void _DtFreeBuffer(Buffer *b);
static void _DtAppendToBuffer(
register Buffer *b,
char *str,
register int len) ;
static void _DtAppendEntryToBuffer(
register Buffer *buffer,
Entry entry) ;
static Entries * _DtAllocEntries( void) ;
static void _DtFreeEntries( Entries *) ;
static void _DtAddEntry(
register Entries *e,
Entry entry) ;
static int _DtCompareEntries(
Entry *e1,
Entry *e2) ;
static char * _DtFindFirst(
register char *string,
register char dest) ;
static void _DtGetEntries(
register Entries *entries,
Buffer *buff,
int dosort) ;
static void _DtMergeEntries(
Buffer *buffer,
Entries new,
Entries old) ;
static void _DtAddToResProp(
Display *dpy,
unsigned int id,
Entries db) ;
static void _getWinProp(
Display *dpy,
unsigned int id,
Window *win,
Atom *prop);
/******** End Public Function Declarations ********/
/****************************************/
/*The meat*/
/****************************************/
static Buffer *
_DtAllocBuffer(
const char **buff )
{
Buffer *b = (Buffer *)malloc(sizeof(Buffer));
b->room = INIT_BUFFER_SIZE;
b->buff = buff ? (char*) *buff :
(char *)malloc(INIT_BUFFER_SIZE*sizeof(char));
b->used = buff && *buff ? strlen(*buff) : 0;
b->freebuff = buff ? False : True;
return(b);
}
static void
_DtFreeBuffer(
Buffer *b)
{
if (b->freebuff == True) free(b->buff);
free(b);
}
static void
_DtAppendToBuffer(
register Buffer *b,
char *str,
register int len )
{
while (b->used + len > b->room) {
b->buff = (char *)realloc(b->buff, 2*b->room*(sizeof(char)));
b->room *= 2;
}
strncpy(b->buff + b->used, str, len);
b->used += len;
}
static Entries *
_DtAllocEntries( void )
{
Entries *e = (Entries *)malloc(sizeof(Entries));
e->room = INIT_ENTRY_SIZE;
e->used = 0;
e->entry = (Entry *)malloc(INIT_ENTRY_SIZE*sizeof(Entry));
return(e);
}
static void
_DtFreeEntries(
Entries *e)
{
int n = 0;
while (n < e->used)
{
free(e->entry[n].tag);
free(e->entry[n].value);
n++;
}
free(e->entry);
free(e);
}
static void
_DtAddEntry(
register Entries *e,
Entry entry )
{
register int n;
for (n = 0; n < e->used; n++)
{
if (strcmp(e->entry[n].tag, entry.tag) == 0)
{ /* overwrite old entry - free its memory first*/
free(e->entry[n].tag);
free(e->entry[n].value);
e->entry[n] = entry;
return ; /* ok to leave, now there's only one of each tag in db */
}
}
if (e->used == e->room) {
e->entry = (Entry *)realloc(e->entry, 2*e->room*(sizeof(Entry)));
e->room *= 2;
}
entry.usable = True;
e->entry[e->used++] = entry;
}
static int
_DtCompareEntries(
Entry *e1,
Entry *e2 )
{
return strcmp(e1->tag, e2->tag);
}
static void
_DtAppendEntryToBuffer(
register Buffer *buffer,
Entry entry )
{
_DtAppendToBuffer(buffer, entry.tag, strlen(entry.tag));
_DtAppendToBuffer(buffer, ":\t", 2);
_DtAppendToBuffer(buffer, entry.value, strlen(entry.value));
_DtAppendToBuffer(buffer, "\n", 1);
}
static char *
_DtFindFirst(
register char *string,
register char dest )
{
int len;
for (;;) {
if((len = mblen(string, MB_CUR_MAX)) > 1) {
string += len;
continue;
}
if (*string == '\0')
return NULL;
if (*string == '\\') {
if (*++string == '\0')
return NULL;
}
else if (*string == dest)
return string;
string++;
}
}
static void
_DtGetEntries(
register Entries *entries,
Buffer *buff,
int dosort )
{
register char *line, *colon, *temp, *str, *temp2;
Entry entry;
register int length;
int lineno = 0;
str = buff->buff;
if (!str) return;
for (; str < buff->buff + buff->used; str = line + 1)
{
line = _DtFindFirst(str, '\n');
lineno++;
if (line == NULL)
break;
if (str[0] == '!')
continue;
if (str[0] == '\n')
continue;
if (str[0] == '#')
{
int dummy;
if (sscanf (str, "# %d", &dummy) == 1) lineno = dummy - 1;
continue;
}
for (temp = str;
*temp && *temp != '\n' && isascii(*temp) && isspace((u_char)*temp);
temp++) ;
if (!*temp || *temp == '\n') continue;
colon = _DtFindFirst(str, ':');
if (colon == NULL)
break;
if (colon > line)
{
line[0] = '\0';
fprintf (stderr,
"%s: colon missing on line %d, ignoring entry \"%s\"\n",
"dtprefs", lineno, str);
continue;
}
temp2 = str;
while (temp2[0] == ' ' || temp2[0] == '\t')
{
temp2++;
}
temp = (char *)malloc((length = colon - temp2) + 1);
strncpy(temp, temp2, length);
temp[length] = '\0';
while (temp[length-1] == ' ' || temp[length-1] == '\t')
temp[--length] = '\0';
entry.tag = temp;
temp2 = colon + 1;
while (temp2[0] == ' ' || temp2[0] == '\t')
{
temp2++;
}
temp = (char *)malloc((length = line - temp2) + 1);
strncpy(temp, temp2, length);
temp[length] = '\0';
entry.value = temp;
entry.lineno = lineno;
_DtAddEntry(entries, entry);
}
if (dosort && (entries->used > 0))
qsort(entries->entry, entries->used, sizeof(Entry),
(int (*)(const void *, const void *))_DtCompareEntries);
}
static void
_DtMergeEntries(
Buffer *buffer,
Entries new,
Entries old )
{
int n, o, cmp;
buffer->used = 0;
n = o = 0;
while ((n < new.used) && (o < old.used))
{
cmp = strcmp(new.entry[n].tag, old.entry[o].tag);
if (cmp > 0)
{
_DtAppendEntryToBuffer(buffer, old.entry[o]);
o++;
}
else
{
_DtAppendEntryToBuffer(buffer, new.entry[n]);
n++;
if (cmp == 0)
{
o++;
}
}
}
while (n < new.used)
{
_DtAppendEntryToBuffer(buffer, new.entry[n]);
n++;
}
while (o < old.used)
{
_DtAppendEntryToBuffer(buffer, old.entry[o]);
o++;
}
_DtAppendToBuffer(buffer, "\0", 1);
}
static void
_getWinProp(
Display *dpy,
unsigned int id,
Window *win,
Atom *prop)
{
static Bool init = True;
static Window winprop;
static Atom xa_resmgr;
static Atom xa_prefs;
_DtSvcProcessLock();
if (init == True)
{
winprop = XRootWindow(dpy, 0);
xa_resmgr = XA_RESOURCE_MANAGER;
xa_prefs = XInternAtom (dpy, _XA_DT_SM_PREFERENCES, False);
init = False;
}
_DtSvcProcessUnlock();
*win = winprop;
*prop = id == _DT_ATR_RESMGR ? xa_resmgr : xa_prefs;
}
static void
_DtAddToResProp(
Display *dpy,
unsigned int id,
Entries db)
{
char *xdefs;
Buffer *oldBuffer, *newBuffer;
Entries *oldDB;
int defStatus;
Atom actualType;
int actualFormat;
unsigned long nitems, leftover;
Window win;
Atom prop;
/*
* Get window and property
*/
_getWinProp(dpy, id, &win, &prop);
if (win == (Window)0)
{
return;
}
/*
* Get resource database from specified window and property.
*/
defStatus = XGetWindowProperty(dpy, win,
prop, 0L,
100000000L,False,XA_STRING,&actualType,
&actualFormat,&nitems,&leftover,
(unsigned char**) &xdefs);
/*
* Allocate oldBuffer and init from resource database string
*/
oldBuffer = _DtAllocBuffer((const char**) &xdefs);
/*
* Allocate oldDB
*/
oldDB = _DtAllocEntries();
/*
* Convert oldBuffer to oldDB.
*/
_DtGetEntries(oldDB, oldBuffer, 1);
/*
* Init empty newBuffer, then populate by merging db into oldDB.
*/
newBuffer = _DtAllocBuffer(NULL);
_DtMergeEntries(newBuffer, db, *oldDB);
/*
* Finally, store newBuffer into resource database.
*/
XChangeProperty (dpy, win, prop,
XA_STRING, 8, PropModeReplace,
(unsigned char *)newBuffer->buff, newBuffer->used);
XSync(dpy, False);
/*
* Free buffer memory
*/
if (oldBuffer->buff) XFree(oldBuffer->buff);
_DtFreeBuffer(oldBuffer);
_DtFreeBuffer(newBuffer);
_DtFreeEntries(oldDB);
}
char *
_DtGetResString(
Display *dpy,
unsigned int id)
{
char *xdefs;
Buffer *oldBuffer, *newBuffer;
Entries *oldDB;
int defStatus;
Atom actualType;
int actualFormat;
unsigned long nitems, leftover;
Window win;
Atom prop;
/*
* Get window and property
*/
_getWinProp(dpy, id, &win, &prop);
if (win == (Window)0)
{
return NULL;
}
/*
* Get resource database from specified window and property.
*/
defStatus = XGetWindowProperty(dpy, win,
prop, 0L,
100000000L,False,XA_STRING,&actualType,
&actualFormat,&nitems,&leftover,
(unsigned char**) &xdefs);
return(xdefs);
}
void
_DtAddToResource(
Display *dpy,
const char *data )
{
_DtAddResString( dpy, data, _DT_ATR_RESMGR|_DT_ATR_PREFS);
}
void
_DtAddResString(
Display *dpy,
const char *data,
unsigned int flags)
{
char *xdefs;
int i;
Buffer *buffer;
Entries *newDB;
int defStatus;
Atom actualType;
int actualFormat;
unsigned long nitems, leftover;
if((data == NULL) || (*data == NULL))
{
return;
}
/*
* Init buffer with input data
*/
buffer = _DtAllocBuffer(&data);
/*
* Init, then populate, newDB from buffer
*/
newDB = _DtAllocEntries();
_DtGetEntries(newDB, buffer, 1);
if (flags & _DT_ATR_RESMGR)
{
/*
* Merge newDB into RESOURCE_MANAGER
*/
_DtAddToResProp(dpy, _DT_ATR_RESMGR, *newDB);
}
if (flags & _DT_ATR_PREFS)
{
/*
* Merge newDB into _DT_SM_PREFERENCES
*/
_DtAddToResProp(dpy, _DT_ATR_PREFS, *newDB);
}
/*
* Free objects
*/
_DtFreeBuffer(buffer);
_DtFreeEntries(newDB);
}

View File

@@ -0,0 +1,178 @@
/* $XConsortium: bitmaps.h /main/3 1995/10/26 15:32:50 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifdef REV_INFO
#ifndef lint
static char SCCSID[] = "OSF/Motif: %W% %E%":
#endif /* lint */
#endif /* REV_INFO */
/******************************************************************************
*******************************************************************************
*
* (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
* (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 HEWLETT-PACKARD COMPANY
* ALL RIGHTS RESERVED
*
* THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED
* AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND
* WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR
* ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE
* AVAILABLE TO ANY OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE
* SOFTWARE IS HEREBY TRANSFERRED.
*
* THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT
* NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY OPEN SOFTWARE
* FOUNDATION, INC. OR ITS THIRD PARTY SUPPLIERS
*
* OPEN SOFTWARE FOUNDATION, INC. AND ITS THIRD PARTY SUPPLIERS,
* ASSUME NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE ANY OF ITS
* SOFTWARE . OSF SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
* KIND, AND OSF EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE.
*
* Notice: Notwithstanding any other lease or license that may pertain to,
* or accompany the delivery of, this computer software, the rights of the
* Government regarding its use, reproduction and disclosure are as set
* forth in Section 52.227-19 of the FARS Computer Software-Restricted
* Rights clause.
*
* (c) Copyright 1989, 1990, 1991, 1992 Open Software Foundation, Inc. Unpublished - all
* rights reserved under the Copyright laws of the United States.
*
* RESTRICTED RIGHTS NOTICE: Use, duplication, or disclosure by the
* Government is subject to the restrictions as set forth in subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software clause
* at DFARS 52.227-7013.
*
* Open Software Foundation, Inc.
* 11 Cambridge Center
* Cambridge, MA 02142
* (617)621-8700
*
* RESTRICTED RIGHTS LEGEND: This computer software is submitted with
* "restricted rights." Use, duplication or disclosure is subject to the
* restrictions as set forth in NASA FAR SUP 18-52.227-79 (April 1985)
* "Commercial Computer Software- Restricted Rights (April 1985)." Open
* Software Foundation, Inc., 11 Cambridge Center, Cambridge, MA 02142. If
* the contract contains the Clause at 18-52.227-74 "Rights in Data General"
* then the "Alternate III" clause applies.
*
* (c) Copyright 1989, 1990, 1991, 1992 Open Software Foundation, Inc.
* ALL RIGHTS RESERVED
*
*
* Open Software Foundation is a trademark of The Open Software Foundation, Inc.
* OSF is a trademark of Open Software Foundation, Inc.
* OSF/Motif is a trademark of Open Software Foundation, Inc.
* Motif is a trademark of Open Software Foundation, Inc.
* DEC is a registered trademark of Digital Equipment Corporation
* DIGITAL is a registered trademark of Digital Equipment Corporation
* X Window System is a trademark of the Massachusetts Institute of Technology
*
*******************************************************************************
******************************************************************************/
/*************************************<+>*************************************
*****************************************************************************
**
** File: bitmaps.h
**
** Description: This file contains a set of predefines bitmaps
** which are used by the image caching functions.
**
****************************************************************************
************************************<+>*************************************/
#ifndef _Xmbitmaps_h
#define _Xmbitmaps_h
#ifdef __cplusplus
extern "C" {
#endif
static unsigned char bitmaps [20][32] =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Solid Background */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x88, 0x88, 0x22, 0x22, 0x88, 0x88, 0x22, 0x22, /* 25 percent */
0x88, 0x88, 0x22, 0x22, 0x88, 0x88, 0x22, 0x22,
0x88, 0x88, 0x22, 0x22, 0x88, 0x88, 0x22, 0x22,
0x88, 0x88, 0x22, 0x22, 0x88, 0x88, 0x22, 0x22 },
{ 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, /* 50 percent */
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA },
{ 0x55, 0x55, 0xFF, 0xFF, 0xAA, 0xAA, 0xFF, 0xFF, /* 75 percent */
0x55, 0x55, 0xFF, 0xFF, 0xAA, 0xAA, 0xFF, 0xFF,
0x55, 0x55, 0xFF, 0xFF, 0xAA, 0xAA, 0xFF, 0xFF,
0x55, 0x55, 0xFF, 0xFF, 0xAA, 0xAA, 0xFF, 0xFF },
{ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, /* Vertical */
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 },
{ 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, /* Horizontal */
0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 },
{ 0x77, 0x77, 0xbb, 0xbb, 0xdd, 0xdd, 0xee, 0xee, /* Slant Left */
0x77, 0x77, 0xbb, 0xbb, 0xdd, 0xdd, 0xee, 0xee,
0x77, 0x77, 0xbb, 0xbb, 0xdd, 0xdd, 0xee, 0xee,
0x77, 0x77, 0xbb, 0xbb, 0xdd, 0xdd, 0xee, 0xee },
{ 0xee, 0xee, 0xdd, 0xdd, 0xbb, 0xbb, 0x77, 0x77, /* Slant Right */
0xee, 0xee, 0xdd, 0xdd, 0xbb, 0xbb, 0x77, 0x77,
0xee, 0xee, 0xdd, 0xdd, 0xbb, 0xbb, 0x77, 0x77,
0xee, 0xee, 0xdd, 0xdd, 0xbb, 0xbb, 0x77, 0x77 },
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Default Cascade */
0x00, 0x03, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x18,
0xff, 0x3f, 0x00, 0x18, 0x00, 0x0c, 0x00, 0x06,
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Default CheckMark */
0x00, 0x00, 0x00, 0x60, 0x00, 0x30, 0x00, 0x18,
0x00, 0x0c, 0x08, 0x06, 0x18, 0x03, 0xb0, 0x01,
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Default menu dash */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
};
static char * bitmap_name_set[] =
{
"background",
"25_foreground",
"50_foreground",
"75_foreground",
"vertical",
"horizontal",
"slant_right",
"slant_left",
"menu_cascade",
"menu_checkmark",
"menu_dash"
};
#ifdef __cplusplus
} /* Close scope of 'extern "C"' declaration which encloses file. */
#endif
#endif /* _Xmbitmaps_h */
/* DON'T ADD STUFF AFTER THIS #endif */

View File

@@ -0,0 +1,79 @@
/*
* File: lock.c $XConsortium: lock.c /main/4 1995/10/26 15:33:05 rswiston $
* Language: C
*
* (C) Copyright 1989, Hewlett-Packard, all rights reserved.
*
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include <X11/Xlib.h>
/******** Public Function Declarations ********/
extern int _DtGetLock( Display *display, char *lock_name) ;
extern void _DtReleaseLock( Display *display, char *lock_name) ;
extern int _DtTestLock( Display *display, char *lock_name) ;
/******** End Public Function Declarations ********/
int
_DtGetLock(
Display *display,
char *lock_name )
{
Atom lock_atom;
Window selection_owner;
Window root_window;
/* Do as much processing as possible before grabbing the server. */
lock_atom = XInternAtom (display, lock_name, False);
root_window = DefaultRootWindow (display);
/* Do an atomic test-and-set of the lock. To make this atomic we
must grab the server. */
XGrabServer (display);
if ((selection_owner = XGetSelectionOwner (display, lock_atom)) == None)
XSetSelectionOwner (display, lock_atom, root_window, CurrentTime);
XUngrabServer (display);
XFlush (display);
/* If the lock was clear then it was successfully acquired. */
if (selection_owner == None)
return (1);
else
return (0);
}
void
_DtReleaseLock(
Display *display,
char *lock_name )
{
Atom lock_atom;
lock_atom = XInternAtom (display, lock_name, False);
XSetSelectionOwner (display, lock_atom, None, CurrentTime);
XFlush (display); /* added to release lock NOW */
}
int
_DtTestLock(
Display *display,
char *lock_name )
{
Atom lock_atom;
lock_atom = XInternAtom (display, lock_name, False);
if (XGetSelectionOwner (display, lock_atom) == None)
return (0);
else
return (1);
}