X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_win32util.c;h=b37c19d78f8df2c454f225d78c287cf179a47723;hb=eb51b1ea1f75a0ec17c9c5937cb28df1e8eeec56;hp=d5bcd70199ed9e189cfcec228e12f9383e499fe0;hpb=1f7a36fe16b11bb4aab51be89bbc1b0f75936b78;p=ncurses.git diff --git a/ncurses/tinfo/lib_win32util.c b/ncurses/tinfo/lib_win32util.c index d5bcd701..b37c19d7 100644 --- a/ncurses/tinfo/lib_win32util.c +++ b/ncurses/tinfo/lib_win32util.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020-2021,2023 Thomas E. Dickey * * Copyright 1998-2009,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -34,7 +34,7 @@ #include -MODULE_ID("$Id: lib_win32util.c,v 1.1 2020/08/14 21:57:01 juergen Exp $") +MODULE_ID("$Id: lib_win32util.c,v 1.3 2023/02/25 20:07:48 tom Exp $") #ifdef _NC_WINDOWS #include @@ -48,7 +48,7 @@ MODULE_ID("$Id: lib_win32util.c,v 1.1 2020/08/14 21:57:01 juergen Exp $") /* This function tests, whether or not the ncurses application is running as a descendant of MSYS2/cygwin mintty terminal - application. mintty doesn't use Windows Console for it's screen + application. mintty doesn't use Windows Console for its screen I/O, so the native Windows _isatty doesn't recognize it as character device. But we can discover we are at the end of an Pipe and can query the server side of the pipe, looking whether @@ -68,10 +68,10 @@ _nc_console_checkmintty(int fd, LPHANDLE pMinTTY) T((T_CALLED("lib_winhelper::_nc_console_checkmintty(%d, %p)"), fd, pMinTTY)); if (handle != INVALID_HANDLE_VALUE) { - dw = GetFileType(handle); + dw = GetFileType(handle); if (dw == FILE_TYPE_PIPE) { if (GetNamedPipeInfo(handle, 0, 0, 0, 0)) { - ULONG pPid; + ULONG pPid; /* Requires NT6 */ if (GetNamedPipeServerProcessId(handle, &pPid)) { TCHAR buf[MAX_PATH]; @@ -79,8 +79,7 @@ _nc_console_checkmintty(int fd, LPHANDLE pMinTTY) /* These security attributes may allow us to create a remote thread in mintty to manipulate the terminal state remotely */ - HANDLE pHandle = OpenProcess( - PROCESS_CREATE_THREAD + HANDLE pHandle = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE @@ -88,20 +87,19 @@ _nc_console_checkmintty(int fd, LPHANDLE pMinTTY) FALSE, pPid); if (pMinTTY) - *pMinTTY = INVALID_HANDLE_VALUE; + *pMinTTY = INVALID_HANDLE_VALUE; if (pHandle != INVALID_HANDLE_VALUE) { - if ((len = GetProcessImageFileName( - pHandle, + if ((len = GetProcessImageFileName(pHandle, buf, (DWORD) array_length(buf)))) { TCHAR *pos = _tcsrchr(buf, _T('\\')); if (pos) { - pos++; + pos++; if (_tcsnicmp(pos, _TEXT("mintty.exe"), 10) == 0) { if (pMinTTY) - *pMinTTY = pHandle; + *pMinTTY = pHandle; code = 1; } } @@ -114,7 +112,8 @@ _nc_console_checkmintty(int fd, LPHANDLE pMinTTY) returnCode(code); } #endif /* _NC_CHECK_MINTTY */ - + +#if HAVE_GETTIMEOFDAY == 2 #define JAN1970 116444736000000000LL /* the value for 01/01/1970 00:00 */ NCURSES_EXPORT(int) @@ -130,5 +129,6 @@ _nc_gettimeofday(struct timeval *tv, void *tz GCC_UNUSED) tv->tv_sec = (long) ((data.since1601 - JAN1970) / 10000000LL); return (0); } +#endif // HAVE_GETTIMEOFDAY == 2 #endif // _NC_WINDOWS