ecu.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. /*+-----------------------------------------------------------------------
  2. ecu.h -- TuckerWare Extended Calling Unit
  3. wht@wht.net
  4. ------------------------------------------------------------------------*/
  5. /*+:EDITS:*/
  6. /*:04-26-2000-11:15-wht@bob-RELEASE 4.42 */
  7. /*:01-08-2000-12:52-wht@menlo-rethink sockserve I/O */
  8. /*:01-02-2000-14:01-wht@menlo-add proc_option_continueOnLineError */
  9. /*:11-03-1997-02:16-wht@kepler-4.08a-add proc_option_localvars */
  10. /*:02-09-1997-19:37-wht@yuriatin-mv find_procedure defn here */
  11. /*:01-24-1997-02:36-wht@yuriatin-SOURCE RELEASE 4.00 */
  12. /*:09-11-1996-19:59-wht@yuriatin-3.48-major telnet,curses,structural overhaul */
  13. /*:09-09-1996-03:39-wht@yuriatin-add LINST_TELNETFAIL */
  14. /*:01-27-1996-20:25-wht@n4hgf-move child_pid decl here */
  15. /*:11-23-1995-11:20-wht@kepler-source control 3.37 for tsx-11 */
  16. /*:11-14-1995-10:23-wht@kepler-3.37.80-source control point: SOCKETS */
  17. /*:11-13-1995-12:16-wht@kepler-need_rcvr_restart now func moved to ecurcvr.c */
  18. /*:11-03-1995-17:32-wht@wwtp1-add enum linst func decls */
  19. /*:10-14-1995-17:08-wht@kepler-'struct termio' to 'struct TERMIO' */
  20. /*:06-12-1995-15:27-wht@n4hgf-add externs for uucp euid globals */
  21. /*:03-12-1995-00:40-wht@kepler-eliminate obsolete CURR_DIRSIZ */
  22. /*:01-12-1995-15:19-wht@n4hgf-apply Andrew Chernov 8-bit clean+FreeBSD patch */
  23. /*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
  24. /*:03-15-1994-14:23-wht@n4hgf-correct doc: ecuxenix.c now ecugrabbag.c */
  25. /*:01-16-1994-17:01-wht@n4hgf-restore SIGCHLD equate for NetBSD */
  26. /*:12-12-1993-13:32-wht@n4hgf-MOTSVR3 port */
  27. /*:12-12-1993-13:03-wht@fep-use ecu_time.h for Ftime/gettimeofday */
  28. /*:12-11-1993-11:27-wht@n4hgf-lost an endif */
  29. /*:12-10-1993-22:09-wht@n4vu-more Linux fixes + no default sun termios */
  30. /*:11-14-1993-15:47-wht@n4hgf-more hpux port */
  31. /*:10-02-1993-22:45-wht@n4hgf-add SIGPTR */
  32. /*:08-01-1993-02:12-wht@n4hgf-add got_delim to LRWT */
  33. /*:09-13-1992-12:52-wht@n4hgf-add tty_is_scoterm */
  34. /*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  35. /*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  36. /*:08-21-1992-13:39-wht@n4hgf-rewire direct/modem device use */
  37. /*:07-21-1992-12:09-wht@n4hgf-3.2v4 only has sys/time.h if TCPRT installed */
  38. /*:04-17-1992-20:10-wht@gyro-default tty, baud and parity moved to config.c */
  39. /*:03-27-1992-16:21-wht@n4hgf-re-include protection for all .h files */
  40. /*:02-13-1992-06:35-wht@n4hgf-when port to many time() can be int/long/time_t */
  41. /*:11-30-1991-13:46-wht@n4hgf-smap conditional compilation reorg */
  42. /*:11-26-1991-20:17-wht@n4hgf-add shm->Ldcdwatch values */
  43. /*:11-26-1991-19:37-wht@n4hgf-add STR_CLASSIFY */
  44. /*:11-13-1991-16:29-wht@n4hgf-use if __STDC__ instead of defined(__STDC__) */
  45. /*:11-11-1991-22:45-wht@n4hgf-redefinition of Ltermio's place in life */
  46. /*:08-25-1991-14:39-wht@n4hgf-SVR4 port thanks to aega84!lh */
  47. /*:08-13-1991-13:53-wht@n4hgf-UNIX and ISC nap() broken; XENIX still wins */
  48. /*:08-09-1991-11:07-wht@n4hgf-configurable lock directory */
  49. /*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  50. /*:01-25-1991-06:08-wht@n4hgf-mulltiple #define of CFG_EcuLibDir */
  51. /*:01-22-1991-14:33-wht@n4hgf-XENIX calloc/memmove fix */
  52. /*:01-01-1991-21:36-wht@n4hgf-add GCC implies STDC */
  53. /*:08-14-1990-20:39-wht@n4hgf-ecu3.00-flush old edit history */
  54. #ifndef _ecu_h
  55. #define _ecu_h
  56. #define pprintf printf
  57. #include "ecu_config.h"
  58. #if !defined(STDIO_H_INCLUDED)
  59. #include <stdio.h>
  60. #endif
  61. #include <signal.h>
  62. /*
  63. * small dialect correction
  64. */
  65. #if !defined(SIGCLD)
  66. #define SIGCLD SIGCHLD
  67. #endif
  68. #include "ecu_types.h"
  69. #include <ctype.h>
  70. #include <errno.h>
  71. #include <string.h>
  72. #include <memory.h>
  73. #include <fcntl.h>
  74. #include "ecu_stat.h"
  75. #include "ecu_time.h"
  76. #ifndef CFG_HasStrerror /* let string.h do it if it will */
  77. char *strerror();
  78. #endif
  79. #if !defined(OMIT_TERMIO_REFERENCES)
  80. #include "ecutermio.h"
  81. #endif /* OMIT_TERMIO_REFERENCES */
  82. #include "ecushm.h"
  83. #include "termecu.h"
  84. #include "ttynaming.h"
  85. /*
  86. * The various flavors of hardware flow control, most of them
  87. * flakey or incomplete .... follow the identifer road
  88. * (fgrep HW_FLOW_CONTROL) to see what it takes to
  89. * include your vendor's attempt.
  90. */
  91. #if defined(RTSFLOW) && !defined(HW_FLOW_CONTROL) /* SCO */
  92. #define HW_FLOW_CONTROL
  93. #endif
  94. #if defined(CRTSFL) && !defined(HW_FLOW_CONTROL) /* 3.2v4 and later */
  95. #define HW_FLOW_CONTROL
  96. #endif
  97. #if defined(RTSXOFF) && !defined(HW_FLOW_CONTROL) /* SVR4 */
  98. #define HW_FLOW_CONTROL
  99. #endif
  100. #if defined(CRTSCTS) && !defined(HW_FLOW_CONTROL) /* sun */
  101. #define HW_FLOW_CONTROL
  102. #endif
  103. /*
  104. * Communication line variables that are not in shared memory
  105. *
  106. * TERMIO is defined 'termio' or 'termios' as appropriate
  107. *
  108. * One special note: Ltermio points to a buffer in shared memory
  109. * used to hold the line's current termio structure. The shared
  110. * memory buffer is defined as a simple array of longs so that
  111. * friend code need not include termio.h if it does not need it.
  112. * What's more, due to sgtty-based curses code, XENIX versions
  113. * cannot include termio.h in some modules. ecushm.c has runtime
  114. * code to initialize Ltermio to point to shm->Ltiobuf and to
  115. * make sure shm->Ltiobuf is long enough.
  116. */
  117. #if defined(DECLARE_LINEVARS_PUBLIC)
  118. #if !defined(OMIT_TERMIO_REFERENCES)
  119. struct TERMIO *Ltermio; /* attributes for the line to remote */
  120. #endif
  121. uchar Ldial_debug_level;
  122. #else
  123. #if !defined(OMIT_TERMIO_REFERENCES)
  124. extern struct TERMIO *Ltermio;
  125. #endif
  126. extern uchar Ldial_debug_level;
  127. #endif
  128. extern int zero_length_read_detected; /* see lgetc_xmtr in eculine.c */
  129. #ifdef M_I286
  130. long time();
  131. #endif
  132. long Nap();
  133. #if __STDC__ == 1 /* sigh ... malloc and such types;
  134. * just a guess */
  135. #define VTYPE void
  136. #define VOLATILE volatile
  137. #ifndef CFG_SigType /* doesnt belong here */
  138. #define CFG_SigType void
  139. #endif
  140. #else
  141. #define VTYPE char
  142. #define VOLATILE
  143. #ifndef CFG_SigType /* doesnt belong here */
  144. #define CFG_SigType int
  145. #endif
  146. #endif
  147. #include "smap.h"
  148. #if defined(CFG_Malloc3X)
  149. #include <malloc.h>
  150. #else
  151. VTYPE *malloc();
  152. VTYPE *calloc();
  153. VTYPE *realloc();
  154. #endif
  155. typedef UINT (*PFU) (); /* pointer to function returning UINT */
  156. typedef char (*PFC) (); /* pointer to function returning char */
  157. typedef int (*PFI) (); /* pointer to function returning integer */
  158. typedef long (*PFL) (); /* pointer to function returning long */
  159. typedef void (*PFV) (); /* pointer to function returning nothing */
  160. typedef CFG_SigType (*SIGPTR) (); /* pointer to signal handler */
  161. /*
  162. * undef M_XENIX must come after any system header inclusion
  163. */
  164. #if defined(M_UNIX)
  165. #undef M_XENIX /* now can truly distinquish between SCO
  166. * XENIX and UNIX */
  167. #endif /* M_UNIX */
  168. /*
  169. * for better source line utilization, frequent use of
  170. * fprintf and stderr warrants the following
  171. */
  172. #define pf printf
  173. #define ff fprintf
  174. #define se stderr
  175. #define so stdout
  176. /*
  177. * console tty information
  178. */
  179. extern int tty_is_multiscreen; /* SCO multiscreen */
  180. extern int tty_is_scoterm; /* SCO scoterm */
  181. extern int tty_is_pty; /* bursty network connection? */
  182. extern int tty_not_char_special; /* /dev/null not considered char
  183. * special */
  184. /*
  185. * uucp euid control
  186. */
  187. extern int setuid_uucp; /* true if ecu is owned by uucp and chmod +s */
  188. extern short uid;
  189. extern short euid;
  190. extern short uid_uucp;
  191. /*
  192. * current working directory of process
  193. */
  194. extern char curr_dir[ECU_MAXPN];
  195. /*
  196. * useful macros
  197. */
  198. #undef max /* just in case they ... */
  199. #undef min /* ... were already defined */
  200. #define max(a,b) (((a) > (b)) ? (a) : (b))
  201. #define min(a,b) (((a) < (b)) ? (a) : (b))
  202. /*
  203. * decide how to write to logfile
  204. */
  205. #define LOGPUTC putc /* fputc() or putc() */
  206. #define TTYIN 0
  207. #define TTYOUT 1 /* ditto tty output */
  208. #define TTYERR 2 /* ditty tty output error channel */
  209. /*
  210. * xbell codes (see ecugrabbag.c)
  211. */
  212. enum xbell
  213. {
  214. XBELL_DONE = 1, /* octaves or morse 'd' */
  215. XBELL_ATTENTION, /* morse .-.-.- ATTENTION */
  216. XBELL_C, /* morse -.-. C */
  217. XBELL_3T /* 3 Ts --- really 'o' */
  218. };
  219. /*
  220. * lopen() and related routines error codes
  221. */
  222. enum linst
  223. {
  224. LINST_OK = 0, /* no error */
  225. LINST_INVALID = -1000, /* for invalid tty name */
  226. LINST_UNKPID, /* unknown pid using line */
  227. LINST_LCKERR, /* lock file open error */
  228. LINST_NODEV, /* device does not exist */
  229. LINST_OPNFAIL, /* could not access line */
  230. LINST_ALREADY, /* line already open */
  231. LINST_ENABLED, /* line enabled for login */
  232. LINST_ENABLED_IN_USE, /* line in use by incoming login */
  233. LINST_DIALOUT_IN_USE, /* line in use by another dial out */
  234. LINST_NOPTY, /* pty not supported */
  235. LINST_WEGOTIT, /* not really an error: we already own the
  236. * line (used by check_utmp()) */
  237. LINST_ECUUNGETTY, /* ecuungetty unexpected response */
  238. LINST_ECUUNGETTY2, /* ecuungetty execution error */
  239. LINST_NOTCHR, /* not a character special */
  240. LINST_TELNETFAIL /* telnet open failed */
  241. };
  242. char *LINST_text(); /* routine to return text for error code */
  243. enum linst lock_tty();
  244. enum linst line_lock_status();
  245. enum linst telnet_open();
  246. char *find_procedure();
  247. char *base_name();
  248. char *erc_text();
  249. extern char lopen_err_str[];
  250. /*
  251. * filename sizes
  252. */
  253. #define PHONEDIR_NAME_SIZE 256 /* phone directory */
  254. /*
  255. * in case errno.h doesn't pick this up
  256. */
  257. extern int errno;
  258. char *getenv();
  259. char *graphic_char_text(); /* ecuutil.c */
  260. /*
  261. * process IDs
  262. */
  263. extern CFG_PidType xmtr_pid;
  264. extern CFG_PidType child_pid; /* ecufork.c */
  265. /*
  266. * both of the following are set by xmtr_SIGINT_handler()
  267. * 'sigint' reset by 1st detector/processor
  268. * 'proc_interrupt' reset/handled by procedure monitor
  269. * (execute_esd and execute_proc)
  270. */
  271. extern int sigint;
  272. /* extern int proc_interrupt; <------ force using modules to declare it */
  273. /*
  274. * procedure nesting level
  275. * non-zero if procedure executing (see proc.c)
  276. */
  277. extern int proc_level;
  278. extern int proc_trace;
  279. extern int proc_option_localvars;
  280. /*
  281. * 'hertz' is getenv("HZ"); that not found, the value from sys/param.h
  282. * 'hzmsec' is ceiling(clock period) in milliseconds
  283. */
  284. extern int hertz; /* HZ from environ or sys/param.h */
  285. extern UINT32 hzmsec; /* clock period in msec rounded up */
  286. /*
  287. * lock file directory
  288. */
  289. extern char *lock_dir_name; /* defined in ecuLCK.c */
  290. /*
  291. * setcolor variables - see setcolor()
  292. */
  293. extern UINT32 colors_current;
  294. extern UINT32 colors_normal;
  295. extern UINT32 colors_success;
  296. extern UINT32 colors_alert;
  297. extern UINT32 colors_error;
  298. extern UINT32 colors_notify;
  299. /*
  300. * miscellaneuous
  301. */
  302. extern char *eculibdir; /* lib dir, i.e., "/usr/local/lib/ecu" */
  303. extern char *ttype; /* getenv("TERM") */
  304. /*
  305. * param to lgets_timeout in eculine.c
  306. */
  307. typedef struct lrwt
  308. {
  309. UINT32 to1; /* timeout for 1st character (granularity 20) */
  310. UINT32 to2; /* timeout for each next char (granularity
  311. * 20) */
  312. int raw_flag; /* !=0, rtn full buffer, ==0, rtn filtered
  313. * hayes result */
  314. char *buffer; /* buffer to fill */
  315. int bufsize; /* size of buffer */
  316. int count; /* from proc, count rcvd */
  317. char *delim; /* ending string for lgets_timeout_or_delim */
  318. int echo_flag; /* echo incoming chars to screen */
  319. int got_delim; /* set true if delim found */
  320. }
  321. LRWT;
  322. /*
  323. * parameter structure for str_classify()
  324. */
  325. typedef struct str_classify
  326. {
  327. char *str; /* string to match */
  328. int min_ch; /* minimum characters required */
  329. int token; /* token for match */
  330. }
  331. STR_CLASSIFY;
  332. /*
  333. * shm->Ldcdwatch values
  334. */
  335. #define DCDW_OFF 0
  336. #define DCDW_ON 1
  337. #define DCDW_TERMINATE 2
  338. #ifdef DEBUG_SRP
  339. #define start_rcvr_process(flag) _start_rcvr_process(flag,__FILE__,__LINE__)
  340. #else
  341. #define start_rcvr_process(flag) _start_rcvr_process(flag)
  342. #endif
  343. #endif /* _ecu_h */
  344. /* vi: set tabstop=4 shiftwidth=4: */
  345. /* end of ecu.h */