Skip to content

Multiple cleanups and upgrades to let gnokii build correctly on current operating systems#8

Open
pkot wants to merge 90 commits into
savannahfrom
cleanups-and-upgrades
Open

Multiple cleanups and upgrades to let gnokii build correctly on current operating systems#8
pkot wants to merge 90 commits into
savannahfrom
cleanups-and-upgrades

Conversation

@pkot

@pkot pkot commented Dec 28, 2025

Copy link
Copy Markdown
Owner

No description provided.

fabzzap and others added 30 commits December 28, 2025 15:01
mingw32 provides lower case names for Win32 header files, use lower
case names in #include directives.
Windows' mkdir() takes only 1 argument, so add a test for that.
Compilation fails with both HAVE_SETENV and WIN32 set.
Update to the latest (7a5b65c88d3b) version from Samba's repository.
Previously connect_script was called only with valid fd, restore that.

Fixes: 4d38aee (Make device_script() generic for all connection types)
Recent updates in common/snprintf.c refactored code a bit. Currently
rep_* functions (e.g. rep_asprinf) are exported. This has to be handled
correctly in the include file, so it builds correctly on systems with
no proper support of sprintf family.
On systems without setenv()/unsetenv() a declaration of these
functions was missing (a definition done in common/compat.c). Add
it to compat.h.
Let it compile with Microsoft Visual C++ 6.0
snprintf function family is needed by both gnokii and libgnokii
on systems without proper snprintf support and we do not want
libgnokii to export snprintf functions. Therefore move snprintf
to convenience library and statically link it to both gnokii and
libgnokii.
Both tcp and socketphonet contains stub functions, so it is safe to
always include them in the build. Not doing so leads to unresoved
functions on Win32.
All these were just updated from original Microsoft Visual C++ 6.0,
so it should be easy to recreate them eventually.
Avoid conflicting types for 'getenv' and 'getopt' error raised by
MSYS2 project compilers.
Remove refrences to obsolete macros AC_HEADER_STDC and AC_HEADER_TIME as per
https://www.gnu.org/software/autoconf/manual/autoconf-2.70/html_node/Obsolete-Macros.html
Introduce AC_INCLUDES_DEFAULT to check for C90 standard headers.
Remove obsolete macros AM_PROG_CC_C_0 and AC_TYPE_SIGNAL.
Remove checks for TIME_WITH_SYS_TIME.
Calling AC_PROG_LEX without an argument is obsolete.
Update local acx_pthread.m4 so it is compliant with recent versions
of autoconf without any obsolete macro warnings.
MSVC6 and MacOS do not provide this type.
compat.h configuration depends on defines from config.h, however
it does not include it. Explicitely include config.h and remove
it from all files which did so only to satisfy compat.h
configuration.
Remove homebrew --enable-win option and use the standard autoconf way
to cross-compile, that is using option --host.
compat.h is there to simplify including common header files. If we
need a number of standard header files we just include "compat.h" and
it does everything for us. Therefore all standard headers includes
are removed from the source files.

In addition add conditional includes where we did the checks in
config.h.

Include config.h where needed.

Add detection of error.h, errno.h and signal.h.
3x380V and others added 30 commits April 19, 2026 23:04
Make batch file work no matter what directory it is called from.
Also although batch files are case insensitive, be consistent.
MSVC6 (and others ancient compilers) does not support variadic macros.
Undoubtedly, code is a bit less elegant, but gnokii codebase is ancient
as well as phones it supports, so it is only reasonable to support
ancient compilers as well.
GN_ERR_MEMORYFULL relates to phone memory not host one.
SMS encoding does not respect locale returned by gn_char_get_encoding()
as g_locale_to_utf8() always uses current locale. Fix that using
utf8_encode() which also drops one glib dependency.
Replace last used glib functions with opencoded alternatives and
remove that depedency from libgnokii.
MSYS2 pacman has no standalone 'autopoint' package; the autopoint
binary ships inside the 'gettext' package, which is already listed.
Including 'autopoint' caused the MINGW64 setup step to fail with
"error: target not found: autopoint".
The base MSYS2 'gettext' package ships the autopoint binary but not
the infrastructure archive (/usr/share/gettext/archive.dir.tar.xz)
that autopoint expands during autogen. Without it, autogen.sh fails
with "infrastructure files for version 0.21 not found".
The archive lives in 'gettext-devel'.
MySQL 8.0 and MariaDB Connector/C 3.x removed the my_bool typedef.
my_bool was always a single-byte type, identical in layout to C99
bool (which compat.h already guarantees is available), so the
MYSQL_OPT_RECONNECT option still gets the same single-byte argument
it expects, on both old and new client libraries.
gcc-14's stricter -Wincompatible-pointer-types rejects assigning
void (*)(GtkWidget *, gpointer) to GtkItemFactoryEntry.callback, whose
nominal type is GtkItemFactoryCallback = void (*)(void). The other
entries in these menu arrays already have (void) signatures, so cast
only the Close* callbacks at the site.
Same gcc-14 -Wincompatible-pointer-types fix as the previous commit,
extended to netmon/calendar/dtmf/speed/xkeyb. Prior compile stopped at
sms/contacts errors so these hid behind the earlier failure.
This reverts the two cast commits (a5d672a, 1f0954a). A compiler-flag
workaround in xgnokii/Makefile.am is a better fit than spraying casts
across legacy GTK1/2 code — hundreds more sites would otherwise need
the same treatment.
gcc-14 promoted -Wincompatible-pointer-types to an error by default.
xgnokii is a legacy GTK1/2 application whose GtkItemFactoryEntry and
gtk_signal_connect APIs intentionally accept heterogeneous callback
signatures via function-pointer type punning (nominal type is
void (*)(void)). Casting every callsite would add hundreds of lines
of noise without improving correctness. Demote the diagnostic back to
a warning for xgnokii only — the warnings remain visible in build
logs.
install_log_handler() builds $HOME/.cache/gnokii on the freedesktop
path, but mkdir() is not recursive. On a fresh account or container
where $HOME/.cache does not yet exist (e.g. GitHub Actions runners),
the final mkdir silently fails with ENOENT and the subsequent
fopen("gnokii-errors") fails, polluting stderr with a warning that
in turn leaks into the testsuite diffs.

