aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32-io.c
Commit message (Collapse)AuthorAgeFilesLines
* w32: Fix typo which broke the buildIngo Klöcker2026-06-291-1/+1
| | | | | | | * src/w32-io.c (_gpgme_io_spawn): Replace bogus #else with #endif. -- Fixes-commit: df6c94f136e5411aabeb3000403f402f2a25092b
* w32: Use gpgrt_w32_set_errno if gpgrt is new enough.Werner Koch2026-06-251-10/+17
| | | | | | * src/w32-io.c (_gpgme_io_spawn): Add mapping from Windows error number. (_gpgme_io_select): Ditto.
* w32:io: Serialize the access to ctx->* between reader/writer and io.NIIBE Yutaka2026-05-191-30/+40
| | | | | | | | | | * src/w32-io.c (reader, writer): Protect shared access to ctx->* correctly, by using the internal buffer. -- GnuPG-bug-id: 8264 Signed-off-by: NIIBE Yutaka <[email protected]>
* io:w32:spawn_sans_helper: Fix inherit of HANDLES to child process.NIIBE Yutaka2026-05-181-7/+7
| | | | | | | | | | | * src/w32-io.c (_gpgme_io_spawn_sans_helper): Inherit HANDLES correctly, even when an argument is not modified. -- Fixes-commit: 64f80903ec9bc8897f9b2dcebb7068c02ff9ae07 GnuPG-bug-id: 7127 Signed-off-by: NIIBE Yutaka <[email protected]>
* w32:spawn: Support the case without no helper.NIIBE Yutaka2026-01-091-37/+239
| | | | | | | | | | * src/w32-io.c (_gpgme_io_spawn_sans_helper): New. (_gpgme_io_spawn): Use _gpgme_io_spawn_sans_helper. -- GnuPG-bug-id: 7127 Signed-off-by: NIIBE Yutaka <[email protected]>
* w32: Use SetHandleInformation for _gpgme_io_pipe.NIIBE Yutaka2026-01-081-35/+9
| | | | | | | | | * src/w32-io.c (_gpgme_io_pipe): Create a pipe with bInheritHandle = TRUE, and then clear an end by SetHandleInformation. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* w32: Fix for process handle.NIIBE Yutaka2026-01-081-4/+11
| | | | | | | | | | * src/assuan-support.c (my_waitpid): Call __assuan_waitpid for libassuan 3. * src/w32-io.c (_gpgme_io_spawn): Use process handle for libassuan 3. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* w32: Fix debug print on 64-bit machine.NIIBE Yutaka2025-12-241-17/+19
| | | | | | | | | | | * src/w32-io.c (release_hddesc): Cast SOCKET to (void *) and use %p. (reader, create_reader, destroy_reader, writer): Likewise. (create_writer, find_writer): Likewise. (_gpgme_io_socket): Likewise. Add "z" modifier for NFDS. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* w32: Fix spawn for 64-bit machine.NIIBE Yutaka2025-12-231-6/+4
| | | | | | | | | | | | | | | | | | | | | | * src/priv-io.h (struct spawn_fd_item_s): Use HANDLE for peer_name field. * src/dirinfo.c (read_gpgconf_dirs): Use ASSUAN_INVALID_FD for default value for peer_name field of CFD. * src/engine-gpgconf.c (gpgconf_read, gpgconf_write) (gpgconf_query_swdb): Likewise. * src/version.c (_gpgme_get_program_version): Likewise. * src/w32-io.c (handle_to_fd): Remove. (_gpgme_io_spawn): Assign HD to the peer_name field. Use %p for printing the value of peer_name field. * src/gpgme-w32spawn.c (my_spawn): Use peer_name field with no cast. Use %p for printing the value of peer_name field. Remove wrong CloseHandle calls. (translate_get_from_file): Use HANDLE type for the TO variable. Use strtoull on 64-bit machine. Use ASSUAN_INVALID_FD. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* Fix portability for the use of the assuan types.NIIBE Yutaka2025-12-111-1/+1
| | | | | | | | | | | | | | | | | | | * src/assuan-support.c (my_spawn, my_waitpid): Use assuan_pid_t. (my_socket, my_connect): Use assuan_fd_t. * src/engine-gpg.c (start): Remove unused PID. * src/engine-spawn.c (engspawn_start): Likewise. * src/gpgme-w32spawn.c: Add util.h for assuan types. * src/version.c: Likewise. * src/wait-user.c: Likewise. * src/posix-io.c (_gpgme_io_spawn): Use assuan_pid_t. * src/priv-io.h (_gpgme_io_spawn): Likewise. * src/w32-io.c (_gpgme_io_spawn): Likewise. * src/wait-private.c: Include util.h earlier. -- GnuPG-bug-id: 7968 Signed-off-by: NIIBE Yutaka <[email protected]>
* Slight changes to comments and trace output.Werner Koch2025-10-141-1/+1
| | | | --
* Fix printing size_t and off_t value for LLP64 Windows.NIIBE Yutaka2024-07-051-4/+4
| | | | | | | | | | | * src/debug.h (_trace_sysres_off_t): Use 'z' length specifier. * src/w32-io.c (_gpgme_io_read): Likewise. (writer, _gpgme_io_write): Likewise. -- GnuPG-bug-id: 7187 Signed-off-by: NIIBE Yutaka <[email protected]>
* doc: Fix typos in documentation and source code commentsIngo Klöcker2023-10-131-5/+5
| | | | | | | | -- Anonymous contribution Signed-off-by: Ingo Klöcker <[email protected]>
* core,w32: Initialize dbg_help for socket debuggingAndre Heinecke2019-10-281-1/+1
| | | | | | | | * src/w32-io.c (_gpgme_io_select): Initialize dbg_help. -- This fixes a crash on Windows because dbg_help might be used unitialized.
* core,w32: Improve handling of Unicode pathsAndre Heinecke2019-04-091-10/+10
| | | | | | | | | | | | | | | | | | | | | | * src/dirinfo.c (get_gpgconf_item): Use _gpgme_access. * src/posix-util.c (_gpgme_access): Add forward to normal access. * src/sys-util.h (_gpgme_access): New for posix and w32. * src/w32-io.c (_gpgme_io_spawn): Use _gpgme_crate_process_utf8. * src/w32-util.c (utf8_to_wchar, utf8_to_wchar0): The usual w32 conv. (find_program_in_dir): Use _gpgme_access. (find_program_at_standard_place): Use wchar API and convert to UTF-8. (_gpgme_access): Convert UTF-8 to wchar and use wchar API. (_gpgme_create_process_utf8): Convert UTF-8 to wchar and use wchar API. -- While we should not say that we have full support for unicode path installations of GnuPG, this ensures that GPGME works if GPGME itself is installed in a unicode path. e.g.: Libreoffice supports this. GnuPG-Bug-Id: T4453 Based on a patch provided by Egor Pugin. Thanks.
* core,w32: Show w32-spawn warning only onceAndre Heinecke2019-04-091-14/+19
| | | | | | | | | | * src/w32-io.c (_gpgme_io_spawn): Show MessageBox only once. -- This prevents multiple message boxes from showing when the GPGME installation is unworkable. GnuPG-Bug-Id: T4453
* core: Fix format string errors in w32-io.c and use of TRACE_SUC.Werner Koch2018-11-191-19/+23
| | | | | | * src/w32-io.c: Fix use of TRACE_SUC. Fix some format strung errors. Signed-off-by: Werner Koch <[email protected]>
* core: Simplify the trace maros by using variadics.Werner Koch2018-11-161-93/+93
| | | | | | | | | | | | | | | | * src/debug.h (TRACE_BEG, TRACE_LOG, TRACE_SUC): Use variadic macros and remove the TRACE_BEG1 et al. Change all users to always pass a format string. (TRACE): Ditto. * src/debug.c (_gpgme_debugf): New. * configure.ac <GCC>: Add -Wno-format-zero-length. -- This makes it easier for use to enable format checks. The zero-length format is required to allow for an empty format due to the comman problematic of __VA_ARGS__. Signed-off-by: Werner Koch <[email protected]>
* spelling: fix misspellingsDaniel Kahn Gillmor2018-11-081-7/+7
| | | | Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* w32: Fix a few compiler warnings.Werner Koch2018-11-021-15/+10
| | | | | | | * src/debug.h (TRACE_SYSERR_NR): New. * src/w32-io.c: Fix compiler warnings. Signed-off-by: Werner Koch <[email protected]>
* w32: Log all errors from CloseHandle and WFSO in w32-io.Werner Koch2018-11-021-49/+70
| | | | | | | | * src/w32-io.c (close_handle, _close_handle): New macro and function; use in place of all CloseHandle calls. (wait_for_single_object, _wait_for_single_object): Likewise. Signed-off-by: Werner Koch <[email protected]>
* w32: Revamp the closing of system objects.Werner Koch2018-11-021-118/+260
| | | | | | | | | | | | | | | | | | | | | | * src/w32-io.c (hddesc_t): New. (reader_context_s, writer_context_s): Replace file_sock and file_hd by the hddesc_t hdd. (fd_table): Ditto. Add want_reader and want_writer. (hddesc_lock): New lock variable. (new_hddesc, ref_hddesc): New. (release_hddesc): New. (reader, writer): Call release_hddesc. (create_reader, create_writer): Change for new hddesc scheme. (destroy_reader, destroy_writer): Replace closing by a call to release_hddesc. (_gpgme_io_pipe): Change for new hddesc scheme. (_gpgme_io_close): Ditto. (_gpgme_io_dup): Ditto. Use want_reader and want_writer. (_gpgme_io_socket): Change for new hddesc scheme. -- GnuPG-bug-id: 4237 Signed-off-by: Werner Koch <[email protected]>
* w32: Use CancelSynchronousIo in destroy_reader.Werner Koch2018-11-011-1/+1
| | | | | | | | | | | * src/w32-util.c (_gpgme_w32_cancel_synchronous_io): New. * src/w32-io.c (destroy_reader): Use it here. -- This has not been tested but should on Vista and later help to fix a possible hang. Signed-off-by: Werner Koch <[email protected]>
* w32: Merge all the object tables of w32-io into one.Werner Koch2018-11-011-263/+244
| | | | | | | | | | * src/w32-io.c (fd_table_size): New. Used in most places instead of the MAX_SLAFD constant. (reader_table, writer_table, notify_table): Merge them into ... (fd_table): this table. Chnage all affected code to take just one lock. Signed-off-by: Werner Koch <[email protected]>
* w32: Remove unused arg from two functions.Werner Koch2018-10-311-32/+47
| | | | | | | * src/w32-io.c (find_reader, find_writer): Remove unused start_it arg. It is always passed as true. Change callers. Signed-off-by: Werner Koch <[email protected]>
* w32: Remove all support for WindowsCEWerner Koch2018-10-311-305/+2
| | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac: Remove WindwosCE support. * contrib/: Remove all; it was only used for WindowsCE. * src/w32-ce.c, src/w32-ce.h: Remove files. * src/Makefile.am (system_components): Remove these files. * src/ath.c, src/ath.h: Remove W32CE support. * src/data-compat.c (gpgme_data_new_from_filepart): Ditto. (gpgme_data_new_from_file): Ditto. * src/debug.c (debug_init, _gpgme_debug): Ditto. * src/gpgme-tool.c (gpgme_server): Ditto. (main): Ditto. * src/priv-io.h: Do not include w32-ce.h. * src/util.h: Remove WindowsCE support. * src/w32-io.c: Ditto. * src/w32-util.c: Ditto. * src/debug.h (TRACE_SUC4): New. -- There is no more hardware to test our code, the support for Windows CE terminated along time ago. Note that our code worked only with the old WindowsCE with that overall system limit of 31 processes. Signed-off-by: Werner Koch <[email protected]>
* w32: Remove cruft in w32-io from WindowsME times.Werner Koch2018-10-311-29/+0
| | | | | | | | | | | | * src/w32-io.c (set_synchronize): Remove. (create_reader, create_writer): No need for set_synchronize. -- The set_synchronize dates back to 2001 at a time when I wrote the Windows support on WindowsME and Windows2000. Maybe this was required then due to bugs in that old NT or partly NT based Windows versions. Signed-off-by: Werner Koch <[email protected]>
* w32: Fix previous commit.Werner Koch2018-10-301-3/+2
| | | | | | | * src/w32-io.c (_gpgme_io_spawn): Move freeing of TMP_NAME behind its use in an error handling. Signed-off-by: Werner Koch <[email protected]>
* core,w32: Fix memleak of tmp_name in w32-ioAndre Heinecke2018-10-291-0/+7
| | | | | | | * src/w32-io.c (_gpgme_io_spawn): Free tmp_name. -- GnuPG-Bug-Id: T4238
* core, w32: Fix flags passing to gpgme-w32-spawnAndre Heinecke2018-02-091-2/+2
| | | | | | | | | * src/w32-io.c (_gpgme_io_spawn): Don't hardcode flags value. -- IOSPAWN_FLAG_ALLOW_SET_FG is 2 and was translated to 1. This might fix the pinentry foreground handling pass through.
* core: Replace all calls to *sprintf by gpgrt_*sprintf.Werner Koch2017-02-021-2/+2
| | | | | | | | | | | | | | * configure.ac (vasprintf): Remove check. * src/vasprintf.c: Remove file. * src/util.h (vasprintf, asprintf): Remove prototypes. Replace all calls to vasprintf and asprintf by gpgrt_vasprintf or gpgrt_asprintf. Also take care to use gpgrt_free on the returned value. * src/w32-util.c (_gpgme_get_gpgconf_path): Replace a gpgrt_asprintf by _gpgme_strconcat. (snprintf): New macro to use gpgrt_snprintf instead of the system's standard snprintf. Signed-off-by: Werner Koch <[email protected]>
* w32: Fix closing file descriptors.Justus Winter2017-01-231-2/+8
| | | | | | | | | * src/w32-io.c (writer): Only stop once the buffer is drained. (destroy_writer): Wait for the writers buffer to be drained. This aligns '_gpgme_io_close's behavior with close(2) and fclose(3). GnuPG-bug-id: 2881 Signed-off-by: Justus Winter <[email protected]>
* w32: Better protect the IO-system's fd_tableWerner Koch2016-11-091-12/+26
| | | | | | | | | | | | * src/w32-io.c (fd_table_lock): New. (new_fd): Lock allocation of a new slot. (release_fd): Lock deallocation of a slot. -- Note that we lock only the allocation but not the sanitiy checks we do further down in the code. Signed-off-by: Werner Koch <[email protected]>
* core: Remove (now) useless diagnosticAndre Heinecke2016-08-181-2/+0
| | | | | | | | | | | * src/w32-io.c(_gpgme_io_spawn): Remove spawnhelper not found diagnostic. -- When spawnhelper is not found the error is now catched before the CreateProcess call so the added diagnostic in bb2d11c (which was not helpful because the value for spawnhelper would be NULL in that case) is now no longer needed.
* core: Fail loudly in case w32 spawner not foundAndre Heinecke2016-08-181-0/+26
| | | | | | | | | | | | | | | | * src/w32-io.c (_gpgme_io_spawn): Show a message box in case gpgme-w32spawn.exe not found. -- Otherwise every engine call will just fail with unsupported protocol. Even in the debug output the problem was not made clear because CreateProcess will fail with error code 87 (Invalid Parameter) because spawnhelper is NULL. The helpful error message for ERROR_INVALID_PARAMETER would have been: "is 'NULL' correctly installed" As GpgME basically becomes useless on Windows without the spawnhelper we want to fail very loud in that case.
* Fix typos found by codespell.Justus Winter2015-12-021-2/+2
| | | | | -- Signed-off-by: Justus Winter <[email protected]>
* w32: Add extra diagnostic about possible missing gpgme-w32spawn.exe.Werner Koch2015-10-281-2/+7
| | | | | | * src/w32-io.c (_gpgme_io_spawn): Add a new diagnostic. Signed-off-by: Werner Koch <[email protected]>
* w32: Fix another memleak on error.Werner Koch2014-04-161-0/+1
| | | | | | | * src/w32-io.c (create_reader): free CTX. -- Found by Hans-Christoph Steiner with cppcheck.
* w32: Fix memleak in an error code paths.Werner Koch2014-04-151-0/+1
| | | | | | | | | * src/w32-io.c (create_writer): Free CTX in cased of bad FD. * src/w32-util.c (_gpgme_mkstemp): Free TMPNAME in case of a failed mkstemp. -- Found by Hans-Christoph Steiner with cppcheck.
* Make use of internal iospawn flags more flexible.Werner Koch2014-04-101-1/+2
| | | | | | | | | | | | | * src/priv-io.h (IOSPAWN_FLAG_DETACHED): New. Renumber the others. * src/w32-io.c (_gpgme_io_spawn): Use DETACHED_PROCESS process only if IOSPAWN_FLAG_DETACHED is given. * src/w32-qt-io.cpp (_gpgme_io_spawn): Ditto. * src/w32-glib-io.c (_gpgme_io_spawn): Ditto. * src/assuan-support.c (my_spawn): Pass IOSPAWN_FLAG_DETACHED flags. * src/dirinfo.c (read_gpgconf_dirs): Ditto. * src/engine-gpg.c (start): Ditto. * src/engine-gpgconf.c (gpgconf_read, gpgconf_write): Ditto. * src/version.c (_gpgme_get_program_version): Ditto.
* w32: Change the way the I/O threads are cleaned up.Werner Koch2013-05-111-90/+73
| | | | | | | | | | | | | | | | | * src/w32-io.c (reader_context_s, create_reader) (writer_context_s, create_writer): Rename STOPPED to CLOSE_EV. (reader, writer): Remove setting of STOPPED. Wait for CLOSE_EV and then release the context. (destroy_reader, destroy_writer): Do not wait but set the CLOSE_EV. (kill_reader, kill_writer): Remove. (_gpgme_io_close): Add code from kill_reader and kill_writer. -- The old code was prone to deadlocks which were actually exhibited at Kleopatra startup. The new code is much more straightforward and easier to understand. The reason for the complex old code was probably due to our former idea to allow re-use of the I/O threads. However we have long given up on this.
* Fix hang in socket closing.Werner Koch2013-05-081-0/+36
| | | | | * src/w32-io.c (destroy_reader): Call shutdown. (reader): Do not print an error in the shutdown case.
* Improve debug output of the I/O reader and writer.Werner Koch2013-05-081-5/+17
| | | | * src/w32-io.c (reader, writer): Also print file_sock.
* Remove all trailing whitespace from source filesWerner Koch2012-09-251-61/+61
| | | | | -- Command used: sed -i 's,[ \t]*$,,' FILE
* Fix socket implementation on Windows.Marcus Brinkmann2011-02-031-1/+1
| | | | | | 2011-02-03 Marcus Brinkmann <[email protected]> * w32-io.c (_gpgme_io_socket): Return fd, not res.
* Fix Windows port (spawn and assuan engine).Marcus Brinkmann2011-02-021-43/+9
| | | | | | | | | | | | | | | | | 2011-02-02 Marcus Brinkmann <[email protected]> * configure.ac (NEED_LIBASSUAN_VERSION): Bump to 2.0.2 for system hooks. src/ 2011-02-02 Marcus Brinkmann <[email protected]> * assuan-support.c (my_socket, my_connect): New functions. (_gpgme_assuan_system_hooks): Add my_Socket, my_connect. * priv-io.h (_gpgme_io_socket): New prototype. * w32-io.c (pid_to_handle, handle_to_oid, fd_to_handle): Remove macros. (is_socket): Remove function. (_gpgme_io_spawn) [HAVE_W32CE_SYSTEM]: Remove some dead code. (_gpgme_io_spawn): Translate handles before DuplicateHandle them.
* 2010-11-23 Marcus Brinkmann <[email protected]>Marcus Brinkmann2010-11-231-0/+12
| | | | | | | * w32-io.c (create_reader, create_writer): Use small stack size on Windows CE.
* More include guards.Werner Koch2010-11-031-1/+3
| | | | | | Provide access for Wince. Install dummy sehmap.h
* First take on changes to allow building with MSC for W32CE.Werner Koch2010-11-021-3/+7
| | | | | Fixed regression in plain W32 build.
* 2010-09-01 Marcus Brinkmann <[email protected]>Marcus Brinkmann2010-09-011-58/+11
| | | | | | | * w32-io.c: Revert change from 2009-06-18, as it created a race condition.