]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - test.c
More cleanups
[xonotic/gmqcc.git] / test.c
diff --git a/test.c b/test.c
index a0484befecb788ddd5f7507af9384e26f3e85945..77ce860626ab8226bef9fd9adc5102fb8a054427 100644 (file)
--- a/test.c
+++ b/test.c
@@ -52,15 +52,15 @@ static const char *task_bins[] = {
 #include <dirent.h>
 #include <unistd.h>
 typedef struct {
-    FILE *handles[3];
-    int   pipes  [3];
+    fs_file_t *handles[3];
+    int        pipes  [3];
 
     int stderr_fd;
     int stdout_fd;
     int pid;
 } popen_t;
 
-static FILE ** task_popen(const char *command, const char *mode) {
+static fs_file_t **task_popen(const char *command, const char *mode) {
     int     inhandle  [2];
     int     outhandle [2];
     int     errhandle [2];
@@ -102,9 +102,9 @@ static FILE ** task_popen(const char *command, const char *mode) {
         data->pipes  [1] = outhandle[0];
         data->pipes  [2] = errhandle[0];
 
-        data->handles[0] = fdopen(inhandle [1], "w");
-        data->handles[1] = fdopen(outhandle[0], mode);
-        data->handles[2] = fdopen(errhandle[0], mode);
+        data->handles[0] = (fs_file_t*)fdopen(inhandle [1], "w");
+        data->handles[1] = (fs_file_t*)fdopen(outhandle[0], mode);
+        data->handles[2] = (fs_file_t*)fdopen(errhandle[0], mode);
 
         /* sigh */
         vec_free(argv);
@@ -136,7 +136,7 @@ task_popen_error_0:
     return NULL;
 }
 
-static int task_pclose(FILE **handles) {
+static int task_pclose(fs_file_t **handles) {
     popen_t *data   = (popen_t*)handles;
     int      status = 0;
 
@@ -152,12 +152,12 @@ static int task_pclose(FILE **handles) {
 }
 #else
     typedef struct {
-        FILE *handles[3];
-        char  name_err[L_tmpnam];
-        char  name_out[L_tmpnam];
+        fs_file_t *handles[3];
+        char       name_err[L_tmpnam];
+        char       name_out[L_tmpnam];
     } popen_t;
 
-    static FILE **task_popen(const char *command, const char *mode) {
+    static fs_file_t **task_popen(const char *command, const char *mode) {
         char    *cmd  = NULL;
         popen_t *open = (popen_t*)mem_a(sizeof(popen_t));
 
@@ -178,10 +178,12 @@ static int task_pclose(FILE **handles) {
         return open->handles;
     }
 
-    static int task_pclose(FILE **files) {
+    static int task_pclose(fs_file_t **files) {
         popen_t *open = ((popen_t*)files);
+
         fs_file_close(files[1]);
         fs_file_close(files[2]);
+
         remove(open->name_err);
         remove(open->name_out);
 
@@ -357,7 +359,7 @@ static bool task_template_generate(task_template_t *tmpl, char tag, const char *
     return true;
 }
 
-static bool task_template_parse(const char *file, task_template_t *tmpl, FILE *fp, size_t *pad) {
+static bool task_template_parse(const char *file, task_template_t *tmpl, fs_file_t *fp, size_t *pad) {
     char  *data = NULL;
     char  *back = NULL;
     size_t size = 0;
@@ -498,7 +500,7 @@ static task_template_t *task_template_compile(const char *file, const char *dir,
     /* a page should be enough */
     char             fullfile[4096];
     size_t           filepadd = 0;
-    FILE            *tempfile = NULL;
+    fs_file_t       *tempfile = NULL;
     task_template_t *tmpl     = NULL;
 
     platform_snprintf(fullfile,    sizeof(fullfile), "%s/%s", dir, file);
@@ -653,9 +655,9 @@ static void task_template_destroy(task_template_t *tmpl) {
  */
 typedef struct {
     task_template_t *tmpl;
-    FILE           **runhandles;
-    FILE            *stderrlog;
-    FILE            *stdoutlog;
+    fs_file_t       **runhandles;
+    fs_file_t       *stderrlog;
+    fs_file_t       *stdoutlog;
     char            *stdoutlogfile;
     char            *stderrlogfile;
     bool             compiled;
@@ -669,8 +671,8 @@ static task_t *task_tasks = NULL;
  */
 static bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
     bool             success = true;
-    DIR             *dir;
-    struct dirent   *files;
+    fs_dir_t        *dir;
+    fs_dirent_t     *files;
     struct stat      directory;
     char             buffer[4096];
     size_t           found = 0;
@@ -866,9 +868,9 @@ static bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
  * left behind from a previous invoke of the test-suite.
  */
 static void task_precleanup(const char *curdir) {
-    DIR             *dir;
-    struct dirent   *files;
-    char             buffer[4096];
+    fs_dir_t     *dir;
+    fs_dirent_t  *files;
+    char          buffer[4096];
 
     dir = fs_dir_open(curdir);
 
@@ -934,7 +936,7 @@ static bool task_trymatch(size_t i, char ***line) {
     bool             success = true;
     bool             process = true;
     int              retval  = EXIT_SUCCESS;
-    FILE            *execute;
+    fs_file_t       *execute;
     char             buffer[4096];
     task_template_t *tmpl = task_tasks[i].tmpl;
 
@@ -958,7 +960,7 @@ static bool task_trymatch(size_t i, char ***line) {
             );
         }
 
-        execute = popen(buffer, "r");
+        execute = (fs_file_t*)popen(buffer, "r");
         if (!execute)
             return false;
     } else if (!strcmp(tmpl->proceduretype, "-pp")) {
@@ -1000,7 +1002,7 @@ static bool task_trymatch(size_t i, char ***line) {
                 if (!process)
                     fs_file_close(execute);
                 else
-                    pclose(execute);
+                    pclose((FILE*)execute);
                 return false;
             }
 
@@ -1060,7 +1062,7 @@ static bool task_trymatch(size_t i, char ***line) {
     }
 
     if (process)
-        retval = pclose(execute);
+        retval = pclose((FILE*)execute);
     else
         fs_file_close(execute);
 
@@ -1147,7 +1149,7 @@ static size_t task_schedualize(size_t *pad) {
             }
 
             fs_file_puts (task_tasks[i].stderrlog, data);
-            fflush(task_tasks[i].stderrlog); /* fast flush for read */
+            fs_file_flush(task_tasks[i].stderrlog); /* fast flush for read */
         }
 
         if (!task_tasks[i].compiled && strcmp(task_tasks[i].tmpl->proceduretype, "-fail")) {