Explicitly create the intermediate $HOME/.cache directory before
creating the gnokii subdirectory. Only needed in the XDG_CACHE_HOME
fallback branch (home=1); all other platforms already build a path
whose parent is guaranteed to exist.
When the error logfile cannot be opened, gnokii printed two stderr
messages and then continued without logging. Both lines leaked into
testsuite diffs on runners where the cache directory is missing or
not writable. Neither message is user-actionable — errorlogpath can
be configured in gnokiirc by anyone who cares about the log — so
drop them and let install_log_handler fail silently. Error-log
writes simply become no-ops via the unregistered gn_elog_handler.
Tests 13/14/15/18 exercise XPM logo/picture/animation handling. The
testsuite previously failed with "gnokii was not compiled with XPM
support" on every OS because libXpm was absent from the CI install
lists. Add libxpm-dev to the Ubuntu and Debian apt lists and libxpm
to the macOS brew list so AC_CHECK_HEADERS(X11/xpm.h) + AC_CHECK_LIB
succeed and HAVE_XPM gets defined at configure time.
macOS CI runs default to the C locale, which iconv/wctomb cannot use
to round-trip the UTF-8 characters embedded in the testsuite fixtures
("vowels àèìòù euro €" in 41.getsms, "Test ÀàÈèÉéÌìÒòÙù" in
01.writephonebook, etc.). The tests currently fail with
"char_wctomb/iconv: Illegal byte sequence" and '?' replacements in
the output. A UTF-8 locale is sufficient; no code change needed.
Debian -slim container images ship only the C and POSIX locales by
default, so testsuite invocations of iconv (ucs2_encode, utf8_encode,
char_wctomb, char_mbtowc) cannot round-trip the UTF-8 fixtures in
tests like 29.sendsms, 03.ucs2sms, 41.getsms and 01.writephonebook.
C.UTF-8 ships unconditionally with glibc from libc-bin, so no extra
locale package is required — just set it for the Test step.
Two independent fixes for the macOS CI job:

gnokii.c: Call setlocale(LC_ALL, "") unconditionally, not only when
ENABLE_NLS is defined. On macOS, Homebrew's gettext does not satisfy
the libintl check, so NLS is disabled and the setlocale() call was
skipped. Without it nl_langinfo(CODESET) returns "US-ASCII" regardless
of the LANG/LC_ALL environment, which made iconv_open() produce
"Illegal byte sequence" for any non-ASCII input in the SMS and
phonebook tests. Locale initialization is orthogonal to NLS and
belongs outside the guard.

ci.yml (macOS): brew install libx11 and pass --x-includes/--x-libraries
pointing at the Homebrew prefix. AC_PATH_X otherwise fails to find
X11/Xlib.h on the runner (no XQuartz), which unconditionally disables
XPM support and causes the XPM-related tests to fail. Also drop the
now-unnecessary LC_ALL override on the Test step — the runner already
pre-exports en_US.UTF-8.
Compilation fails with both HAVE_SETENV and WIN32 set.
On MSYS2/MinGW64 several assumptions baked into gnokii's CLI and its
test driver broke the suite even though the code built cleanly:

* locale_charset() on Windows derives the codeset from GetACP() and
  ignores LC_ALL/LANG, so UTF-8 env vars had no effect and SMS tests
  produced wrong UCS-2 output. Honor LC_ALL/LC_CTYPE/LANG in main()
  via gn_char_set_encoding() when the value mentions UTF-8.
* Text-mode stdio translates CRLF to LF, corrupting iMelody payloads
  piped through stdin. Switch stdin/stdout to binary mode on Windows.
* isatty(0) returns true for NUL, so "--sendsms ... </dev/null"
  triggered the interactive prompt. Use GetConsoleMode() to detect a
  real console in readtext().
* testsuite/testit compared outputs with cmp, which does not tolerate
  CRLF line endings on Windows. Switch to diff --strip-trailing-cr.
* XPM is unavailable on the MSYS2 mingw64 stack. Probe gnokii once
  and skip any test that references an .xpm input when support is
  absent, rather than failing.

Also: add .claude/ to .gitignore to avoid accidentally committing
local agent state.
Function verify_max_message_len is using static local variable
making it thread unsafe. Move that variable into incoming message
instance.
This API breaking change should be done a long time ago. Do it
now as we already broke API with commit 6d59b8b
("Move callbacks from gn_data to gn_statemachine->callbacks")
When sending strings to AT driver treat it as strings (char *) and
not byte arrays (unsigned char *)
compat.h is there to simplify including common header files. If we
need a number of standard header files we just include "compat.h" and
it does everything for us. Therefore all standard headers includes
are removed from the source files.

In addition add conditional includes where we did the checks in
config.h.

Include config.h where needed.

Add detection of error.h, errno.h and signal.h.
We already do have a list of supported connection in connectiontypes
array, so use it here as well. This removes another #ifdeffery
and fixed bug where condition for TCP was inverted.
asprintf returns -1 on error while strp is left undefined. Update
error check accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants