--- cherokee_trunk/cherokee/post.c 2007-07-04 13:23:51.357915000 -0700 +++ cherokee/cherokee/post.c 2007-07-23 14:35:27.946125000 -0700 @@ -81,6 +81,58 @@ } +#ifdef __MINGW32__ +int +win32_mkstemp (cherokee_buffer_t *buffer) +{ + int rv = -1; + static char tmp_file[MAX_PATH + 14] = {0}; + + while (1) { + char buferr[ERROR_MAX_BUFSIZE]; + char winerr[ERROR_MAX_BUFSIZE]; + + static char tmp_path[MAX_PATH + 14] = {0}; + static UINT uUnique = 0; + FILE *fp; + DWORD err; + + *tmp_file = '\0'; + + if (!*tmp_path) { + if (!GetTempPath(sizeof(tmp_path), tmp_path)) { + err = GetLastError(); + win_strerror(err, winerr, sizeof(winerr)); + PRINT_MSG ("Couldn't get temporary path: %s (error %d)", winerr, err); + /* strcpy(tmp_path, "\\"); /* TODO FIXME use c:\Progra~\cherokee\var\tmp ? */ + break; + } + } + + if (!GetTempFileName(tmp_path, "chp", uUnique++, tmp_file)) { + err = GetLastError(); + win_strerror(err, winerr, sizeof(winerr)); + PRINT_MSG ("Couldn't generate temporary file name: %s (error %d)", winerr, err); + break; + } + + fp = fopen(tmp_file, "wb"); + if (!fp) { + PRINT_MSG ("Couldn't create '%s': %s (error %d)", tmp_file, strerror(errno), errno); + break; + } + + rv = _fileno(fp); + break; + } + + cherokee_buffer_add_str (buffer, tmp_file); + + return rv; +} +#endif /* __MINGW32__ */ + + ret_t cherokee_post_set_len (cherokee_post_t *post, off_t len) { @@ -88,11 +140,16 @@ post->size = len; if (post->type == post_in_tmp_file) { +#ifndef __MINGW32__ cherokee_buffer_add_str (&post->tmp_file, "/tmp/cherokee_post_XXXXXX"); /* Generate a unique name */ post->tmp_file_fd = mkstemp (post->tmp_file.buf); +#else + post->tmp_file_fd = win32_mkstemp (&post->tmp_file); +#endif + if (unlikely (post->tmp_file_fd < 0)) { return ret_error; } --- cherokee_trunk/ChangeLog 2007-07-22 15:58:32.472611000 -0700 +++ cherokee/ChangeLog 2007-07-23 15:27:37.133625000 -0700 @@ -1,3 +1,8 @@ +2007-07-23 Ross Smith II + + * cherokee/post.c: Add mkstemp() functionality missing in + MinGW. + 2007-07-22 Alvaro Lopez Ortega * cherokee/handler_redir.c, cherokee/read_config_embedded.c, @@ -492,7 +497,7 @@ * cherokee/win32_cservice.h, cherokee/win32_cservice.c, cherokee/win32_cherokeeserv.c, windows/cherokee.reg: Added a Win32 - service. Code by Ross Smith II + service. Code by Ross Smith II * cherokee/Makefile.am (win32_cherokeeserv), windows/cherokee.reg: Created new binary target, and added win32_cservice.h, @@ -503,7 +508,7 @@ * cherokee/win32_misc.h, cherokee/win32_misc.c: Added new func cherokee_win32_shutdown_signaled(). Patch by Ross Smith II - + * cherokee/server.c (cherokee_server_step): Call cherokee_win32_shutdown_signaled() before checking if the server