home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / tex / texsrc1 / Src / lib / c / main < prev    next >
Text File  |  1993-05-02  |  1KB  |  50 lines

  1. /* main.c -- the usual main program.  */
  2.  
  3. #include "config.h"
  4.  
  5.  
  6. /* ridderbusch.pad@nixdorf.com says this is necessary.  */
  7. #ifdef ATARI_ST
  8. int _stksize = -1L;
  9. #endif
  10.  
  11.  
  12. /* The command line is stored under `gargv', since Pascal has usurped `argv' 
  13.    for a procedure.  These variables are referenced from the Pascal, so
  14.    we can't make them static.  */
  15. char **gargv;
  16. int argc;
  17.  
  18.  
  19. /* The entry point for all the programs except TeX and Metafont, which
  20.    have more to do.  We just have to set up the command line.  Pascal's
  21.    main block is transformed into the procedure `main_body'.  */
  22.  
  23. int
  24. main (ac, av)
  25.   int ac;
  26.   char **av;
  27. {
  28.   argc = ac;
  29.   gargv = av;
  30.   main_body ();
  31.   uexit (0);
  32. }
  33.  
  34.  
  35. /* Read the Nth argument from the command line and return it in BUF as a
  36.    Pascal string, i.e., starting at index 1 and ending with a space.  If
  37.    N is beyond the end of the command line, abort.  */
  38.  
  39. void
  40. argv P2C(int, n,  string, buf)
  41. {
  42.   if (n >= argc)
  43.     {
  44.       fprintf (stderr, "%s: Not enough arguments.\n", gargv[0]);
  45.       uexit (1);
  46.     }
  47.   (void) strcpy (buf + 1, gargv[n]);
  48.   (void) strcat (buf + 1, " ");
  49. }
  50.