"Fossies" - the Fresh Open Source Software Archive

Member "cpost.h" (9 May 1995, 11360 Bytes) of package /linux/misc/old/cpost.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "cpost.h" see the Fossies "Dox" file reference documentation.

    1 /*------------------------------------------------------------------
    2  * cpost.h : include file for cPost
    3  *------------------------------------------------------------------
    4  * 10-10-91 originally by Patrick J. Mueller
    5  * 12-03-92 converted from cBook to cPost
    6  *------------------------------------------------------------------*/
    7 
    8 #include "list.h"
    9 #include "hash.h"
   10 
   11 /*------------------------------------------------------------------
   12  * additional token types
   13  *------------------------------------------------------------------*/
   14 #define TOKEN_LBRACE -1
   15 #define TOKEN_RBRACE -2
   16 #define TOKEN_LPAREN -3
   17 #define TOKEN_RPAREN -4
   18 
   19 #define TOKEN_FUNPRO -5
   20 #define TOKEN_FUNUSE -6
   21 #define TOKEN_FUNDEF -7
   22 
   23 #define TOKEN_RESER  -8
   24 
   25 #define TOKEN_SCOLON -9
   26 #define TOKEN_COMMA  -10
   27 
   28 /*------------------------------------------------------------------
   29  * number of lines to buffer in at a time
   30  *------------------------------------------------------------------*/
   31 #define FILE_LINES 256
   32 
   33 /*------------------------------------------------------------------
   34  * max length of line
   35  *------------------------------------------------------------------*/
   36 #define MAX_LINE_LEN 4096
   37 
   38 /*------------------------------------------------------------------
   39  * typedefs
   40  *------------------------------------------------------------------*/
   41 
   42 /*------------------------------------------------------------------
   43  * page eject
   44  *------------------------------------------------------------------*/
   45 typedef struct PageEject
   46    {
   47    unsigned long     lineNo;
   48    struct PageEject *next;
   49    } PageEject;
   50 
   51 /*------------------------------------------------------------------
   52  * token structure
   53  *------------------------------------------------------------------*/
   54 typedef struct Tok
   55    {
   56    int         nestParen;
   57    int         nestBrace;
   58    int         extType;
   59    int         flags;
   60    char       *str;
   61    struct Tok *sib;
   62    struct Tok *next;
   63    Token       tok;
   64    } Tok;
   65 
   66 /*------------------------------------------------------------------
   67  * a file entry for a list of files
   68  *------------------------------------------------------------------*/
   69 typedef struct File
   70    {
   71    char            *name;
   72    char            *pathName;
   73    char            *tempName;
   74    char            *ext;
   75    int              type;
   76    int              maxLineLen;
   77    char           **line;
   78    unsigned long    lines;
   79    unsigned long    cline;
   80    List            *funcDefList;
   81    List            *funcProList;
   82    Tok             *tokList;
   83    char             date[9];
   84    char             time[9];
   85    Hash            *identHash;
   86    PageEject       *breakList;
   87    } File;
   88 
   89 /*------------------------------------------------------------------
   90  * information about a function
   91  *------------------------------------------------------------------*/
   92 typedef struct Function
   93    {
   94    char            *name;
   95    char            *fileName;
   96    unsigned long    lineNo;
   97    int              id;
   98    int              spotted;
   99    List            *callsList;
  100    List            *calledByList;
  101    } Function;
  102 
  103 /*------------------------------------------------------------------
  104  * formatting options
  105  *------------------------------------------------------------------*/
  106 typedef struct
  107    {
  108    char *fontNormal   ; int sizeNormal   ;
  109    char *fontKeyword  ; int sizeKeyword  ;
  110    char *fontFunction ; int sizeFunction ;
  111    char *fontComment  ; int sizeComment  ;
  112    char *fontPreproc  ; int sizePreproc  ;
  113    char *fontLineNo   ; int sizeLineNo   ;
  114 
  115    char *fontHeader;
  116 
  117    int   pageLen;
  118    int   pageWid;
  119 
  120    int   hMargin;
  121    int   tMargin;
  122    int   bMargin;
  123    int   lMargin;
  124    } Format;
  125 
  126 /*------------------------------------------------------------------
  127  * global control block
  128  *------------------------------------------------------------------*/
  129 typedef struct Info
  130    {
  131    List            *fileList;
  132    List            *funcTree;
  133    FILE            *oFile;
  134    Hash            *identHash;
  135    Hash            *reservedHash;
  136    int              indent1;
  137    int              count1;
  138    int              count2;
  139    Format           format;
  140 
  141    char            *oHtype;
  142    char            *oCtype;
  143    int              oTabs;
  144    char            *oTemp;
  145    int              oDebug;
  146    char            *oSort;
  147    int              oBrack;
  148    int              oDuplex;
  149    char            *oImbed;
  150    int              oSpace;
  151    int              oBreak;
  152    int              oXlateX;
  153    int              oXlateY;
  154    char            *oWrapB;
  155    char            *oWrapA;
  156    char            *oRepHdr;
  157    } Info;
  158 
  159 /*------------------------------------------------------------------
  160  * global variables
  161  *------------------------------------------------------------------*/
  162 #if defined(DEFINE_GLOBALS)
  163           Info info;
  164 #else
  165    extern Info info;
  166 #endif
  167 
  168 /*------------------------------------------------------------------
  169  * some stuff for c/370
  170  *------------------------------------------------------------------*/
  171 #if defined(OPSYS_CMS)
  172    #define FileNameCompare              fncomp
  173    #define FileSpecAdd                  fsadd
  174    #define FileReadLines                frline
  175    #define GetBlockOfFile               gbofile
  176    #define InitCAttrs                   icattr
  177    #define FunctionNameCompare          fnccomp
  178    #define FunctionNamePtrCompare       fncpcomp
  179    #define GetFunction                  getfnc
  180    #define PrintFunctionPtrInfo         pfpinf
  181    #define PrintFunctionInfo            pfinf
  182    #define TempFileName                 tfname
  183    #define IsTempFileName               itfname
  184    #define cPostError                   cperror
  185 #endif
  186 
  187 #if !defined(max)
  188    #define max(x,y) ((x) > (y) ? (x) : (y))
  189 #endif
  190 
  191 #if !defined(min)
  192    #define min(x,y) ((x) < (y) ? (x) : (y))
  193 #endif
  194 
  195 /*-/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\-*/
  196 /*-\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/-*/
  197 
  198 /*------------------------------------------------------------------
  199  * pass 1 of cPost
  200  *------------------------------------------------------------------*/
  201 int Pass1(
  202    File     *file,
  203    Info     *info
  204    );
  205 
  206 /*------------------------------------------------------------------
  207  * pass 2 of cPost
  208  *------------------------------------------------------------------*/
  209 int Pass2(
  210    File     *file,
  211    Info     *info
  212    );
  213 
  214 /*-/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\-*/
  215 /*-\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/-*/
  216 
  217 /*------------------------------------------------------------------
  218  * utility functions
  219  *------------------------------------------------------------------*/
  220 
  221 /*------------------------------------------------------------------
  222  * compare two file names
  223  *------------------------------------------------------------------*/
  224 int FileNameCompare(
  225    File *name1,
  226    File *name2
  227    );
  228 
  229 /*------------------------------------------------------------------
  230  * add a file name to the filename list
  231  *------------------------------------------------------------------*/
  232 void FileSpecAdd(
  233    Info      *info,
  234    List      *fileList,
  235    char      *fileSpec
  236    );
  237 
  238 /*------------------------------------------------------------------
  239  * hash an identifier
  240  *------------------------------------------------------------------*/
  241 int IdentHash(
  242    char     **str,
  243    int        hashSize
  244    );
  245 
  246 /*------------------------------------------------------------------
  247  * compare two strings indirectly
  248  *------------------------------------------------------------------*/
  249 int IdentCompare(
  250    char **str1,
  251    char **str2
  252    );
  253 
  254 /*------------------------------------------------------------------
  255  * read file into array of lines
  256  *------------------------------------------------------------------*/
  257 File *FileReadLines(
  258    Info *info,
  259    File *file
  260    );
  261 
  262 /*------------------------------------------------------------------
  263  * return bytes from the file, conveniently a line at a time
  264  *------------------------------------------------------------------*/
  265 unsigned long GetBlockOfFile(
  266    void  *readInfo,
  267    char **buffer
  268    );
  269 
  270 /*------------------------------------------------------------------
  271  * compare two function names
  272  *------------------------------------------------------------------*/
  273 int FunctionNameCompare(
  274    Function *func1,
  275    Function *func2
  276    );
  277 
  278 int FunctionNamePtrCompare(
  279    Function **func1,
  280    Function **func2
  281    );
  282 
  283 /*------------------------------------------------------------------
  284  * get function (add if needed) from global function table
  285  *------------------------------------------------------------------*/
  286 Function *GetFunction(
  287    Info          *info,
  288    char          *name
  289    );
  290 
  291 /*------------------------------------------------------------------
  292  * dump function information
  293  *------------------------------------------------------------------*/
  294 int PrintFunctionPtrInfo(
  295    Function **func,
  296    Info      *info
  297    );
  298 
  299 /*------------------------------------------------------------------
  300  * dump function information
  301  *------------------------------------------------------------------*/
  302 int PrintFunctionInfo(
  303    Function *func,
  304    Info     *info
  305    );
  306 
  307 /*------------------------------------------------------------------
  308  * generate a temporary file name
  309  *------------------------------------------------------------------*/
  310 char *TempFileName(
  311    FILE **file,
  312    Info  *info
  313    );
  314 
  315 /*------------------------------------------------------------------
  316  * check for temporary file name
  317  *------------------------------------------------------------------*/
  318 int IsTempFileName(
  319    char *name
  320    );
  321 
  322 /*------------------------------------------------------------------
  323  * compare strings case insensitively
  324  *------------------------------------------------------------------*/
  325 int Stricmp(
  326    char *str1,
  327    char *str2
  328    );
  329 
  330 /*------------------------------------------------------------------
  331  * compare strings case insensitively
  332  *------------------------------------------------------------------*/
  333 int Memicmp(
  334    char *str1,
  335    char *str2,
  336    int   len
  337    );
  338 
  339 /*------------------------------------------------------------------
  340  * upper case a string
  341  *------------------------------------------------------------------*/
  342 char *Strupr(
  343    char *str
  344    );
  345 
  346 /*------------------------------------------------------------------
  347  * reverse a string
  348  *------------------------------------------------------------------*/
  349 char *Strrev(
  350    char *str
  351    );
  352 
  353 /*------------------------------------------------------------------
  354  * generate an error message and exit
  355  *------------------------------------------------------------------*/
  356 void cPostError(
  357    int   exitCode,
  358    char *format,
  359    ...
  360    );
  361 
  362 /*------------------------------------------------------------------
  363  * print out of memory message and exit
  364  *------------------------------------------------------------------*/
  365 void cPostNoMem(
  366    void
  367    );
  368 
  369 /*------------------------------------------------------------------
  370  * parse file
  371  *------------------------------------------------------------------*/
  372 void cParse(
  373    File     *file,
  374    Info     *info
  375    );
  376 
  377 /*------------------------------------------------------------------
  378  * clean up after parsing file
  379  *------------------------------------------------------------------*/
  380 void cParseDone(
  381    File     *file,
  382    Info     *info
  383    );
  384