exksh.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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 librararies 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. /* $XConsortium: exksh.h /main/3 1995/11/01 15:54:01 rswiston $ */
  24. /* "%W%" */
  25. /* Copyright (c) 1991, 1992 UNIX System Laboratories, Inc. */
  26. /* All Rights Reserved */
  27. /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
  28. /* UNIX System Laboratories, Inc. */
  29. /* The copyright notice above does not evidence any */
  30. /* actual or intended publication of such source code. */
  31. #ifndef _Dtksh_exksh_h
  32. #define _Dtksh_exksh_h
  33. #include <sys/types.h>
  34. #ifndef SYMS_ONLY
  35. #define SH_FAIL 1
  36. #define SH_SUCC 0
  37. #define PRSYMBOLIC 1
  38. #define PRMIXED 2
  39. #define PRDECIMAL 4
  40. #define PRHEX 8
  41. #define PRMIXED_SYMBOLIC 16
  42. #define PRNAMES 32
  43. #define UPP(CH) (islower(CH) ? toupper(CH) : (CH))
  44. #define C_PAIR(STR, CH1, CH2) (((STR)[0] == (CH1)) && ((STR)[1] == (CH2)))
  45. #define XK_USAGE(X) return(xk_usage(X), SH_FAIL);
  46. /* In the future, this will require following pointers, unless we
  47. ** can always trace back types to typedefs. For example, unsigned long is
  48. ** a typedef, but it is simple because it is really just a long.
  49. */
  50. #define IS_SIMPLE(TBL) ((TBL)->flags & F_SIMPLE)
  51. #ifndef N_DEFAULT /* From name.h */
  52. /* Stolen out of include/name.h, the problems of including things
  53. ** out of the ksh code is major. Hence, the copy rather than the
  54. ** include.
  55. */
  56. struct Bfunction {
  57. long (*f_vp)(); /* value function */
  58. long (*f_ap)(); /* assignment function */
  59. };
  60. #endif /* N_DEFAULT: From name.h */
  61. #define ALLDATA INT_MAX
  62. #define BIGBUFSIZ (10 * BUFSIZ)
  63. #define IN_BAND 1
  64. #define OUT_BAND 2
  65. #define NEW_PRIM 4
  66. struct fd {
  67. int vfd;
  68. int flags;
  69. char mode;
  70. struct strbuf *lastrcv;
  71. int rcvcount;
  72. int sndcount;
  73. int uflags;
  74. };
  75. struct vfd {
  76. int fd;
  77. };
  78. extern struct fd *Fds;
  79. extern struct vfd *Vfds;
  80. struct libdesc {
  81. char *name;
  82. void *handle;
  83. };
  84. struct libstruct {
  85. char *prefix;
  86. int nlibs;
  87. struct libdesc *libs;
  88. };
  89. #ifndef OSI_LIB_CODE
  90. #define PARPEEK(b, s) (((b)[0][0] == s[0]) ? 1 : 0 )
  91. #define PAREXPECT(b, s) (((b)[0][0] == s[0]) ? 0 : -1 )
  92. #define OFFSET(T, M) ((int)(&((T)NULL)->M))
  93. typedef char *string_t;
  94. /*
  95. * Structures for driving generic print/parse/copy/free routines
  96. */
  97. typedef struct memtbl {
  98. char *name; /* name of the member */
  99. char *tname; /* name of the typedef */
  100. char kind; /* kind of member, see #defines below */
  101. char flags; /* flags for member, see #defines below */
  102. short tbl; /* -1 or index into ASL_allmems[] array */
  103. short ptr; /* number of "*" in front of member */
  104. short subscr; /* 0 if no subscript, else max number of elems */
  105. short delim; /* 0 if no length delim, +1 if next field, -1 if prev */
  106. short id; /* Id of the ASL in which this def is made */
  107. short offset; /* offset into the C structure */
  108. short size; /* size of this member, for easy malloc'ing */
  109. long choice; /* def of tag indicating field chosen for unions */
  110. } memtbl_t;
  111. struct envsymbols {
  112. char *name;
  113. int id;
  114. int (*parsefunc)();
  115. int (*printfunc)();
  116. char *tname;
  117. int intlike;
  118. int string;
  119. int topptr;
  120. int valbits;
  121. struct {
  122. char *name;
  123. unsigned long val;
  124. int cover;
  125. } vals[64];
  126. };
  127. /*
  128. * Definitions for the kind field of the above structure
  129. */
  130. #define K_CHAR (0) /* char or unchar */
  131. #define K_SHORT (1) /* short or ushort */
  132. #define K_INT (2) /* int or uint */
  133. #define K_LONG (3) /* long, unsigned long, PRIM, etc. */
  134. #define K_STRING (4) /* char * or char [] */
  135. #define K_OBJID (5) /* objid_t *, note the star is included */
  136. #define K_ANY (6) /* any_t */
  137. #define K_STRUCT (7) /* struct { } */
  138. #define K_UNION (8) /* union { } */
  139. #define K_TYPEDEF (9) /* typedef */
  140. #define K_DSHORT (10) /* short delimiter */
  141. #define K_DINT (11) /* int delimiter */
  142. #define K_DLONG (12) /* long delimiter */
  143. /*
  144. * Definitions for the flags field of the above structure, bitmask
  145. */
  146. #define F_SIMPLE (1) /* simple, flat type */
  147. #define F_FIELD (2) /* memtbl is a field of a structure, not the
  148. name of a type */
  149. #define F_TBL_IS_PTR (4) /* tbl field is pointer, not number; */
  150. #define F_TYPE_IS_PTR (8) /* type is built-in, but is already a pointer, like K_STRING */
  151. #define SUCCESS 0
  152. #define FAIL (-1)
  153. #define TRUE 1
  154. #define FALSE 0
  155. /* The following macro, RIF, stands for Return If Fail. Practically
  156. * every line of encode/decode functions need to do this, so it aids
  157. * in readability.
  158. */
  159. #define RIF(X) do { if ((X) == FAIL) return(FAIL); } while(0)
  160. #endif /* not OSI_LIB_CODE */
  161. #if !defined(OSI_LIB_CODE) || defined(NEED_SYMLIST)
  162. struct symlist {
  163. struct memtbl tbl;
  164. int isflag;
  165. int nsyms;
  166. struct symarray *syms;
  167. };
  168. #endif
  169. #define DYNMEM_ID (1)
  170. #define BASE_ID (2)
  171. #define ALTPUTS(STR) puts(STR)
  172. #ifndef NULL
  173. #define NULL (0)
  174. #endif
  175. #ifdef SPRINTF_RET_LEN
  176. #define lsprintf sprintf
  177. #endif
  178. #define MAX_CALL_ARGS 15
  179. #define TREAT_SIMPLE(TBL) ((TBL)->ptr || IS_SIMPLE(TBL))
  180. #ifdef EXKSH_INCLUDED
  181. #define XK_PRINT(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) (_Delim = 0, xk_print(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7))
  182. #define XK_PARSE(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) (_Delim = 0, xk_parse(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7))
  183. #define XK_FREE(ARG1, ARG2, ARG3, ARG4, ARG5) (_Delim = 0, xk_free(ARG1, ARG2, ARG3, ARG4, ARG5))
  184. #endif
  185. #define NOHASH 1
  186. #define TYPEONLY 2
  187. #define STRUCTONLY 4
  188. #endif /* not SYMS_ONLY */
  189. struct symarray {
  190. const char *str;
  191. unsigned long addr;
  192. };
  193. #endif /* _Dtksh_exksh_h */
  194. /* DON'T ADD ANYTHING AFTER THIS #endif */