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,48 @@
/* $XConsortium: DtSvcLock.h /main/6 1996/08/28 17:58:14 rswiston $ */
/* *
* (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 Digital Equipment Corporation. *
* (c) Copyright 1996 FUJITSU LIMITED. *
* (c) Copyright 1996 Hitachi. *
*/
#ifndef _DtSvc_Lock_h
#define _DtSvc_Lock_h
/******** Conditionally defined macros for thread_safe DtSvc ******/
#ifdef XTHREADS
#define _DtSvcWidgetToAppContext(w) \
XtAppContext app = XtWidgetToApplicationContext(w)
#define _DtSvcDisplayToAppContext(d) \
XtAppContext app = XtDisplayToApplicationContext(d)
#define _DtSvcAppLock(app) XtAppLock(app)
#define _DtSvcAppUnlock(app) XtAppUnlock(app)
/*
* NOTE: To use _DtSvcApp{Lock,Unlock}Default(), your file
* must either include <Dt/DtP.h> or declare _DtAppContext
* as an external variable, i.e. "extern XtAppContext _DtAppContext;"
*/
#define _DtSvcAppLockDefault() \
if (_DtAppContext != (XtAppContext)NULL) XtAppLock(_DtAppContext)
#define _DtSvcAppUnlockDefault() \
if (_DtAppContext != (XtAppContext)NULL) XtAppUnlock(_DtAppContext)
#define _DtSvcProcessLock() XtProcessLock()
#define _DtSvcProcessUnlock() XtProcessUnlock()
#else /* XTHREADS */
#define _DtSvcWidgetToAppContext(w)
#define _DtSvcDisplayToAppContext(d)
#define _DtSvcAppLock(app)
#define _DtSvcAppUnlock(app)
#define _DtSvcAppLockDefault()
#define _DtSvcAppUnlockDefault()
#define _DtSvcProcessLock()
#define _DtSvcProcessUnlock()
#endif /* XTHREADS */
#endif /* _DtSvc_Lock_h */
/* DON'T ADD ANYTHING AFTER THIS #endif... */

View File

@@ -0,0 +1,8 @@
XCOMM $TOG: Imakefile /main/3 1998/08/10 18:02:40 mgreess $
#define IHaveSubdirs
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' 'CXXDEBUGFLAGS=$(CXXDEBUGFLAGS)'
SUBDIRS = bms SPC
MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))

View File

@@ -0,0 +1,12 @@
XCOMM $XConsortium: Imakefile /main/4 1996/04/21 19:09:55 drk $
HEADERS = chars.h spc-obj.h spc-proto.h spcE.h spcP.h
all::
BuildIncludes($(HEADERS),SPC,..)
InstallMultipleFlags($(HEADERS),$(INCDIR)/SPC,$(INSTINCFLAGS))
depend::
clean::

View File

@@ -0,0 +1,26 @@
/*
* File: char.h $XConsortium: chars.h /main/3 1995/10/26 15:43:03 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 _chars_h
#define _chars_h
#define Space (XeChar) ' '
#define Newline (XeChar) '\n'
#define Tab (XeChar) '\t'
#define Pound (XeChar) '#'
#define Pad (XeChar) '\0'
#define Colon (XeChar) ':'
#define Equal (XeChar) '='
#define Nil_String (XeString) ""
#endif /* _chars_h */

View File

@@ -0,0 +1,96 @@
/*
* File: spc-obj.h $XConsortium: spc-obj.h /main/3 1995/10/26 15:43:20 rswiston $
* Language: C
*
* (c) Copyright 1989, 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 _spc_obj_h
#define _spc_obj_h
typedef SPC_Channel_Ptr (*SPC_F_open)(SPC_Channel_Ptr, int, XeString);
typedef int (*SPC_F_close)(SPC_Channel_Ptr);
typedef int (*SPC_F_read)(SPC_Channel_Ptr, int, XeString, int);
typedef int (*SPC_F_write)(SPC_Channel_Ptr, XeString, int);
typedef int (*SPC_F_reset)(SPC_Channel_Ptr);
typedef int (*SPC_F_exec_proc)(SPC_Channel_Ptr);
typedef int (*SPC_F_signal)(SPC_Channel_Ptr, int);
typedef int (*SPC_F_attach)(SPC_Channel_Ptr, int);
typedef int (*SPC_F_add_input)(SPC_Channel_Ptr, SbInputHandlerProc, void *);
typedef int (*SPC_F_wait_for_termination)(SPC_Channel_Ptr);
typedef int (*SPC_F_pre_fork)(SPC_Channel_Ptr);
typedef int (*SPC_F_post_fork)(SPC_Channel_Ptr, int);
typedef int (*SPC_F_remove_logfile)(SPC_Channel_Ptr);
/*
**
** New methods for B.00
**
*/
typedef int (*SPC_F_send_eof)(SPC_Channel_Ptr);
typedef int (*SPC_F_set_termio)(SPC_Channel_Ptr, int, int, struct termios *);
#define channel_class_part \
root_class_part \
SPC_F_open open; /* opening a channel */ \
SPC_F_close close; /* close a channel */ \
SPC_F_read read; /* read from a channel */ \
SPC_F_write write; /* write to a channel */ \
SPC_F_reset reset; /* reset io to channel */ \
SPC_F_exec_proc exec_proc; /* execute a subprocess over a channel */ \
SPC_F_signal signal; /* signal a subprocess over a channel */ \
SPC_F_attach attach; /* attach a subprocess to this channel */ \
SPC_F_add_input add_input; /* how to add input callbacks to channel */ \
SbInputCallbackProc input; \
SPC_F_wait_for_termination wait_for_termination; /* wait for subprocess to exit */ \
SPC_F_pre_fork pre_fork; /* setup before a fork */ \
SPC_F_post_fork post_fork; /* setup after a fork */ \
SPC_F_remove_logfile remove_logfile; /* remove log file associated with channel */ \
SPC_F_send_eof send_eof; /* close stdin of subprocess */ \
SPC_F_set_termio set_termio; /* set termio struct for PTY channels */
typedef struct channel_class {
root_clasp base;
channel_class_part
} *channel_clasp;
typedef struct pty_channel_class {
channel_clasp base;
channel_class_part
} *pty_channel_clasp;
typedef struct pipe_channel_class {
channel_clasp base;
channel_class_part
} *pipe_channel_clasp;
typedef struct noio_channel_class {
channel_clasp base;
channel_class_part
} *noio_channel_clasp;
typedef struct remote_channel_class {
channel_clasp base;
channel_class_part
} *remote_channel_clasp;
#define call_parent_method(channel, func, args, result) { \
pipe_channel_clasp parent_class=(pipe_channel_clasp) (channel)->class_ptr; \
result=base_memf(parent_class, func, args); }
/* class definitions */
extern channel_clasp channel_class;
extern pty_channel_clasp pty_channel_class;
extern pipe_channel_clasp pipe_channel_class;
extern noio_channel_clasp noio_channel_class;
extern remote_channel_clasp remote_channel_class;
#endif /* _spc_obj_h */

View File

@@ -0,0 +1,275 @@
/*
* File: spc-proto.h $XConsortium: spc-proto.h /main/3 1995/10/26 15:43:39 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 _spc_proto_h
#define _spc_proto_h
/*
* Commands which are known to spcd and clients
*/
/* The internet service */
#define SPC_SERVICE (XeString)"dtspc" /* The name of the registered service */
#define SPC_PROTOCOL (XeString)"tcp" /* The name of the registered protocol */
/* MUST be a DECIMAL number as "%d" */
#define SPC_PROTOCOL_VERSION_CDE_BASE 1000
#define SPC_PROTOCOL_VERSION SPC_PROTOCOL_VERSION_CDE_BASE
/* is used to read the string version */
#define SPC_PROTOCOL_VERSION_CDE_BASE_STR "1000"
#define SPC_PROTOCOL_VERSION_STR SPC_PROTOCOL_VERSION_CDE_BASE_STR
/* We could make this user config for old domain systems? */
#define SPC_UNKNOWN_HOSTINFO_STR "HP-UX:7.0:*"
/*
**
** Pseudo-filenames used for validating user
**
*/
#define PASSED_FILE_NAME (XeString)"<!passed>!"
#define FAILED_FILE_NAME (XeString)"<!failed>!"
/*
*** Protocol command numbers. These MUST remain in the same order
*** to work with previous version of the spcd
*/
/* Connections to the server */
#define APPLICATION_DATA 0 /* send data to subprocess */
#define APPLICATION_STDOUT 1 /* data from subprocess */
#define APPLICATION_STDERR 2 /* error messages from subprocess */
#define ABORT 3 /* Client aborted */
#define REGISTER 4 /* Register client */
#define UNREGISTER 5 /* Unregister client */
/* Channel requests */
#define CHANNEL_OPEN 6 /* enable this channel for read/write */
#define CHANNEL_CLOSE 7 /* no more i/o to this channel (send EOF) */
#define CHANNEL_RESET 8 /* reset this channel */
#define CHANNEL_ATTACH 9 /* attach PTY device to this channel */
/* Application messages, client -> server */
#define APPLICATION_SPAWN 10 /* start up subprocess */
#define APPLICATION_SIGNAL 11 /* send signal to subprocess */
/* application messages, server -> client */
#define APPLICATION_DIED 12 /* sent when subprocess dies */
#define SERVER_ERROR 13 /* server has detected an error */
#define REPLY 14
#define SERVER_DEBUG 15
#define ENVIRON_RESET 16
/* Query / reply protocols, client -> server -> client */
#define QUERY_DEVICES 17
#define DEVICE_REPLY 18
#define QUERY_LOGFILE 19
#define LOGFILE_REPLY 20
/* Application messages, client -> server */
#define DELETE_LOGFILE 21
#define RESET_TERMIO 22 /* This is obsolete, (hpux binary version) */
#define RESET_TERMIOS 23
/* New B.00 protocol requests */
#define CHANNEL_SEND_EOF 24 /* Send EOF to standard input of sub process */
#define CHANNEL_TERMIOS 25 /* Send termios info for a particular pty */
#define APP_B00_SPAWN 26 /* Enhanced spawn */
#define NREQS 27 /* total number of requests. If
any are added, this should constant
should reflect the new total */
#define PROT_TO_CONNECTOR(a) a
#define CONNECTOR_TO_PROT(a) a
#define PDRP(_pdata) _pdata->data+REQUEST_HEADER_LENGTH
#define WRITE_INT(pdata, val)\
sprintf_len(PDRP(pdata), (XeString)"%x", val)
#define READ_INT(pdata, val) sscanf(PDRP(pdata), (XeString)"%x", &val)
#define WRITE_STRING(pdata, name)\
sprintf_len(PDRP(pdata), (XeString)"%s", name)
#define READ_STRING(pdata, name) sscanf(PDRP(pdata), (XeString)"%s", name)
#define READ_STRING_NO_COPY(pdata, name) (name = PDRP(pdata))
#define WRITE_ABORT WRITE_INT
#define READ_ABORT READ_INT
#define WRITE_OPEN WRITE_INT
#define READ_OPEN READ_INT
#define WRITE_ATTACH WRITE_INT
#define READ_ATTACH READ_INT
#define WRITE_APPLICATION_DIED WRITE_INT
#define READ_APPLICATION_DIED READ_INT
#define WRITE_DEBUG WRITE_STRING
#define READ_DEBUG READ_STRING
#define WRITE_ERROR WRITE_INT
#define READ_ERROR READ_INT
#define WRITE_REGISTER(pdata, name, passwd, proto_ver, hostinfo)\
sprint_register_data(PDRP(pdata), name, passwd, proto_ver, hostinfo)
#define READ_REGISTER(pdata, name, passwd, proto_rev, hostinfo)\
sscan_register_data(PDRP(pdata), &name, &passwd, &proto_rev, &hostinfo)
#define WRITE_REPLY(pdata, val, err)\
sprintf_len(PDRP(pdata), (XeString)"%x %x", val, err)
#define READ_REPLY(pdata, val, err)\
sscanf(PDRP(pdata), (XeString)"%x %x", &val, &err)
#define WRITE_DEVICE_REPLY(pdata, m0, s0, m1, s1, m2, s2) \
sprint_device_data(PDRP(pdata), m0, s0, m1, s1, m2, s2)
#define READ_DEVICE_REPLY(pdata, m0, s0, m1, s1, m2, s2) \
sscan_device_data(PDRP(pdata), m0, s0, m1, s1, m2, s2)
#define WRITE_LOGFILE_REPLY(pdata, logfile, proto_ver, hostinfo) \
sprint_logfile_data(PDRP(pdata), logfile, proto_ver, hostinfo)
#define READ_LOGFILE_REPLY(pdata, logfile, proto_ver, hostinfo) \
sscan_logfile_data(PDRP(pdata), logfile, proto_ver, hostinfo)
#define WRITE_APPLICATION_SPAWN(pdata, path, dir, argv, envp) \
sprint_application_data(PDRP(pdata), (XeString)"%s %d %d ", \
path, dir, argv, envp, REQUEST_HEADER_LENGTH)
#define READ_APPLICATION_SPAWN(pdata, path, dir, argv, envp) \
sscan_application_data(PDRP(pdata), (XeString)"%s %d %d ", \
&path, &dir, &argv, &envp, REQUEST_HEADER_LENGTH)
#define WRITE_ENVIRON_RESET(pdata, numenv) \
sprintf_len(PDRP(pdata), (XeString)"%d ", numenv)
#define READ_ENVIRON_RESET(pdata, numenv) \
sscanf(PDRP(pdata), (XeString)"%d ", &numenv)
#define WRITE_APP_DATA(pdata, buffer, len) \
(memcpy(PDRP(pdata), buffer, len), len)
/* New B.00 protocol requests */
#define WRITE_TERMIOS(pdata, connector, side, buffer) \
sprintf_len(PDRP(pdata), (XeString)"%d %d %s", connector, side, buffer)
#define READ_TERMIOS(pdata, connector, side, buffer) \
sscanf(PDRP(pdata), (XeString)"%d %d %s", &connector, &side, buffer)
/* Writing a header is special, as we don't want to be offset by
REQUEST_HEADER_LENGTH */
#define WRITE_HEADER(pdata, cid, type, len, seq) \
sprintf_len(pdata->data, (XeString)"%08x%02x%04x%04x", cid, type, len, seq)
#define READ_HEADER(pdata, cid, type, len, seq) \
sscanf(pdata->data, (XeString)"%8x%2x%4x%4x", cid, type, len, seq)
#define min(a, b) (((a) < (b)) ? (a) : (b))
/*
**
** The test here is reversed, that is, we check only for those
** requests where there is no reply expected, and assume the other
** ones do expect replies.
**
*/
#define NO_REPLY_VAL (-1)
#define REPLY_EXPECTED(a, retval) \
(((a==REPLY) || \
(a==APPLICATION_DATA) || \
(a==APPLICATION_STDOUT) || \
(a==APPLICATION_STDERR) || \
(a==REGISTER) || \
(a==QUERY_LOGFILE) || \
(a==QUERY_DEVICES) || \
(a==ABORT) || \
(a==SERVER_ERROR) \
) ? NO_REPLY_VAL : retval)
typedef struct _prot_request {
buffered_data_ptr dataptr;
int seqno;
int request_type;
SPC_Channel_Ptr channel;
struct _prot_request *next;
} protocol_request, *protocol_request_ptr;
typedef int (*protocol_request_handler)(protocol_request_ptr);
/* spc-proto.c */
buffered_data_ptr SPC_New_Buffered_Data_Ptr (void);
void SPC_Reset_Protocol_Ptr (protocol_request_ptr prot, SPC_Channel_Ptr channel, XeChar req, int len);
protocol_request_ptr SPC_New_Protocol_Ptr (SPC_Channel_Ptr channel, XeChar req, int len);
void SPC_Free_Protocol_Ptr (protocol_request_ptr prot);
SPC_Channel_Ptr SPC_Lookup_Channel (int cid, SPC_Connection_Ptr connection);
SPC_Connection_Ptr SPC_Alloc_Connection (void);
SPC_Connection_Ptr SPC_Lookup_Connection (XeString hostname);
SPC_Connection_Ptr SPC_Lookup_Connection_Fd (int fd);
SPC_Connection_Ptr SPC_Make_Connection (XeString hostname);
void SPC_Add_Connection (SPC_Connection_Ptr connection);
void SPC_Close_Connection (SPC_Connection_Ptr connection);
int SPC_Read_Chars (SPC_Connection_Ptr connection, int request_len, XeString charptr);
int SPC_Write_Chars (int fd, XeString charptr, int request_len);
protocol_request_ptr SPC_Read_Protocol (SPC_Connection_Ptr connection);
protocol_request_ptr SPC_Filter_Connection (SPC_Connection_Ptr connection, SPC_Channel_Ptr channel, int reqtype, int deletep);
void SPC_Flush_Queued_Data (SPC_Channel_Ptr channel);
int SPC_Read_Remote_Data (SPC_Channel_Ptr channel, int connector, XeString client_buffer, int nbytes);
int print_protocol_request (XeString name, protocol_request_ptr proto);
int SPC_Write_Protocol_Request (SPC_Connection_Ptr connection, SPC_Channel_Ptr channel, int request, ...);
int SPC_Write_Single_Prot_Request (SPC_Connection_Ptr connection, XeString name, protocol_request_ptr prot);
int SPC_Waitfor_Reply (SPC_Connection_Ptr connection, SPC_Channel_Ptr channel, int seqno);
int SPC_Dispatch_Protocol (protocol_request_ptr proto, protocol_request_handler *);
int SPC_Write_Reply (SPC_Connection_Ptr conn, protocol_request_ptr proto, int retval, int errval);
int SPC_Send_Environ (SPC_Connection_Ptr connection, protocol_request_ptr prot);
int sprint_counted_string (XeString buf, int count, XeString *vect, int limit);
XeString *sscan_counted_string (XeString buf, XeString *newbuf);
int sprint_application_data (XeString buf, XeString fmt, XeString path, XeString dir, XeString *argv, XeString *envp, int chars_used);
int sscan_application_data (XeString buf, XeString fmt, XeString *path, XeString *dir, XeString **argv, XeString **envp, int offset);
int sprint_device_data (XeString buf, XeString m0, XeString s0, XeString m1, XeString s1, XeString m2, XeString s2);
int sscan_device_data (XeString buf, XeString *m0, XeString *s0, XeString *m1, XeString *s1, XeString *m2, XeString *s2);
int sprint_logfile_data (XeString buf, XeString logfile, XeString proto_ver, XeString hostinfo);
int sscan_logfile_data (XeString buf, XeString *logfile, XeString *proto_ver, XeString *hostinfo);
int sprint_register_data (XeString buf, XeString username, XeString passwd, XeString proto_ver, XeString hostinfo);
int sscan_register_data (XeString buf, XeString *username, XeString *passwd, XeString *proto_ver, XeString *hostinfo);
int SPC_Query_Devices (SPC_Channel_Ptr channel);
int SPC_Query_Logfile (SPC_Channel_Ptr channel);
int SPC_Validate_User (XeString hostname, SPC_Connection_Ptr connection);
int SPC_Get_Termio (protocol_request_ptr prot_request);
int SPC_Get_Termios (protocol_request_ptr prot_request);
XeString SPC_LocalHostinfo(void);
int SPC_Send_Multi_Packet(SPC_Connection_Ptr connection,
protocol_request_ptr prot,
char **str_vect,
int num_str,
int req,
XeString name,
int errid);
char **SPC_Get_Multi_Packet(SPC_Connection_Ptr connection,
protocol_request_ptr prot,
char **out,
int *outlen,
int request,
XeString name);
#endif /* _spc_proto_h */

