home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 345_01 / tlp.c < prev    next >
C/C++ Source or Header  |  1989-07-10  |  5KB  |  211 lines

  1. /* TLP.C - "The Last Pascal Cross-referencer" - Pascal Main routine        */
  2. /*    Last Modified:    02/10/89                                            */
  3.  
  4. /*
  5. ---------------------------------------------------------------------
  6. Copyright (c) 1987-1989, Eduard Schwan Programs [esp] - All rights reserved
  7. TLC (The Last C-Cross-Referencer) and TLP (same, but for Pascal) are
  8. Cross-Reference Generators crafted and shot into the Public Domain by
  9. Eduard Schwan.  The source code and executable program may be freely
  10. distributed as long as the copyright/author notices remain intact, and
  11. it is not used in part or whole as the basis of a commercial product.
  12. Any comments, bug-fixes, or enhancements are welcome.
  13. Also, if you find TLC and it's source code useful, a contribution of
  14. $20 (check/money order) is encouraged!  Hopefully we will all see more
  15. source code distributed!
  16.     Eduard Schwan, 1112 Oceanic Drive, Encinitas, Calif. 92024
  17. ---------------------------------------------------------------------
  18. */
  19.  
  20. /*
  21. HEADER:        The Last Cross-Referencer;
  22. TITLE:        TLC/TLP - The Last Cross-Referencer;
  23. VERSION:    1.01;
  24.  
  25. DESCRIPTION: "TLC/TLP.
  26.             Pascal Main routine";
  27.  
  28. KEYWORDS:    Utility, Cross-reference, C, Pascal, Apple, Macintosh, APW, Aztec;
  29. SYSTEM:        Macintosh MPW, v3.0;
  30. FILENAME:    TLP.C;
  31. WARNINGS:    "Has not yet been ported to MS-DOS.
  32.             Shareware, $20 Check/Money Order suggested.";
  33.  
  34. SEE-ALSO:    README.TLC,TLCHELP.DOC,TLPHELP.DOC;
  35. AUTHORS:    Eduard Schwan;
  36. COMPILERS:    AZTEC C65 v3.2b, APPLEIIGS APW C v1.0, APPLE MACINTOSH MPW C v3.0;
  37. */
  38.  
  39.  
  40. /*-------------------------- include files ---------------------------*/
  41.  
  42. #include    <stdio.h>
  43. #include    "tlc.h"
  44.  
  45.  
  46. /*------------------------ external declarations ----------------------*/
  47.  
  48. extern    VOID
  49.                 handle_cmd_line(),
  50.                 handle_resw_file(),
  51.                 handle_parm_file(),
  52.                 process_files(),
  53.                 print_xref(),
  54.                 print_stats();
  55. extern    int        close_text_file();
  56. extern    FILE *    open_text_file();
  57.  
  58.  
  59. /*-------------------------- static variables ------------------------*/
  60.  
  61.  
  62. /*-------------------------- global variables ------------------------*/
  63.  
  64. char        ref_chars[MAX_REF_CHARS+1] = " fpu";
  65.  
  66. emph_rec_type        emph_array[EMPH_MAX]=
  67.     {
  68.     {NULL, NULL},
  69.     {NULL, NULL},
  70.     {NULL, NULL}
  71.     };
  72.  
  73. file_rec_type        file_rec=
  74.     {
  75.     /*    num_in_fnames    */        0,
  76.     /*    file_list        */        NULL,
  77.     /*    curr_file        */        NULL,
  78.     /*    parm_fname        */        "TLPParm.Dat",
  79.     /*    resw_fname        */        "TLPResw.Dat"
  80.     };
  81.  
  82. parm_rec_type        parm_rec=
  83.     {
  84.  
  85. /* GENERAL */
  86.     /*    do_includes     */        FALSE,
  87.     /*    do_listing        */        FALSE,
  88.     /*    do_xref         */        FALSE,
  89.     /*    do_stats        */        FALSE,
  90.     /*    out_fname        */        "TLP.Out",
  91.  
  92. /* PRINTER */
  93.     /*    page_lines        */        66,
  94.     /*    page_columns    */        80,
  95.     /*    top_line        */        1,
  96.     /*    bot_line        */        56,
  97.     /*    left_column     */        1,
  98.     /*    right_column    */        80,
  99.     /*    user_heading    */        NULL,
  100.     /*    do_single_shts    */        FALSE,
  101.     /*    printer_init    */        NULL,
  102.     /*    has_form_feed    */        TRUE,
  103.     /*    first_page        */        1,
  104.     /*    last_page        */        9999,
  105.  
  106. /* LISTING */
  107.     /*    tab_width        */        4,
  108.     /*    emph_comments    */        EMPH_NONE,
  109.     /*    emph_heading    */        EMPH_NONE,
  110.     /*    emph_reserved    */        EMPH_NONE,
  111.     /*    emph_funcheads    */        EMPH_NONE,
  112.     /*    paging_string    */        NULL,
  113.  
  114. /* XREF */
  115.     /*    symbol_size     */        MAX_SYM_SIZE,
  116.     /*    xref_nums        */        FALSE,
  117.     /*    xref_strings    */        FALSE,
  118.     /*    do_conditionals */        FALSE,
  119.     /*    do_case_sens    */        FALSE,
  120.     /*    do_xcase_sens    */        FALSE,
  121.     /*    do_underscores    */        FALSE,
  122.     /*    emph_symbols    */        EMPH_NONE
  123.  
  124. /* STATS */
  125.  
  126.     };
  127.  
  128. resw_rec_type        resw_rec=
  129.     {
  130.     /*    num_reswords    */        0,
  131.     /*    resw_list        */        NULL
  132.     };
  133.  
  134. sym_table_type        symbol_table=
  135.     {
  136.     /*    symbol_list     */        NULL
  137.     };
  138.  
  139. stat_rec_type        stat_rec=
  140.     {
  141.     /*    total_lines     */        0
  142.     };
  143.  
  144. token_rec_type        token=
  145.     {
  146.     /*    tok_type        */        -1, /* init to bad value */
  147.     /*    tok_string        */        "",
  148.     /*    tok_value        */        0L,
  149.     /*    tok_column        */        0
  150.     };
  151.  
  152. line_type            curr_line        = "";
  153. pos_int             out_page_number = 0;
  154. pos_int             verbose         = 0;
  155. int                 enable_debugs    = FALSE;
  156. FILE*                out_file;
  157.  
  158.  
  159.  
  160. /*===================[ main ]=====================*/
  161.  
  162. main(argc,argv)
  163. int     argc;
  164. char    **argv;
  165.  
  166.     { /* main() */
  167.     int        error;
  168.     char    curr_time_str[30];
  169.  
  170.     printf("\nThe Last Pascal Cross-referencer (TLP) version:%s\n",TLC_VERSION);
  171.     printf("Copyright 1987-1989 by Eduard Schwan [esp]\n\n");
  172.     fflush(stdout);
  173.  
  174.     get_time(curr_time_str);
  175.     fprintf(stderr, "\nStarting at > %s\n",curr_time_str);
  176.     fflush(stderr);
  177.  
  178.     handle_cmd_line(argc, argv);
  179.     handle_resw_file();
  180.     handle_parm_file();
  181.     out_file = open_text_file(parm_rec.out_fname, "w+", &error);
  182.     if (error)
  183.         {
  184.         fprintf(stderr,"Error #%d/$%x opening output file '%s'\n",
  185.                 error,error,parm_rec.out_fname);
  186.         exit(BAD_EXIT);
  187.         }
  188.     else
  189.         {
  190.         if (parm_rec.printer_init != NULL)
  191.             fputs(parm_rec.printer_init, out_file);
  192.         process_files();
  193.         if (parm_rec.do_xref)
  194.             print_xref();
  195.         if (parm_rec.do_stats)
  196.             print_stats();
  197.         error = close_text_file(out_file, parm_rec.out_fname);
  198.         if (error)
  199.             {
  200.             fprintf(stderr,"Error #%d/$%x closing output file '%s'\n",
  201.                     error,error,parm_rec.out_fname);
  202.             exit(BAD_EXIT);
  203.             }
  204.  
  205.         get_time(curr_time_str);
  206.         fprintf(stderr, "\nFinished at > %s\n",curr_time_str);
  207.         fflush(stderr);
  208.  
  209.         }
  210.     } /* main() */
  211.