main.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef NORCSID
  2. static char rcsid[] = "$Header$";
  3. #endif
  4. #include <stdio.h>
  5. #include "param.h"
  6. #include "types.h"
  7. #include "shc.h"
  8. #include "alloc.h"
  9. #include <em_spec.h>
  10. #include "ext.h"
  11. /*
  12. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  13. * See the copyright notice in the ACK home directory, in the file "Copyright".
  14. *
  15. * Author: Hans van Staveren
  16. */
  17. /*
  18. * Main program for EM optimizer
  19. */
  20. main(argc,argv) int argc; char *argv[]; {
  21. int somespace[STACKROOM];
  22. progname = argv[0];
  23. while (argc-->1 && **++argv == '-')
  24. flags(*argv);
  25. if (argc>1) {
  26. fprintf(stderr,"Usage: %s [-Ln] [name]\n",progname);
  27. exit(-1);
  28. }
  29. if (argc)
  30. if (freopen(*argv,"r",stdin) == NULL)
  31. error("Cannot open %s",*argv);
  32. fileinit();
  33. coreinit((short *)somespace,(short *)(somespace+STACKROOM));
  34. getlines();
  35. cleanup();
  36. return(0);
  37. }
  38. flags(s) register char *s; {
  39. for (s++;*s;s++)
  40. switch(*s) {
  41. case 'L': Lflag = TRUE; break;
  42. case 'n': nflag = TRUE; break;
  43. }
  44. }
  45. fileinit() {
  46. char *mktemp();
  47. short readshort();
  48. if (readshort() != (short) sp_magic)
  49. error("wrong input file");
  50. if (Lflag) {
  51. outfile = fopen(mktemp(template),"w");
  52. if (outfile == NULL)
  53. error("can't create %s",template);
  54. } else {
  55. outfile = stdout;
  56. outshort(sp_magic);
  57. }
  58. }