View File

@@ -0,0 +1,99 @@
/*
* File: spcE.h $XConsortium: spcE.h /main/3 1995/10/26 15:43: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 _spcE_h
#define _spcE_h
/* Keep this up to date with the first error number declared below */
#define SPC_First_Error_Number 100
#define SPC_Min_Error SPC_First_Error_Number
#define SPC_Out_Of_Memory 100
#define SPC_Bad_Argument 101
#define SPC_Active_Channel 102
#define SPC_Inactive_Channel 103
#define SPC_Internal_Error 104
#define SPC_Cannot_Fork 105
#define SPC_Cannot_Exec 106
#define SPC_Cannot_Execute 107
#define SPC_No_Pipe 108
#define SPC_No_Pty 109
#define SPC_Bad_Connector 110
#define SPC_Reading 111
#define SPC_Writing 112
#define SPC_Bad_Service 113
#define SPC_Bad_Port 114
#define SPC_Unknown_Host 115
#define SPC_Bad_Socket 116
#define SPC_Bad_Connect 117
#define SPC_Bad_Bind 118
#define SPC_Bad_Listen 119
#define SPC_Bad_Accept 120
#define SPC_Bad_Linger 121
#define SPC_Bad_Reuse 122
#define SPC_Bad_Sockname 123
#define SPC_Bad_Open 124
#define SPC_Connection_EOF 125
#define SPC_Timeout 126
#define SPC_Protocol 127
#define SPC_Unexpected_Reply 128
#define SPC_No_Channel 129
#define SPC_Illegal_Iomode 130
#define SPC_No_Signal_Handler 131
#define SPC_Bad_Operation 132
#define SPC_Bad_Fd 133
#define SPC_Bad_Ioctl 134
#define SPC_Bad_Select 135
#define SPC_Bind_Timeout 136
#define SPC_Arg_Too_Long 137
#define SPC_Write_Prot 138
#define SPC_Bad_Username 139
#define SPC_Bad_Password 140
#define SPC_Client_Not_Valid 141
#define SPC_Cannot_Open_Slave 142
/* #define SPC_Register_Error 143 */ /* This has been obsoleted by the
expanded register errors below */
#define SPC_Protocol_Abort 144
#define SPC_Env_Too_Big 145
#define SPC_Unlink_Logfile 146
#define SPC_Closed_Channel 147
#define SPC_Bad_Authentication 148
#define SPC_Cannot_Open_Log 149
#define SPC_Connection_Reset 150
#define SPC_Register_Username 151
#define SPC_Register_Netrc 152
#define SPC_Register_Open 153
#define SPC_Register_Handshake 154
#define SPC_Bad_Termios_Mode 155
#define SPC_Bad_Termios_Speed 156
#define SPC_Bad_Termios_CC 157
#define SPC_Bad_Termios_Proto 158
#define SPC_Bad_Signal_Name 159
#define SPC_Bad_Signal_Value 160
#define SPC_Bad_Signal_Format 161
#define SPC_Bad_tc_Call 162
#define SPC_cannot_Chdir 163
#define SPC_Bad_Permission 164
#define SPC_Cannot_Create_Netfilename 165
#define SPC_Protocol_Version_Error 166
/* Keep this up to date with the last error number declared above */
#define SPC_Max_Error 167
/* The definition of the SPC Error structure has been moved to spc.h
(to make it public) */
#endif /* _spcE_h */

View File

