diff options
author | Werner Koch <wk@gnupg.org> | 2022-06-02 16:10:37 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2022-06-03 10:08:21 +0200 |
commit | d2d7a2b128e981740ee3a3c6e2859bec0202cb86 (patch) | |
tree | e4e8e62681ca9ae4cb678c0a9ac85d2b25ebd7a9 /common | |
parent | tools: Minor fix to gpg-connect-agent options. (diff) | |
download | gnupg2-d2d7a2b128e981740ee3a3c6e2859bec0202cb86.tar.xz gnupg2-d2d7a2b128e981740ee3a3c6e2859bec0202cb86.zip |
Remove remaining support for WindowsCE
--
Diffstat (limited to 'common')
-rw-r--r-- | common/init.c | 97 | ||||
-rw-r--r-- | common/iobuf.c | 24 | ||||
-rw-r--r-- | common/mischelp.c | 22 | ||||
-rw-r--r-- | common/stringhelp.c | 6 | ||||
-rw-r--r-- | common/sysutils.c | 110 | ||||
-rw-r--r-- | common/t-dotlock.c | 6 | ||||
-rw-r--r-- | common/t-stringhelp.c | 5 | ||||
-rw-r--r-- | common/t-sysutils.c | 4 | ||||
-rw-r--r-- | common/utf8conv.c | 4 | ||||
-rw-r--r-- | common/util.h | 11 | ||||
-rw-r--r-- | common/w32help.h | 15 |
11 files changed, 22 insertions, 282 deletions
diff --git a/common/init.c b/common/init.c index b9f05f359..269119ff1 100644 --- a/common/init.c +++ b/common/init.c @@ -35,9 +35,6 @@ # endif # include <windows.h> #endif -#ifdef HAVE_W32CE_SYSTEM -# include <assuan.h> /* For _assuan_w32ce_finish_pipe. */ -#endif #include <gcrypt.h> #include "util.h" @@ -69,16 +66,6 @@ static mem_cleanup_item_t mem_cleanup_list; gpg_err_source_t default_errsource = 0; -#ifdef HAVE_W32CE_SYSTEM -static void parse_std_file_handles (int *argcp, char ***argvp); -static void -sleep_on_exit (void) -{ - /* The sshd on CE swallows some of the command output. Sleeping a - while usually helps. */ - Sleep (400); -} -#endif /*HAVE_W32CE_SYSTEM*/ #if HAVE_W32_SYSTEM static void prepare_w32_commandline (int *argcp, char ***argvp); @@ -178,14 +165,6 @@ _init_common_subsystems (gpg_err_source_t errsource, int *argcp, char ***argvp) } #endif -#ifdef HAVE_W32CE_SYSTEM - /* Register the sleep exit function before the estream init so that - the sleep will be called after the estream registered atexit - function which flushes the left open estream streams and in - particular es_stdout. */ - atexit (sleep_on_exit); -#endif - if (!gcry_check_version (NEED_LIBGCRYPT_VERSION)) { log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt", @@ -196,11 +175,6 @@ _init_common_subsystems (gpg_err_source_t errsource, int *argcp, char ***argvp) gpgrt_init (); gpgrt_set_alloc_func (gcry_realloc); -#ifdef HAVE_W32CE_SYSTEM - /* Special hack for Windows CE: We extract some options from arg - to setup the standard handles. */ - parse_std_file_handles (argcp, argvp); -#endif #ifdef HAVE_W32_SYSTEM /* We want gettext to always output UTF-8 and we put the console in @@ -251,77 +225,6 @@ _init_common_subsystems (gpg_err_source_t errsource, int *argcp, char ***argvp) -/* WindowsCE uses a very strange way of handling the standard streams. - There is a function SetStdioPath to associate a standard stream - with a file or a device but what we really want is to use pipes as - standard streams. Despite that we implement pipes using a device, - we would have some limitations on the number of open pipes due to - the 3 character limit of device file name. Thus we don't take this - path. Another option would be to install a file system driver with - support for pipes; this would allow us to get rid of the device - name length limitation. However, with GnuPG we can get away be - redefining the standard streams and passing the handles to be used - on the command line. This has also the advantage that it makes - creating a process much easier and does not require the - SetStdioPath set and restore game. The caller needs to pass the - rendezvous ids using up to three options: - - -&S0=<rvid> -&S1=<rvid> -&S2=<rvid> - - They are all optional but they must be the first arguments on the - command line. Parsing stops as soon as an invalid option is found. - These rendezvous ids are then used to finish the pipe creation.*/ -#ifdef HAVE_W32CE_SYSTEM -static void -parse_std_file_handles (int *argcp, char ***argvp) -{ - int argc = *argcp; - char **argv = *argvp; - const char *s; - assuan_fd_t fd; - int i; - int fixup = 0; - - if (!argc) - return; - - for (argc--, argv++; argc; argc--, argv++) - { - s = *argv; - if (*s == '-' && s[1] == '&' && s[2] == 'S' - && (s[3] == '0' || s[3] == '1' || s[3] == '2') - && s[4] == '=' - && (strchr ("-01234567890", s[5]) || !strcmp (s+5, "null"))) - { - if (s[5] == 'n') - fd = ASSUAN_INVALID_FD; - else - fd = _assuan_w32ce_finish_pipe (atoi (s+5), s[3] != '0'); - _es_set_std_fd (s[3] - '0', (int)fd); - fixup++; - } - else - break; - } - - if (fixup) - { - argc = *argcp; - argc -= fixup; - *argcp = argc; - - argv = *argvp; - for (i=1; i < argc; i++) - argv[i] = argv[i + fixup]; - for (; i < argc + fixup; i++) - argv[i] = NULL; - } - - -} -#endif /*HAVE_W32CE_SYSTEM*/ - - /* For Windows we need to parse the command line so that we can * provide an UTF-8 encoded argv. If there is any Unicode character * we return a new array but if there is no Unicode character we do diff --git a/common/iobuf.c b/common/iobuf.c index 05486b976..2137604a9 100644 --- a/common/iobuf.c +++ b/common/iobuf.c @@ -78,13 +78,8 @@ static unsigned int iobuf_buffer_size = DEFAULT_IOBUF_BUFFER_SIZE; #ifdef HAVE_W32_SYSTEM -# ifdef HAVE_W32CE_SYSTEM -# define FD_FOR_STDIN (es_fileno (es_stdin)) -# define FD_FOR_STDOUT (es_fileno (es_stdout)) -# else -# define FD_FOR_STDIN (GetStdHandle (STD_INPUT_HANDLE)) -# define FD_FOR_STDOUT (GetStdHandle (STD_OUTPUT_HANDLE)) -# endif +# define FD_FOR_STDIN (GetStdHandle (STD_INPUT_HANDLE)) +# define FD_FOR_STDOUT (GetStdHandle (STD_OUTPUT_HANDLE)) #else /*!HAVE_W32_SYSTEM*/ # define FD_FOR_STDIN (0) # define FD_FOR_STDOUT (1) @@ -1287,14 +1282,8 @@ iobuf_cancel (iobuf_t a) { /* Argg, MSDOS does not allow removing open files. So * we have to do it here */ -#ifdef HAVE_W32CE_SYSTEM - wchar_t *wtmp = utf8_to_wchar (remove_name); - if (wtmp) - DeleteFile (wtmp); - xfree (wtmp); -#else remove (remove_name); -#endif + xfree (remove_name); } #endif @@ -2893,12 +2882,7 @@ iobuf_read_line (iobuf_t a, byte ** addr_of_buffer, static int translate_file_handle (int fd, int for_write) { -#if defined(HAVE_W32CE_SYSTEM) - /* This is called only with one of the special filenames. Under - W32CE the FD here is not a file descriptor but a rendezvous id, - thus we need to finish the pipe first. */ - fd = _assuan_w32ce_finish_pipe (fd, for_write); -#elif defined(HAVE_W32_SYSTEM) +#if defined(HAVE_W32_SYSTEM) { int x; diff --git a/common/mischelp.c b/common/mischelp.c index 81dd501f8..68fd2bc24 100644 --- a/common/mischelp.c +++ b/common/mischelp.c @@ -81,34 +81,12 @@ same_file_p (const char *name1, const char *name2) HANDLE file1, file2; BY_HANDLE_FILE_INFORMATION info1, info2; -#ifdef HAVE_W32CE_SYSTEM - { - wchar_t *wname = utf8_to_wchar (name1); - if (wname) - file1 = CreateFile (wname, 0, 0, NULL, OPEN_EXISTING, 0, NULL); - else - file1 = INVALID_HANDLE_VALUE; - xfree (wname); - } -#else file1 = CreateFile (name1, 0, 0, NULL, OPEN_EXISTING, 0, NULL); -#endif if (file1 == INVALID_HANDLE_VALUE) yes = 0; /* If we can't open the file, it is not the same. */ else { -#ifdef HAVE_W32CE_SYSTEM - { - wchar_t *wname = utf8_to_wchar (name2); - if (wname) - file2 = CreateFile (wname, 0, 0, NULL, OPEN_EXISTING, 0, NULL); - else - file2 = INVALID_HANDLE_VALUE; - xfree (wname); - } -#else file2 = CreateFile (name2, 0, 0, NULL, OPEN_EXISTING, 0, NULL); -#endif if (file2 == INVALID_HANDLE_VALUE) yes = 0; /* If we can't open the file, it is not the same. */ else diff --git a/common/stringhelp.c b/common/stringhelp.c index 3e56d664d..6959299e4 100644 --- a/common/stringhelp.c +++ b/common/stringhelp.c @@ -783,11 +783,6 @@ w32_strerror (int ec) if (ec == -1) ec = (int)GetLastError (); -#ifdef HAVE_W32CE_SYSTEM - /* There is only a wchar_t FormatMessage. It does not make much - sense to play the conversion game; we print only the code. */ - snprintf (strerr, sizeof strerr, "ec=%d", (int)GetLastError ()); -#else FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, ec, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), strerr, DIM (strerr)-1, NULL); @@ -797,7 +792,6 @@ w32_strerror (int ec) if (n > 2 && strerr[n-2] == '\r' && strerr[n-1] == '\n' ) strerr[n-2] = 0; } -#endif return strerr; } #endif /*HAVE_W32_SYSTEM*/ diff --git a/common/sysutils.c b/common/sysutils.c index 1342d1016..21b6eefb2 100644 --- a/common/sysutils.c +++ b/common/sysutils.c @@ -535,10 +535,7 @@ gnupg_usleep (unsigned int usecs) int translate_sys2libc_fd (gnupg_fd_t fd, int for_write) { -#if defined(HAVE_W32CE_SYSTEM) - (void)for_write; - return (int) fd; -#elif defined(HAVE_W32_SYSTEM) +#if defined(HAVE_W32_SYSTEM) int x; if (fd == GNUPG_INVALID_FD) @@ -563,10 +560,7 @@ translate_sys2libc_fd (gnupg_fd_t fd, int for_write) int translate_sys2libc_fd_int (int fd, int for_write) { -#if HAVE_W32CE_SYSTEM - fd = (int) _assuan_w32ce_finish_pipe (fd, for_write); - return translate_sys2libc_fd ((void*)fd, for_write); -#elif HAVE_W32_SYSTEM +#ifdef HAVE_W32_SYSTEM if (fd <= 2) return fd; /* Do not do this for error, stdin, stdout, stderr. */ @@ -611,15 +605,8 @@ gnupg_tmpfile (void) { #ifdef HAVE_W32_SYSTEM int attempts, n; -#ifdef HAVE_W32CE_SYSTEM - wchar_t buffer[MAX_PATH+7+12+1]; -# define mystrlen(a) wcslen (a) - wchar_t *name, *p; -#else char buffer[MAX_PATH+7+12+1]; -# define mystrlen(a) strlen (a) char *name, *p; -#endif HANDLE file; int pid = GetCurrentProcessId (); unsigned int value; @@ -631,18 +618,13 @@ gnupg_tmpfile (void) sec_attr.bInheritHandle = TRUE; n = GetTempPath (MAX_PATH+1, buffer); - if (!n || n > MAX_PATH || mystrlen (buffer) > MAX_PATH) + if (!n || n > MAX_PATH || strlen (buffer) > MAX_PATH) { gpg_err_set_errno (ENOENT); return NULL; } - p = buffer + mystrlen (buffer); -#ifdef HAVE_W32CE_SYSTEM - wcscpy (p, L"_gnupg"); - p += 7; -#else + p = buffer + strlen (buffer); p = stpcpy (p, "_gnupg"); -#endif /* We try to create the directory but don't care about an error as it may already exist and the CreateFile would throw an error anyway. */ @@ -658,11 +640,7 @@ gnupg_tmpfile (void) *p++ = tohex (((value >> 28) & 0x0f)); value <<= 4; } -#ifdef HAVE_W32CE_SYSTEM - wcscpy (p, L".tmp"); -#else strcpy (p, ".tmp"); -#endif file = CreateFile (buffer, GENERIC_READ | GENERIC_WRITE, 0, @@ -673,10 +651,6 @@ gnupg_tmpfile (void) if (file != INVALID_HANDLE_VALUE) { FILE *fp; -#ifdef HAVE_W32CE_SYSTEM - int fd = (int)file; - fp = _wfdopen (fd, L"w+b"); -#else int fd = _open_osfhandle ((intptr_t)file, 0); if (fd == -1) { @@ -684,7 +658,6 @@ gnupg_tmpfile (void) return NULL; } fp = fdopen (fd, "w+b"); -#endif if (!fp) { int save = errno; @@ -698,9 +671,11 @@ gnupg_tmpfile (void) } gpg_err_set_errno (ENOENT); return NULL; -#undef mystrlen + #else /*!HAVE_W32_SYSTEM*/ + return tmpfile (); + #endif /*!HAVE_W32_SYSTEM*/ } @@ -799,7 +774,7 @@ gnupg_allow_set_foregound_window (pid_t pid) if (!pid) log_info ("%s called with invalid pid %lu\n", "gnupg_allow_set_foregound_window", (unsigned long)pid); -#if defined(HAVE_W32_SYSTEM) && !defined(HAVE_W32CE_SYSTEM) +#if defined(HAVE_W32_SYSTEM) else if (inhibit_set_foregound_window) ; else if (!AllowSetForegroundWindow ((pid_t)pid == (pid_t)(-1)?ASFW_ANY:pid)) @@ -1148,13 +1123,7 @@ gnupg_mkdtemp (char *tmpl) int gnupg_setenv (const char *name, const char *value, int overwrite) { -#ifdef HAVE_W32CE_SYSTEM - (void)name; - (void)value; - (void)overwrite; - return 0; -#else /*!W32CE*/ -# ifdef HAVE_W32_SYSTEM +#ifdef HAVE_W32_SYSTEM /* Windows maintains (at least) two sets of environment variables. One set can be accessed by GetEnvironmentVariable and SetEnvironmentVariable. This set is inherited by the children. @@ -1172,11 +1141,11 @@ gnupg_setenv (const char *name, const char *value, int overwrite) return -1; } } -# endif /*W32*/ +#endif /*W32*/ -# ifdef HAVE_SETENV +#ifdef HAVE_SETENV return setenv (name, value, overwrite); -# else /*!HAVE_SETENV*/ +#else /*!HAVE_SETENV*/ if (! getenv (name) || overwrite) { char *buf; @@ -1196,19 +1165,14 @@ gnupg_setenv (const char *name, const char *value, int overwrite) return putenv (buf); } return 0; -# endif /*!HAVE_SETENV*/ -#endif /*!W32CE*/ +#endif /*!HAVE_SETENV*/ } int gnupg_unsetenv (const char *name) { -#ifdef HAVE_W32CE_SYSTEM - (void)name; - return 0; -#else /*!W32CE*/ -# ifdef HAVE_W32_SYSTEM +#ifdef HAVE_W32_SYSTEM /* Windows maintains (at least) two sets of environment variables. One set can be accessed by GetEnvironmentVariable and SetEnvironmentVariable. This set is inherited by the children. @@ -1220,11 +1184,11 @@ gnupg_unsetenv (const char *name) gpg_err_set_errno (EINVAL); /* (Might also be ENOMEM.) */ return -1; } -# endif /*W32*/ +#endif /*W32*/ -# ifdef HAVE_UNSETENV +#ifdef HAVE_UNSETENV return unsetenv (name); -# else /*!HAVE_UNSETENV*/ +#else /*!HAVE_UNSETENV*/ { char *buf; @@ -1241,8 +1205,7 @@ gnupg_unsetenv (const char *name) # endif return putenv (buf); } -# endif /*!HAVE_UNSETENV*/ -#endif /*!W32CE*/ +#endif /*!HAVE_UNSETENV*/ } @@ -1571,43 +1534,6 @@ gnupg_chuid (const char *user, int silent) -#ifdef HAVE_W32CE_SYSTEM -/* There is a isatty function declaration in cegcc but it does not - make sense, thus we redefine it. */ -int -_gnupg_isatty (int fd) -{ - (void)fd; - return 0; -} -#endif - - -#ifdef HAVE_W32CE_SYSTEM -/* Replacement for getenv which takes care of the our use of getenv. - The code is not thread safe but we expect it to work in all cases - because it is called for the first time early enough. */ -char * -_gnupg_getenv (const char *name) -{ - static int initialized; - static char *assuan_debug; - - if (!initialized) - { - assuan_debug = read_w32_registry_string (NULL, - "\\Software\\GNU\\libassuan", - "debug"); - initialized = 1; - } - - if (!strcmp (name, "ASSUAN_DEBUG")) - return assuan_debug; - else - return NULL; -} - -#endif /*HAVE_W32CE_SYSTEM*/ #ifdef HAVE_W32_SYSTEM diff --git a/common/t-dotlock.c b/common/t-dotlock.c index 48f2e1f67..994ef1be3 100644 --- a/common/t-dotlock.c +++ b/common/t-dotlock.c @@ -59,11 +59,6 @@ w32_strerror (int ec) if (ec == -1) ec = (int)GetLastError (); -#ifdef HAVE_W32CE_SYSTEM - /* There is only a wchar_t FormatMessage. It does not make much - sense to play the conversion game; we print only the code. */ - snprintf (strerr, sizeof strerr, "ec=%d", (int)GetLastError ()); -#else FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, ec, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), strerr, DIM (strerr)-1, NULL); @@ -73,7 +68,6 @@ w32_strerror (int ec) if (n > 2 && strerr[n-2] == '\r' && strerr[n-1] == '\n' ) strerr[n-2] = 0; } -#endif return strerr; } diff --git a/common/t-stringhelp.c b/common/t-stringhelp.c index 4086f8c3d..6723d65b6 100644 --- a/common/t-stringhelp.c +++ b/common/t-stringhelp.c @@ -83,10 +83,6 @@ mygetcwd (void) for (;;) { buffer = xmalloc (size+1); -#ifdef HAVE_W32CE_SYSTEM - strcpy (buffer, "/"); /* Always "/". */ - return buffer; -#else if (getcwd (buffer, size) == buffer) { #ifdef HAVE_W32_SYSTEM @@ -105,7 +101,6 @@ mygetcwd (void) exit (2); } size *= 2; -#endif } } diff --git a/common/t-sysutils.c b/common/t-sysutils.c index 79f8385ac..9908c16cd 100644 --- a/common/t-sysutils.c +++ b/common/t-sysutils.c @@ -24,10 +24,6 @@ #include "util.h" #include "sysutils.h" -#ifdef HAVE_W32CE_SYSTEM -# define rewind(f) do { fseek (f, 0, SEEK_SET); clearerr (f); } while (0) -#endif - #define pass() do { ; } while(0) #define fail(a) do { fprintf (stderr, "%s:%d: test %d failed\n",\ __FILE__,__LINE__, (a)); \ diff --git a/common/utf8conv.c b/common/utf8conv.c index 1f01841c7..8b66e7f41 100644 --- a/common/utf8conv.c +++ b/common/utf8conv.c @@ -170,10 +170,8 @@ set_native_charset (const char *newset) different one for console input. Not sure how to cope with that. If the console Code page is not known we fall back to the system code page. */ -#ifndef HAVE_W32CE_SYSTEM cpno = GetConsoleOutputCP (); if (!cpno) -#endif cpno = GetACP (); sprintf (codepage, "CP%u", cpno ); /* Resolve alias. We use a long string string and not the usual @@ -806,10 +804,8 @@ get_w32_codepage (void) if (!cp) { -#ifndef HAVE_W32CE_SYSTEM cp = GetConsoleOutputCP (); if (!cp) -#endif cp = GetACP (); } return cp; diff --git a/common/util.h b/common/util.h index 43cb2fd3e..4327153bc 100644 --- a/common/util.h +++ b/common/util.h @@ -390,18 +390,7 @@ _gnupg_ttyname (int fd) # define gnupg_ttyname(n) ttyname ((n)) #endif /*HAVE_TTYNAME */ -#ifdef HAVE_W32CE_SYSTEM -#define getpid() GetCurrentProcessId () -char *_gnupg_getenv (const char *name); /* See sysutils.c */ -#define getenv(a) _gnupg_getenv ((a)) -char *_gnupg_setenv (const char *name); /* See sysutils.c */ -#define setenv(a,b,c) _gnupg_setenv ((a),(b),(c)) -int _gnupg_isatty (int fd); -#define gnupg_isatty(a) _gnupg_isatty ((a)) -#else #define gnupg_isatty(a) isatty ((a)) -#endif - /*-- Macros to replace ctype ones to avoid locale problems. --*/ diff --git a/common/w32help.h b/common/w32help.h index a79081f8e..33000acc7 100644 --- a/common/w32help.h +++ b/common/w32help.h @@ -46,21 +46,6 @@ char *read_w32_registry_string (const char *root, const char *dir, const char *name ); char *read_w32_reg_string (const char *key); -/* Other stuff. */ -#ifdef HAVE_W32CE_SYSTEM -/* Setmode is missing in cegcc but available since CE 5.0. */ -int _setmode (int handle, int mode); -# define setmode(a,b) _setmode ((a),(b)) - -static inline int -umask (int a) -{ - (void)a; - return 0; -} - - -#endif /*HAVE_W32CE_SYSTEM*/ #endif /*HAVE_W32_SYSTEM*/ #endif /*GNUPG_COMMON_MISCHELP_H*/ |