Fix the Watcom build, and UNC paths in httpsrv on Windows
Some checks are pending
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Waiting to run

Open Watcom has no struct _stat64 or _wstat64: its 64-bit stat is
struct _stati64 and _wstati64, so httpsrv.c did not compile there and
the 1.0.1 lite build had no binaries.

widepath() compared and wrote '\\\\', a two-character constant, for a
backslash: a UNC path (\\server\share) never took the \\?\UNC\ form,
and forward slashes became backslashes only because the constant was
truncated to its last byte.

The Watcom workflow passed although nmake failed; it now fails when
the build does or leaves no 3proxy.exe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 9651848bf1)
This commit is contained in:
Vladimir Dubrovin 2026-10-14 17:40:16 +03:00
parent d0e88a7b88
commit 44e372649a
2 changed files with 14 additions and 2 deletions

View File

@ -40,6 +40,8 @@ jobs:
run: |
echo "volatile char VerSion[]=^"3APA3A-3proxy-Internal-Build: 3proxy-%RELEASE%-%NOW%\r\n^";" >>src/3proxy.c
nmake /F Makefile.watcom
if errorlevel 1 exit /b 1
if not exist bin\3proxy.exe (echo bin\3proxy.exe was not built & exit /b 1)
- name: make dist dir
shell: cmd
run: |

View File

@ -457,12 +457,12 @@ static int widepath(const char *path, wchar_t *out, int outchars)
char *p;
if(!strncmp(path, "\\\\?\\", 4)) snprintf(prefixed, sizeof(prefixed), "%s", path);
else if(path[0] == '\\\\' && path[1] == '\\\\')
else if(path[0] == '\\' && path[1] == '\\')
snprintf(prefixed, sizeof(prefixed), "\\\\?\\UNC\\%s", path + 2);
else snprintf(prefixed, sizeof(prefixed), "\\\\?\\%s", path);
/* the extended form takes no forward slashes */
for(p = prefixed; *p; p++) if(*p == '/') *p = '\\\\';
for(p = prefixed; *p; p++) if(*p == '/') *p = '\\';
return MultiByteToWideChar(CP_UTF8, 0, prefixed, -1, out, outchars) > 0? 0 : 1;
}
@ -479,9 +479,19 @@ static int filemeta(const char *path, struct filemeta *m)
{
#ifdef _WIN32
wchar_t wide[HTTPSRV_LINE];
#ifdef __WATCOMC__
/* Open Watcom has the 64-bit stat under its older name */
#ifndef _S_IFREG
#define _S_IFREG S_IFREG
#endif
struct _stati64 st;
if(widepath(path, wide, HTTPSRV_LINE) || _wstati64(wide, &st)) return 1;
#else
struct _stat64 st;
if(widepath(path, wide, HTTPSRV_LINE) || _wstat64(wide, &st)) return 1;
#endif
m->size = (uint64_t)st.st_size;
m->mtime = st.st_mtime;
m->isreg = (st.st_mode & _S_IFREG) != 0;