@@ -0,0 +1,542 @@
/*
* $XConsortium: spcP.h /main/4 1996/05/15 12:01:55 drk $
* Language: C
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1988,1993,1994,1996 Hewlett-Packard Company.
* (c) Copyright 1993,1994,1996 International Business Machines Corp.
* (c) Copyright 1993,1994,1996 Sun Microsystems, Inc.
* (c) Copyright 1993,1994,1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
#ifndef _spcP_h
#define _spcP_h
#include <netdb.h> /* hostent */
#include <termios.h>
#include <bms/bms.h>
#include <bms/Symbolic.h>
#include <bms/XeUserMsg.h>
#include <bms/SbEvent.h>
#include <bms/spc.h>
#include <bms/scoop.h>
#include <bms/connect.h>
#include <bms/MemoryMgr.h>
#include "chars.h"
#include "spcE.h"
#include "spc-obj.h"
/* ---------------------------------------------------------------------- */
#ifndef CDE_CONFIGURATION_TOP
#define CDE_CONFIGURATION_TOP "/etc/opt/dt"
#endif
#ifndef CDE_INSTALLATION_TOP
#define CDE_INSTALLATION_TOP "/usr/dt"
#endif
#define Stdin(chn) chn->file_descs[STDIN]
#define Stdout(chn) chn->file_descs[STDOUT]
#define Stderr(chn) chn->file_descs[STDERR]
/* Some necessary identifiers */
#define OK 0
#define ERROR -1
#define Undefined -1
/* Some character constants */
#define Channel_ByteID (XeChar)'\077'
/* And finally, the common channel identifier */
#ifndef BITSPERBYTE
#define BITSPERBYTE 8
#endif
#define CID_High_Bits (Channel_ByteID << (BITSPERBYTE * (sizeof(int) - 1)))
#define CID_Middle_Bits (0x1010 << BITSPERBYTE)
#define CID_Low_Bits (Channel_ByteID & 0xff)
#define Channel_Identifier (CID_High_Bits | CID_Middle_Bits | CID_Low_Bits)
/*** Note: If device names ever increase from: /dev/ptym/ptyp0, look here ***/
#define PTY_NAMLEN 20
#define EXCEPT_FLAG -1 /* Used for TIOC handling in PTY's */
/* Define lengths of buffers for protocol requests and other sizes of things */
#define REQUEST_HEADER_LENGTH 20
#define MAXREQLEN (SPC_BUFSIZ+REQUEST_HEADER_LENGTH)
#define DEFAULT_ENVP_SIZE 50
/*
**
** Definitions for select.
**
*/
extern int max_fds;
/*
* Macros to access SPC_IOMode bit fields
*/
/* These are derived from above spc bit specifications */
#define IS_SPCIO_STDIN(a) (a & SPCIO_WRITEONLY)
#define IS_SPCIO_STDOUT(a) (a & SPCIO_READONLY)
#define IS_SPCIO_STDERR(a) (a & SPCIO_ERRORONLY)
#define IS_SPCIO_SEPARATE(a) (a & SPCIO_SEPARATEREADERROR)
#define IS_SPCIO_NOIO(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_NOIO)
#define IS_SPCIO_WRITEONLY(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_WRITEONLY)
#define IS_SPCIO_READONLY(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_READONLY)
#define IS_SPCIO_READWRITE(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_READWRITE)
#define IS_SPCIO_ERRORONLY(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_ERRORONLY)
#define IS_SPCIO_WRITEERROR(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_WRITEERROR)
#define IS_SPCIO_READERROR(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_READERROR)
#define IS_SPCIO_READWRITEERROR(a)((a&SPCIO_SOURCE_MASK) == SPCIO_READWRITEERROR)
/* Style flags (mutually exclusive) */
#define IS_SPCIO_PIPE(a) ((a & SPCIO_STYLE_MASK) == SPCIO_PIPE)
#define IS_SPCIO_PTY(a) ((a & SPCIO_STYLE_MASK) == SPCIO_PTY)
#define IS_SPCIO_NOIOMODE(a) ((a & SPCIO_STYLE_MASK) == SPCIO_NOIOMODE)
#define IS_SPCIO_LINEEDIT(a) (a & SPCIO_LINEEDIT)
/* Other non-mutually exclusive flags */
#define IS_SPCIO_SYSTEM(a) (a & SPCIO_SYSTEM)
#define IS_SPCIO_LINEORIENTED(a)(a & SPCIO_LINEORIENTED)
#define IS_SPCIO_WAIT(a) (a & SPCIO_WAIT)
#define IS_SPCIO_TOOLKIT(a) (a & SPCIO_USE_XTOOLKIT)
#define IS_SPCIO_SYNC_TERM(a) (a & SPCIO_SYNC_TERMINATOR)
#define IS_SPCIO_USE_LOGFILE(a) (a & SPCIO_USE_LOGFILE)
#define IS_SPCIO_SIGNAL_PGRP(a) (a & SPCIO_SIGNAL_PGRP)
#define IS_SPCIO_FORCE_CONTEXT(a) (a & SPCIO_FORCE_CONTEXT)
#define SPCIO_HAS_DATA 0x2000 /* Used for line-oriented IO */
#define HAS_DATA(chn) (((chn->IOMode) & SPCIO_HAS_DATA) == SPCIO_HAS_DATA)
#define SPCIO_UNUSED3 0x80000
/* Flags for internal use only */
#define SPCIO_DEALLOC_ARGV 0x4000
#define IS_SPCIO_DEALLOC_ARGV(a) (a & SPCIO_DEALLOC_ARGV)
#define SPCIO_DELAY_CLOSE 0x8000
#define IS_SPCIO_DELAY_CLOSE(a) (a & SPCIO_DELAY_CLOSE)
#define SPCIO_DO_CLOSE 0x10000
#define IS_SPCIO_DO_CLOSE(a) (a & SPCIO_DO_CLOSE)
/* Make sure that STATE_OFFSET is always such that you will clear the
IOMode flags */
#define STATE_OFFSET 24
#define SPCIO_ACTIVE (1<<STATE_OFFSET) /* channel has subprocess */
#define SPCIO_DATA (2<<STATE_OFFSET) /* channel has data */
#define IS_SPCIO_ACTIVE(a) (a & SPCIO_ACTIVE)
#define IS_SPCIO_DATA(a) (a & SPCIO_DATA)
#define IS_ACTIVE(chn) (IS_SPCIO_ACTIVE(chn->IOMode))
#define IS_DATA(chn) (IS_SPCIO_DATA(chn->IOMode))
#define IS_REMOTE(chn) (chn->connection)
/* SPC state machine */
#define CHANNEL_STATE(io_mode) ((io_mode)>>STATE_OFFSET & 0x3)
#define MAKE_CHANNEL_STATE(io_mode, _state) \
(((_state)<<STATE_OFFSET) | (io_mode & ~(0x3<<STATE_OFFSET)))
#define MAKE_STATE(_data,_proc) ((_data)<<1 | (_proc))
#define MAKE_STATE_INDEX(_old,_new) ((_old)<<2 | (_new))
#define DATA_LINE(_state) ((_state) >> 1)
#define PROC_LINE(_state) ((_state) & 1)
/* Defaults */
#define DEFAULT_CHANNEL_CLASS pty_channel_class
#define IS_SPCIO_DEFAULT(a) !((a) & SPCIO_STYLE_MASK)
#define SPCIO_DEFAULT SPCIO_PTY
/*
* Type definitions for SPC file descriptors
*/
/* Definitions for wires */
#define READ_SIDE 0
#define WRITE_SIDE 1
/*
* Constants and external declarations for managing the SPC daemon's
* logfile list, exit timer and process id list.
*/
#define SPCD_DEFAULT_TIMEOUT 10
#define SPCD_DEAD_PROCESS -1
#define SPCD_NO_TIMER -1
#define SPCD_REQUEST_PENDING 1
#define SPCD_NO_REQUEST_PENDING 0
/*
* Constants for the 'SPC_who_am_i' variable.
*/
#define SPC_I_AM_A_CLIENT 1
#define SPC_I_AM_A_DAEMON 2
/*
* External variables defined in noio.c
*/
extern char **SPC_logfile_list;
/*
* External variables defined in spc-exec.c
*/
extern pid_t *SPC_pid_list;
extern char *SPC_mount_point_env_var;
/*
* External variables defined in spc-obj.c
*/
extern int SPC_who_am_i;
/*
* The client version number.
*/
extern int SPC_client_version_number;
/*
* The name of the directory used for authentication and
* for temporary logfiles.
*/
extern XeString SPCD_Authentication_Dir;
/*
* Definitions for file locations
*/
#define SPCD_ENV_INSTALL_DIRECTORY CDE_INSTALLATION_TOP "/config"
#define SPCD_ENV_CONFIG_DIRECTORY CDE_CONFIGURATION_TOP "/config"
#define SPCD_ENV_HOME_DIRECTORY ".dt"
#define SPCD_ENV_FILE "dtspcdenv"
#define SPCD_PROG_NAME "dtspcd"
/*
* The name of the remove environment 'keyword'.
*/
#define SPC_REMOVE_VAR "unset"
/*
***
*** Start typedefs
***
*/
typedef int Files[3]; /* Standard set of file descriptors */
typedef int SPC_IOMode; /* Sub-Process Control IO Mode Bits */
/* This is a "wire", a data structure used in creating communication paths
to / from a subprocess. It encapsulates all the information needed by
all types of paths */
typedef struct _wire {
SPC_IOMode flags; /* Basically, acts like an IOMode, but
we are only interested in its data bits */
int fd[2];
XeString master_name, slave_name;
int read_toolkit_id, except_toolkit_id;
struct termios master_termio, slave_termio;
struct _wire *next;
} Wire;
typedef struct _buffered_data {
XeChar data[MAXREQLEN];
int len, offset;
} buffered_data, *buffered_data_ptr;
typedef enum {
SPC_Input,
SPC_Exception,
SPC_Terminator,
SPC_Client
} SPC_Callback_Condition;
/*
* Type definition for an SPC Connection (a socket to SPCD server)
*/
typedef struct _SPC_Connection {
/* The host on which other end resides */
XeChar hostname[MAXHOSTNAMELEN];
int sid; /* The Socket ID */
XeChar connected; /* Whether server connection is made */
struct hostent *local; /* socket address information for */
struct hostent *remote; /* ... local, remote machine */
int termination_id;
struct _SPC_Connection
*next; /* The next server in the list */
XeQueue queued_remote_data; /* queue for remote data */
int protocol_version; /* Version of protocol of remote */
XeString hostinfo; /* Info about remote, (type, os, etc) */
} SPC_Connection, *SPC_Connection_Ptr;
/*
* This next macro returns a newly allocated string.
* The caller should free it.
*/
#define CONNECTION_HOSTNAME(conn) \
((conn->remote) ? XeFindShortHost((conn)->remote->h_name) : \
Xestrdup(XeString_Empty))
/*
* Type definition for an SPC Channel
*/
typedef int (*SPC_F_read_filter)(SPC_Channel_Ptr, int, XeString, int);
typedef struct _SPC_Channel { /* Sub-Process Control Channel */
/* stuff for SCOOP */
channel_clasp class_ptr;
root_object_part
/* First, we place a channel identifier, so we can check cid (see below) */
int identifier; /* The common identifier for every channel */
/* The setup request information */
SPC_Connection *connection; /* The connection structure (Local = NULL) */
XeString context_dir; /* Directory to "cd" to during spawn */
XeString path; /* The command path pointer */
XeString *argv; /* The command argument list pointers */
XeString *envp; /* The command environment list pointers */
SPC_IOMode IOMode; /* The IO Control Mode settings */
/* User defined data handling procedures */
SbInputHandlerProc Input_Handler;
/* The user input handler routine */
void * client_data; /* The user associated input handler data */
/* Useful (ie.) as input Widget */
SPC_TerminateHandlerType Terminate_Handler; /* The SIGCLD user handler routine */
void * Terminate_Data; /* The client_data for user handler routine */
/* Now the recorded information */
int pid; /* The child Process IDentification number */
/* Also the RPID for a Remote channel */
int cid; /* The remote Channel IDentification number */
int status; /* The Process status */
Wire *wires[3]; /* The read side/write side file descriptors */
Files file_descs; /* Which file descriptors to use */
Wire *wire_list; /* Pointer to list of wires we have
(used for reset & pre_fork processing) */
buffered_data_ptr linebufs[3]; /* Buffers for lined oriented IO */
SPC_F_read_filter read_filter;
/* Function to use to read. It may
be the actual read method, or it
may be a filter for newlines
(which would eventually call the read
method) */
XeQueue queued_remote_data; /* queue for remote data */
XeString logfile; /* logfile name for SPCIO_USE_LOGFILE */
int close_timeout; /* Amount of time to wait for a pty close */
struct _SPC_Channel *next; /* The next active channel */
int sync_pipe[2]; /* Only used in pty.c for __hpux_pty */
} SPC_Channel;
/* The default shell when none can be derived */
#ifdef hpV4
#define DEFAULT_SHELL (XeString ) "/usr/bin/sh"
#else
#define DEFAULT_SHELL (XeString ) "/bin/sh"
#endif /* hpV4 */
/* Some macros which define the bit field portions of a wait() status */
/* NOTE: These should be independent of integer word size */
#define WAIT_STATUS_MASK 0xff
#define IS_WAIT_STATUS_STOPPED 0177
#define IS_WAIT_STATUS_EXITED 0000
#define IS_WAIT_STATUS_DUMPED 0200
typedef unsigned long SPCInputId;
/* SPC/local.c */
int close_local_channel_object (SPC_Channel_Ptr channel);
int write_local_channel_object (SPC_Channel_Ptr channel, XeString buffer, int nbytes);
int signal_local_channel_object (SPC_Channel_Ptr channel, int sig);
int local_channel_object_wait_for_termination (SPC_Channel_Ptr channel);
int remove_logfile_local_channel_object (SPC_Channel_Ptr channel);
void local_channel_object_input_handler (void * client_data, int *source, SPCInputId *id);
int local_channel_object_send_eof(SPC_Channel_Ptr channel);
/* noio.c */
void noio_channel_class_init (object_clasp c);
SPC_Channel_Ptr open_noio_channel_object (SPC_Channel_Ptr channel, int iomode, XeString hostname);
int read_noio_channel_object (SPC_Channel_Ptr channel, int connector, XeString buffer, int nbytes);
int write_noio_channel_object (SPC_Channel_Ptr channel, XeString buffer, int nbytes);
int pre_fork_noio_channel_object (SPC_Channel_Ptr channel);
int post_fork_noio_channel_object (SPC_Channel_Ptr channel, int parentp);
int reset_noio_channel_object (SPC_Channel_Ptr channel);
int attach_noio_channel_object (SPC_Channel_Ptr channel, int);
void noio_channel_object_input_handler (void * client_data, int *source, SPCInputId *id);
int send_eof_noio_channel_object(SPC_Channel_Ptr channel);
int set_termio_noio_channel_object(SPC_Channel_Ptr, int, int, struct termios *);
/* pipe.c */
void pipe_channel_class_init (object_clasp c);
Wire *getpipe (Wire *prevwire);
SPC_Channel_Ptr open_pipe_channel_object (SPC_Channel_Ptr channel, int iomode, XeString hostname);
int read_pipe_channel_object (SPC_Channel_Ptr channel, int connector, XeString buffer, int nbytes);
int pre_fork_pipe_channel_object (SPC_Channel_Ptr channel);
int post_fork_pipe_channel_object (SPC_Channel_Ptr channel, int parentp);
int reset_pipe_channel_object (SPC_Channel_Ptr channel);
int attach_pipe_channel_object (SPC_Channel_Ptr channel, int);
int add_input_pipe_channel_object (SPC_Channel_Ptr channel, SbInputHandlerProc handler, void *data);
/* pty.c */
void pty_channel_class_init (object_clasp c);
SPC_Channel_Ptr open_pty_channel_object (SPC_Channel_Ptr channel, int iomode, XeString hostname);
int read_pty_channel_object (SPC_Channel_Ptr channel, int connector, XeString buffer, int nbytes);
int pre_fork_pty_channel_object (SPC_Channel_Ptr channel);
int post_fork_pty_channel_object (SPC_Channel_Ptr channel, int parentp);
int reset_pty_channel_object (SPC_Channel_Ptr channel);
int attach_pty_channel_object (SPC_Channel_Ptr channel, int pid);
int add_input_pty_channel_object (SPC_Channel_Ptr channel, SbInputHandlerProc handler, void *data);
int set_termio_pty_channel_object(SPC_Channel_Ptr channel, int, int,
struct termios *);
struct termios *SPC_Get_Current_Termio(void);
int SPC_Setpgrp(int);
/* remote.c */
void remote_channel_class_init (object_clasp c);
Wire *get_new_remote_wire (Wire *prevwire);
SPC_Channel_Ptr open_remote_channel_object (SPC_Channel_Ptr channel, int iomode, XeString hostname);
int close_remote_channel_object (SPC_Channel_Ptr channel);
int reset_remote_channel_object (SPC_Channel_Ptr channel);
int exec_proc_remote_channel_object (SPC_Channel_Ptr channel);
int write_remote_channel_object (SPC_Channel_Ptr channel, XeString buffer, int len);
int read_remote_channel_object (SPC_Channel_Ptr channel, int connection, XeString buffer, int len);
int signal_remote_channel_object (SPC_Channel_Ptr channel, int sig);
int attach_remote_channel_object (SPC_Channel_Ptr channel, int pid);
int remove_logfile_remote_channel_object (SPC_Channel_Ptr channel);
int add_input_remote_channel_object (SPC_Channel_Ptr channel, SbInputHandlerProc handler, void *data);
int SPC_Debug_Mode (SPC_Channel_Ptr channel, XeString file);
int send_eof_remote_channel_object(SPC_Channel_Ptr channel);
int set_termio_remote_channel_object(SPC_Channel_Ptr channel,
int, int, struct termios *);
/* spc-env.c */
XeString SPC_Getenv (XeString var, XeString *envp);
XeString *SPC_Putenv (XeString val, XeString *envp);
XeString *SPC_Add_Env_File (XeString filename, XeString *envp);
XeString *SPC_Create_Default_Envp (XeString *old_envp);
XeString *SPC_Fixup_Environment (XeString *envp, SPC_Channel_Ptr channel);
XeString *SPC_Merge_Envp (XeString *dest_envp, XeString *source_envp);
void SPC_Free_Envp (XeString *envp);
/* spc-exec.c */
int SPC_Setup_Synchronous_Terminator (void);
SPC_Connection_Ptr SPC_Channel_Terminator_Connection (SPC_Channel_Ptr channel);
void SPC_Close_Unused (void);
int SPC_MakeSystemCommand (SPC_Channel_Ptr channel);
void SPC_Child_Terminated(int);
int exec_proc_local_channel_object (SPC_Channel_Ptr channel);
/* spc-net.c */
Boolean SPC_Init_Local_Host_Info (void);
int SPC_Local_Hostname (XeString hostname);
SPC_Connection_Ptr SPC_Open_Connection (XeString hostname);
int SPC_Open_Socket (SPC_Connection_Ptr conn, int type);
int SPC_Contact_Server (SPC_Connection_Ptr connection);
SPC_Connection_Ptr SPC_Init_Child (SPC_Connection_Ptr conn, int from);
SPC_Connection_Ptr SPC_Standalone_Daemon (SPC_Connection_Ptr conn);
int SPC_Inetd_Daemon (SPC_Connection_Ptr conn);
SPC_Connection_Ptr SPC_Start_Daemon (int standalone);
/* spc-obj.c */
void spc_init_fds(void);
object *alloc_channel_object (object_clasp c);
void channel_class_init (object_clasp c);
int SPC_ResetTerminator(void);
int SPC_Initialize (void);
SPC_Channel_Ptr SPC_Initialize_Channel (XeString hostname, int iomode);
void SPC_Channel_Terminated (SPC_Channel_Ptr channel);
int SPC_Check_Style (int iomode);
int SPC_Transform_Iomode (int iomode);
int SPC_Newline_Filter (SPC_Channel_Ptr channel, int connector, XeString buffer, int ntoread);
int SPC_Input_Handler (SPC_Channel_Ptr channel, int connector);
SPC_Channel_Ptr open_channel_object (SPC_Channel_Ptr channel, int iomode, XeString hostname);
int close_channel_object (SPC_Channel_Ptr channel);
int read_channel_object (SPC_Channel_Ptr channel, int connector, XeString buffer, int nbytes);
int write_channel_object (SPC_Channel_Ptr channel, XeString buffer, int nbytes);
int reset_channel_object (SPC_Channel_Ptr channel);
int pre_fork_channel_object (SPC_Channel_Ptr channel);
int post_fork_channel_object (SPC_Channel_Ptr channel, int parentp);
int exec_proc_channel_object (SPC_Channel_Ptr channel);
int signal_channel_object (SPC_Channel_Ptr channel, int sig);
int channel_object_wait_for_termination (SPC_Channel_Ptr channel);
int attach_channel_object (SPC_Channel_Ptr channel, int pid);
int add_input_channel_object (SPC_Channel_Ptr channel, SbInputHandlerProc handler, void *data);
int remove_logfile_channel_object (SPC_Channel_Ptr channel);
/* spc-sm.c */
int SPC_Change_State (SPC_Channel_Ptr channel, int connector, int data_line, int process_line);
int error_fun (SPC_Channel_Ptr channel, int connector);
int connector_eof (SPC_Channel_Ptr channel, int connector);
int connector_eof_with_reset (SPC_Channel_Ptr channel, int connector);
int sigcld_with_reset (SPC_Channel_Ptr channel, int connector);
/* spc-xt.c */
typedef void (*spc_handler_func_type) (void *, int *, SPCInputId *);
int SPC_Wait_For_Termination (SPC_Channel_Ptr channel);
void SPC_XtBreak (void);
void SPC_XtAddInput (SPC_Channel_Ptr channel, int *id_addr, int fd, spc_handler_func_type handler, SPC_Callback_Condition condition);
void SPC_XtRemoveInput (int *id_addr, SPC_Callback_Condition condition);
/* spc-util.c */
Wire *get_new_wire (void);
void free_wire (Wire *wire);
SPC_Channel_Ptr SPC_Find_PID (int pid);
int spc_close (int fd);
int spc_dup2 (int from, int to);
int SPC_fd_to_connector (SPC_Channel_Ptr channel, int fd);
XeString *Alloc_Argv (int n);
void SPC_Conditional_Packet_Handler (void * client_data, int *source, SPCInputId *id);
int sprintf_len (XeString s, XeString format, ...);
typedef Boolean (path_search_predicate)(XeString, XeString, XeString);
Boolean path_search (XeString path, XeString filename, path_search_predicate p);
/* spc-error.c */
XeString SPC_copy_string (XeString str);
void SPC_Error (int error, ...);
int SPC_Make_Log_Filename (XeString name, int unique);
int SPC_Open_Log (XeString filename, int unique);
int SPC_Close_Log (void);
int SPC_Write_Log (XeString str);
int SPC_Format_Log (XeString format, ...);
SPCError *SPC_Lookup_Error (int errornum);
SPCError *SPC_Lookup_Error (int errornum);
/* spc-termio.c */
XeString SPC_Decode_Termios( struct termios * );
void SPC_Encode_Termios(XeString buff, struct termios *tio);
#endif /* _spcP_h */

