| 1 |
/* @(#)subproc.h 19.1 (ESO-IPG) 02/25/03 13:41:47 */ |
| 2 |
/*--------------------------------------------------------------------- |
| 3 |
* $Date: 2003-06-04 14:49:18 $ $Revision: 1.1.1.1 $ |
| 4 |
*--------------------------------------------------------------------- |
| 5 |
* Copyright (c) 1992, Visual Edge Software Ltd. |
| 6 |
* |
| 7 |
* ALL RIGHTS RESERVED. Permission to use, copy, modify, and |
| 8 |
* distribute this software and its documentation for any purpose |
| 9 |
* and without fee is hereby granted, provided that the above |
| 10 |
* copyright notice appear in all copies and that both that |
| 11 |
* copyright notice and this permission notice appear in supporting |
| 12 |
* documentation, and that the name of Visual Edge Software not be |
| 13 |
* used in advertising or publicity pertaining to distribution of |
| 14 |
* the software without specific, written prior permission. The year |
| 15 |
* included in the notice is the year of the creation of the work. |
| 16 |
*--------------------------------------------------------------------- |
| 17 |
* File_Description_Section |
| 18 |
*--------------------------------------------------------------------*/ |
| 19 |
|
| 20 |
#ifndef SUBPROC_H |
| 21 |
#define SUBPROC_H |
| 22 |
|
| 23 |
/*--- include files ---*/ |
| 24 |
#include "uxproto.h" |
| 25 |
#include <ctype.h> |
| 26 |
#include <stdio.h> |
| 27 |
#include <string.h> |
| 28 |
/* |
| 29 |
#include <malloc.h> |
| 30 |
*/ |
| 31 |
#include <valloc.h> |
| 32 |
|
| 33 |
#include <X11/Intrinsic.h> |
| 34 |
#include <X11/X.h> |
| 35 |
|
| 36 |
#include "UxSubproc.h" |
| 37 |
#include "uimx_cat.h" |
| 38 |
#include "misc1_ds.h" |
| 39 |
#include "global.h" |
| 40 |
|
| 41 |
#ifdef __cplusplus |
| 42 |
extern "C" { /* C++ compatability */ |
| 43 |
#endif /* __cplusplus */ |
| 44 |
|
| 45 |
/*--- macro symbolic constants ---*/ |
| 46 |
|
| 47 |
#ifdef RUNTIME |
| 48 |
#define UxError(msg) UxStandardError((msg)) |
| 49 |
#endif /* RUNTIME */ |
| 50 |
|
| 51 |
/* Provide 32 entries which is the maximum number of |
| 52 |
* of tty/pty pairs for one process on most extended |
| 53 |
* architectures. Pseudo terminals are only in use if |
| 54 |
* a subprocess is between a Run - Exit cycle. Double |
| 55 |
* the number of subprocess structures should suffice. |
| 56 |
* Refered to in the functions UxDeleteSubproc and GetSp. |
| 57 |
*/ |
| 58 |
#define MAX_SUBPROC 64 |
| 59 |
|
| 60 |
/* These are the possible values for the field subprocStatus |
| 61 |
* in the structure SubprocInfo_t. |
| 62 |
*/ |
| 63 |
#define UNDEFINED -1 /* the process state is unknown */ |
| 64 |
#define RUNNING 0 /* the process is running */ |
| 65 |
#define EXITING 1 /* the process is exiting */ |
| 66 |
#define DEAD 2 /* the process is dead */ |
| 67 |
#define DELAYED_EXIT 3 /* the process is in a delayed exit state */ |
| 68 |
|
| 69 |
#ifdef SYSV |
| 70 |
# define USE_SYSV_TERMIO |
| 71 |
# define USE_SYSV_PGRP |
| 72 |
#endif /* SYSV */ |
| 73 |
|
| 74 |
/*--- macro functions ---*/ |
| 75 |
/* X/OPEN message catalog macros. These will make the code more compact. */ |
| 76 |
#define CGETS(ms,ds_ms) UxCatGets(MC_MISC1,ms,ds_ms) |
| 77 |
#define error_msg(x) UxStandardError("%s", x); |
| 78 |
|
| 79 |
/*--- types ---*/ |
| 80 |
typedef struct { |
| 81 |
char *process; |
| 82 |
char *defarg; |
| 83 |
char *output_str; |
| 84 |
void (*output_fnt)(); |
| 85 |
void (*exit_cb)(); |
| 86 |
int handle; |
| 87 |
int echo, |
| 88 |
pid; |
| 89 |
int subprocStatus; |
| 90 |
char *user_data; |
| 91 |
XtInputId input_id; |
| 92 |
XtInputId except_id; |
| 93 |
} SubprocInfo_t; |
| 94 |
|
| 95 |
typedef void (*void_func_ptr)(); |
| 96 |
typedef int (*int_func_ptr)(); |
| 97 |
typedef char ** (*char_func_ptr)(); |
| 98 |
|
| 99 |
typedef struct { |
| 100 |
char_func_ptr prepare_command_m; |
| 101 |
int_func_ptr set_parent_side_m; |
| 102 |
int_func_ptr setup_parent_communication_m; |
| 103 |
int_func_ptr start_child_m; |
| 104 |
int_func_ptr set_child_side_m; |
| 105 |
void_func_ptr setup_child_communication_m; |
| 106 |
int_func_ptr exec_subprocess_m; |
| 107 |
void_func_ptr close_communication_m; |
| 108 |
} SubprocMgr_t; |
| 109 |
|
| 110 |
/*--- external functions ---*/ |
| 111 |
extern int UxGetSp UXPROTO((void)); |
| 112 |
extern int UxCheckIndex UXPROTO((handle index)); |
| 113 |
extern void UxSyserr UXPROTO((char *msg1, char *msg2)); |
| 114 |
extern int UxPrintArgs UXPROTO((char **tmp)); |
| 115 |
extern void UxSpCheck UXPROTO((SubprocInfo_t *sp)); |
| 116 |
extern void UxOutputHandler UXPROTO((SubprocInfo_t *sp)); |
| 117 |
extern void UxSpExit UXPROTO((SubprocInfo_t *sp)); |
| 118 |
extern void UxOnExitRunExitCb UXPROTO((int pid, int status)); |
| 119 |
extern char **UxBuildArgs UXPROTO((char *process, char *command_line)); |
| 120 |
extern void UxKillAllSubprocs UXPROTO((void)); |
| 121 |
|
| 122 |
/*--- external variables ---*/ |
| 123 |
extern SubprocInfo_t *UxSpArray[MAX_SUBPROC]; |
| 124 |
extern SubprocMgr_t UxSubprocMgr; |
| 125 |
|
| 126 |
|
| 127 |
#ifdef __cplusplus |
| 128 |
} /* Close scope of 'extern "C"' declaration which encloses file. */ |
| 129 |
#endif /* __cplusplus */ |
| 130 |
|
| 131 |
#endif |