spcP.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * $XConsortium: spcP.h /main/4 1996/05/15 12:01:55 drk $
  25. * Language: C
  26. *
  27. * (c) Copyright 1996 Digital Equipment Corporation.
  28. * (c) Copyright 1988,1993,1994,1996 Hewlett-Packard Company.
  29. * (c) Copyright 1993,1994,1996 International Business Machines Corp.
  30. * (c) Copyright 1993,1994,1996 Sun Microsystems, Inc.
  31. * (c) Copyright 1993,1994,1996 Novell, Inc.
  32. * (c) Copyright 1996 FUJITSU LIMITED.
  33. * (c) Copyright 1996 Hitachi.
  34. */
  35. #ifndef _spcP_h
  36. #define _spcP_h
  37. #include <netdb.h> /* hostent */
  38. #include <termios.h>
  39. #include <bms/bms.h>
  40. #include <bms/Symbolic.h>
  41. #include <bms/XeUserMsg.h>
  42. #include <bms/SbEvent.h>
  43. #include <bms/spc.h>
  44. #include <bms/scoop.h>
  45. #include <bms/connect.h>
  46. #include <bms/MemoryMgr.h>
  47. #include "chars.h"
  48. #include "spcE.h"
  49. #include "spc-obj.h"
  50. /* ---------------------------------------------------------------------- */
  51. #ifndef CDE_CONFIGURATION_TOP
  52. #define CDE_CONFIGURATION_TOP "/etc/opt/dt"
  53. #endif
  54. #ifndef CDE_INSTALLATION_TOP
  55. #define CDE_INSTALLATION_TOP "/usr/dt"
  56. #endif
  57. #define Stdin(chn) chn->file_descs[STDIN]
  58. #define Stdout(chn) chn->file_descs[STDOUT]
  59. #define Stderr(chn) chn->file_descs[STDERR]
  60. /* Some necessary identifiers */
  61. #define OK 0
  62. #define ERROR -1
  63. #define Undefined -1
  64. /* Some character constants */
  65. #define Channel_ByteID (XeChar)'\077'
  66. /* And finally, the common channel identifier */
  67. #ifndef BITSPERBYTE
  68. #define BITSPERBYTE 8
  69. #endif
  70. #define CID_High_Bits (Channel_ByteID << (BITSPERBYTE * (sizeof(int) - 1)))
  71. #define CID_Middle_Bits (0x1010 << BITSPERBYTE)
  72. #define CID_Low_Bits (Channel_ByteID & 0xff)
  73. #define Channel_Identifier (CID_High_Bits | CID_Middle_Bits | CID_Low_Bits)
  74. /*** Note: If device names ever increase from: /dev/ptym/ptyp0, look here ***/
  75. #define PTY_NAMLEN 20
  76. #define EXCEPT_FLAG -1 /* Used for TIOC handling in PTY's */
  77. /* Define lengths of buffers for protocol requests and other sizes of things */
  78. #define REQUEST_HEADER_LENGTH 20
  79. #define MAXREQLEN (SPC_BUFSIZ+REQUEST_HEADER_LENGTH)
  80. #define DEFAULT_ENVP_SIZE 50
  81. /*
  82. **
  83. ** Definitions for select.
  84. **
  85. */
  86. extern int max_fds;
  87. /*
  88. * Macros to access SPC_IOMode bit fields
  89. */
  90. /* These are derived from above spc bit specifications */
  91. #define IS_SPCIO_STDIN(a) (a & SPCIO_WRITEONLY)
  92. #define IS_SPCIO_STDOUT(a) (a & SPCIO_READONLY)
  93. #define IS_SPCIO_STDERR(a) (a & SPCIO_ERRORONLY)
  94. #define IS_SPCIO_SEPARATE(a) (a & SPCIO_SEPARATEREADERROR)
  95. #define IS_SPCIO_NOIO(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_NOIO)
  96. #define IS_SPCIO_WRITEONLY(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_WRITEONLY)
  97. #define IS_SPCIO_READONLY(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_READONLY)
  98. #define IS_SPCIO_READWRITE(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_READWRITE)
  99. #define IS_SPCIO_ERRORONLY(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_ERRORONLY)
  100. #define IS_SPCIO_WRITEERROR(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_WRITEERROR)
  101. #define IS_SPCIO_READERROR(a) ((a & SPCIO_SOURCE_MASK) == SPCIO_READERROR)
  102. #define IS_SPCIO_READWRITEERROR(a)((a&SPCIO_SOURCE_MASK) == SPCIO_READWRITEERROR)
  103. /* Style flags (mutually exclusive) */
  104. #define IS_SPCIO_PIPE(a) ((a & SPCIO_STYLE_MASK) == SPCIO_PIPE)
  105. #define IS_SPCIO_PTY(a) ((a & SPCIO_STYLE_MASK) == SPCIO_PTY)
  106. #define IS_SPCIO_NOIOMODE(a) ((a & SPCIO_STYLE_MASK) == SPCIO_NOIOMODE)
  107. #define IS_SPCIO_LINEEDIT(a) (a & SPCIO_LINEEDIT)
  108. /* Other non-mutually exclusive flags */
  109. #define IS_SPCIO_SYSTEM(a) (a & SPCIO_SYSTEM)
  110. #define IS_SPCIO_LINEORIENTED(a)(a & SPCIO_LINEORIENTED)
  111. #define IS_SPCIO_WAIT(a) (a & SPCIO_WAIT)
  112. #define IS_SPCIO_TOOLKIT(a) (a & SPCIO_USE_XTOOLKIT)
  113. #define IS_SPCIO_SYNC_TERM(a) (a & SPCIO_SYNC_TERMINATOR)
  114. #define IS_SPCIO_USE_LOGFILE(a) (a & SPCIO_USE_LOGFILE)
  115. #define IS_SPCIO_SIGNAL_PGRP(a) (a & SPCIO_SIGNAL_PGRP)
  116. #define IS_SPCIO_FORCE_CONTEXT(a) (a & SPCIO_FORCE_CONTEXT)
  117. #define SPCIO_HAS_DATA 0x2000 /* Used for line-oriented IO */
  118. #define HAS_DATA(chn) (((chn->IOMode) & SPCIO_HAS_DATA) == SPCIO_HAS_DATA)
  119. #define SPCIO_UNUSED3 0x80000
  120. /* Flags for internal use only */
  121. #define SPCIO_DEALLOC_ARGV 0x4000
  122. #define IS_SPCIO_DEALLOC_ARGV(a) (a & SPCIO_DEALLOC_ARGV)
  123. #define SPCIO_DELAY_CLOSE 0x8000
  124. #define IS_SPCIO_DELAY_CLOSE(a) (a & SPCIO_DELAY_CLOSE)
  125. #define SPCIO_DO_CLOSE 0x10000
  126. #define IS_SPCIO_DO_CLOSE(a) (a & SPCIO_DO_CLOSE)
  127. /* Make sure that STATE_OFFSET is always such that you will clear the
  128. IOMode flags */
  129. #define STATE_OFFSET 24
  130. #define SPCIO_ACTIVE (1<<STATE_OFFSET) /* channel has subprocess */
  131. #define SPCIO_DATA (2<<STATE_OFFSET) /* channel has data */
  132. #define IS_SPCIO_ACTIVE(a) (a & SPCIO_ACTIVE)
  133. #define IS_SPCIO_DATA(a) (a & SPCIO_DATA)
  134. #define IS_ACTIVE(chn) (IS_SPCIO_ACTIVE(chn->IOMode))
  135. #define IS_DATA(chn) (IS_SPCIO_DATA(chn->IOMode))
  136. #define IS_REMOTE(chn) (chn->connection)
  137. /* SPC state machine */
  138. #define CHANNEL_STATE(io_mode) ((io_mode)>>STATE_OFFSET & 0x3)
  139. #define MAKE_CHANNEL_STATE(io_mode, _state) \
  140. (((_state)<<STATE_OFFSET) | (io_mode & ~(0x3<<STATE_OFFSET)))
  141. #define MAKE_STATE(_data,_proc) ((_data)<<1 | (_proc))
  142. #define MAKE_STATE_INDEX(_old,_new) ((_old)<<2 | (_new))
  143. #define DATA_LINE(_state) ((_state) >> 1)
  144. #define PROC_LINE(_state) ((_state) & 1)
  145. /* Defaults */
  146. #define DEFAULT_CHANNEL_CLASS pty_channel_class
  147. #define IS_SPCIO_DEFAULT(a) !((a) & SPCIO_STYLE_MASK)
  148. #define SPCIO_DEFAULT SPCIO_PTY
  149. /*
  150. * Type definitions for SPC file descriptors
  151. */
  152. /* Definitions for wires */
  153. #define READ_SIDE 0
  154. #define WRITE_SIDE 1
  155. /*
  156. * Constants and external declarations for managing the SPC daemon's
  157. * logfile list, exit timer and process id list.
  158. */
  159. #define SPCD_DEFAULT_TIMEOUT 10
  160. #define SPCD_DEAD_PROCESS -1
  161. #define SPCD_NO_TIMER -1
  162. #define SPCD_REQUEST_PENDING 1
  163. #define SPCD_NO_REQUEST_PENDING 0
  164. /*
  165. * Constants for the 'SPC_who_am_i' variable.
  166. */
  167. #define SPC_I_AM_A_CLIENT 1
  168. #define SPC_I_AM_A_DAEMON 2
  169. /*
  170. * External variables defined in noio.c
  171. */
  172. extern char **SPC_logfile_list;
  173. /*
  174. * External variables defined in spc-exec.c
  175. */
  176. extern pid_t *SPC_pid_list;
  177. extern char *SPC_mount_point_env_var;
  178. /*
  179. * External variables defined in spc-obj.c
  180. */
  181. extern int SPC_who_am_i;
  182. /*
  183. * The client version number.
  184. */
  185. extern int SPC_client_version_number;
  186. /*
  187. * The name of the directory used for authentication and
  188. * for temporary logfiles.
  189. */
  190. extern XeString SPCD_Authentication_Dir;
  191. /*
  192. * Definitions for file locations
  193. */
  194. #define SPCD_ENV_INSTALL_DIRECTORY CDE_INSTALLATION_TOP "/config"
  195. #define SPCD_ENV_CONFIG_DIRECTORY CDE_CONFIGURATION_TOP "/config"
  196. #define SPCD_ENV_HOME_DIRECTORY ".dt"
  197. #define SPCD_ENV_FILE "dtspcdenv"
  198. #define SPCD_PROG_NAME "dtspcd"
  199. /*
  200. * The name of the remove environment 'keyword'.
  201. */
  202. #define SPC_REMOVE_VAR "unset"
  203. /*
  204. ***
  205. *** Start typedefs
  206. ***
  207. */
  208. typedef int Files[3]; /* Standard set of file descriptors */
  209. typedef int SPC_IOMode; /* Sub-Process Control IO Mode Bits */
  210. /* This is a "wire", a data structure used in creating communication paths
  211. to / from a subprocess. It encapsulates all the information needed by
  212. all types of paths */
  213. typedef struct _wire {
  214. SPC_IOMode flags; /* Basically, acts like an IOMode, but
  215. we are only interested in its data bits */
  216. int fd[2];
  217. XeString master_name, slave_name;
  218. int read_toolkit_id, except_toolkit_id;
  219. struct termios master_termio, slave_termio;
  220. struct _wire *next;
  221. } Wire;
  222. typedef struct _buffered_data {
  223. XeChar data[MAXREQLEN];
  224. int len, offset;
  225. } buffered_data, *buffered_data_ptr;
  226. typedef enum {
  227. SPC_Input,
  228. SPC_Exception,
  229. SPC_Terminator,
  230. SPC_Client
  231. } SPC_Callback_Condition;
  232. /*
  233. * Type definition for an SPC Connection (a socket to SPCD server)
  234. */
  235. typedef struct _SPC_Connection {
  236. /* The host on which other end resides */
  237. XeChar hostname[MAXHOSTNAMELEN];
  238. int sid; /* The Socket ID */
  239. XeChar connected; /* Whether server connection is made */
  240. struct hostent *local; /* socket address information for */
  241. struct hostent *remote; /* ... local, remote machine */
  242. int termination_id;
  243. struct _SPC_Connection
  244. *next; /* The next server in the list */
  245. XeQueue queued_remote_data; /* queue for remote data */
  246. int protocol_version; /* Version of protocol of remote */
  247. XeString hostinfo; /* Info about remote, (type, os, etc) */
  248. } SPC_Connection, *SPC_Connection_Ptr;
  249. /*
  250. * This next macro returns a newly allocated string.
  251. * The caller should free it.
  252. */
  253. #define CONNECTION_HOSTNAME(conn) \
  254. ((conn->remote) ? XeFindShortHost((conn)->remote->h_name) : \
  255. Xestrdup(XeString_Empty))
  256. /*
  257. * Type definition for an SPC Channel
  258. */
  259. typedef int (*SPC_F_read_filter)(SPC_Channel_Ptr, int, XeString, int);
  260. typedef struct _SPC_Channel { /* Sub-Process Control Channel */
  261. /* stuff for SCOOP */
  262. channel_clasp class_ptr;
  263. root_object_part
  264. /* First, we place a channel identifier, so we can check cid (see below) */
  265. int identifier; /* The common identifier for every channel */
  266. /* The setup request information */
  267. SPC_Connection *connection; /* The connection structure (Local = NULL) */
  268. XeString context_dir; /* Directory to "cd" to during spawn */
  269. XeString path; /* The command path pointer */
  270. XeString *argv; /* The command argument list pointers */
  271. XeString *envp; /* The command environment list pointers */
  272. SPC_IOMode IOMode; /* The IO Control Mode settings */
  273. /* User defined data handling procedures */
  274. SbInputHandlerProc Input_Handler;
  275. /* The user input handler routine */
  276. void * client_data; /* The user associated input handler data */
  277. /* Useful (ie.) as input Widget */
  278. SPC_TerminateHandlerType Terminate_Handler; /* The SIGCLD user handler routine */
  279. void * Terminate_Data; /* The client_data for user handler routine */
  280. /* Now the recorded information */
  281. int pid; /* The child Process IDentification number */
  282. /* Also the RPID for a Remote channel */
  283. int cid; /* The remote Channel IDentification number */
  284. int status; /* The Process status */
  285. Wire *wires[3]; /* The read side/write side file descriptors */
  286. Files file_descs; /* Which file descriptors to use */
  287. Wire *wire_list; /* Pointer to list of wires we have
  288. (used for reset & pre_fork processing) */
  289. buffered_data_ptr linebufs[3]; /* Buffers for lined oriented IO */
  290. SPC_F_read_filter read_filter;
  291. /* Function to use to read. It may
  292. be the actual read method, or it
  293. may be a filter for newlines
  294. (which would eventually call the read
  295. method) */
  296. XeQueue queued_remote_data; /* queue for remote data */
  297. XeString logfile; /* logfile name for SPCIO_USE_LOGFILE */
  298. int close_timeout; /* Amount of time to wait for a pty close */
  299. struct _SPC_Channel *next; /* The next active channel */
  300. int sync_pipe[2]; /* Only used in pty.c for __hpux_pty */
  301. } SPC_Channel;
  302. /* The default shell when none can be derived */
  303. #ifdef hpV4
  304. #define DEFAULT_SHELL (XeString ) "/usr/bin/sh"
  305. #else
  306. #define DEFAULT_SHELL (XeString ) "/bin/sh"
  307. #endif /* hpV4 */
  308. /* Some macros which define the bit field portions of a wait() status */
  309. /* NOTE: These should be independent of integer word size */
  310. #define WAIT_STATUS_MASK 0xff
  311. #define IS_WAIT_STATUS_STOPPED 0177
  312. #define IS_WAIT_STATUS_EXITED 0000
  313. #define IS_WAIT_STATUS_DUMPED 0200
  314. typedef unsigned long SPCInputId;
  315. /* SPC/local.c */
  316. int close_local_channel_object (SPC_Channel_Ptr channel);
  317. int write_local_channel_object (SPC_Channel_Ptr channel, XeString buffer, int nbytes);
  318. int signal_local_channel_object (SPC_Channel_Ptr channel, int sig);
  319. int local_channel_object_wait_for_termination (SPC_Channel_Ptr channel);
  320. int remove_logfile_local_channel_object (SPC_Channel_Ptr channel);
  321. void local_channel_object_input_handler (void * client_data, int *source, SPCInputId *id);
  322. int local_channel_object_send_eof(SPC_Channel_Ptr channel);
  323. /* noio.c */
  324. void noio_channel_class_init (object_clasp c);
  325. SPC_Channel_Ptr open_noio_channel_object (SPC_Channel_Ptr channel, int iomode, XeString hostname);
  326. int read_noio_channel_object (SPC_Channel_Ptr channel, int connector, XeString buffer, int nbytes);
  327. int write_noio_channel_object (SPC_Channel_Ptr channel, XeString buffer, int nbytes);
  328. int pre_fork_noio_channel_object (SPC_Channel_Ptr channel);
  329. int post_fork_noio_channel_object (SPC_Channel_Ptr channel, int parentp);
  330. int reset_noio_channel_object (SPC_Channel_Ptr channel);
  331. int attach_noio_channel_object (SPC_Channel_Ptr channel, int);
  332. void noio_channel_object_input_handler (void * client_data, int *source, SPCInputId *id);
  333. int send_eof_noio_channel_object(SPC_Channel_Ptr channel);
  334. int set_termio_noio_channel_object(SPC_Channel_Ptr, int, int, struct termios *);
  335. /* pipe.c */
  336. void pipe_channel_class_init (object_clasp c);
  337. Wire *getpipe (Wire *prevwire);
  338. SPC_Channel_Ptr open_pipe_channel_object (SPC_Channel_Ptr channel, int iomode, XeString hostname);
  339. int read_pipe_channel_object (SPC_Channel_Ptr channel, int connector, XeString buffer, int nbytes);
  340. int pre_fork_pipe_channel_object (SPC_Channel_Ptr channel);
  341. int post_fork_pipe_channel_object (SPC_Channel_Ptr channel, int parentp);
  342. int reset_pipe_channel_object (SPC_Channel_Ptr channel);
  343. int attach_pipe_channel_object (SPC_Channel_Ptr channel, int);
  344. int add_input_pipe_channel_object (SPC_Channel_Ptr channel, SbInputHandlerProc handler, void *data);
  345. /* pty.c */
  346. void pty_channel_class_init (object_clasp c);
  347. SPC_Channel_Ptr open_pty_channel_object (SPC_Channel_Ptr channel, int iomode, XeString hostname);
  348. int read_pty_channel_object (SPC_Channel_Ptr channel, int connector, XeString buffer, int nbytes);
  349. int pre_fork_pty_channel_object (SPC_Channel_Ptr channel);
  350. int post_fork_pty_channel_object (SPC_Channel_Ptr channel, int parentp);
  351. int reset_pty_channel_object (SPC_Channel_Ptr channel);
  352. int attach_pty_channel_object (SPC_Channel_Ptr channel, int pid);
  353. int add_input_pty_channel_object (SPC_Channel_Ptr channel, SbInputHandlerProc handler, void *data);
  354. int set_termio_pty_channel_object(SPC_Channel_Ptr channel, int, int,
  355. struct termios *);
  356. struct termios *SPC_Get_Current_Termio(void);
  357. int SPC_Setpgrp(int);
  358. /* remote.c */
  359. void remote_channel_class_init (object_clasp c);
  360. Wire *get_new_remote_wire (Wire *prevwire);
  361. SPC_Channel_Ptr open_remote_channel_object (SPC_Channel_Ptr channel, int iomode, XeString hostname);
  362. int close_remote_channel_object (SPC_Channel_Ptr channel);
  363. int reset_remote_channel_object (SPC_Channel_Ptr channel);
  364. int exec_proc_remote_channel_object (SPC_Channel_Ptr channel);
  365. int write_remote_channel_object (SPC_Channel_Ptr channel, XeString buffer, int len);
  366. int read_remote_channel_object (SPC_Channel_Ptr channel, int connection, XeString buffer, int len);
  367. int signal_remote_channel_object (SPC_Channel_Ptr channel, int sig);
  368. int attach_remote_channel_object (SPC_Channel_Ptr channel, int pid);
  369. int remove_logfile_remote_channel_object (SPC_Channel_Ptr channel);
  370. int add_input_remote_channel_object (SPC_Channel_Ptr channel, SbInputHandlerProc handler, void *data);
  371. int SPC_Debug_Mode (SPC_Channel_Ptr channel, XeString file);
  372. int send_eof_remote_channel_object(SPC_Channel_Ptr channel);
  373. int set_termio_remote_channel_object(SPC_Channel_Ptr channel,
  374. int, int, struct termios *);
  375. /* spc-env.c */
  376. XeString SPC_Getenv (XeString var, XeString *envp);
  377. XeString *SPC_Putenv (XeString val, XeString *envp);
  378. XeString *SPC_Add_Env_File (XeString filename, XeString *envp);
  379. XeString *SPC_Create_Default_Envp (XeString *old_envp);
  380. XeString *SPC_Fixup_Environment (XeString *envp, SPC_Channel_Ptr channel);
  381. XeString *SPC_Merge_Envp (XeString *dest_envp, XeString *source_envp);
  382. void SPC_Free_Envp (XeString *envp);
  383. /* spc-exec.c */
  384. int SPC_Setup_Synchronous_Terminator (void);
  385. SPC_Connection_Ptr SPC_Channel_Terminator_Connection (SPC_Channel_Ptr channel);
  386. void SPC_Close_Unused (void);
  387. int SPC_MakeSystemCommand (SPC_Channel_Ptr channel);
  388. void SPC_Child_Terminated(int);
  389. int exec_proc_local_channel_object (SPC_Channel_Ptr channel);
  390. /* spc-net.c */
  391. Boolean SPC_Init_Local_Host_Info (void);
  392. int SPC_Local_Hostname (XeString hostname);
  393. SPC_Connection_Ptr SPC_Open_Connection (XeString hostname);
  394. int SPC_Open_Socket (SPC_Connection_Ptr conn, int type);
  395. int SPC_Contact_Server (SPC_Connection_Ptr connection);
  396. SPC_Connection_Ptr SPC_Init_Child (SPC_Connection_Ptr conn, int from);
  397. SPC_Connection_Ptr SPC_Standalone_Daemon (SPC_Connection_Ptr conn);
  398. int SPC_Inetd_Daemon (SPC_Connection_Ptr conn);
  399. SPC_Connection_Ptr SPC_Start_Daemon (int standalone);
  400. /* spc-obj.c */
  401. void spc_init_fds(void);
  402. object *alloc_channel_object (object_clasp c);
  403. void channel_class_init (object_clasp c);
  404. int SPC_ResetTerminator(void);
  405. int SPC_Initialize (void);
  406. SPC_Channel_Ptr SPC_Initialize_Channel (XeString hostname, int iomode);
  407. void SPC_Channel_Terminated (SPC_Channel_Ptr channel);
  408. int SPC_Check_Style (int iomode);
  409. int SPC_Transform_Iomode (int iomode);
  410. int SPC_Newline_Filter (SPC_Channel_Ptr channel, int connector, XeString buffer, int ntoread);
  411. int SPC_Input_Handler (SPC_Channel_Ptr channel, int connector);
  412. SPC_Channel_Ptr open_channel_object (SPC_Channel_Ptr channel, int iomode, XeString hostname);
  413. int close_channel_object (SPC_Channel_Ptr channel);
  414. int read_channel_object (SPC_Channel_Ptr channel, int connector, XeString buffer, int nbytes);
  415. int write_channel_object (SPC_Channel_Ptr channel, XeString buffer, int nbytes);
  416. int reset_channel_object (SPC_Channel_Ptr channel);
  417. int pre_fork_channel_object (SPC_Channel_Ptr channel);
  418. int post_fork_channel_object (SPC_Channel_Ptr channel, int parentp);
  419. int exec_proc_channel_object (SPC_Channel_Ptr channel);
  420. int signal_channel_object (SPC_Channel_Ptr channel, int sig);
  421. int channel_object_wait_for_termination (SPC_Channel_Ptr channel);
  422. int attach_channel_object (SPC_Channel_Ptr channel, int pid);
  423. int add_input_channel_object (SPC_Channel_Ptr channel, SbInputHandlerProc handler, void *data);
  424. int remove_logfile_channel_object (SPC_Channel_Ptr channel);
  425. /* spc-sm.c */
  426. int SPC_Change_State (SPC_Channel_Ptr channel, int connector, int data_line, int process_line);
  427. int error_fun (SPC_Channel_Ptr channel, int connector);
  428. int connector_eof (SPC_Channel_Ptr channel, int connector);
  429. int connector_eof_with_reset (SPC_Channel_Ptr channel, int connector);
  430. int sigcld_with_reset (SPC_Channel_Ptr channel, int connector);
  431. /* spc-xt.c */
  432. typedef void (*spc_handler_func_type) (void *, int *, SPCInputId *);
  433. int SPC_Wait_For_Termination (SPC_Channel_Ptr channel);
  434. void SPC_XtBreak (void);
  435. void SPC_XtAddInput (SPC_Channel_Ptr channel, int *id_addr, int fd, spc_handler_func_type handler, SPC_Callback_Condition condition);
  436. void SPC_XtRemoveInput (int *id_addr, SPC_Callback_Condition condition);
  437. /* spc-util.c */
  438. Wire *get_new_wire (void);
  439. void free_wire (Wire *wire);
  440. SPC_Channel_Ptr SPC_Find_PID (int pid);
  441. int spc_close (int fd);
  442. int spc_dup2 (int from, int to);
  443. int SPC_fd_to_connector (SPC_Channel_Ptr channel, int fd);
  444. XeString *Alloc_Argv (int n);
  445. void SPC_Conditional_Packet_Handler (void * client_data, int *source, SPCInputId *id);
  446. int sprintf_len (XeString s, XeString format, ...);
  447. typedef Boolean (path_search_predicate)(XeString, XeString, XeString);
  448. Boolean path_search (XeString path, XeString filename, path_search_predicate p);
  449. /* spc-error.c */
  450. XeString SPC_copy_string (XeString str);
  451. void SPC_Error (int error, ...);
  452. int SPC_Make_Log_Filename (XeString name, int unique);
  453. int SPC_Open_Log (XeString filename, int unique);
  454. int SPC_Close_Log (void);
  455. int SPC_Write_Log (XeString str);
  456. int SPC_Format_Log (XeString format, ...);
  457. SPCError *SPC_Lookup_Error (int errornum);
  458. SPCError *SPC_Lookup_Error (int errornum);
  459. /* spc-termio.c */
  460. XeString SPC_Decode_Termios( struct termios * );
  461. void SPC_Encode_Termios(XeString buff, struct termios *tio);
  462. #endif /* _spcP_h */