View File

@@ -0,0 +1,17 @@
XCOMM $XConsortium: Imakefile /main/4 1996/04/21 19:09:58 drk $
HEADERS = \
MemoryMgr.h SbEvent.h Symbolic.h \
XeUserMsg.h bms.h connect.h \
pathwexp.h sbport.h sbstdinc.h \
scoop.h spc.h stringbuf.h \
usersig.h
all::
BuildIncludes($(HEADERS),bms,..)
InstallMultipleFlags($(HEADERS),$(INCDIR)/bms,$(INSTINCFLAGS))
depend::
clean::

View File

@@ -0,0 +1,49 @@
/*
* File: MemoryMgr.h $XConsortium: MemoryMgr.h /main/3 1995/10/26 15:45: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. *
*/
/* Allocation routines */
#ifndef _MemoryMgr_h
#define _MemoryMgr_h
void *XeMalloc
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(size_t size);
#else
();
#endif
void XeFree
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(void * ptr);
#else
();
#endif
#define Xe_make_struct(type) ((struct type *)XeMalloc(sizeof(struct type)))
#define Xe_make_ntype(n, type) ((type *) XeMalloc((n)*sizeof(type)))
#define Xe_make_buffer(size) ((XeString) XeMalloc(size))
#define Xe_make_str(size) ((XeString) XeMalloc((size)+1))
#define XeCopyStringM(string_xxx) (string_xxx \
? (XeString) strcpy(Xe_make_str(strlen(string_xxx)), string_xxx) \
: (XeString) NULL)
/* Dellocation */
#define Xe_release_ntype(ptr, n, type) XeFree(ptr)
#define Xe_release_str(ptr) XeFree(ptr)
#endif /* _MemoryMgr_h */
/* PLACE NOTHING AFTER THIS endif */

View File

@@ -0,0 +1,75 @@
/*
* File: SbEvent.h $XConsortium: SbEvent.h /main/3 1995/10/26 15:45:29 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 _SbEvent_h
#define _SbEvent_h
typedef unsigned long SbInputId;
typedef void (*SbInputCallbackProc)
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(void* data, int *fd, SbInputId *id);
#else
();
#endif
extern SbInputId (*SbAddInput_hookfn)
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(int fd, SbInputCallbackProc proc, void* data);
#else
();
#endif
extern SbInputId (*SbAddException_hookfn)
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(int fd, SbInputCallbackProc proc, void* data);
#else
();
#endif
extern void (*SbRemoveInput_hookfn)
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(SbInputId id);
#else
();
#endif
extern void (*SbRemoveException_hookfn)
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(SbInputId id);
#else
();
#endif
extern void (*SbMainLoopUntil_hookfn)
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(Boolean *flag);
#else
();
#endif
extern void XeCall_SbMainLoopUntil
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(Boolean *flag);
#else
();
#endif
extern void (*SbBreakMainLoop_hookfn)
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(void);
#else
();
#endif
#endif /* _SbEvent_h */

View File

@@ -0,0 +1,350 @@
/*
* File: Symbolic.h $XConsortium: Symbolic.h /main/3 1995/10/26 15:45: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. *
*/
/* SYMBOLS */
#ifndef _Symbolic_h_
#define _Symbolic_h_
/* -------------------------------------------- */
/* Requires: */
#ifdef __recursive_includes
#include <bms/bms.h>
#endif
/* -------------------------------------------- */
/****************************************************************************/
/* Symbol (hash) Tables */
/*
There are two types of symbol (hash) tables. The common case is where the
key (index) is ascii string. The Xe_intern() and XeRegisterSymbol()
routines assume this type of table. In these cases an "XeSymbol" entry is
created in the symbol table (see type below). After it is created a COPY of
the string is made and stored in the "name" field. The "value" field is
free for the user to fill in on his own.
*/
typedef struct _XeSymbol {
XeString name;
void *value;
} *XeSymbol;
/*
This type is used for the XeRegisterFunction() routine.
*/
typedef void (*XeAnyFunction) ();
/*
The second type of table is where the user defines his own type of
data, hash functions, compare functions, etc.
*/
/* The following types for the the user configurable functions that */
/* are set with the Xe_set_syms_fns() routine. */
/* ---------------------------------------------------------------- */
/* CMP_FN: */
/* */
/* Any user defined function should return "0" for a "match" */
/* */
/* Used for Xe_intern() and XeRegisterSymbol() */
/* */
/* If NO "cmp_fn", strcmp("next_table_entry"->name, "name") */
/* If "cmp_fn", cmp_fn("next_table_entry"->name, "name") */
/* */
/* Used for Xe_intern_anysym() */
/* */
/* If NO "cmp_fn", strcmp("next_table_entry"->name, "data"->name) */
/* If "cmp_fn", cmp_fn("next_table_entry", "data") */
/* -------------------------------------------------------------------- */
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
typedef int (*XeSymFn_cmp) (void *, void *); /* 0 mean match */
#else
typedef int (*XeSymFn_cmp) ();
#endif
/* HASH_FN: */
/* */
/* Note, the internal hash function in not user accesable. */
/* */
/* Used for Xe_intern() and XeRegisterSymbol() */
/* */
/* If NO "hash_fn", internal_hash("next_table_entry"->name, "name") */
/* If "hash_fn", hash_fn("next_table_entry"->name, "name") */
/* */
/* Used for Xe_intern_anysym() */
/* */
/* If NO "hash_fn", internal_hash("next_table_entry"->name, "data"->name)*/
/* If "hash_fn", hash_fn("next_table_entry" , "data") */
/* ----------------------------------------------------------------------- */
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
typedef unsigned int (*XeSymFn_hash) (void *, unsigned int);
#else
typedef unsigned int (*XeSymFn_hash) ();
#endif
/* INIT_FN: */
/* */
/* Used for Xe_intern() and XeRegisterSymbol() */
/* */
/* 1) A XeSymbol entry is created, */
/* - XeSymbol->name = strdup("name"), */
/* - XeSymbol->value = NULL */
/* 2) If a "init_fn" is configured, */
/* - XeSymbol->value = init_fn( XeSymbol, 0 ) */
/* */
/* Used for Xe_intern_anysym() */
/* */
/* 1) If "size" != 0, */
/* - malloc "size" bytes, */
/* - copy "size" bytes from "data" into malloced space, */
/* - Save pointer to malloc space as user's data pointer */
/* Else */
/* - Save "data" as pointer to user's data */
/* 3) If a "init_fn" is configured, */
/* - call init_fn( user's data pointer, "size" ) */
/* - set user's data pointer to return value of init_fn */
/* ONLY if "size" was zero. */
/* */
/* If size is non zero AND there is a user's malloc function, */
/* beware that the return value from the malloc function is not */
/* save anywhere by these routines. If size was zero, the */
/* return value of the user's function is kept. */
/* */
/* -------------------------------------------------------------------- */
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
typedef void * (*XeSymFn_init)(void *, unsigned int);
#else
typedef void * (*XeSymFn_init)();
#endif
/* CLEAN_FN: */
/* */
/* If created by Xe_intern() or XeRegisterSymbol() */
/* */
/* 1) free(XeSymbol->name) */
/* 2) If a "clean_fn" is configured, */
/* - clean_fn(XeSymbol->value), */
/* - the XeSymbol entry is deleted. */
/* */
/* If created by Xe_intern_anysym() */
/* */
/* 1) If a "clean_fn" is configured, */
/* - init_fn( user's data pointer, "size" ) */
/* 2) If "size" != 0 during at creation time, */
/* - free( user's data pointer ) */
/* */
/* Take note of the what happens during creation with "size" is */
/* non-zero and there is a user's malloc function. The result of */
/* the user's malloc function will be passed to this clean function */
/* only if "size" was zero at creation time. Otherwise, the memory */
/* malloc'ed by this routine due to the non-zero size parameter is */
/* what is passed to the user's clean function. */
/* -------------------------------------------------------------------- */
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
typedef void (*XeSymFn_clean) (void *);
#else
typedef void (*XeSymFn_clean) ();
#endif
/* This is what an internal symbol table entry looks like: */
/* ------------------------------------------------------- */
typedef struct _XeSymtabList {
struct _XeSymtabList *rest;
void *data;
Boolean data_is_XeSymbol;
Boolean data_is_malloc_mem;
} *XeSymtabList;
/* This is the master record for a symbol table */
/* -------------------------------------------- */
typedef struct _XeSymTable
{
unsigned int hashsize; /* # of hash buckets. */
XeSymtabList *list; /* Hash buckets. */
XeSymtabList curr_list; /* Used to dump/traver the table. */
unsigned int curr_hash;
XeSymFn_cmp cmp_fn; /* Read above description with each */
XeSymFn_hash hash_fn; /* function typedef for more info. */
XeSymFn_init init_fn;
XeSymFn_clean clean_fn;
} *XeSymTable;
/* Create a new hashtable. "hashsize must be power of 2 if using default */
/* hash function (no checking is done to ensure this). */
/* --------------------------------------------------------------------- */
XeSymTable Xe_new_symtab
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(unsigned int hashsize);
#else
();
#endif
/* Create the default symbol table. If already created, just */
/* return the symtable pointer. */
/* ---------------------------------------------------------- */
XeSymTable Xe_default_symtab
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(void);
#else
();
#endif
/* Configure user defined function for use with symtab routines. */
/* NOTE: Be sure you understand the interaction of these functions */
/* Read the decriptions with each of the typdef's above. A */
/* null function pointer will overwrite any previously */
/* installed value. */
/* --------------------------------------------------------------- */
XeSymTable Xe_set_sym_fns
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeSymTable t,
XeSymFn_cmp cmp_fn,
XeSymFn_init init_fn,
XeSymFn_clean clean_fn,
XeSymFn_hash hash_fn);
#else
();
#endif
/* Find or create a symbol for "name". Its "value" is set to NULL. */
/* None of the user defined init/cmp, etc functions are honored by */
/* this routine */
/* WARNING: Read the notes for the function typedef's above. */
/* ----------------------------------------------------------------- */
XeSymbol Xe_intern
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeSymTable t, ConstXeString const name);
#else
();
#endif
/* Find the symbol for "name". NULL is returned if not found. */
/* None of the user defined init/cmp, etc functions are honored by */
/* this routine */
/* WARNING: Read the notes for the function typedef's above. */
/* ----------------------------------------------------------------- */
XeSymbol Xe_lookup
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeSymTable t, ConstXeString const name);
#else
();
#endif
/****************************************************************************/
/* LISTS */
typedef struct _XeList {
struct _XeList *rest;
void *data;
} *XeList;
/* make a list from data and rest */
/* ------------------------------ */
XeList Xe_make_list
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(void *data, XeList rest);
#else
();
#endif
/****************************************************************************/
/* QUEUES */
typedef struct _XeQueue {
XeList head;
XeList tail;
void * null;
} *XeQueue;
/* for static or auto struct queues */
/* -------------------------------- */
XeQueue Xe_init_queue
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeQueue q, void * nullval);
#else
();
#endif
XeQueue Xe_make_queue
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(void * nullval);
#else
();
#endif
void Xe_release_queue
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeQueue q);
#else
();
#endif
/* nullval returned if queue empty */
/* ------------------------------- */
void * Xe_pop_queue
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeQueue q);
#else
();
#endif
/* nullval returned if not found */
/* ------------------------------- */
void * Xe_delete_queue_element
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeQueue q, void * val);
#else
();
#endif
void Xe_push_queue
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeQueue q, void * val);
#else
();
#endif
/* user declares his own "type var" */
/* -------------------------------- */
#define Xe_for_queue(type,var,q) \
XeList q_next, q_list; \
for(q_list = q->head; \
q_list && (var = (type) q_list->data, q_next = q_list->rest , 1);\
q_list = q_next)
/* PUT NOTHING AFTER THIS endif */
#endif /* _Symbolic_h_ */

View File

@@ -0,0 +1,45 @@
/*
* File: XeUserMsg.h $XConsortium: XeUserMsg.h /main/3 1995/10/26 15:46:16 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 _XeUserMsg_h
#define _XeUserMsg_h
#include <bms/sbport.h>
/* Global Variables */
/* ---------------- */
extern XeString XeProgName; /* saves value of arg[0] */
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
typedef enum {
XeIgnore,
XeInformation,
XeWarning,
XeError,
XeFatalError,
XeInternalError
} XeSeverity;
#else
# define XeIgnore 0
# define XeInformation 1
# define XeWarning 2
# define XeError 3
# define XeFatalError 4
# define XeInternalError 5
typedef int XeSeverity;
#endif
#define export /* Use this noop to mark non-static procedures. */
#endif /* _XeUserMsg_h */
/* DON'T ADD STUFF AFTER THIS #endif */

View File

@@ -0,0 +1,54 @@
/*
* File: bms.h $XConsortium: bms.h /main/4 1996/06/21 17:20:07 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. *
*/
#ifndef _bms_h
#define _bms_h
#ifdef SVR4
#include <netdb.h> /* MAXHOSTNAMELEN */
#else
#include <sys/param.h> /* MAXHOSTNAMELEN */
#endif
/* WARNINGS: */
/* */
/* 1) <bms/sbport.h> MUST included before this file. */
/* 2) Any <X11/...> includes MUST come before this file. */
/* ---------------------------------------------------------- */
#ifndef _XtIntrinsic_h /* Define "Boolean" if not already */
typedef char Boolean; /* defined from <X11/Intrinsic.h> */
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
extern char *XeToolClass;
extern XeString XeProgName; /* From noXinit.c */
extern XeString /* Returns Malloc'ed memory */
XeSBTempPath
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeString);
#else
();
#endif
/* DON'T ADD STUFF AFTER THIS #endif */
#endif /* _bms_h */

View File

