X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=test.c;h=0af74771cda014922689192acba012216030c2fa;hp=6987bb3f6af9bd0b435d13c3bd60806fd65067b8;hb=10dd7aacfe87f97e10d61dff343e00b9c03eac69;hpb=dc8523c6503e014a463df42520b48f597c7655be diff --git a/test.c b/test.c old mode 100755 new mode 100644 index 6987bb3..0af7477 --- a/test.c +++ b/test.c @@ -26,7 +26,7 @@ opts_cmd_t opts; -const char *task_bins[] = { +static const char *task_bins[] = { "./gmqcc", "./qcvm" }; @@ -152,27 +152,41 @@ int task_pclose(FILE **handles) { return status; } #else - /* - * Bidirectional piping implementation for windows using CreatePipe and DuplicateHandle + - * other hacks. - */ typedef struct { - int __dummy; - /* TODO: implement */ + FILE *handles[3]; + char name_err[L_tmpnam]; + char name_out[L_tmpnam]; } popen_t; FILE **task_popen(const char *command, const char *mode) { - (void)command; - (void)mode; + char *cmd = NULL; + popen_t *open = (popen_t*)mem_a(sizeof(popen_t)); + + tmpnam(open->name_err); + tmpnam(open->name_out); + + (void)mode; /* excluded */ + + util_asprintf(&cmd, "%s -redirout=%s -redirerr=%s", command, open->name_out, open->name_err); - /* TODO: implement */ - return NULL; + system(cmd); /* HACK */ + open->handles[0] = NULL; + open->handles[1] = fs_file_open(open->name_out, "r"); + open->handles[2] = fs_file_open(open->name_err, "r"); + + mem_d(cmd); + + return open->handles; } void task_pclose(FILE **files) { - /* TODO: implement */ - (void)files; - return; + popen_t *open = ((popen_t*)files); + fs_file_close(files[1]); + fs_file_close(files[2]); + remove(open->name_err); + remove(open->name_out); + + mem_d(open); } #endif /*! _WIN32 */ @@ -640,7 +654,7 @@ typedef struct { bool compiled; } task_t; -task_t *task_tasks = NULL; +static task_t *task_tasks = NULL; /* * Read a directory and searches for all template files in it