9 progfuncs_t *qccprogfuncs;
13 extern int qcc_compileactive;
14 jmp_buf qcccompileerror;
15 char qcc_gamedir[128];
16 void QCC_PR_ResetErrorScope(void);
27 void *qccHunkAlloc(size_t mem)
32 if (qccalloced > qcchunksize)
33 QCC_Error(ERR_INTERNAL, "Compile hunk was filled");
35 memset(qcchunk+qccalloced-mem, 0, mem);
36 return qcchunk+qccalloced-mem;
38 void qccClearHunk(void)
47 void PostCompile(void)
58 pbool PreCompile(void)
60 QCC_PR_ResetErrorScope();
63 strcpy(qcc_gamedir, "");
64 qcchunk = malloc(qcchunksize=256*1024*1024);
65 while(!qcchunk && qcchunksize > 8*1024*1024)
68 qcchunk = malloc(qcchunksize);
75 void QCC_main (int argc, char **argv);
76 void QCC_ContinueCompile(void);
77 void QCC_FinishCompile(void);
79 int comp_nump;char **comp_parms;
80 //void Editor(char *fname, int line, int numparms, char **compileparms);
81 pbool CompileParams(progfuncs_t *progfuncs, int doall, int nump, char **parms)
86 qccprogfuncs = progfuncs;
87 if (setjmp(qcccompileerror))
92 if (!externs->useeditor)
93 printf("Error in %s on line %i\n", errorfile, errorline);
95 externs->useeditor(progfuncs, errorfile, errorline, nump, parms);
102 QCC_main(nump, parms);
104 while(qcc_compileactive)
105 QCC_ContinueCompile();
111 int Comp_Begin(progfuncs_t *progfuncs, int nump, char **parms)
115 qccprogfuncs = progfuncs;
117 if (setjmp(qcccompileerror))
121 externs->useeditor(progfuncs, errorfile, errorline, nump, parms);
127 QCC_main(nump, parms);
131 int Comp_Continue(progfuncs_t *progfuncs)
133 qccprogfuncs = progfuncs;
134 if (setjmp(qcccompileerror))
137 if (*errorfile && externs->useeditor)
138 externs->useeditor(progfuncs, errorfile, errorline, comp_nump, comp_parms);
142 if (qcc_compileactive)
143 QCC_ContinueCompile();
148 if (*errorfile && externs->useeditor)
149 externs->useeditor(progfuncs, errorfile, errorline, comp_nump, comp_parms);
157 pbool CompileFile(progfuncs_t *progfuncs, char *filename)
171 strcpy(newname, filename);
173 if (strchr(s+1, '/'))
177 s2 = strchr(s+1, '/');
186 p[parms+1] = newname;
189 strcpy(srcfile, s+1);
190 srcfile[strlen(srcfile)-4] = '\0';
191 strcat(srcfile, ".src");
193 if (externs->FileSize(qcva("%s/%s", newname, srcfile))>0)
195 p[parms] = "-srcfile";
196 p[parms+1] = srcfile;
202 p[parms] = "-srcfile";
203 p[parms+1] = newname;
204 newname[strlen(newname)-4] = '\0';
205 strcat(newname, ".src");
208 // p[2][strlen(p[2])-4] = '\0';
209 // strcat(p[2], "/");
211 while (!CompileParams(progfuncs, true, parms, p))
219 int QC_strncasecmp(const char *s1, const char *s2, int n)
229 return 0; // strings are equal until end point
233 if (c1 >= 'a' && c1 <= 'z')
235 if (c2 >= 'a' && c2 <= 'z')
238 return -1; // strings not equal
241 return 0; // strings are equal
247 void editbadfile(char *fname, int line)
249 strcpy(errorfile, fname);