@@ -0,0 +1,201 @@
/*
* File: connect.h $XConsortium: connect.h /main/3 1995/10/26 15:47:00 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 _connect_h
#define _connect_h
#if defined(__cplusplus) && defined(__c_callable)
extern "C" {
#endif
int XeParseFileString
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeString line, XeString *host_addr, XeString *path_addr);
#else
();
#endif
#if defined(__cplusplus) && defined(__c_callable)
}
#endif
/*
Take the filespec as a line and return a path the host and path
components as separate fields (finds the ':' and replaces it with
NULL). THIS FUNCTION MUNGES THE ORIGINAL LINE.
*/
extern XeString XeFindHost
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeString host_spec);
#else
();
#endif
extern XeString XeFindShortHost
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeString host_spec);
#else
();
#endif
/*
Returns a host name corresponding to host_spec.
In all cases a NEW STRING, OWNED BY THE
CALLER, is returned. XeFindHost returns the full host specification
including domain if there is one. XeFindShortHost does not
include the domain. These functions can be used to convert between
domain and simple names when needed. The domain names should be
used always internally and the simple names only used for display.
*/
extern int Xegethostname
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeString hostname, unsigned int size);
#else
();
#endif
#if defined(__cplusplus) && defined(__c_callable)
extern "C" {
#else
extern
#endif
int Xegetshorthostname
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeString hostname, unsigned int size);
#else
();
#endif
#if defined(__cplusplus) && defined(__c_callable)
}
#endif
/*
Identical to the libc function gethostname, except that Xegethostname
returns a full domain qualified name and Xegetshorthostname returns
a simple name. These functions are necessary because the system
hostname may or may not contain a domain name and the internal
representation should always be canonical form (domain qualified).
Use Xegethostname except when the name is being used for display
purposes only. Storage allocation is identical to gethostname
(it copies into the caller's buffer).
*/
#if defined(__cplusplus) && defined(__c_callable)
extern "C" {
#else
extern
#endif
Boolean XeIsLocalHostP
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeString hostname);
#else
();
#endif
#if defined(__cplusplus) && defined(__c_callable)
}
#endif
/*
Returns true if the hostname passed in identifies the host on which
this function is executed. This is needed in order to handle all
combinations of simple and domain-qualified names for either the
hostname passed in or the one defined on the local host. Be sure
to include Xe.h or provide a local declaration for this function
as Boolean is not the same length as int and it won't function
correctly without the declaration.
*/
#if defined(__cplusplus) && defined(__c_callable)
extern "C" {
#else
extern
#endif
Boolean XeIsSameHostP
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeString host1, XeString host2);
#else
();
#endif
#if defined(__cplusplus) && defined(__c_callable)
}
#endif
/*
Returns true if host1 and host2 specify the same host. This is
needed, because either or both hosts may be specified with or
without domain qualifiers, and the correct result must be
obtained. This function canonicalizes both and compares them
only in canonical form.
*/
extern Boolean XeIsSameHostP
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeString host1, XeString host2);
#else
();
#endif
/*
Returns true if host1 and host2 specify the same host. This is
needed, because either or both hosts may be specified with or
without domain qualifiers, and the correct result must be
obtained. This function canonicalizes both and compares them
only in canonical form.
*/
XeString XeCreateContextString
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeString host, XeString directory, XeString file);
#else
();
#endif
/*
XeCreateContextString changes the given context into a
label which is exactly the same as the one shown in a
fileview modeline. A NEW STRING, OWNED BY THE CALLER,
is returned.
*/
#define XeEliminateDots(path) (XeString)pathcollapse(path, path, FALSE)
/*
Removes /./'s and /../ 's from path. THIS ROUTINE OVERWRITES
THE path IT WAS PASSED. If there are too many ..'s in path,
NULL is returned, so you better keep a pointer to path if you hope
to reclaim it. Does not handle host:/path, shell variables or other
exotic animals.
*/
int Xechdir
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(const char *path);
#else
();
#endif
/*
performs a chdir and caches the new directory in $PWD so that
Xegetcwd() can get the current directory without slow stat calls
*/
char *Xegetcwd
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(char *buf,
int size);
#else
();
#endif
/*
version of getcwd() which uses cached $PWD (or $PWD from shell)
if available and calls getcwd only when PWD not set
*/
/* DON'T ADD STUFF AFTER THIS #endif */
#endif /* _connect_h */

View File

@@ -0,0 +1,23 @@
/*
* File: pathwexp.h $XConsortium: pathwexp.h /main/3 1995/10/26 15:47:18 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 _pathwexp_h
#define _pathwexp_h
extern XeString Xe_shellexp
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeString path);
#else
();
#endif
#endif /* _pathwexp_h */

View File

@@ -0,0 +1,388 @@
/*
* File: sbport.h $TOG: sbport.h /main/4 1998/03/16 14:40:52 mgreess $
* 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 PORT_H_INCLUDED
#define PORT_H_INCLUDED
/*---------------------------------------------------------------------------
The following is a list of #defines that may be tested for in the code:
=======================================================================
__STDC__ - Will be set for ANSI C compilers
__cplusplus - Will be set for C++ compilers
__STDCPP__ - Will be set for ANSI and C++ compilers
__hpux - Will be set for HP-UX systems
__sun - Will be set for SUN systems
__apollo - Will be set for APOLLO (domain) systems
__aix - Will be set for IBM (AIX) systems
__sysv - Set when using SYSV semantics (e.g. HP, SUN)
SYSV - Set when __sysv is set (needed for some X11 includes)
__bsd - Set when using BSD semantics
__hp_7_0 - For running on HP-UX 7.0
__hp_nls_16 - Set if HP's 16 bit support is to be compiled in
__hp_color_object - Set if HP's ColorObject extension is available in the Motif library
__hp9000s300 - Set for S300 (and S400?) HP-UX machines
__hp9000s800 - Set for S800 (PA-RISC) machines
__sparc - Set for SUN sparc machines
__sun68k - Set for SUN m68k machines
__apollo88k - Set for apollo (domain) risc (PRISM) machines
__apollo68k - Set for apollo (domain) m68k machines
__apollo_null - Set to allow null pointer dereferences on domain
__apollo_paths - Set to have "//<host>" converted to "host:"
__identification_strings - Set when RCS header strings are to be in code
__recursive_includes - Set to have .h files #includes prerequisite files
__char_ptr_yytext - Set if the lex/yacc variable yytext is defined
to be of type char[].
__unsigned_char_ptr_yytext - Set if the lex/yacc variable yytext is defined
to be of type unsigned char[].
KEEP_DEADWOOD - Currently set to "FALSE". If set to "TRUE",
lots of old code and semantics will be enabled.
----------------------------------------------------------------------------*/
/* First task is to make sure all of the defines that we use in the */
/* code are properly set up. */
/* ---------------------------------------------------------------- */
#if !defined(sun)
#if !defined(__STDCPP__) && (defined(__STDC__) || defined(__cplusplus))
# define __STDCPP__
#endif
#endif
#if defined(sun) && !defined(__sun)
# define __sun
#endif
#if defined(apollo) && !defined(__apollo)
# define __apollo
#endif
#if defined(hpux) && !defined(__hpux)
# define __hpux
#endif
#if defined(_AIX) && !defined(__aix)
# define __aix
# define OSF_MOTIF_1_1_1
# define OSF_BUG
#endif
#if defined(__osf__) && !defined(__osf)
# define __osf
# define __sysv
# define OSF_BUG
# define __char_ptr_yytext
#endif
#if defined(osf) && !defined(__osf)
# define __osf
# define __sysv
# define __osfs700
# define OSF_BUG
# define __hp_color_object
# define __char_ptr_yytext
#endif
#ifdef __hpux
# define __sysv
/* __hp9000s300 or __hp9000s800 is defined by HP-UX cpp */
# if !defined (__hpux_8_0)
# define __hp_7_0
# endif
# define __hp_nls_16
# define __hp_color_object
# define __unsigned_char_ptr_yytext
#endif /* __hpux */
#ifdef __sun
# if defined(sparc) && !defined(__sparc)
# define __sparc
# else
# if defined(mc68000) || defined(__mc68000)
# define __sun68k
# endif
# endif
# define __hp_color_object /* Should only be set if linking with */
/* HP's version of Motif (1.1 or later). */
# define __char_ptr_yytext
# define __c_callable /* Set so VUE can link with libbms. */
#endif
#ifdef __apollo
# ifndef __bsd
# define __sysv /* NOTE: not bsd!!! */
# endif
# ifndef __apollo_paths
# define __apollo_paths
# endif
# ifndef __apollo_null
# define __apollo_null
# endif
# if defined(a88k) && !defined(__apollo88k)
# define __apollo88k
# endif
# if defined(_ISP__A88K) && !defined(__apollo88k)
# define __apollo88k
# endif
# if defined(m68k) && !defined(__apollo68k)
# define __apollo68k
# endif
# if defined(_ISP__M68K) && !defined(__apollo68k)
# define __apollo68k
# endif
# define __hp_color_object
# define __unsigned_char_ptr_yytext
#endif
#ifdef __aix
# define __sysv
#endif
#if defined(__sysv) && !defined(SYSV)
# define SYSV /* Needed for X11 include files */
#endif
#ifndef KEEP_DEADWOOD /* Setting this to "TRUE" will cause */
# define KEEP_DEADWOOD FALSE /* all sorts of unknown problems. */
#endif
#ifndef __apollo_paths
# define __apollo_paths /* We always want this feature */
#endif
#ifdef __cplusplus
#define UNUSED_PARM(_parm)
#else
#define UNUSED_PARM(_parm) _parm
#endif /* __cplusplus */
/* There are a few things that are not part of XPG3 that we need. */
/* sockets are one of them. To use this stuff, we just include the */
/* non XOPEN include files and things work. However, there are a */
/* few XOPEN include files that have stuff to support this extra */
/* functionality (e.g. sockets) that are #ifdef'ed for conditional */
/* inclusion with the _XOPEN_SOURCE define. In order to pull those */
/* extra types in, we relas the XPG3 compliance for that file. The */
/* following are the three areas where we must do this: */
/* */
/* __need_timeval gets "struct timeval" */
/* __need_fd_set gets "typedef struct fd_set {..." */
/* __need_S_IF gets "S_IFNWK, S_IFLNK" */
/* __need_all_signals gets all SIGxxx values */
/* __need_all_errors gets all errno values */
/* */
/* We get at these declarations differently on each platform... */
/* ----------------------------------------------------------------- */
#if defined(__need_timeval) /* Get "struct timeval" */
# ifdef __osf
# define _OSF_SOURCE
# include <sys/time.h>
# endif
# ifdef __sun
# include <sys/time.h>
# endif
#if defined(USL) || defined(__uxp__)
# include <sys/time.h>
# endif
# ifdef __apollo
# include <sys/time.h>
# endif
# ifdef __aix
# include <sys/time.h>
# endif
#endif /* __need_timeval */
#if defined(__need_fd_set) /* Get "typedef struct fd_set" */
# ifdef __osf
# define _OSF_SOURCE
# include <sys/types.h>
# endif
# ifdef __apollo
# define _INCLUDE_BSD_SOURCE
# include "/bsd4.3/usr/include/sys/types.h"
# endif
# ifdef _AIX
# include <sys/select.h>
# endif
/*
# if defined(USL) || defined(__uxp__)
# include <sys/select.h>
# endif
*/
#endif /* __need_fd_st */
#if defined(__need_S_IF) /* Get S_IFNWK, S_IFLNK */
# ifdef __osf
# define _OSF_SOURCE
# endif
# ifdef __apollo
# define _APOLLO_SOURCE
# endif
#endif /* __need_S_IF */
#if defined(__need_all_errors)
# ifdef __apollo
# define _APOLLO_SOURCE
# undef _SYS_STDSYMS_INCLUDED /* So we can include <sys/stdsyms.h> again */
# endif
#endif
#if defined(__need_all_signals) /* Get all SIGxxx values */
# ifdef __osf
# define _OSF_SOURCE
# endif
# ifdef __apollo
# define _APOLLO_SOURCE
# include "/bsd4.3/usr/include/sys/types.h"
# endif
#endif /* __need_all_signal */
/* We also use the following non XPG3 types. However, they may be */
/* defined when we relax the XPG3 compliance to get the stuff talked */
/* about above. So, declare them only if we don't already have them */
/* ----------------------------------------------------------------- */
#if defined(_HPUX_SOURCE) || defined(__sun) || defined(USL) || defined(_INCLUDE_BSD_SOURCE) || defined(_OSF_SOURCE) || defined(__aix) || defined(__uxp__) || defined(__osf__) || defined(linux)
/* the "u_types" are defined in standard files */
# undef _INCLUDE_BSD_SOURCE
#else
typedef unsigned int u_int;
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned long u_long;
#endif
/* Use these if you must ensure that you get a specific number of bits */
/* -------------------------------------------------------------------- */
typedef char int8;
typedef short int16;
#ifndef __osf__
typedef long int32;
#endif
typedef unsigned char u_int8;
typedef unsigned short u_int16;
#ifndef __osf__
typedef unsigned long u_int32;
#endif
#define __xechar_is_signed
#undef __xechar_is_unsigned
#ifdef __xechar_is_signed
typedef char XeChar;
#else
typedef unsigned char XeChar;
#endif
/* The following type is a VARIABLE pointer to a VARIABLE XeChar. */
typedef XeChar *XeString;
/***********************************************************************
* The following type is a VARIABLE pointer to a CONST XeChar.
* Thus, ConstXeString p;
* p = "abcd"; #Legal
* *p = "\0'; #Illegal
*
* This is NOT the same as (const XeString)
* which is equivilent to (XeChar * const)
*
* Thus, const XeString p;
* p = "abcd"; #Illegal
* *p = "\0'; #Legal
*
************************************************************************/
typedef const XeChar *ConstXeString;
typedef unsigned short XeChar16;
typedef XeChar16 *XeString16;
#define XeString_NULL (XeString) 0
#define XeString_Empty (XeString) ""
#define XeChar_NULL (XeChar) 0
/* XtPointer was added in R4, so define it ourselves in R3 */
#ifdef __motif10
typedef void * XtPointer;
#endif
/* The X11 R4 header file "Intrinsic.h" is internally inconsistent */
/* with respect to XtAppAddInput. The third parameter ("condition") */
/* is defined to be of type XtPointer (void *), but the input masks */
/* commonly used with it are scalar values. Until the problem is */
/* corrected by M.I.T, use the following type as a cast in calls */
/* to XtAppAddInput. When it is corrected, change this typedef */
/* accordingly. */
/* ---------------------------------------------------------------- */
typedef void * XeInputMask;
#ifdef __cplusplus
/* Define several macros to handle the C++ vs XtOffset problem. */
/* The problem is that C++ cannot at compile time evaluate the */
/* XtOffset macro within an initializer. XtOffset is most often */
/* used within an XtResource array initialization list. */
/* class_names must be a typedef, non pointer type. */
/* ---------------------------------------------------------------- */
#define XtOffsetSimpleField(class_name,field) \
((Cardinal) &class_name::field - 1)
#define XtOffsetCompoundField(class_name1,field1,class_name2,field2) \
(((Cardinal) &class_name1::field1 - 1) + ((Cardinal) &class_name2::field2 - 1))
#else
#define XtOffsetSimpleField(class_name,field) \
((Cardinal) (((char *) (&(((class_name *)NULL)->field))) - ((char *) NULL)))
#define XtOffsetCompoundField(class_name1,field1,class_name2,field2) \
((Cardinal) (((char *) (&(((class_name1 *)NULL)->field1))) - ((char *) NULL))) + \
((Cardinal) (((char *) (&(((class_name2 *)NULL)->field2))) - ((char *) NULL)))
#endif
#ifndef __identification_strings
#define SUPPRESS_RCS_ID /*forces equivalent action for VED/EDIT shared files*/
#endif
#ifndef SBSTDINC_H_NO_INCLUDE
#include <bms/sbstdinc.h>
#endif
#ifdef __aix
# undef NULL
# define NULL 0 /* AIX uses NULL=(void *)0 */
#endif
#endif /* PORT_H_INCLUDED */

View File

