aboutsummaryrefslogtreecommitdiffstats
path: root/src/stringutils.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* New public API gpgrt_strlist_*Werner Koch2025-04-011-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/strlist.c: Rename all functions to have a _gpgrt_strlist prefix. (append_to_strlist2, strlist_length): Remove. (_gpgrt_strlist_free): rtake care of the wipe flag. (_gpgrt_strlist_add): Add a flags arg to use it for prepend and append. Return an error on failure. (_gpgrt_strlist_tokenize): Ditto. (_gpgrt_strlist_copy): Chnage to return an error on failure. (_gpgrt_strlist_pop): Ditto. * src/Makefile.am (libgpg_error_la_SOURCES): Add strlist.c. * src/argparse.c (trim_spaces): Move to ... * src/stringutils.c (_gpgrt_trim_spaces): here and rename. * src/visibility.c: Add wrappers for all exported functions. * src/visibility.h: MArk exported functions as visisble. * src/gpg-error.def.in: Export new functions * src/gpg-error.vers: Ditto. * src/gpg-error.h.in (GPGRT_STRLIST_APPEND): New. (GPGRT_STRLIST_WIPE): New. (gpgrt_strlist_free): New. (gpgrt_strlist_add): New. (gpgrt_strlist_tokenize): New. (gpgrt_strlist_copy): New. (gpgrt_strlist_rev): New. (gpgrt_strlist_prev): New. (gpgrt_strlist_last): New. (gpgrt_strlist_pop): New. (gpgrt_strlist_find): New. (gpgrt_strlist_count): New inline function. -- This is a modified set of function as used by gpg for ages. These are quite useful functions and will be needed internally for some other planned features. The idea is to make their counterparts in gnupg wrapper around those new functions. After we have moved the secure memory stuff from Libgcrypt to here we can also implement a GPGRT_STRLICT_SECMEM flag to allow allocating strings here ion secure memory. For now we only have the WIPE flag which wipes the memory on free.
* core: Minor clean up.NIIBE Yutaka2021-08-051-3/+0
| | | | | | * src/stringutils.c: Remove inclusion of pwd.h. Signed-off-by: NIIBE Yutaka <[email protected]>
* w32: Support utf8 also for getcwd.Werner Koch2020-10-091-1/+1
| | | | | | | | | | | | * 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.
* core: Add gpgrt_fnameconcat and gpgrt_absfnameconcat.Werner Koch2020-02-181-0/+224
* 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]>