inp_pkg.spec 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* This is the specification of the generic part of the input package.
  2. It can be instantiated by #defining or not #defining
  3. INP_TYPE, INP_VAR, INP_READ_IN_ONE, and INP_NPUSHBACK.
  4. INP_TYPE is the type of the variable INP_VAR, which contains
  5. all values the user wants to save when an InsertFile is done,
  6. and restored when an input stream is continued after a suspend.
  7. For instance, line numbers and position within a line might
  8. be interesting.
  9. Not defining INP_TYPE has the effect that the instantiation is
  10. done without saving and restoring INP_VAR.
  11. Defining INP_READ_IN_ONE has the effect that files will be read
  12. completely with one "read". Only use this if you have lots of
  13. memory. Not defining it causes files to be read in blocks, with
  14. a suitable blocksize.
  15. INP_NPUSHBACK is the number of PushBacks that are guaranteed
  16. to work. Its default value is 1.
  17. */
  18. #include <ansi.h>
  19. /* INPUT PRIMITIVES */
  20. #define LoadChar(dest) ((void)((dest = *_ipp++) || (dest = loadbuf())))
  21. #define PushBack() (--_ipp)
  22. #define ChPushBack(ch) (*--_ipp = (ch))
  23. /* EOI may be defined as -1 in most programs but the character -1 may
  24. be expanded to the int -1 which causes troubles with indexing.
  25. */
  26. #define EOI (0200)
  27. extern char *_ipp;
  28. _PROTOTYPE(int loadbuf, (void));
  29. _PROTOTYPE(int AtEoIT, (void));
  30. _PROTOTYPE(int AtEoIF, (void));
  31. _PROTOTYPE(int InsertFile, (char *, char **, char **));
  32. _PROTOTYPE(int InsertText, (char *, int));
  33. /* int InsertFile(filename, table, result)
  34. char *filename;
  35. char **table;
  36. char **result;
  37. This function suspends input from the current input stream. The next
  38. characters are obtained from the file indicated by "filename". This file
  39. will be looked for in the directories, mentioned in the null-terminated
  40. list indicated by "table". It returns 1 if it succeeds, 0 if it fails.
  41. "result" will contain the full path if InsertFile returns 1.
  42. int InsertText(text, length)
  43. char *text;
  44. int length;
  45. This funtion suspends input from the current input stream. The next
  46. input characters are obtained from the string indicated by "text",
  47. whose length is indicated by "length".
  48. It returns 1 if it succeeds, 0 if it fails.
  49. */