@@ -0,0 +1,224 @@
/*
* File: sbstdinc.h $TOG: sbstdinc.h /main/7 1998/07/31 17:50:45 mgreess $
* 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 _sbstdinc_h
#define _sbstdinc_h
#include <sys/types.h>
#include <sys/param.h>
#ifdef SVR4
#include <netdb.h> /* MAXHOSTNAMELEN */
#endif /* SVR4 */
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y)) /* From <sys/param.h>, but not an XPG3 file */
#endif
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>
#include <nl_types.h>
/************************************************************************/
/* Routines not defined in include files (yet). */
/************************************************************************/
/* Domain/OS BSD has bzero(), bcmp(), and bcopy() defined. */
#if !defined(apollo) || !defined(__bsd)
#if defined(__STDC__)
#if !defined(linux) && !defined(__osf__) && !defined(_XFUNCS_H_)
extern void bcopy(char *b1, char *b2, int length);
extern int bcmp(char *b1, char *b2, int length);
extern void bzero(char *b, int length);
#endif
extern char *mktemp(char *tmplate);
#elif ! defined(__cplusplus)
#if !defined(linux) && !defined(__osf__) && !defined(_XFUNCS_H_)
extern void bcopy();
extern int bcmp();
extern void bzero();
#endif
extern char *mktemp();
#endif
#endif
#ifndef SBSTDINC_H_NO_REDEFINE /* sbstdinc.c turns this on */
/************************************************************************/
/* Routines from <string.h> */
/* --- These always get redefined so we can catch null ptr deref's */
/************************************************************************/
#if defined(__STDC__) || defined(__cplusplus)
extern XeString Xestrcat(XeString s1, ConstXeString s2);
#else
extern XeString Xestrcat();
#endif
#ifdef strcat
# undef strcat
#endif
#define strcat Xestrcat
#if defined(__STDC__) || defined(__cplusplus)
extern XeString Xestrncat(XeString s1, ConstXeString s2, size_t n);
#else
extern XeString Xestrncat();
#endif
#ifdef strncat
# undef strncat
#endif
#define strncat Xestrncat
#if defined(__STDC__) || defined(__cplusplus)
extern int Xestrcmp(ConstXeString s1, ConstXeString s2);
#else
extern int Xestrcmp();
#endif
#ifdef strcmp
# undef strcmp
#endif
#define strcmp Xestrcmp
#if defined(__STDC__) || defined(__cplusplus)
extern int Xestrncmp(ConstXeString s1, ConstXeString s2, size_t n);
#else
extern int Xestrncmp();
#endif
#ifdef strncmp
# undef strncmp
#endif
#define strncmp Xestrncmp
#if defined(__STDC__) || defined(__cplusplus)
extern XeString Xestrcpy(XeString s1, ConstXeString s2);
#else
extern XeString Xestrcpy();
#endif
#ifdef strcpy
# undef strcpy
#endif
#define strcpy Xestrcpy
#if defined(__STDC__) || defined(__cplusplus)
extern XeString Xestrncpy(XeString s1, ConstXeString s2, size_t n);
#else
extern XeString Xestrncpy();
#endif
#ifdef strncpy
# undef strncpy
#endif
#define strncpy Xestrncpy
#if defined(__STDC__) || defined(__cplusplus)
extern int Xestrcoll(ConstXeString s1, ConstXeString s2);
#else
extern int Xestrcoll();
#endif
#ifdef strcoll
# undef strcoll
#endif
#define strcoll Xestrcoll
#if defined(__STDC__) || defined(__cplusplus)
extern size_t Xestrxfrm(XeString s1, ConstXeString s2, size_t n);
#else
extern size_t Xestrxfrm();
#endif
#ifdef strxfrm
# undef strxfrm
#endif
#define strxfrm Xestrxfrm
#if defined(__STDC__) || defined(__cplusplus)
extern XeString Xestrchr(ConstXeString s, int c);
#else
extern XeString Xestrchr();
#endif
#ifdef strchr
# undef strchr
#endif
#define strchr Xestrchr
#if defined(__STDC__) || defined(__cplusplus)
extern XeString Xestrpbrk(ConstXeString s1, ConstXeString s2);
#else
extern XeString Xestrpbrk();
#endif
#ifdef strpbrk
# undef strpbrk
#endif
#define strpbrk Xestrpbrk
#if defined(__STDC__) || defined(__cplusplus)
extern XeString Xestrrchr(ConstXeString s, int c);
#else
extern XeString Xestrrchr();
#endif
#ifdef strrchr
# undef strrchr
#endif
#define strrchr Xestrrchr
#if defined(__STDC__) || defined(__cplusplus)
extern XeString Xestrstr(ConstXeString s1, ConstXeString s2);
#else
extern XeString Xestrstr();
#endif
#ifdef strstr
# undef strstr
#endif
#define strstr Xestrstr
#if defined(__STDC__) || defined(__cplusplus)
extern XeString Xestrtok(XeString s1, ConstXeString s2);
#else
extern XeString Xestrtok();
#endif
#ifdef strtok
# undef strtok
#endif
#define strtok Xestrtok
#if defined(__STDC__) || defined(__cplusplus)
extern size_t Xestrlen(ConstXeString s);
#else
extern size_t Xestrlen();
#endif
#ifndef __osf__
# ifdef strlen
# undef strlen
# endif
# define strlen Xestrlen
#endif
#if defined(__STDC__) || defined(__cplusplus)
extern XeString Xestrdup(ConstXeString s);
#else
extern XeString Xestrdup();
#endif
#ifdef strdup
# undef strdup
#endif
#define strdup Xestrdup
#endif /* ifndef SBSTDINC_H_NO_REDEFINE */
#endif /* _sbstdinc_h */

View File

@@ -0,0 +1,140 @@
/*
* File: scoop.h $XConsortium: scoop.h /main/3 1995/10/26 15:48:17 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 _scoop_h
#define _scoop_h
#ifndef NULL
#define NULL 0L
#endif
#ifndef TRUE
#define FALSE 0
#define TRUE 1
#endif /* TRUE */
#if !defined(__sun)
# if (defined(__STDC__) || defined(__STDCPP__) || defined(__cplusplus) || defined(c_plusplus))
# define CAT(a,b) a##b
# else
# define CAT(a,b) a/**/b
# endif
#else
/* Sun C++ compiler uses the non-ansi cpp. */
# if defined(__cplusplus)
# define CAT(a,b) a/**/b
# else
# define CAT(a,b) a##b
# endif
#endif
typedef long OSizeType ;
typedef struct root_class *root_clasp, *object_clasp ;
typedef struct object_struct object;
typedef void (*SC_class_init)(object_clasp);
typedef void (*SC_object_init)(object *);
typedef object * (*SC_new_obj)(object_clasp);
typedef void (*SC_free_obj)(object *);
typedef object * (*SC_clone)(object *, object *);
#define root_class_part \
XeString name ; /* class name */ \
SC_class_init class_init; /* fn to init my class struct */ \
OSizeType object_size ; /* size of object of this class */ \
short init ; /* boolean--class initialized state */ \
SC_object_init object_init; /* fn to init my object struct */ \
SC_new_obj new_obj; /* fn to allocate class objects */ \
SC_free_obj free_obj; /* fn to free class objects */ \
SC_clone clone; /* `method' to clone an object */ \
/* no root private parts */
#define root_object_part
struct object_struct
{ root_clasp class_ptr;
root_object_part
};
struct root_class
{ object_clasp base ; /* pointer to base class */
root_class_part } ;
#define memf(vref, fn, arglist) ( (vref class_ptr)->fn arglist)
#define memvf0(v,fn) memf(v., fn, (&(v)))
#define memvf1(v,fn,a1) memf(v., fn, (&(v),a1))
#define memvf2(v,fn,a1,a2) memf(v., fn, (&(v),a1,a2))
#define memvf3(v,fn,a1,a2,a3) memf(v., fn, (&(v),a1,a2,a3))
#define memvf4(v,fn,a1,a2,a3,a4) memf(v., fn, (&(v),a1,a2,a3,a4))
#define memvf5(v,fn,a1,a2,a3,a4,a5) memf(v., fn, (&(v),a1,a2,a3,a4,a5))
#define memvf6(v,fn,a1,a2,a3,a4,a5,a6) memf(v., fn, (&(v),a1,a2,a3,a4,a5,a6))
#define memvf7(v,fn,a1,a2,a3,a4,a5,a6,a7) \
memf(v., fn, (&(v),a1,a2,a3,a4,a5,a6,a7))
#define memvf8(v,fn,a1,a2,a3,a4,a5,a6,a7,a8) \
memf(v., fn, (&(v),a1,a2,a3,a4,a5,a6,a7,a8))
#define memvf9(v,fn,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
memf(v., fn, (&(v),a1,a2,a3,a4,a5,a6,a7,a8,a9))
#define mempf0(p,fn) memf(p->, fn, (p))
#define mempf1(p,fn,a1) memf(p->, fn, (p,a1))
#define mempf2(p,fn,a1,a2) memf(p->, fn, (p,a1,a2))
#define mempf3(p,fn,a1,a2,a3) memf(p->, fn, (p,a1,a2,a3))
#define mempf4(p,fn,a1,a2,a3,a4) memf(p->, fn, (p,a1,a2,a3,a4))
#define mempf5(p,fn,a1,a2,a3,a4,a5) memf(p->, fn, (p,a1,a2,a3,a4,a5))
#define mempf6(p,fn,a1,a2,a3,a4,a5,a6) memf(p->, fn, (p,a1,a2,a3,a4,a5,a6))
#define mempf7(p,fn,a1,a2,a3,a4,a5,a6,a7) \
memf(p->, fn, (p,a1,a2,a3,a4,a5,a6,a7))
#define mempf8(p,fn,a1,a2,a3,a4,a5,a6,a7,a8) \
memf(p->, fn, (p,a1,a2,a3,a4,a5,a6,a7,a8))
#define mempf9(p,fn,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
memf(p->, fn, (p,a1,a2,a3,a4,a5,a6,a7,a8,a9))
#define memd(vref, dm) (vref dm)
#define base_memf(my_class, fn, arglist) \
((*(my_class->base->fn)) arglist)
#define memfp(vref, fn, arglist) memf (vref, CLASS.fn, arglist)
#define memdp(vref, dm) memd (vref, CLASS.dm)
#define memvs(v, sdm) (*((v.class_ptr)->sdm))
#define memps(p, sdm) (*((p->class_ptr)->sdm))
#define stat_def(name, type) type *name; type CAT(name,_static) ;
#define stat_init(def_class, class_ptr, name) \
(class_ptr->name) = &(def_class->CAT(name,_static))
extern object_clasp root_class ;
extern void object_destroy
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(object *p);
#else
();
#endif
extern object *object_create
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(object_clasp c);
#else
();
#endif
extern void object_init
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(object_clasp c, object *p);
#else
();
#endif
#endif /* _scoop_h */
/* PLACE NOTHING AFTER THIS endif */

View File

