aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysutils.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2023-05-17w32: Use _putenv_s when available.NIIBE Yutaka1-4/+28
* src/sysutils.c (_gpgrt_setenv): Use _putenv_s when the macro _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES is defined. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2023-03-21Avoid segv in logging with improper use of the "socket://" .Werner Koch1-0/+4
* src/logging.c (fun_writer): Protect calling socket_dir_cb if not set. -- If no callback has been registered the use of the "socket://" shortcut caused a segv.
2022-06-28Remove Windows CE support.NIIBE Yutaka1-5/+1
* contrib/*: Remove. * Makefile.am: Remove contrib. * autogen.sh: Remove Windows CE support. * configure.ac (have_w32ce_system): Remove. * src/Makefile.am [HAVE_W32CE_SYSTEM] (extra_cppflags): Remove. (gpg_extra_headers): Remove. (EXTRA_DIST): Remove mkw32errmap.c and w32ce-add.h (BUILT_SOURCES): Remove mkw32errmap.map.c. (tmp_files): Remove mkw32errmap.tab.h mkw32errmap.map.c (CLEANFILES): Likewise. * src/estream-printf.c [HAVE_W32CE_SYSTEM]: Remove. * src/estream.c [HAVE_W32CE_SYSTEM]: Remove. * src/gpg-error.def.in [HAVE_W32CE_SYSTEM]: Remove. * src/gpgrt-int.h: Fix comment. * src/init.c [HAVE_W32CE_SYSTEM]: Remove. * src/init.h [HAVE_W32CE_SYSTEM]: Remove. * src/mkheader.c: Remove Windows CE support. * src/mkw32errmap.c, src/w32ce-add.h: Remove. * src/spawn-posix.c [HAVE_W32CE_SYSTEM]: Remove. * src/spawn-w32.c [HAVE_W32CE_SYSTEM]: Remove. * src/sysutils.c [HAVE_W32CE_SYSTEM]: Remove. * src/w32-estream.c [HAVE_W32CE_SYSTEM]: Remove. * src/w32-reg.c [HAVE_W32CE_SYSTEM]: Remove. * tests/Makefile.am [HAVE_W32CE_SYSTEM]: Remove. -- GnuPG-bug-id: 5912 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-03-04w32: Support file names longer than MAX_PATH.Werner Koch1-31/+118
* src/sysutils.c (any8bitchar): Remove. (_gpgrt_fname_to_wchar): New. (_gpgrt_mkdir): Use instead of plain utf8 conversion. (_gpgrt_access): Reimplement using GetFileAttributesW so that long files names are supported. * src/estream.c (_gpgrt_w32_get_last_err_code): New. (func_file_create_w32): New. (_gpgrt_fopen): Handle the "sysopen" mode flag. Support mapping of /dev/null. (_gpgrt_freopen): Support mapping of /dev/null. * src/w32-gettext.c (load_domain): Allow long file names. * src/visibility.c (gpgrt_free_wchar): Make function public. (gpgrt_fname_to_wchar): Ditto. (gpgrt_utf8_to_wchar): Ditto. (gpgrt_wchar_to_utf8): Ditto. * src/w32-add.h (gpgrt_free_wchar): New prototype. (gpgrt_fname_to_wchar): Ditto. (gpgrt_utf8_to_wchar): Ditto. (gpgrt_wchar_to_utf8): Ditto. * src/gpg-error.def.in: Add them here too.
2020-12-21Release 1.40libgpg-error-1.40gpgrt-1.40Werner Koch1-1/+2
* configure.ac: Bump LT version to C31/A31/R0.
2020-12-21w32: Allow Unicode for internal getusername function.Werner Koch1-9/+19
* src/sysutils.c (_gpgrt_getusername) [W32]: Use GetUserNameW. -- This is used by argparse for user specific parts. Tested using the echo meta-command. Signed-off-by: Werner Koch <[email protected]>
2020-10-19New public function gpgrt_access.Werner Koch1-0/+43
* src/gpg-error.h.in (gpgrt_access): New. * src/gpg-error.vers. src/gpg-error.def.in: Add new function. * src/sysutils.c (any8bitchar): New. (_gpgrt_access): New. * src/visibility.c (gpgrt_access): New. * src/spawn-w32.c (_gpgrt_spawn_process_detached): Use it. * src/argparse.c (try_versioned_conffile): Use it. * tests/t-stringutils.c (check_access): New simple test. -- This is basically a wrapper to allow handling of utf8 encoded file names on Windows. This also fixes the case for versioned config files in directories with non-ascii characters. The new test needs to be run manually on Windows using a directory with Unicode characters. GnuPG-bug-id: 5098
2020-10-09w32: Support utf8 also for getcwd.Werner Koch1-6/+32
* src/sysutils.c (_gpgrt_getcwd) [W32]: Implement utf-8 support. * src/w32-gettext.c (wchar_to_native): Factor some code out to .. (wchar_to_cp): new. (_gpgrt_wchar_to_utf8): New. * tests/t-stringutils.c: Include windows.h. (utf8_to_wchar): New. (wchar_to_utf8): New. (mygetcwd): Use wchar version for Windows. (main): New option --pwd.
2020-08-21core,w32: Add UTF-8 support to gpgrt_fopen, gpgrt_mkdir and gpgrt_chdir.Werner Koch1-11/+39
* src/protos.h: New. * src/Makefile.am (libgpg_error_la_SOURCES): Add file. * src/gpgrt-int.h: Include protos.h. * src/sysutils.c (_gpgrt_mkdir) [W32]: Make UTF-8 aware. (_gpgrt_chdir) [W32]: Ditto. * src/w32-gettext.c: Include protos.h. (utf8_to_wchar): Allow for strings. (_gpgrt_utf8_to_wchar): New. (_gpgrt_free_wchar): New. * src/estream.c (map_w32_to_errno): Add more error codes. (_gpgrt_w32_set_errno): New. (any8bitchar) [W32]: New helper. (func_file_create) [W32]: Convert file name and use _wopen. -- GnuPG-bug-id: 4083 Signed-off-by: Werner Koch <[email protected]>
2020-04-03core: Implement meta command [user] also for WindowsWerner Koch1-2/+20
* src/argparse.c (initialize): Clear username. * src/sysutils.c (_gpgrt_getusername): Implement for Windows. -- This also fixes a missing intialization Signed-off-by: Werner Koch <[email protected]>
2020-04-03core: Implement meta command [user] for the arg parser.Werner Koch1-1/+21
* src/sysutils.c (_gpgrt_getusername): New. * src/argparse.c (struct _gpgrt_argparse_internal_s): New flags user_* and store the current user. (initialize): Free new malloced field. Clear new flags. (handle_meta_user): Implement. (handle_metacmd): Implement user sections. Remove "group" meta command. (_gpgrt_argparse): Implement user sections. (finish_read_sys): Reset new vars. -- Implementing group would be somewhat complicated and it is doubtful whether this really makes sense and is manageable for the admin. Note that we have not yet implemented this for Windows. Signed-off-by: Werner Koch <[email protected]>
2020-02-18core: Add gpgrt_fnameconcat and gpgrt_absfnameconcat.Werner Koch1-0/+39
* src/gpg-error.h.in (gpgrt_fnameconcat): New. (gpgrt_absfnameconcat): New. * src/visibility.c (gpgrt_fnameconcat, gpgrt_absfnameconcat): New. * src/stringutils.c: New file. (_gpgrt_vfnameconcat): New. (_gpgrt_fnameconcat, _gpgrt_absfnameconcat): New. * src/gpg-error.def.in: Add new functions. * src/gpg-error.vers: Ditto. * src/sysutils.c: Include pwd.h. (_gpgrt_getpwdir): New. * configure.ac: Test for pwd.h, getpwnam, getpwuid, and their _r variants. * src/Makefile.am (libgpg_error_la_SOURCES): Add new file. * tests/t-stringutils.c: New. * tests/t-common.h (xmalloc, xstrdup, xfree): New. (die): Kludge to avoid compiler warnings. -- The new functions are based on the code of make_filename from GnuPG. They have been written by me ages ago with only minor modifications by David Shaw. I re-license them from LGPL-3.0+ OR GPL-2.0+ to LGPL-2.1-or-later. Signed-off-by: Werner Koch <[email protected]>
2019-09-18gpgrt_setenv: Define behavior when value=NULL.NIIBE Yutaka1-1/+1
* src/sysutils.c (_gpgrt_setenv): Avoid call with value=NULL. GnuPG-bug-id: 4698 Signed-off-by: NIIBE Yutaka <[email protected]>
2018-03-12core: Do not export the process APIWerner Koch1-1/+1
-- We may need to change the API and thus we better wait before publishing this new interface. Signed-off-by: Werner Koch <[email protected]>
2017-11-28core: Change new functions to return gpg_err_code_t.Werner Koch1-29/+38
* src/gpg-error.h.in (gpgrt_sentenv, gpgrt_mkdir, gpgrt_chdir): Change return type to gpg_err_code_t. * src/sysutils.c (_gpgrt_setenv): Implement that. (_gpgrt_mkdir): Ditto. (_gpgrt_chdir): Ditto. * gpgscm/ffi.c (do_setenv, do_mkdir): Adjust for this change. -- The functions are already a bit different and thus it is useful to let them return a gpg-error style error code and don't let the user implement that for each call. Signed-off-by: Werner Koch <[email protected]>
2017-11-28core: New API functions gpgrt_mkdir, gpgrt_chdir, gpgrt_getcwd.Werner Koch1-0/+116
* src/gpg-error.h.in (gpgrt_mkdir, gpgrt_chdir, gpgrt_getcwd): New. * src/visibility.c, src/visibility.h: Add wrappers. * src/gpg-error.vers, src/gpg-error.def.in: Add them. * src/sysutils.c (modestr_to_mode): New. (_gpgrt_mkdir, _gpgrt_chdir, _gpgrt_getcwd): New. * m4/gnupg-misc.m4: New. * m4/Makefile.am (EXTRA_DIST): Add new M4 file. * configure.ac: Call new GNUPG_FUNC_MKDIR_TAKES_ONE_ARG. (AC_CHECK_FUNCS): Add stat. -- The code has been taken from GnuPG. _gpgrt_mkdir was originally written by me as gnupg_mkdir and here relicensed to LGPLv2.1+. _gpgrt_getcwd was originally written by in 2007 and also here relicensed to LGPLv2.1. The new M4 macro was also written by me for use in in GnuPG; it has been taken from GnUPG's acinclude.m4, moved to its own file here, and relicensed to FSFULLR. Signed-off-by: Werner Koch <[email protected]>
2017-11-28core: New API functions gpgrt_getenv and gpgrt_setenv.Werner Koch1-0/+175
* src/gpg-error.h.in (gpgrt_getenv, gpgrt_setenv): New. (gpgrt_unsetenv): New macro. * src/gpg-error.vers, src/gpg-error.def.in: Add them. * src/visibility.c (gpgrt_getenv, gpgrt_setenv): New. * src/visibility.h: Add them. * src/sysutils.c: Include string.h and on Windows windows.h. (_gpgrt_getenv): New. (_gpgrt_setenv): New. -- These functions are wrappers to cope with Windows problems. The code is similar to what we have in GnuPG but not identical. Requires better testing. Signed-off-by: Werner Koch <[email protected]>
2017-11-17New configure options and macros for internal use.Werner Koch1-9/+18
* configure.ac: Add option --enable-log-clock. * configure.ac: Add option --enable-werror. * src/sysutils.c: New. * src/Makefile.am (libgpg_error_la_SOURCES): Add sysutils.c * src/gpgrt-int.h: Add internal i18n macros and hacks to make working with sockets easier. (es_stdin, es_stdout, es_stderr): New internal macros. (snprintf): New macro. Signed-off-by: Werner Koch <[email protected]>
2017-02-26Rename internal functions of estream.Werner Koch1-1/+1
* src/estream.c (_gpgrt_es_init): Rename to _gpgrt_estream_init. (es_fill): Rename to fill_stream. (es_fflush): Rename to flush_stream. (es_deinitialize): Rename to deinit_stream_obj. (es_create): Rename to create_stream (es_read_nbf): Rename to do_read_nbf. (es_read_lbf): Rename to do_read_lbf. (es_read_fbf): Rename to do_read_fbf. (es_peek): Rename to peek_stream. (es_skip): Rename to skip_stream. (es_print): Rename to do_print_stream. -- The use of the "es_" was confusing. Avoid that. Signed-off-by: Werner Koch <[email protected]>
2016-02-08Convert http links to https where possible in the source.Daniel Kahn Gillmor1-1/+1
-- * use https for bug reporting * in comments and docs, use https to refer to: - www.gnu.org - creativecommons.org - translationproject.org - mail.gnome.org - www.perl.org - www.ctan.org - www.cl.cam.ac.uk - www.ntg.nl - cygwin.com - www.ethnologue.com
2014-08-25Implement symbol visibility.Werner Koch1-1/+1
* configure.ac: New option --enable-ld-version-script. (GPGRT_USE_VISIBILITY): New ac_define. (HAVE_LD_VERSION_SCRIPT): New am_conditional. * src/gpg-error.vers: New. * src/gpgrt-int.h: New. * src/visibility.c, src/visibility.h: New. Lot of changes to symbold names. -- This is only doe for the old API. The estream API needs to be added.
2014-08-25First set of changes to include estream into the API.Werner Koch1-420/+11
* configure.ac (AH_BOTTOM): Define GPGRT_ENABLE_ES_MACROS. * src/gpg-error.h.in: include stdio.h. Include most of the estream functions and rename structures and types. * src/estream.h: Rewrite. Include only gpg-error.h and local prototypes. * src/estream.c: Rename types and macros. * src/estream-printf.c (_gpgrt_estream_snprintf): Prefix public functions with _gpgrt_.
2014-08-25Add missing redefine macros to cleanup the external symbols.Werner Koch1-0/+5
2014-08-25Add estream code from GnuPG.Werner Koch1-0/+434
* src/estream-printf.c, src/estream-printf.h: New. * src/estream.c, src/estream.h: New. * m4/estream.m4: New. * src/Makefile.am (libgpg_error_la_SOURCES): Add new files. * configure.ac (AH_BOTTOM): Define estream prefix. <gcc>: Add useful gcc warning options. (estream_INIT): Call. -- This is the base line patch to move the estream code from GnuPG to libgpg-error. The code has been taken from the GnuPG repository at commit cb680c5ea540738692a5c74951802b0fdc658e85. Signed-off-by: Werner Koch <[email protected]>