home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume14 / shellforms / part02 / sf.c < prev    next >
C/C++ Source or Header  |  1988-05-09  |  4KB  |  125 lines

  1. /**************************************************************************
  2. *
  3. * File name:    sf.c
  4. *
  5. * Author:    Paul Lew, General Systems Group, Inc. Salem NH
  6. * Created at:    05/08/86  10:11 AM
  7. * Last update:    02/08/88  00:23 AM  (Edition: 29)
  8. *
  9. * Description:    This program will take standard input  (if no argument
  10. *        specified in  command line) or  the specified  file as
  11. *        form  template and  display   it  on  the terminal  to
  12. *        perform basic form editing function.  It then generate
  13. *        the Csh  or Bourne shell set script  on  stdout  to be
  14. *        executed (ala tset -s).
  15. *
  16. *        This program is designed to  give programmer  an  easy
  17. *        way of doing form filling in shell level.
  18. *
  19. * Update History:
  20. *
  21. *    Date    Modification Description                By
  22. *  --------    ------------------------------------------------------    ---
  23. *  05/08/86    Initial version                        Lew
  24. *  08/04/87    added Help_display flag                    Lew
  25. *  12/29/87    modify to add Bourne shell output flag, use getopt()    Lew
  26. *  01/12/88    added init_sno(), added CTRL L redisplay function,    Lew
  27. *        added signal trap handling.
  28. *  01/26/88    added AUTOTAB at end of a field, added NUMERIC field    Lew
  29. *        attribute
  30. *  02/08/88    modified to add perl script output flag            Lew
  31. *
  32. ***************************************************************************/
  33. #define    EXTERN
  34. #include    <stdio.h>
  35. #include    <ctype.h>
  36. #include    "form.h"
  37. #include    "basic.h"
  38.  
  39. char    *Version = "1.8  02/08/88  00:21 AM";
  40. char    *Bugs = "Bug report send to: decvax!gsg!lew (UUCP)";
  41. char    *Copyright = "Copyright by Paul Lew (1987,1988) All rights reserved";
  42. char    *Prgname;            /* program name */
  43.  
  44. extern    unsigned char    Shell;
  45. extern    int        Help_display;
  46. int            Debug = NO;
  47.  
  48. /*------------------------------------------------------------07/13/84--+
  49. |                                    |
  50. |        M a i n    R o u t i n e    S t a r t s    H e r e        |
  51. |                                    |
  52. +----------------------------------------------------------------------*/
  53. main (argc, argv)
  54. int    argc;        /* number of argument passed */
  55. char    **argv;        /* pointer to argument list */
  56.     {
  57.     int        n;        /* number of files (so far 2)    */
  58.     char        *fname;        /* form file name */
  59.  
  60.     Prgname = *argv;
  61.     n = procarg (argc, argv);
  62.     if (n == argc) fname = NULL;    /* read from stdin if no input    */
  63.     else fname = argv[n];
  64.     edit_form (fname, (int (*)())NULL);
  65.     exit (0);
  66.     }
  67.  
  68. /*----------------------------------------------------------------------+
  69. |                                    |
  70. |    proc_arg : process input argument and set global flags        |
  71. |                                    |
  72. +----------------------------------------------------------------------*/
  73. procarg (argc, argv)
  74. int    argc;
  75. char    **argv;
  76.     {
  77.     int        rvideo = 0;
  78.     int        undline = 0;
  79.     int        hilite = 0;
  80.     char        *fname = NULL;
  81.     int        c;
  82.     extern    char    *optarg;    /* ptr to argument */
  83.     extern    int    optind;        /* remember which one to process next */
  84.  
  85.     ENTER (procarg);
  86.     while ((c = getopt (argc, argv, "Hbdhmo:pru")) != EOF) {
  87.         switch (c) {
  88.             when 'b': Shell = BOURNE;
  89.             when 'd': Debug = YES;
  90.             when 'h': hilite = YES;
  91.             when 'm': Help_display = YES;
  92.             when 'o': fname = optarg;
  93.             when 'p': Shell = PERL;
  94.             when 'r': rvideo = YES;
  95.             when 'u': undline = YES;
  96.             otherwise:help ();
  97.                   exit (1);
  98.             }
  99.         }
  100.     set_options (hilite, rvideo, undline, fname);
  101.     RETURN (optind);
  102.     }
  103.  
  104. /*-------------------------------------------------------------05/08/86-+
  105. |                                    |
  106. |               help : display help message            |
  107. |                                    |
  108. +----------------------------------------------------------------------*/
  109. help ()
  110.     {
  111.     ENTER(help);
  112.     fprintf (stderr, "%s Version %s\r\n", Prgname, Version);
  113.     fprintf (stderr, "Command Options:\r\n");
  114.     fprintf (stderr, "  -H        display this help message\r\n");
  115.     fprintf (stderr, "  -b        generate Bourne shell output [Csh]\r\n");
  116.     fprintf (stderr, "  -d        debug mode, will show CTRL chars\r\n");
  117.     fprintf (stderr, "  -h        input in highlight mode\r\n");
  118.     fprintf (stderr, "  -m        display selection help automatically\r\n");
  119.     fprintf (stderr, "  -o file   use file as output file\r\n");
  120.     fprintf (stderr, "  -p        generate perl script output\r\n");
  121.     fprintf (stderr, "  -r        input in reverse video mode\r\n");
  122.     fprintf (stderr, "  -u        input in underline mode\r\n");
  123.     EXIT;
  124.     }
  125.