@@ -0,0 +1,467 @@
/*
* File: spc.h $XConsortium: spc.h /main/3 1995/10/26 15:48:38 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 _spc_h
#define _spc_h
/* -------------------------------------------- */
/* Requires: */
#include <stdio.h>
#include <bms/XeUserMsg.h>
#include <termios.h>
/* -------------------------------------------- */
typedef struct _SPC_Channel *SPC_Channel_Ptr;
typedef struct _XeHostInfo {
XeString os;
XeString os_ver;
XeString hw_arch;
} *XeHostInfo;
extern FILE *SPC_Print_Protocol;
extern FILE *spc_logF;
extern XeString spc_user_environment_file;
/* Error returns for SPC routines */
#define SPC_ERROR FALSE /* Use this value for error checking */
/*
* These are the channel connector definitions
*/
#define STDIN 0
#define STDOUT 1
#define STDERR 2
#define MASTER_SIDE 0
#define SLAVE_SIDE 1
/* These are the sub-process notification identifiers */
#define SPC_PROCESS_STOPPED 1 /* Child process is in background */
#define SPC_PROCESS_EXITED 2 /* Child process called exit(cause); */
#define SPC_PROCESS_SIGNALLED 3 /* Child process received signal: cause */
#define SPC_PROCESS_INTERRUPT 4 /* Child process WAIT was interrupted */
#define SPC_PROCESS_DUMPED(a) ((a) & 0200) /* True when core dumped */
/* This is the maximum size of an SPC I/O Buffer */
#define SPC_BUFSIZ 4096
/*
* These macros define the bit field portion of an SPC_IOMode
*/
#define SPCIO_ALL_MASK 0xffffffff
/* The IO Modes that define the input and output sources */
#define SPCIO_SOURCE_MASK 0xf
#define SPCIO_NOIO 0x0 /* The default - no input/output */
#define SPCIO_WRITEONLY 0x1 /* Only write app stdin */
#define SPCIO_READONLY 0x2 /* Only read app stdout */
#define SPCIO_READWRITE 0x3 /* Read stdout, write stdin */
#define SPCIO_ERRORONLY 0x4 /* Only read stderr */
#define SPCIO_WRITEERROR 0x5 /* Write stdin, read stderr */
#define SPCIO_READERROR 0x6 /* Only read stdout/stderr */
#define SPCIO_READWRITEERROR 0x7 /* Full std (in, out, err) */
/* Use this bit with above IO Mode for splitting stdout and stderr data */
#define SPCIO_SEPARATEREADERROR 0x8 /* Separate stdout & stderr */
/* The IO Modes that deal with communication styles (features) */
#define SPCIO_STYLE_MASK 0x70
#define SPCIO_PTY 0x10 /* Use a PTY */
#define SPCIO_PIPE 0x20 /* Use pipe() - no line editing */
#define SPCIO_NOIOMODE 0x40 /* Use neither */
#define SPCIO_LINEEDIT 0x80 /* Valid only with PTY */
/* Other flags */
#define SPCIO_SYSTEM 0x100 /* Use system() - Spawns a SHELL */
#define SPCIO_LINEORIENTED 0x200 /* Invoke callback on line bounds */
/* It is possible to break two byte
characters. See note on XeSPCRead. */
#define SPCIO_WAIT 0x400 /* Wait for process to finish */
#define SPCIO_USE_XTOOLKIT 0x800 /* Use the X toolkit */
#define SPCIO_SYNC_TERMINATOR 0x1000 /* Handle termination synchronously */
#define SPCIO_USE_LOGFILE 0x2000 /* Use logfile for stderr -- only
valid with SPCIO_NOIO */
#define SPCIO_SIGNAL_PGRP 0x20000 /* Propagate signals to entire process
group. */
#define SPCIO_FORCE_CONTEXT 0x40000 /* Error on SPC Spawn if context dir
is not present */
/*
* Routines
*/
/* spc.c */
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
# define EXTERN_DECL(type, name, arglist) type name arglist
# if defined(__cplusplus) && defined(__c_callable)
# define EXTERN_C_CALLABLE(type, name, arglist) \
extern "C" { type name arglist ; }
# else
# define EXTERN_C_CALLABLE(type, name, arglist) \
EXTERN_DECL(type, name, arglist)
# endif
#else
#ifdef _AIX
# define EXTERN_C_CALLABLE(type, name, arglist) \
extern type name arglist
# define EXTERN_DECL(type, name, arglist) \
type name arglist
#else /* _AIX */
# define EXTERN_DECL(type, name, arglist) name arglist
# define EXTERN_C_DECL(type, name, arglist) EXTERN_DECL(type, name, arglist)
#endif /* (_AIX) */
#endif
EXTERN_C_CALLABLE(SPC_Channel_Ptr, XeSPCOpen, (XeString hostname, int iomode));
/*
Open an SPC channel. Process will run on 'hostname' (or the local
host if value is NULL), with the specified iomode.
*/
EXTERN_C_CALLABLE(int, XeSPCClose, (SPC_Channel_Ptr channel));
/*
Close an SPC channel. Closing a channel will automatically deactivate it
(meaning that any subprocess associated with the channel is terminated).
*/
EXTERN_DECL(int, XeSPCReset, (SPC_Channel_Ptr channel));
/*
Reset an SPC channel. This will allow it to be used in a subsequent
spawn or exec call.
*/
EXTERN_DECL(int, XeSPCRead,
(SPC_Channel_Ptr channel, int connector,
XeString buffer, int length));
/*
Read length characters from an SPC channel into some preallocated buffer.
Note that it is possible to split a two-byte character, if the first
byte if the character is read in just at buffer[length]. However, the
next read will return the second byte (just like Unix read). The
'connector' value is either STDOUT or STDERR.
*/
EXTERN_DECL(int, XeSPCWrite,
(SPC_Channel_Ptr channel, XeString buffer, int length));
/*
Write length characters from buffer to the standard input of a
process on the other side of an SPC channel.
*/
EXTERN_C_CALLABLE(int, XeSPCActive, (SPC_Channel_Ptr channel));
/*
Returns True when channel is active, False otherwise
*/
EXTERN_DECL(int, XeSPCData, (SPC_Channel_Ptr channel));
/*
Returns True when channel be read from, False otherwise
*/
EXTERN_C_CALLABLE(int, XeSPCSpawn,
(XeString pathname, XeString context_dir, XeString *argv,
XeString *envp, SPC_Channel_Ptr channel));
/*
Spawn an application under SPC
*/
EXTERN_DECL(SPC_Channel_Ptr, XeSPCOpenAndSpawn,
(XeString hostname, int iomode, XeString pathname,
XeString context_dir, XeString *argv, XeString *envp));
/*
Combine the Open and Spawn channel operations
*/
EXTERN_DECL(int, XeSPCExecuteProcess, (SPC_Channel_Ptr channel));
/*
Restart a new subprocess on a channel
*/
EXTERN_C_CALLABLE(void, XeSPCKillProcesses, (int wait));
/*
Kill all known executing processes (useful for catching SIGTERM, etc)
*/
EXTERN_DECL(int, XeSPCKillProcess, (SPC_Channel_Ptr channel, int wait));
/*
Kill executing process on an SPC channel. 'wait' TRUE means don't
return from call until process is completely terminated (including
after user specified callbacks are called).
*/
EXTERN_DECL(int, XeSPCInterruptProcess, (SPC_Channel_Ptr channel));
/*
Interrupt executing process on an SPC channel (send SIGINT).
*/
EXTERN_DECL(int, XeSPCSignalProcess, (SPC_Channel_Ptr channel, int sig));
/*
Send an arbitrary signal to executing process on an SPC channel.
*/
typedef
EXTERN_DECL(void, (*SbInputHandlerProc),
(void *client_data, XeString buf, int nchars, int connector));
EXTERN_C_CALLABLE(int, XeSPCAddInput,
(SPC_Channel_Ptr channel,
SbInputHandlerProc handler,
void *client_data));
/*
Add an input channel handler
*/
/*
* The user input handler takes the following form:
*
* void UserInputHandler(client_data, text, size, connection)
* void * client_data; *** Useful for passing widet destination ***
* XeString text; *** The text coming from the SPC channel ***
* int size; *** The number of character in passed text ***
* int connection; *** The connection where data was received ***
* *** (STDOUT or STDERR) ***
*/
typedef
EXTERN_DECL(void, (*SPC_TerminateHandlerType),
(SPC_Channel_Ptr chan,
int pid,
int type,
int cause,
void *Terminate_Data));
EXTERN_C_CALLABLE(int, XeSPCRegisterTerminator,
(SPC_Channel_Ptr channel,
SPC_TerminateHandlerType teminator,
void * client_data));
/*
Add a termination handler to a channel (called when sub-process dies)
*/
/*
* The user termination handler takes the following form:
*
* void UserTerminator(channel, pid, type, cause, client_data)
* SPC_CHannel_ptr channel;
* int pid; *** The Process ID of the terminated appl. ***
* int type; *** The type of termination (see above) ***
* int cause; *** The number associated w/termination ***
* void * client_data; *** User specified client data ***
*/
/*
* These are the channel access routines
*/
EXTERN_DECL(XeString, XeSPCGetDevice,
(SPC_Channel_Ptr channel, int connector, int side));
/*
Return the device name associated with a side of a channel device
pair. 'connector' is either STDIN, STDOUT, or STDERR, and 'side' is
either MASTER_SIDE or SLAVE_SIDE. This call is valid only in PTY
channels.
*/
EXTERN_DECL(int, XeSPCGetProcessStatus,
(SPC_Channel_Ptr channel, int *type, int *cause));
/*
Fill in the type and cause of a process termination.
*/
EXTERN_DECL(int, XeSPCAttach, (SPC_Channel_Ptr channel, int pid));
/*
Returns True if a process ID was associated with an SPC channel.
*/
EXTERN_DECL(int, XeSPCDetach, (SPC_Channel_Ptr channel));
EXTERN_DECL(int, XeSPCGetPID, (SPC_Channel_Ptr channel));
/*
Returns the Process ID of the channel or NULL if none
*/
EXTERN_DECL(int, XeSPCGetLogfile,
(SPC_Channel_Ptr channel, XeString *host, XeString *file));
/*
Return the logfile for the channel. If the channel was not opened
with SPCIO_USE_LOGFILE specified, it will return NULL. Also note
that it returns an XeString *, not an XeString.
*/
EXTERN_DECL(int, XeSPCRemoveLogfile, (SPC_Channel_Ptr channel));
/*
Remove the logfile associated with the channel
*/
/*
*
* Features currently not implemented:
*
* SPCIO_WAIT with ptys
*
* SEPARATEREADERROR with ptys
*
* Complete error checking. For example, there
* are no checks for trying to write to a channel
* opened W/O SPCIO_WRITE specified
*
*/
EXTERN_DECL(int, XeSPCGetChannelSyncFd, (SPC_Channel_Ptr channel));
/*
Get the file descriptor for checking synchronous termination. This
is used for interfacing with event loops.
*/
EXTERN_DECL(SPC_Channel_Ptr, XeSPCHandleTerminator, (int fd));
/*
Handle a synchronous termination condition
This routine is to be used with the file descriptor returned by
XeSPCGetChannelSyncFd. The idea is that one opens a channel using
SPCIO_SYNC_TERMINATOR set in the iomode, and then at some point
checks for input available on the returned file descriptor (possibly
using a select(2) system call). If there is input, it means that
some SYNC_TERMINATOR channel had a subprocess die. The program then
calls XeSPCHandleTerminator to get the termination handler invoked.
IT IS THE RESPONSIBILITY OF THE USER PROGRAM TO EVENTUALLY CALL
XeSPCHandleTerminator. IF IT DOES NOT, THE PROGRAM MAY DEADLOCK
ITSELF.
*/
/* SPC Error handling */
typedef struct _SPCError { /* An SPC Error message */
XeString text; /* The text */
XeString format; /* How to format args */
XeSeverity severity; /* How bad is it, doc? */
char use_errno; /* Whether to use the system errno */
} SPCError;
/* Use this to get the current error number */
extern int XeSPCErrorNumber;
EXTERN_DECL(SPCError *, XeSPCLookupError, (int errnum));
/*
Returns the SPCError structure associated with the passed error number or
NULL if the passed error number is not a valid SPC error. The
error structure returned will be overwritten by a subsequent
XeSPCLookupError call.
*/
EXTERN_DECL(void, XeSPCShutdownCallbacks, (void));
EXTERN_DECL(void, XeSPCRestartCallbacks, (void));
/* These two routines are used to temporarily suspend SPC callbacks */
EXTERN_DECL(int, XeSetpgrp, (int read_current_termio));
/*
This routine will do the following:
1. open /dev/tty
2. get the termio information from the file descriptor just opened
3. close /dev/tty
3. allocate a master / slave pty pair, opening the master side
4. set the termio info of the master side to be the result of step 2
5. setpgrp
6. open the slave side.
All of this has the effect of making the process which called this
routine immune to interrupts, etc., but also passing on the termio
characteristics of the original tty.
If read_current_termio is non-zero, steps 1-3 will NOT be performed, but
instead this routine will get the information from the following termio
struct:
*/
EXTERN_DECL(XeHostInfo, SPC_GetHostinfo, (SPC_Channel_Ptr channel));
/*
Return information about the host (os, os-ver, hw) to which "channel"
is currently connected. The return is to a static structure of static
strings. Do not modify or free and of them!
*/
/*
**
** New B.00 functions
**
*/
EXTERN_C_CALLABLE(int, XeSPCSendEOF, (SPC_Channel_Ptr channel));
/*
Close the standard input of the process on the other side of the channel
*/
EXTERN_C_CALLABLE(int, XeSPCSetTermio,
(SPC_Channel_Ptr channel,
int connection,
int side,
struct termios *termio));
/*
Set the termio value of the PTY associated with 'connection' (STDIN,
STDOUT, or STDERR), on 'side' (MASTER_SIDE or SLAVE_SIDE) to the
value pointed to by termio. This call must be made before the
subprocess is spawned.
*/
#endif /* #ifdef _spc_h */

View File

@@ -0,0 +1,47 @@
/*
* File: stringbuf.h $XConsortium: stringbuf.h /main/3 1995/10/26 15:49:00 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 _stringbuf_h
#define _stringbuf_h
typedef struct _XeStringBuffer {
int last_char; /* index of trailing NULL */
int size;
int increment; /* how much to expand when more space is needed */
XeString buffer;
} *XeStringBuffer;
int XeAppendToStringBuffer
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeStringBuffer buffer, XeString string);
#else
();
#endif
XeStringBuffer XeMakeStringBuffer
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(int increment_size);
#else
();
#endif
/* erase the contents (but don't deallocate any space). */
void XeClearStringBuffer
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeStringBuffer buffer);
#else
();
#endif
/*** add nothing after the following endif ***/
#endif /* _stringbuf_h */

View File

@@ -0,0 +1,39 @@
/*
* File: usersig.h $XConsortium: usersig.h /main/3 1995/10/26 15:49:19 rswiston $
* Language: C
*
* (c) Copyright 1989, 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 _usersig_h
#define _usesig_h
/* -------------------------------------------- */
/* Requires: */
#ifdef __recursive_includes
#include <signal.h>
#endif
/* -------------------------------------------- */
#define XE_SIG_NOT_IN_TABLE -2
extern int XeNameToSignal
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(XeString name);
#else
();
#endif
extern XeString XeSignalToName
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
(int sig);
#else
();
#endif
#endif /* _usersig_h */

View File

@@ -0,0 +1,57 @@
/*
* File: boolean.h $XConsortium: boolean.h /main/3 1995/10/26 16:10:48 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.
*/
#ifndef __BOOLEAN_H_
#define __BOOLEAN_H_
#if defined(__aix)
#undef NULL
#define NULL 0
#endif
#if defined(SVR4)
#include <sys/types.h>
#if defined(sun) && defined(_XOPEN_SOURCE)
#ifndef B_TRUE
#define B_TRUE _B_TRUE
#endif
#ifndef B_FALSE
#define B_FALSE _B_FALSE
#endif
#endif /* sun && _XOPEN_SOURCE */
#ifndef boolean
typedef boolean_t boolean;
#endif
#ifndef TRUE
#define TRUE B_TRUE
#endif
#ifndef FALSE
#define FALSE B_FALSE
#endif
#endif /* SVR4 */
#if !defined(SVR4)
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef boolean
typedef int boolean;
#endif
#endif /* ! SVR4 */
#endif /* __BOOLEAN_H_ */

View File

@@ -0,0 +1,197 @@
/*
* $TOG: dynarray.h /main/5 1999/10/15 17:22:58 mgreess $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1993,1994,1996 Hewlett-Packard Company.
* (c) Copyright 1993,1994,1996 International Business Machines Corp.
* (c) Copyright 1993,1994,1996 Sun Microsystems, Inc.
* (c) Copyright 1993,1994,1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
/* Handle dynamic arrays of arbitrary type and range. */
#ifndef __DYNARRAY_H_
#define __DYNARRAY_H_
#include <generic.h>
#if defined(USL) || defined(__uxp__) || defined(__osf__) || defined(sun)
#define _DELETE_ARRAY(sz) delete[]
#else
#define _DELETE_ARRAY(sz) delete[(sz)]
#endif
// this is used to create an ARRAY of a TYPE
#define declare_array(ARRAY, TYPE, BUMP) \
class ARRAY \
{ \
long len; \
long max; \
TYPE *arr; \
protected: \
TYPE &bumpsize(long); \
public: \
ARRAY() { arr = 0; max = len = 0; } \
ARRAY(long siz) \
{ arr = 0; max = len = 0; if (siz > 0) bumpsize(siz-1); } \
ARRAY(const ARRAY &); \
~ARRAY() { _DELETE_ARRAY(max) arr; } \
ARRAY &operator=(const ARRAY &); \
long size() const { return len; } \
void reset(long l = 0) { bumpsize(l); len = l; } \
TYPE &operator[](long e) \
{ if (e < len) return arr[e]; else return bumpsize(e); } \
TYPE &elt(long e) const { return arr[e]; } \
TYPE &end() { return bumpsize(len); } \
TYPE *getarr() const { return arr; } \
TYPE *operator()() const { return arr; } \
};
// this implements an ARRAY of a TYPE
// - this must be done once and only once in the user code
// printf("0x%X: max=%d len=%d elt=%d\n", this, max, len, elt);
#define implement_array(ARRAY, TYPE, BUMP) \
TYPE &ARRAY::bumpsize(long elt) \
{ \
if (elt < 0) \
elt = 0; \
if (elt >= max) \
{ \
if (max <= 0) \
max = 1; \
long omax = max; \
TYPE *narr = new TYPE[max = elt + (omax > BUMP ? BUMP : omax)]; \
for (long i = 0; i < len; i++) \
narr[i] = arr[i]; \
_DELETE_ARRAY(omax) arr; \
arr = narr; \
} \
if (elt >= len) \
len = elt + 1; \
return arr[elt]; \
} \
ARRAY &ARRAY::operator=(const ARRAY &a) \
{ \
if (&a == this) \
return *this; \
if (a.len > len) \
bumpsize(a.len); \
len = a.len; \
for (long i = 0; i < len; i++) \
arr[i] = a.arr[i]; \
return *this; \
} \
ARRAY::ARRAY(const ARRAY &t) \
{ \
arr = 0; \
max = len = 0; \
*this = t; \
}
// the user can also use these to define an array of any type
#define darray(TYPE) name2(TYPE,array)
#define darraydeclare(TYPE) declare_array(darray(TYPE), TYPE, 1024)
#define darrayimplement(TYPE) implement_array(darray(TYPE), TYPE, 1024)
#define darraydeclare2(TYPE,BUMP) declare_array(darray(TYPE), TYPE, BUMP)
#define darrayimplement2(TYPE,BUMP) implement_array(darray(TYPE), TYPE, BUMP)
// this is used to define a DYNARRAY of a TYPE
#define declare_dynarray(DYNARRAY, TYPE) \
class DYNARRAY \
{ \
long low; \
long high; \
long min; \
long max; \
unsigned bump; \
TYPE *arr; \
TYPE *aptr; \
void init(long, long, unsigned); \
void chsize(long, long); \
public: \
DYNARRAY(long l, long s = 0, unsigned b = 1024) { init(l, s, b); } \
DYNARRAY() { init(0, 0, 1024); } \
DYNARRAY(const DYNARRAY &t) \
{ init(t.high - t.low + 1, t.low, t.bump); *this = t; } \
~DYNARRAY() { _DELETE_ARRAY(max - min + 1) arr; } \
DYNARRAY &operator=(const DYNARRAY &); \
long size() const { return high - low + 1; } \
void reset(long len = 0, long st = 0) \
{ chsize(st, st + len - 1); high = st + len - 1; low = st; } \
long smallest() const { return low; } \
long largest() const { return high; } \
TYPE &operator[](long e) \
{ if (e <= low || e >= high) chsize(e,e); return aptr[e]; } \
TYPE &elt(long e) const { return aptr[e]; } \
TYPE &end() { return (*this)[largest() + 1]; } \
TYPE *getarr() const { return aptr; } \
TYPE *operator()() const { return aptr; } \
};
// this creates the code needed for a DYNARRAY of TYPE
// - this must be done once and only once in the user code
#define implement_dynarray(DYNARRAY, TYPE) \
void DYNARRAY::init(long len, long start, unsigned bmp) \
{ \
if (len < 0) \
len = 0; \
high = start + len - 1; \
low = start; \
max = high; \
min = low; \
bump = bmp > 0 ? bmp : 1024; \
if (max < min) \
max = min; \
arr = new TYPE[max - min + 1]; \
aptr = arr - min; \
} \
void DYNARRAY::chsize(long lelt, long helt) \
{ \
long nlow = lelt < low ? lelt : low; \
long nhigh = helt > high ? helt : high; \
if (nlow <= min || nhigh >= max) \
{ \
long nmin = nlow < min ? nlow : min; \
long nmax = nhigh > max ? nhigh : max; \
long m = max - min + 1; \
long nm = nmax - nmin + 1 + (m > bump ? bump : m); \
long nl = nhigh - nlow + 1; \
TYPE *narr = new TYPE[nm]; \
TYPE *naptr = narr - nmin; \
for (long i = low; i <= high; i++) \
naptr[i] = aptr[i]; \
_DELETE_ARRAY(m) arr; \
arr = narr; \
aptr = naptr; \
min = nmin; \
max = nmax; \
} \
high = nhigh; \
low = nlow; \
} \
DYNARRAY &DYNARRAY::operator=(const DYNARRAY &a) \
{ \
if (&a == this) \
return *this; \
if (a.low < low || a.high > high) \
chsize(a.low, a.high); \
low = a.low; \
high = a.high; \
for (long i = a.low; i <= a.high; i++) \
aptr[i] = a.aptr[i]; \
bump = a.bump; \
return *this; \
}
// the user can also use these to define arrays of any type
#define dynarray(TYPE) name2(TYPE,dynarray)
#define dynarraydeclare(TYPE) declare_dynarray(dynarray(TYPE), TYPE)
#define dynarrayimplement(TYPE) implement_dynarray(dynarray(TYPE), TYPE)
// Predefined dynarrays for most common uses
/* declare_array(Charbuf, char, 256) */
#endif /* __DYNARRAY_H_ */

