home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / c / c2man-2.0pl33.lha / c2man-2.0 / c2man.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-24  |  7.3 KB  |  280 lines

  1. /* $Id: c2man.h,v 2.0.1.16 1994/05/12 02:23:21 greyham Exp $
  2.  *
  3.  * Definitions for C language manual page generator
  4.  */
  5. #ifndef _C2MAN_H
  6. #define _C2MAN_H
  7.  
  8. #include "config.h"
  9. #include "symbol.h"
  10.  
  11. #ifdef I_SYS_TYPES
  12. #include <sys/types.h>
  13. #endif
  14.  
  15. #ifdef I_STDLIB
  16. #include <stdlib.h>
  17. #endif
  18.  
  19. #ifdef I_STRING
  20. #include <string.h>
  21. #else
  22. #include <strings.h>
  23. #endif
  24.  
  25. #include <stdio.h>
  26.  
  27. #ifdef I_UNISTD
  28. #include <unistd.h>
  29. #endif
  30.  
  31. #ifdef I_STDDEF
  32. #include <stddef.h>
  33. #endif
  34.  
  35. #ifdef I_TIME
  36. #include <time.h>
  37. #endif
  38. #ifdef I_SYS_TIME
  39. #include <sys/time.h>
  40. #endif
  41.  
  42. #ifdef NeXT
  43. #include <libc.h>
  44. #undef ECHO    /* lex generates ECHO */
  45. #endif
  46.  
  47. #ifdef DBMALLOC
  48. #include </usr/local/debug_include/malloc.h>
  49. #endif
  50.  
  51. #include "confmagic.h"
  52.  
  53. /* number of spaces in a tab */
  54. #define NUM_TAB_SPACES 4
  55.  
  56. /* maximum include file nesting */
  57. #define MAX_INC_DEPTH 15
  58.  
  59. /* maximum number of include directories */
  60. #define MAX_INC_DIR 15
  61.  
  62. /* maximum number of characters in a text buffer */
  63. #define MAX_TEXT_LENGTH    256
  64.  
  65. /* Boolean type */
  66. typedef int boolean;
  67. #ifndef TRUE
  68. #define FALSE    0
  69. #define TRUE    1
  70. #endif
  71.  
  72. /* NULL char *, useful for passing NULL to functions wanting a char * */
  73. #define NULLCP    ((char *)0)
  74.  
  75. /* This is a list of function parameters. */
  76. typedef struct _parameter_list {
  77.     struct _parameter    *first;    /* pointer to first parameter in list */
  78.     struct _parameter    *last;  /* pointer to last parameter in list */  
  79. } ParameterList;
  80.  
  81. /* Declaration specifier flags */
  82. #define DS_NONE     0    /* default */
  83. #define DS_EXTERN    1    /* contains "extern" specifier */
  84. #define DS_STATIC    2    /* contains "static" specifier */
  85. #define DS_CHAR     4    /* contains "char" type specifier */
  86. #define DS_SHORT    8    /* contains "short" type specifier */
  87. #define DS_FLOAT    16    /* contains "float" type specifier */
  88. #define DS_JUNK     32    /* we're not interested in this declaration */
  89. #define DS_INLINE    64    /* makes static look interesting */
  90.  
  91. /* This structure stores information about a declaration specifier. */
  92. typedef struct _decl_spec {
  93.     unsigned short    flags;    /* flags defined above */
  94.     char        *text;    /* source text */
  95.     struct _enumerator_list *enum_list;    /* associated enum (if any) */
  96. } DeclSpec;
  97.  
  98. /* Styles of declaration/definition */
  99. typedef enum {
  100.     DECL_SIMPLE,    /* simple declaration */
  101.     DECL_COMPOUND,    /* compound declaration */
  102.     DECL_FUNCTION,    /* function declaration (prototype) */
  103.     DECL_FUNCDEF    /* an actual function definition */
  104. } DeclType;
  105.  
  106. /* This structure stores information about a declarator. */
  107. typedef struct _declarator {
  108.     char        *name;        /* name of variable or function */
  109.     char        *text;        /* source text */
  110.     DeclType        type;        /* style of function declaration */
  111.     ParameterList    params;        /* function parameters */
  112.     char         *comment;    /* description of param or variable */
  113.     struct _declarator     *head;        /* head function declarator */
  114.     struct _declarator     *func_stack;    /* stack of function declarators */
  115.     struct _declarator    *next;        /* next declarator in list */
  116. } Declarator;
  117.  
  118. /* This is a list of declarators. */
  119. typedef struct _declarator_list {
  120.     Declarator        *first;    /* pointer to first declarator in list */
  121.     Declarator        *last;  /* pointer to last declarator in list */  
  122. } DeclaratorList;
  123.  
  124. /* This structure stores information about a declaration. */
  125. typedef struct _declaration {
  126.     DeclSpec        decl_spec;
  127.     DeclaratorList    decl_list;
  128. } Declaration;
  129.  
  130. /* this structure store information about an enumerator */
  131. typedef struct _enumerator {
  132.     char *name;            /* name of enum entry */
  133.     char *comment;        /* description of entry */
  134.     char *group_comment;    /* general descr. for next few enums in list */
  135.     struct _enumerator *next;    /* next enumerator in list */
  136. } Enumerator;
  137.  
  138. /* This is a list of enumerators. */
  139. typedef struct _enumerator_list {
  140.     Enumerator        *first;    /* pointer to first enumerator in list */
  141.     Enumerator        *last;  /* pointer to last enumerator in list */
  142.     struct _enumerator_list *next;    /* next list in a list-of-lists */
  143. } EnumeratorList;
  144.  
  145.  
  146. /* This structure stores information about a function parameter. */
  147. typedef struct _parameter {
  148.     DeclSpec        decl_spec;
  149.     Declarator        *declarator;
  150.     boolean        suppress;    /* don't print in grouped page */
  151.     boolean        duplicate;    /* mention fn in grouped page */
  152.     struct _parameter    *next;        /* next parameter in list */
  153. } Parameter;
  154.  
  155. /* this is an identifier, with surrounding comments (if any) */
  156. typedef struct _identifier {
  157.     char *name;
  158.     char *comment_before, *comment_after;
  159. } Identifier;
  160.  
  161. /* parser stack entry type */
  162. typedef union {
  163.     char        *text;
  164.     DeclSpec        decl_spec;
  165.     Parameter        parameter;
  166.     ParameterList    param_list;
  167.     Declarator        *declarator;
  168.     DeclaratorList    decl_list;
  169.     Declaration        declaration;
  170.     Enumerator        enumerator;
  171.     EnumeratorList    *enum_list;
  172.     Identifier        identifier;
  173.     boolean        boolean;
  174. } yystype;
  175.  
  176. /* include files specified by user */
  177. typedef struct _includefile
  178. {
  179.     char *name;
  180.     struct _includefile *next;
  181. } IncludeFile;
  182.  
  183. /* output object types */
  184. enum Output_Object
  185. {
  186. #if 0    /* C++ stuff */
  187.     OBJECT_CLASS,
  188.     OBJECT_STRUCT,
  189.     OBJECT_ENUM,
  190.     OBJECT_TYPEDEF,
  191. #endif
  192.     OBJECT_FUNCTION,
  193.     OBJECT_VARIABLE,
  194.     OBJECT_STATIC_FUNCTION,
  195.     OBJECT_STATIC_VARIABLE,
  196.     _OBJECT_NUM
  197. };
  198.  
  199. struct Output_Object_Info
  200. {
  201.     char flag;        /* -O flag used to set it */
  202.     char *name;        /* descriptive name for usage() */
  203.     char *extension;    /* file extension */
  204.     char *subdir;    /* subdirectory */
  205. };
  206.  
  207. /* list of sections to exclude */
  208. typedef struct ExcludeSection
  209. {
  210.   char *name;
  211.   struct ExcludeSection *next;
  212. } ExcludeSection;
  213.  
  214. #define YYSTYPE yystype
  215.  
  216. /* Program options */
  217. extern boolean static_out;
  218. extern boolean variables_out;
  219. extern boolean promote_param;
  220. extern const char *decl_spec_prefix, *declarator_prefix, *declarator_suffix;
  221. extern const char *first_param_prefix, *middle_param_prefix, *last_param_suffix;
  222. extern int num_inc_dir;
  223. extern const char *inc_dir[];
  224. extern char *manual_name;
  225. extern const char *progname;
  226. extern char *header_prefix;
  227. extern IncludeFile *first_include;
  228. extern ExcludeSection *first_excluded_section;
  229.  
  230. extern char *group_terse;
  231. extern boolean group_together;
  232. extern boolean terse_specified;
  233. extern boolean always_document_params;
  234.  
  235. extern char *output_dir;
  236.  
  237. /* Global declarations */
  238. extern int line_num;
  239. extern const char *basefile;
  240. extern Time_t basetime;
  241. extern boolean inbasefile;
  242. extern boolean header_file;
  243. extern SymbolTable *typedef_names;
  244. extern void output_error();
  245. extern void parse_file _((const char *start_file));
  246. extern int errors;
  247. extern const char *manual_section;
  248. extern boolean use_input_name;
  249. extern boolean make_embeddable;
  250. extern struct Output_Object_Info output_object[_OBJECT_NUM];
  251.  
  252.  
  253.  
  254. /* Output a string to standard output. */
  255. #define put_string(s)    fputs(s, stdout)
  256.  
  257. /* a malloc that handles errors, and a free that handles NULL */
  258. #ifndef DBMALLOC
  259. void *safe_malloc _((size_t size));
  260. #else
  261. /* use macro so dbmalloc tells us where safe_malloc is called from */
  262. #define safe_malloc(s)    malloc(s)
  263. #endif
  264. #define safe_free(p)    do { if (p) free(p); } while(0)
  265.  
  266. void outmem();
  267. void print_includes _((FILE *f));/* write #include lines */
  268.  
  269. void yyerror _V((const char *fmt, ...));
  270.  
  271. char *strduplicate _((const char *s));
  272. int strncmpi _((const char *s1, const char *s2, size_t n));
  273. char *strtoupper _((char *s));
  274.  
  275. void my_perror _((const char *action, const char *filename));
  276.  
  277. char *alloc_string _((const char *start, const char *end));
  278.  
  279. #endif
  280.