main.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Header$ */
  6. /* MAIN PROGRAM */
  7. #include <alloc.h>
  8. #include <system.h>
  9. #include "arith.h"
  10. #include "file_info.h"
  11. #include "idfsize.h"
  12. extern char *symbol2str();
  13. extern char *getwdir();
  14. extern int err_occurred;
  15. int idfsize = IDFSIZE;
  16. arith ifval;
  17. char *prog_name;
  18. extern char **inctable;
  19. extern int inc_max, inc_total;
  20. main(argc, argv)
  21. char *argv[];
  22. {
  23. /* parse and interpret the command line options */
  24. prog_name = argv[0];
  25. init_idf();
  26. inctable = (char **) Malloc(10 * sizeof(char *));
  27. inc_max = 10;
  28. inc_total = 2;
  29. inctable[0] = ".";
  30. inctable[1] = "/usr/include";
  31. init_pp(); /* initialise the preprocessor macros */
  32. /* Note: source file "-" indicates that the source is supplied
  33. as standard input. This is only allowed if INP_READ_IN_ONE is
  34. not defined!
  35. */
  36. while (argc > 1 && *argv[1] == '-' && argv[1][1] != '\0') {
  37. char *par = &argv[1][1];
  38. if (*par == '-')
  39. par++;
  40. do_option(par);
  41. argc--, argv++;
  42. }
  43. compile(argc - 1, &argv[1]);
  44. sys_stop(err_occurred ? S_EXIT : S_END);
  45. /*NOTREACHED*/
  46. }
  47. compile(argc, argv)
  48. char *argv[];
  49. {
  50. register char *source = 0;
  51. char *dummy;
  52. switch (argc) {
  53. case 1:
  54. source = argv[0];
  55. FileName = source;
  56. break;
  57. case 0:
  58. FileName = "";
  59. WorkingDir = 0;
  60. break;
  61. default:
  62. FileName = argv[0];
  63. fatal("use: %s [options] [source]", prog_name);
  64. break;
  65. }
  66. if (!InsertFile(source, (char **) 0, &dummy)) /* read the source file */
  67. fatal("%s: no source file %s\n", prog_name,
  68. source ? source : "stdin");
  69. if (source) WorkingDir = getwdir(dummy);
  70. preprocess(source);
  71. }