View File

@@ -0,0 +1,47 @@
/*
* File: exception.h $XConsortium: exception.h /main/3 1995/10/26 16:12: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.
*/
/* C++ exception handler package */
#ifndef __EXCEPTION_H_
#define __EXCEPTION_H_
#include <stddef.h>
#include <setjmp.h>
typedef const char *const Exception;
class _Exception
{
char raised, accepted;
_Exception *prev;
public:
const char *val;
jmp_buf buf;
_Exception();
~_Exception();
int accept(Exception val);
int recover();
void raise(Exception val);
};
extern _Exception *_curr_exception;
extern void _raise_exception(Exception val);
#define TRY _Exception _new_exception; if (setjmp(_new_exception.buf) == 0)
#define RECOVER else if (_new_exception.recover())
#define HANDLE(val) else if (_new_exception.accept(val))
#define RAISE(val) _raise_exception(val)
#define EXCEPTION (_curr_exception != NULL ? _curr_exception->val : NULL)
#endif /* __EXCEPTION_H_ */
/*
@(#)REV: 2.18 90/12/13
*/

View File

@@ -0,0 +1,62 @@
/*
* File: mbstring.h $XConsortium: mbstring.h /main/3 1995/10/26 16:12:25 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.
*/
#ifndef __MBSTRING_H_
#define __MBSTRING_H_
#if defined(USL) || defined(__uxp__)
#include <stdlib.h>
#endif
#include <stddef.h>
#ifdef apollo
#define _NEED_WCHAR_T
#include <sys/stdtypes.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#if defined __cplusplus || defined __STDC__
#ifdef __cplusplus2_1
extern char *_mb_schr(char *str, wchar_t ch);
extern char *_mb_srchr(char *str, wchar_t ch);
#else /* __cplusplus2_1 */
extern char *_mb_schr(const char *str, wchar_t ch);
extern char *_mb_srchr(const char *str, wchar_t ch);
#endif /* __cplusplus2_1 */
#else /* defined __cplusplus || defined __STDC__ */
extern char *_mb_schr();
extern char *_mb_srchr();
#endif /* defined __cplusplus || defined __STDC__ */
#ifdef __cplusplus
}
#ifdef __cplusplus2_1
inline const char *_mb_schr(const char *str, wchar_t ch)
{
return (const char *)_mb_schr((char *)str, ch);
}
inline const char *_mb_srchr(const char *str, wchar_t ch)
{
return (const char *)_mb_srchr((char *)str, ch);
}
#endif /* __cplusplus2_1 */
#endif /* __cplusplus */
#endif /* __MBSTRING_H_ */

View File

@@ -0,0 +1,62 @@
/*
* $XConsortium: nl_hack.h /main/5 1996/11/15 18:12:32 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.
*/
#ifndef __NL_HACK_H_
#define __NL_HACK_H_
#include <ctype.h>
#ifdef NO_NLS16
# define ADVANCE(p) (++(p))
# define CHARAT(p) (*(unsigned char *)(p))
# define CHARADV(p) (*(unsigned char *)(p)++)
# define WCHAR(c, p) (*(unsigned char *)(p) = c)
# define WCHARADV(c, p) (*(unsigned char *)(p)++ = c)
#else
# include <locale.h>
# include <stdlib.h>
/* These two globals are needed for the following macros to work.
* The definitions are neither "extern" nor "static". This keeps both
* C and C++ from complaining about unused variables, keeps the linker
* from complaining about multiply-defined symbols, and creates only a
* single instance of each var per program (rather than one per *.o).
* This is also why both variables are uninitialized arrays.
*
* These macros imitate the original HP NLS16 equivalents so that rest
* of the Codelibs code does not need to be modified. The original
* definitions are below within the "#ifdef NLS16" section.
*
* The original HP NLS16 assumes 2 byte multi-byte characters. It is
* generalized for all multi-byte characters.
*/
/* wchar_t __nlh_char[1]; */
# define __NLH_WIDTH(p) (mblen(p, MB_CUR_MAX) > 1 ? mblen(p, MB_CUR_MAX) : 1)
# define __NLH_CHAR(p) \
(mbtowc(__nlh_char, p, MB_CUR_MAX) < 0 ? *p : __nlh_char[0])
# define ADVANCE(p) ((p) += __NLH_WIDTH(p))
# define CHARAT(p) (__NLH_CHAR(p))
# define CHARADV(p) (__NLH_CHAR(p), \
(p) += __NLH_WIDTH(p), __nlh_char[0])
# define WCHAR(c, p) (wctomb(p, (wchar_t)c), c)
# define WCHARADV(c, p) (WCHAR(c, p), ADVANCE(p))
#endif
#endif /* __NL_HACK_H_ */

View File

@@ -0,0 +1,41 @@
/*
* $XConsortium: pathutils.h /main/4 1996/05/08 11:21:09 drk $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1993,1994,1996 Hewlett-Packard Company.
* (c) Copyright 1993,1994,1996 International Business Machines Corp.
* (c) Copyright 1993,1994,1996 Sun Microsystems, Inc.
* (c) Copyright 1993,1994,1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
#ifndef __PATHUTILS_H_
#define __PATHUTILS_H_
#include <stddef.h>
#include <codelibs/boolean.h>
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
extern char *pathcollapse(const char *src,
char *dst = NULL,
boolean show_dir = FALSE);
#elif defined(__STDC__)
extern char *pathcollapse(const char *src, char *dst, boolean show_dir);
#else /* old-style C */
extern char *pathcollapse();
#endif
#ifdef __cplusplus
}
#endif
#endif /* __PATHUTILS_H_ */

View File

@@ -0,0 +1,59 @@
/*
* $TOG: privbuf.h /main/5 1999/10/15 17:23:22 mgreess $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1993,1994,1996 Hewlett-Packard Company.
* (c) Copyright 1993,1994,1996 International Business Machines Corp.
* (c) Copyright 1993,1994,1996 Sun Microsystems, Inc.
* (c) Copyright 1993,1994,1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
#ifndef __PRIVBUF_H_
#define __PRIVBUF_H_
#ifdef DOMAIN_ALLOW_MALLOC_OVERRIDE
#include "/usr/include/apollo/shlib.h"
#endif
#ifdef apollo
#include <stdlib.h>
#endif
typedef void (*privbuf_func)(void *v);
#ifdef __PRIVATE_
// this is only for internal library routines needing dynamic buffers:
#include <stddef.h>
#include <stdlib.h>
#if defined(__osf__) || defined(sun)
// The DEC C++ compiler rejects valid inline declarations, claiming
// they have both internal and external linkage.
#else
inline static void *operator new(size_t size) { return malloc((unsigned)size); }
inline static void operator delete(void *p) { if (p) free((char*)p); }
#endif
#include <codelibs/dynarray.h>
declare_array(privbuf_charbuf, char, 128)
declare_array(privbuf_strvec, char*, 128)
struct privbuf_buffer
{
privbuf_func func;
privbuf_charbuf buf;
privbuf_strvec vec;
};
extern void privbuf_freeprivbuf(void *buf);
extern privbuf_buffer *privbuf_allocprivbuf();
#undef __PRIVATE_
#endif /* __PRIVATE_ */
#ifdef __cplusplus
extern "C" {
void privbuf_release(void **var);
}
#else
extern void privbuf_release();
#endif
#endif /* __PRIVBUF_H_ */

View File

@@ -0,0 +1,34 @@
/*
* File: shellutils.h $XConsortium: shellutils.h /main/3 1995/10/26 16:13:31 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.
*/
#ifndef __SHELLUTILS_H_
#define __SHELLUTILS_H_
#ifdef __cplusplus
extern "C"
{
char const *const *shellscan(char const *str, int *argc = (int *)0,
unsigned opts = 0);
}
#else
extern char **shellscan();
#endif
#define SHX_NOGLOB 0x0001
#define SHX_NOTILDE 0x0002
#define SHX_NOVARS 0x0004
#define SHX_NOQUOTES 0x0008
#define SHX_NOSPACE 0x0010
#define SHX_NOMETA 0x0020
#define SHX_NOCMD 0x0040
#define SHX_COMPLETE 0x0080
#define SHX_NOGRAVE 0x0040 /* Obsolete, use NOCMD */
#endif /* __SHELLUTILS_H_ */

View File

@@ -0,0 +1,147 @@
/*
* File: stringx.h $TOG: stringx.h /main/5 1999/10/15 17:23:52 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.
*/
#ifndef __STRINGX_H_
#define __STRINGX_H_
#ifdef DOMAIN_ALLOW_MALLOC_OVERRIDE
#include "/usr/include/apollo/shlib.h"
#endif
#ifdef apollo
#include <stdlib.h>
#endif
#include <stddef.h>
#include <string.h>
#include <codelibs/boolean.h>
#define streq(a,b) (strcmp(a,b) == 0)
/* private buffer variables */
extern void *_strsep_privbuf;
extern void *_strcmbn_privbuf;
#if defined(__cplusplus)
extern "C"
{
#endif
#if defined(__cplusplus) || defined(__STDC__)
#if !defined(__osf__) && !defined(sun)
/* The DEC C++ compiler rejects this, claiming it has both */
/* internal and external linkage. */
char *strnew(size_t len);
void strfree(const char *s);
#endif
char *strstrx(char *s1, const char *s2);
char *strrstrx(char *s1, const char *s2);
int strwcmp(const char *pattern, const char *str);
int strwcmpi(const char *pattern, const char *str);
char *strwpat(const char *pattern);
char *strend(const char *str);
unsigned strhash(const char *key);
unsigned strhashi(const char *key);
char *strupper(char *str);
char *strlower(char *str);
#ifdef __cplusplus
char *strtokx(char *&ptr, const char *sep);
# if !defined(__osf__) && !defined(linux)
char **strsep(const char *str, const char *sep,
boolean whsp = TRUE, int *num = NULL);
# if !defined(__osf__)
const char *strcmbn(const char **vec, const char *sep = " ");
# endif
# endif
#else /* __STDC__ */
char *strtokx(char **ptr, const char *sep);
# if !defined(linux)
char **strsep(const char *str, const char *sep,
boolean whsp, int *num);
#endif
#ifndef __osf__
const char *strcmbn(const char **vec, const char *sep);
#endif
#endif /* __STDC__ */
#ifdef __OBSOLETE
size_t nl_strlen(const char *str); /* __OBSOLETE */
int strcharsize(const char *str); /* __OBSOLETE */
#endif /* __OBSOLETE */
#else /* C */
extern void strfree();
extern char *strstrx(), strrstrx();
extern int strwcmp(), strwcmpi();
extern char *strwpat();
extern char *strend();
extern char *strtokx();
extern unsigned strhash();
extern unsigned strhashi();
extern char *strupper(), *strlower();
#ifdef __OBSOLETE
extern int strcharsize(); /* __OBSOLETE */
extern size_t nl_strlen(); /* __OBSOLETE */
#endif /* __OBSOLETE */
#endif /* C */
#if defined(__cplusplus)
}
#if defined(apollo) || defined(__aix) || defined(USL) || defined(__uxp__) || defined(__osf__)
#include <stdlib.h>
#else
#include <malloc.h>
#endif /* apollo */
inline char *strnew(size_t len) { return (char*)malloc(len + 1); }
#if defined(sun) || defined(__sun) || defined(USL) || defined(__uxp__)
inline void strfree(const char *s)
{ if (s != NULL) free((char *)s); }
#else
inline void strfree(const char *s)
#if defined(__hpux) || defined(__osf__)
{ if (s != NULL) free((void *)s); }
#else
{ if (s != NULL) free((const void *)s); }
#endif /* __hpux */
#endif
#if defined(bsd)
inline char *strdup(const char *s)
{ return strcpy((char*)malloc(strlen(s) + 1), s); }
#endif
/* private buffer funcs - we use inlines to handle default args properly */
#else /* C || __STDC__ */
#define strnew(len) ((char*)malloc((len) + 1))
#define strbld strblds
/* macros for funcs that work on top of privbuf versions */
/* for backward compatibility only - __OBSOLETE */
#ifdef __OBSOLETE
#define strpos strstrx /* __OBSOLETE */
#define strrpos strrstrx /* __OBSOLETE */
#endif /* __OBSOLETE */
#endif /* C || __STDC__ */
#endif /* __STRINGX_H_ */