cvs commit: apache-1.3/src/os/win32 os.h util_win32.c
manoj 98/11/05 11:20:18 Modified:src CHANGES src/include ap_config.h src/os/win32 os.h util_win32.c Log: Work around incomplete implementation of strftime on Win32. Revision ChangesPath 1.1134+3 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1133 retrieving revision 1.1134 diff -u -u -r1.1133 -r1.1134 --- CHANGES 1998/11/04 22:23:42 1.1133 +++ CHANGES 1998/11/05 19:20:14 1.1134 @@ -1,5 +1,8 @@ Changes with Apache 1.3.4 + *) Work around incomplete implementation of strftime on Win32. + [Manoj Kasichainula, Ken Parzygnat [EMAIL PROTECTED]] + *) Move a typedef to fix compile problems on Linux with 1.x kernels. [Manoj Kasichainula] PR#3177 1.243 +3 -0 apache-1.3/src/include/ap_config.h Index: ap_config.h === RCS file: /export/home/cvs/apache-1.3/src/include/ap_config.h,v retrieving revision 1.242 retrieving revision 1.243 diff -u -u -r1.242 -r1.243 --- ap_config.h 1998/11/04 22:23:45 1.242 +++ ap_config.h 1998/11/05 19:20:16 1.243 @@ -938,6 +938,9 @@ #endif /* ndef WIN32 */ #include time.h/* for ctime */ +#ifdef WIN32 +#define strftime(s,max,format,tm) os_strftime(s,max,format,tm) +#endif #include signal.h #include errno.h #if !defined(QNX) !defined(CONVEXOS11) !defined(NEXT) 1.25 +2 -0 apache-1.3/src/os/win32/os.h Index: os.h === RCS file: /export/home/cvs/apache-1.3/src/os/win32/os.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -u -r1.24 -r1.25 --- os.h 1998/09/19 12:27:25 1.24 +++ os.h 1998/11/05 19:20:17 1.25 @@ -93,6 +93,8 @@ #define stat(f,ps) os_stat(f,ps) API_EXPORT(int) os_stat(const char *szPath,struct stat *pStat); +API_EXPORT(int) os_strftime(char *s, size_t max, const char *format, const struct tm *tm); + #define _spawnv(mode,cmdname,argv) os_spawnv(mode,cmdname,argv) #define spawnv(mode,cmdname,argv)os_spawnv(mode,cmdname,argv) API_EXPORT(int) os_spawnv(int mode,const char *cmdname,const char *const *argv); 1.27 +69 -0 apache-1.3/src/os/win32/util_win32.c Index: util_win32.c === RCS file: /export/home/cvs/apache-1.3/src/os/win32/util_win32.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -u -r1.26 -r1.27 --- util_win32.c 1998/10/01 04:52:32 1.26 +++ util_win32.c 1998/11/05 19:20:17 1.27 @@ -1,6 +1,8 @@ #include windows.h #include sys/stat.h #include stdarg.h +#include time.h +#include stdlib.h #include httpd.h #include http_log.h @@ -415,4 +417,71 @@ va_end(vlist); return _spawnve(mode, szCmd, aszArgs, aszEnv); +} + +#undef strftime + +/* Partial replacement for strftime. This adds certain expandos to the + * Windows version + */ + +API_EXPORT(int) os_strftime(char *s, size_t max, const char *format, +const struct tm *tm) { + /* If the new format string is bigger than max, the result string probably +* won't fit anyway. When %-expandos are added, made sure the padding below +* is enough. +*/ +char *new_format = (char *) _alloca(max + 11); +size_t i, j, format_length = strlen(format); +int return_value; +int length_written; + +for (i = 0, j = 0; (i format_length j max)) { +if (format[i] != '%') { +new_format[j++] = format[i++]; +continue; +} +switch (format[i+1]) { +case 'D': +/* Is this locale dependent? Shouldn't be... + Also note the year 2000 exposure here */ +memcpy(new_format + j, %m/%d/%y, 8); +i += 2; +j += 8; +break; +case 'r': +memcpy(new_format + j, %I:%M:%S %p, 11); +i += 2; +j += 11; +break; +case 'T': +memcpy(new_format + j, %H:%M:%S, 8); +i += 2; +j += 8; +break; +case 'e': +length_written = ap_snprintf(new_format + j, max - j, %2d, +tm-tm_mday); +j = (length_written == -1) ? max : (j + length_written); +i += 2; +break; +/* Handle %% to avoid dying on strftime(out, 600, 1200 %'s) */ +case '%': +
cvs commit: apache-1.3/src/os/win32 util_win32.c
coar98/11/05 12:07:53 Modified:src CHANGES src/include httpd.h src/main http_request.c src/os/win32 util_win32.c Log: Simplify the Win32 os_demoniacal_fil.. er, os_canonical_filename() routine so that it's a bit more deterministic. PR: 2555, 2915, 3064, 3232 Submitted by: Ken Parzygnat [EMAIL PROTECTED] Reviewed by: Ben Laurie, Marc Slemko Revision ChangesPath 1.1135+4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1134 retrieving revision 1.1135 diff -u -r1.1134 -r1.1135 --- CHANGES 1998/11/05 19:20:14 1.1134 +++ CHANGES 1998/11/05 20:07:48 1.1135 @@ -1,5 +1,9 @@ Changes with Apache 1.3.4 + *) Rework os_canonical_*() on Win32 so it's simpler, more + robust, and works. [Ken Parzygnat [EMAIL PROTECTED]] + PR#2555, 2915, 3064, 3232 + *) Work around incomplete implementation of strftime on Win32. [Manoj Kasichainula, Ken Parzygnat [EMAIL PROTECTED]] 1.250 +9 -0 apache-1.3/src/include/httpd.h Index: httpd.h === RCS file: /export/home/cvs/apache-1.3/src/include/httpd.h,v retrieving revision 1.249 retrieving revision 1.250 diff -u -r1.249 -r1.250 --- httpd.h 1998/10/28 19:26:28 1.249 +++ httpd.h 1998/11/05 20:07:51 1.250 @@ -998,8 +998,17 @@ #ifndef HAVE_CANONICAL_FILENAME #define ap_os_canonical_filename(p,f) (f) +#define ap_os_case_canonical_filename(p,f) (f) +#define ap_os_systemcase_filename(p,f) (f) #else API_EXPORT(char *) ap_os_canonical_filename(pool *p, const char *file); +#ifdef WIN32 +API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile); +API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile); +#else +#define ap_os_case_canonical_filename(p,f) ap_os_canonical_filename(p,f) +#define ap_os_systemcase_filename(p,f) ap_os_canonical_filename(p,f) +#endif #endif #ifdef _OSD_POSIX 1.136 +8 -5 apache-1.3/src/main/http_request.c Index: http_request.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_request.c,v retrieving revision 1.135 retrieving revision 1.136 diff -u -r1.135 -r1.136 --- http_request.c1998/10/20 17:42:43 1.135 +++ http_request.c1998/11/05 20:07:52 1.136 @@ -359,16 +359,19 @@ return OK; } -r-filename = ap_os_canonical_filename(r-pool, r-filename); -test_filename = ap_pstrdup(r-pool, r-filename); - -ap_no2slash(test_filename); -num_dirs = ap_count_dirs(test_filename); +r-filename = ap_os_case_canonical_filename(r-pool, r-filename); res = get_path_info(r); if (res != OK) { return res; } + +r-filename = ap_os_canonical_filename(r-pool, r-filename); + +test_filename = ap_pstrdup(r-pool, r-filename); + +ap_no2slash(test_filename); +num_dirs = ap_count_dirs(test_filename); if ((res = check_safe_file(r))) { return res; 1.28 +254 -200 apache-1.3/src/os/win32/util_win32.c Index: util_win32.c === RCS file: /export/home/cvs/apache-1.3/src/os/win32/util_win32.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- util_win32.c 1998/11/05 19:20:17 1.27 +++ util_win32.c 1998/11/05 20:07:53 1.28 @@ -7,214 +7,275 @@ #include httpd.h #include http_log.h -/* Returns TRUE if the path is real, FALSE if it is PATH_INFO */ -static BOOL sub_canonical_filename(char *szCanon, unsigned nCanon, -const char *szInFile) +/* Returns TRUE if the input string is a string + * of one or more '.' characters. + */ +static BOOL OnlyDots(char *pString) { +char *c; + +if (*pString == '\0') +return FALSE; + +for (c = pString;*c;c++) +if (*c != '.') +return FALSE; + +return TRUE; +} + +/* Accepts as input a pathname, and tries to match it to an + * existing path and return the pathname in the case that + * is present on the existing path. This routine also + * converts alias names to long names. + */ +API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, + const char *szFile) +{ char buf[HUGE_STRING_LEN]; -int n; -char *szFilePart; -char *s; -int nSlashes; -WIN32_FIND_DATA d; -HANDLE h; -const char *szFile; - -szFile = szInFile; -