home *** CD-ROM | disk | FTP | other *** search
- /*
- * filestack.c
- *
- * (c) Andy Duplain, August 1992.
- * Added line numbers Niklas Röjemo
- */
-
- #include <stdio.h>
- #include "input.h"
- #include "error.h"
-
- #define STACKSIZE 10
-
- static FILE *stack[STACKSIZE];
- static int stackLine[STACKSIZE];
- static int top = 0;
-
- int
- push_file(FILE *fp)
- {
- if (top == STACKSIZE) {
- error(ErrorSerious, TRUE, "Maximum file nesting level reached (%d)", STACKSIZE);
- return (-1);
- }
- stackLine[top] = inputLineNo;
- stack[top++] = fp;
- return (0);
- }
-
- FILE *
- pop_file(void)
- {
- if(top) {
- inputLineNo = stackLine[--top];
- return stack[top];
- }
- return NULL;
- }
-