void _pushFileStack(char *fileName) { int i; if (fileStackLevel >= 0) { for (i = 0; i < g_tlang.numOfOutFiles; i++) { g_tlang.outputCurrLine(i, 0); if (CURR_OUTPUT(i) != NULL) { wicFclose(CURR_OUTPUT(i)); } } } fileStackLevel++; if (fileStackLevel >= MAX_INCLUDE_NEST) { fileStackLevel--; reportError(ERR_NEST_INCLUDE); return; } else { FDReadInd entry; pFDReadInd incFile; initFDReadInd(&entry, fileName, 0); incFile = findHTableElem(g_fileTable, &entry); assert(incFile != NULL); assert(fileName != NULL); for (i = 0; i < g_tlang.numOfOutFiles; i++) { setNewFileExt(CURR_FILE_NAME(i), fileName, g_tlang.extension[i]); if (incFile->readOnly) { CURR_OUTPUT(i) = NULL; } else { CURR_OUTPUT(i) = wicFopen(CURR_FILE_NAME(i), "wt"); if (CURR_OUTPUT(i) == NULL) { int j; for (j = i-1; j >= 0; j--) { wicFclose(CURR_OUTPUT(j)); CURR_OUTPUT(j) = NULL; } // fileStackLevel--; return; } } CURR_LAST_CHAR(i) = 0; CURR_LINE_LEN(i) = 0; CURR_LINE(i)[0] = 0; CURR_LINE_FLAGS(i) = g_tlang.lfInitFlags; } } }
pFDReadInd createFDReadInd(char *name, int readOnly) { pFDReadInd entry = wicMalloc(sizeof *entry); assert(name != NULL); initFDReadInd(entry, name, readOnly); return entry; }