ini.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* $Header$ */
  2. /*
  3. * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. *
  5. * This product is part of the Amsterdam Compiler Kit.
  6. *
  7. * Permission to use, sell, duplicate or disclose this software must be
  8. * obtained in writing. Requests for such permissions may be sent to
  9. *
  10. * Dr. Andrew S. Tanenbaum
  11. * Wiskundig Seminarium
  12. * Vrije Universiteit
  13. * Postbox 7161
  14. * 1007 MC Amsterdam
  15. * The Netherlands
  16. *
  17. */
  18. /* Author: J.W. Stevenson */
  19. #include <pc_file.h>
  20. #include <pc_err.h>
  21. extern (*_sig())();
  22. extern _catch();
  23. #ifndef CPM
  24. extern int _gtty();
  25. #endif
  26. struct file **_extfl;
  27. int _extflc; /* number of external files */
  28. char *_m_lb; /* LB of _m_a_i_n */
  29. struct file *_curfil; /* points to file struct in case of errors */
  30. int _pargc;
  31. char **_pargv;
  32. char **_penvp;
  33. int _fp_hook = 1; /* This is for Minix, but does not harm others */
  34. _ini(args,c,p,mainlb) char *args,*mainlb; int c; struct file **p; {
  35. struct file *f;
  36. char buf[128];
  37. _pargc= *(int *)args; args += sizeof (int);
  38. _pargv= *(char ***)args; args += sizeof (char **);
  39. _penvp= *(char ***)args;
  40. _sig(_catch);
  41. _extfl = p;
  42. _extflc = c;
  43. if( !c ) return;
  44. _m_lb = mainlb;
  45. if ( (f = _extfl[0]) != (struct file *) 0) {
  46. f->ptr = f->bufadr;
  47. f->flags = MAGIC|TXTBIT;
  48. f->fname = "INPUT";
  49. f->ufd = 0;
  50. f->size = 1;
  51. f->count = 0;
  52. f->buflen = PC_BUFLEN;
  53. }
  54. if ( (f = _extfl[1]) != (struct file *) 0) {
  55. f->ptr = f->bufadr;
  56. f->flags = MAGIC|TXTBIT|WRBIT|EOFBIT|ELNBIT;
  57. f->fname = "OUTPUT";
  58. f->ufd = 1;
  59. f->size = 1;
  60. #ifdef CPM
  61. f->count = 1;
  62. #else
  63. f->count = (_gtty(1,buf) >= 0 ? 1 : PC_BUFLEN);
  64. #endif
  65. f->buflen = f->count;
  66. }
  67. }