From 8b398fda8e82e104badf681813eff66076779371 Mon Sep 17 00:00:00 2001 From: thor Date: Thu, 7 Sep 2023 13:25:24 +0000 Subject: [PATCH] always use INT123_strerror() wrapper that tries to do the threadsafe thing git-svn-id: svn://scm.orgis.org/mpg123/trunk@5321 35dc7657-300d-0410-a2e5-dc2837fedb53 --- NEWS | 1 + configure.ac | 2 +- ports/cmake/src/CMakeLists.txt | 2 ++ ports/cmake/src/config.cmake.h.in | 2 ++ src/Makemodule.am | 1 - src/compat/compat.h | 7 +------ src/compat/compat_str.c | 24 +++++++++++++++++++----- src/control_generic.c | 11 ++++++----- src/filters.c | 4 ++-- src/intsym.h | 13 ------------- src/libmpg123/dither.c | 1 - src/libmpg123/icy.c | 3 +-- src/libmpg123/icy2utf8.c | 1 - src/libmpg123/index.c | 1 - src/libmpg123/lfs_wrap.c | 2 +- src/libmpg123/mangle.h | 3 +-- src/libmpg123/mpg123lib_intern.h | 1 - src/libout123/hextxt.c | 8 ++++---- src/libout123/libout123.c | 6 +++--- src/libout123/module.c | 9 ++++----- src/libout123/out123_int.h | 3 +-- src/libout123/wav.c | 14 +++++++------- src/libout123/xfermem.c | 4 ++-- src/libsyn123/syn123_int.h | 3 +-- src/mpg123-id3dump.c | 4 ++-- src/mpg123-strip.c | 4 ++-- src/net123_exec.c | 13 +++++++++---- src/out123.c | 6 +++--- src/resolver.c | 10 +++++----- src/streamdump.c | 6 +++--- src/term.c | 2 +- src/term_posix.c | 8 ++++---- src/win32_net.c | 14 +++++++++++--- 33 files changed, 99 insertions(+), 94 deletions(-) delete mode 100644 src/intsym.h diff --git a/NEWS b/NEWS index e2c8bbed..36c48652 100644 --- a/NEWS +++ b/NEWS @@ -49,6 +49,7 @@ -- Made mpg123_seek() and friends ignore offset sign for SEEK_END (always seeking towards beginning, assuming negative offset) to make lseek()-conforming usage possible. Seeking beyond the end never made sense, so no loss of valid functionality. +- Overall use of INT123_strerror(), trying to use thread-safe strerror_l() if possible. 1.31.3 ------ diff --git a/configure.ac b/configure.ac index e4cb46e3..56a8f25e 100644 --- a/configure.ac +++ b/configure.ac @@ -1320,7 +1320,7 @@ AC_CHECK_FUNCS( sched_setscheduler setuid getuid) # Check for setpriority AC_CHECK_FUNCS( setpriority ) -AC_CHECK_FUNCS( strerror ) +AC_CHECK_FUNCS( strerror strerror_l uselocale ) AC_CHECK_FUNCS( setlocale nl_langinfo mbstowcs wcstombs wcswidth iswprint ) diff --git a/ports/cmake/src/CMakeLists.txt b/ports/cmake/src/CMakeLists.txt index a1582b36..1eb349e8 100644 --- a/ports/cmake/src/CMakeLists.txt +++ b/ports/cmake/src/CMakeLists.txt @@ -56,12 +56,14 @@ check_function_exists(random HAVE_RANDOM) check_function_exists(setenv HAVE_SETENV) check_function_exists(unsetenv HAVE_UNSETENV) check_function_exists(setlocale HAVE_SETLOCALE) +check_function_exists(uselocale HAVE_USELOCALE) check_function_exists(setpriority HAVE_SETPRIORITY) check_function_exists(shmget HAVE_SHMGET) check_function_exists(shmat HAVE_SHMAT) check_function_exists(shmdt HAVE_SHMDT) check_function_exists(shmctl HAVE_SHMCTL) check_function_exists(strerror HAVE_STRERROR) +check_function_exists(strerror_l HAVE_STRERROR_L) check_function_exists(fork HAVE_FORK) check_function_exists(execvp HAVE_EXECVP) check_function_exists(ctermid HAVE_CTERMID) diff --git a/ports/cmake/src/config.cmake.h.in b/ports/cmake/src/config.cmake.h.in index b1446d30..ba44421b 100644 --- a/ports/cmake/src/config.cmake.h.in +++ b/ports/cmake/src/config.cmake.h.in @@ -39,12 +39,14 @@ #cmakedefine HAVE_RANDOM 1 #cmakedefine HAVE_SCHED_H 1 #cmakedefine HAVE_SETLOCALE 1 +#cmakedefine HAVE_USELOCALE 1 #cmakedefine HAVE_SETPRIORITY 1 #cmakedefine HAVE_SIGNAL_H 1 #cmakedefine HAVE_STDIO_H 1 #cmakedefine HAVE_STDINT_H 1 #cmakedefine HAVE_STDLIB_H 1 #cmakedefine HAVE_STRERROR 1 +#cmakedefine HAVE_STRERROR_L 1 #cmakedefine HAVE_FORK 1 #cmakedefine HAVE_EXECVP 1 #cmakedefine HAVE_CTERMID 1 diff --git a/src/Makemodule.am b/src/Makemodule.am index ce22009b..6175ede3 100644 --- a/src/Makemodule.am +++ b/src/Makemodule.am @@ -35,7 +35,6 @@ src_out123_LDADD = \ src_out123_LDFLAGS = @EXEC_LT_LDFLAGS@ EXTRA_DIST += \ - src/intsym.h \ src/version.h \ src/mpg123-with-modules \ src/out123-with-modules diff --git a/src/compat/compat.h b/src/compat/compat.h index aaf6dc40..07f17757 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -138,18 +138,13 @@ typedef unsigned char byte; #include #endif -// Not too early, leave system headers alone (strerror). -#include "intsym.h" - /* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */ void *INT123_safe_realloc(void *ptr, size_t size); // Also freeing ptr if result is NULL. You can do // ptr = INT123_safer_realloc(ptr, size) // Also, ptr = INT123_safer_realloc(ptr, 0) will do free(ptr); ptr=NULL;. void *INT123_safer_realloc(void *ptr, size_t size); -#ifndef HAVE_STRERROR -const char *strerror(int errnum); -#endif +const char *INT123_strerror(int errnum); /* Roll our own strdup() that does not depend on libc feature test macros and returns NULL on NULL input instead of crashing. */ diff --git a/src/compat/compat_str.c b/src/compat/compat_str.c index 65a9762b..27729f2d 100644 --- a/src/compat/compat_str.c +++ b/src/compat/compat_str.c @@ -4,11 +4,13 @@ The mpg123 code is determined to keep it's legacy. A legacy of old, old UNIX. So anything possibly somewhat advanced should be considered to be put here, with proper #ifdef;-) - copyright 2007-2016 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright 2007-2023 by the mpg123 project + free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Thomas Orgis, Windows Unicode stuff by JonY. */ - +// Need POSIX 2008 for uselocale stuff. +#define _POSIX_C_SOURCE 200809L #include "compat.h" /* Win32 is only supported with unicode now. These headers also cover @@ -20,6 +22,10 @@ #include #endif +#if HAVE_LOCALE_H +#include +#endif + #include "debug.h" /* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */ @@ -39,15 +45,23 @@ void *INT123_safer_realloc(void *ptr, size_t size) return nptr; } -#ifndef HAVE_STRERROR -const char *strerror(int errnum) +const char *INT123_strerror(int errnum) { +#if defined(HAVE_STRERROR_L) && defined(HAVE_USELOCALE) + locale_t curloc = uselocale((locale_t)0); + if(curloc != LC_GLOBAL_LOCALE) + return strerror_l(errnum, curloc); +#endif +// Also fall back to strerror() in case of no set locale. +#if defined(HAVE_STRERROR) + return strerror(errnum); +#else extern int sys_nerr; extern char *sys_errlist[]; return (errnum < sys_nerr) ? sys_errlist[errnum] : ""; -} #endif +} char* INT123_compat_strdup(const char *src) { diff --git a/src/control_generic.c b/src/control_generic.c index 9e50fe21..abd8f5fe 100644 --- a/src/control_generic.c +++ b/src/control_generic.c @@ -1,7 +1,8 @@ /* control_generic.c: control interface for frontends and real console warriors - copyright 1997-99,2004-20 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright 1997-99,2004-23 by the mpg123 project + free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Andreas Neuhaus and Michael Hipp reworked by Thomas Orgis - it was the entry point for eventually becoming maintainer... @@ -431,7 +432,7 @@ int control_generic (mpg123_handle *fr) unlink(param.fifo); if(mkfifo(param.fifo, 0666) == -1) { - error2("Failed to create FIFO at %s (%s)", param.fifo, strerror(errno)); + error2("Failed to create FIFO at %s (%s)", param.fifo, INT123_strerror(errno)); return 1; } debug("going to open named pipe ... blocking until someone gives command"); @@ -541,7 +542,7 @@ int control_generic (mpg123_handle *fr) /* on error */ if(n < 0) { - merror("waiting for command: %s", strerror(errno)); + merror("waiting for command: %s", INT123_strerror(errno)); return 1; } /* read & process commands */ @@ -572,11 +573,11 @@ int control_generic (mpg123_handle *fr) close(control_file); control_file = open(param.fifo,O_RDONLY|O_NONBLOCK); #endif - if(control_file < 0){ error1("open of fifo failed... %s", strerror(errno)); break; } + if(control_file < 0){ error1("open of fifo failed... %s", INT123_strerror(errno)); break; } continue; } #endif - if(len < 0) error1("command read error: %s", strerror(errno)); + if(len < 0) error1("command read error: %s", INT123_strerror(errno)); break; } diff --git a/src/filters.c b/src/filters.c index 32f2ca65..7174da80 100644 --- a/src/filters.c +++ b/src/filters.c @@ -1,7 +1,7 @@ /* filters: parse filter specifications - copyright 2020 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright 2020-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Thomas Orgis */ @@ -91,7 +91,7 @@ static int store_filters(struct filterlist *fl, const char *spec) } if(errno) { - merror("Number parsing error on validated spec: %s", strerror(errno)); + merror("Number parsing error on validated spec: %s", INT123_strerror(errno)); return -1; } if(*spec) // Skip ":" diff --git a/src/intsym.h b/src/intsym.h deleted file mode 100644 index a9126076..00000000 --- a/src/intsym.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef MPG123_INTSYM_H -#define MPG123_INTSYM_H -// Used to map lots of internal symbols to prefixed names to help static linking, -// reduciton potential naming conflicts. Now only stays here to redirect strerror -// if it does not exist in the system. Might just drop that, though. -// Probably it needs to be replaced by strerror_r() or strerror_s(). -#include "config.h" - -#ifndef HAVE_STRERROR -#define strerror INT123_strerror -#endif - -#endif diff --git a/src/libmpg123/dither.c b/src/libmpg123/dither.c index 329a4de7..c698b79a 100644 --- a/src/libmpg123/dither.c +++ b/src/libmpg123/dither.c @@ -1,3 +1,2 @@ /* Hack to allow building the same code with and without libtool. */ -#include "intsym.h" #include "dither_impl.h" diff --git a/src/libmpg123/icy.c b/src/libmpg123/icy.c index 022e38dc..1dddb61b 100644 --- a/src/libmpg123/icy.c +++ b/src/libmpg123/icy.c @@ -1,13 +1,12 @@ /* icy: Puny code to pretend for a serious ICY data structure. - copyright 2007-2015 by the mpg123 project + copyright 2007-2023 by the mpg123 project -= free software under the terms of the LGPL 2.1 =- see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Thomas Orgis */ -#include "intsym.h" #include "icy.h" void INT123_init_icy(struct icy_meta *icy) diff --git a/src/libmpg123/icy2utf8.c b/src/libmpg123/icy2utf8.c index fba834a1..cfda64ec 100644 --- a/src/libmpg123/icy2utf8.c +++ b/src/libmpg123/icy2utf8.c @@ -27,7 +27,6 @@ */ #include "config.h" -#include "intsym.h" /* Includes string and stdlib headers... */ #include "compat.h" diff --git a/src/libmpg123/index.c b/src/libmpg123/index.c index fc63c084..2f1d0b7d 100644 --- a/src/libmpg123/index.c +++ b/src/libmpg123/index.c @@ -7,7 +7,6 @@ initially written by Thomas Orgis */ -#include "intsym.h" #include "index.h" #include "debug.h" diff --git a/src/libmpg123/lfs_wrap.c b/src/libmpg123/lfs_wrap.c index 58c4da93..165042f8 100644 --- a/src/libmpg123/lfs_wrap.c +++ b/src/libmpg123/lfs_wrap.c @@ -774,7 +774,7 @@ int INT123_wrap_open(mpg123_handle *mh, void *handle, const char *path, int fd, if(fd < 0) { if(!quiet) - error2("Cannot open file %s: %s", path, strerror(errno)); + error2("Cannot open file %s: %s", path, INT123_strerror(errno)); return INT123_set_err(mh, MPG123_BAD_FILE); } } diff --git a/src/libmpg123/mangle.h b/src/libmpg123/mangle.h index aaebfd3c..762e2127 100644 --- a/src/libmpg123/mangle.h +++ b/src/libmpg123/mangle.h @@ -1,7 +1,7 @@ /* mangle: support defines for preprocessed assembler - copyright 1995-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright 1995-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org This once started out as mangle.h from MPlayer, but you can't really call it derived work... the small part that in principle stems from MPlayer also being not very special (once you decided to use such a header at all, it's quite obvious material). @@ -11,7 +11,6 @@ #define __MANGLE_H #include "config.h" -#include "intsym.h" #if (defined OPT_I486) || (defined OPT_I586) || (defined OPT_I586_DITHER) \ || (defined OPT_MMX) || (defined OPT_SSE) || (defined OPT_3DNOW) || (defined OPT_3DNOWEXT) \ diff --git a/src/libmpg123/mpg123lib_intern.h b/src/libmpg123/mpg123lib_intern.h index f12c17af..2121e490 100644 --- a/src/libmpg123/mpg123lib_intern.h +++ b/src/libmpg123/mpg123lib_intern.h @@ -14,7 +14,6 @@ #define MPG123_ENCODINGS 12 #include "config.h" /* Load this before _anything_ */ -#include "intsym.h" /* Prefixing of internal symbols that still are public in a static lib. */ #include "abi_align.h" diff --git a/src/libout123/hextxt.c b/src/libout123/hextxt.c index 80a6a2de..74f59e36 100644 --- a/src/libout123/hextxt.c +++ b/src/libout123/hextxt.c @@ -1,8 +1,8 @@ /* hextxt: hex or printf text output (ASCII/UTF-8) - copyright 2017 by the mpg123 project - - free software under the terms of the LGPL 2.1 + copyright 2017-2023 by the mpg123 project + free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Thomas Orgis @@ -96,7 +96,7 @@ int hextxt_close(out123_handle *ao) if(fp != stdout && INT123_compat_fclose(fp)) { if(!AOQUIET) - error1("problem closing the output: %s\n", strerror(errno)); + error1("problem closing the output: %s\n", INT123_strerror(errno)); return -1; } } @@ -262,5 +262,5 @@ void hextxt_drain(out123_handle *ao) if(!ao || !ao->userptr) return; if(fflush(ao->userptr) && !AOQUIET) - error1("flushing failed: %s\n", strerror(errno)); + error1("flushing failed: %s\n", INT123_strerror(errno)); } diff --git a/src/libout123/libout123.c b/src/libout123/libout123.c index 9f894561..f8e9b19e 100644 --- a/src/libout123/libout123.c +++ b/src/libout123/libout123.c @@ -1,7 +1,7 @@ /* audio: audio output interface - copyright ?-2020 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright ?-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Michael Hipp */ @@ -721,7 +721,7 @@ out123_play(out123_handle *ao, void *bytes, size_t count) int block = count > (size_t)maxcount ? maxcount : (int)count; written = ao->write(ao, bytes, block); debug4( "written: %d errno: %i (%s), keep_on=%d" - , written, errno, strerror(errno) + , written, errno, INT123_strerror(errno) , ao->flags & OUT123_KEEP_PLAYING ); if(written > 0) { @@ -742,7 +742,7 @@ out123_play(out123_handle *ao, void *bytes, size_t count) ao->errcode = OUT123_DEV_PLAY; if(!AOQUIET) merror( "Error in writing audio, wrote only %d of %d (%s?)!" - , written, block, strerror(errno) ); + , written, block, INT123_strerror(errno) ); /* This is a serious issue ending this playback round. */ break; } diff --git a/src/libout123/module.c b/src/libout123/module.c index 5889bb26..7ede2d3c 100644 --- a/src/libout123/module.c +++ b/src/libout123/module.c @@ -1,7 +1,7 @@ /* module.c: modular code loader - copyright 1995-2015 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright 1995-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Nicholas J Humfrey */ @@ -10,7 +10,6 @@ #define _DEFAULT_SOURCE #define _BSD_SOURCE #include "config.h" -#include "intsym.h" #include "stringlists.h" #include "compat.h" #include @@ -109,7 +108,7 @@ mpg123_module_t* open_module_here( const char *dir, const char* type if(!module_file) { if(verbose > -1) - error1( "Failed to allocate memory for module name: %s", strerror(errno) ); + error1( "Failed to allocate memory for module name: %s", INT123_strerror(errno) ); return NULL; } snprintf(module_file, module_file_len, "%s_%s%s", type, name, LT_MODULE_EXT); @@ -141,7 +140,7 @@ mpg123_module_t* open_module_here( const char *dir, const char* type module_symbol = malloc(module_symbol_len); if (module_symbol == NULL) { if(verbose > -1) - error1( "Failed to allocate memory for module symbol: %s", strerror(errno) ); + error1( "Failed to allocate memory for module symbol: %s", INT123_strerror(errno) ); return NULL; } snprintf( module_symbol, module_symbol_len, "%s%s%s", MODULE_SYMBOL_PREFIX, type, MODULE_SYMBOL_SUFFIX ); @@ -224,7 +223,7 @@ int INT123_list_modules( const char *type, char ***names, char ***descr, int ver if (dir==NULL) { if(verbose > -1) error2("Failed to open the module directory (%s): %s\n" - , moddir, strerror(errno)); + , moddir, INT123_strerror(errno)); free(moddir); return -1; } diff --git a/src/libout123/out123_int.h b/src/libout123/out123_int.h index 09354b13..452bfc2e 100644 --- a/src/libout123/out123_int.h +++ b/src/libout123/out123_int.h @@ -1,7 +1,7 @@ /* out123_int: internal header for libout123 - copyright ?-2021 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright ?-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Michael Hipp (some traces left) */ @@ -12,7 +12,6 @@ #define MPG123_ENUM_API #include "config.h" -#include "intsym.h" #include "abi_align.h" /* export DLL symbols */ #if defined(WIN32) && defined(DYNAMIC_BUILD) diff --git a/src/libout123/wav.c b/src/libout123/wav.c index 3d3c52e2..7f852b11 100644 --- a/src/libout123/wav.c +++ b/src/libout123/wav.c @@ -1,7 +1,7 @@ /* wav.c: write wav/au/cdr files (and headerless raw - copyright ?-2015 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright ?-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Samuel Audet @@ -201,7 +201,7 @@ static int close_file(out123_handle *ao) if(INT123_compat_fclose(wdat->wavfp)) { if(!AOQUIET) - error1("problem closing the audio file, probably because of flushing to disk: %s\n", strerror(errno)); + error1("problem closing the audio file, probably because of flushing to disk: %s\n", INT123_strerror(errno)); ret = -1; } } @@ -230,7 +230,7 @@ static int write_header(out123_handle *ao) ) { if(!AOQUIET) - error1("cannot write header: %s", strerror(errno)); + error1("cannot write header: %s", INT123_strerror(errno)); return -1; } else return 0; @@ -596,7 +596,7 @@ int INT123_wav_write(out123_handle *ao, unsigned char *buf, int len) if(fflush(wdat->wavfp)) { if(!AOQUIET) - error1("flushing failed: %s\n", strerror(errno)); + error1("flushing failed: %s\n", INT123_strerror(errno)); return -1; } #endif @@ -619,7 +619,7 @@ int INT123_wav_close(out123_handle *ao) if(fflush(wdat->wavfp)) { if(!AOQUIET) - error1("cannot flush WAV stream: %s", strerror(errno)); + error1("cannot flush WAV stream: %s", INT123_strerror(errno)); return close_file(ao); } if(fseek(wdat->wavfp, 0L, SEEK_SET) >= 0) @@ -673,7 +673,7 @@ int INT123_au_close(out123_handle *ao) if(fflush(wdat->wavfp)) { if(!AOQUIET) - error1("cannot flush WAV stream: %s", strerror(errno)); + error1("cannot flush WAV stream: %s", INT123_strerror(errno)); return close_file(ao); } if(fseek(wdat->wavfp, 0L, SEEK_SET) >= 0) @@ -746,5 +746,5 @@ void INT123_wav_drain(out123_handle *ao) return; if(fflush(wdat->wavfp) && !AOQUIET) - error1("flushing failed: %s\n", strerror(errno)); + error1("flushing failed: %s\n", INT123_strerror(errno)); } diff --git a/src/libout123/xfermem.c b/src/libout123/xfermem.c index 171845bc..fb638e64 100644 --- a/src/libout123/xfermem.c +++ b/src/libout123/xfermem.c @@ -1,7 +1,7 @@ /* xfermem: unidirectional fast pipe - copyright ?-2015 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright ?-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Oliver Fromme old timestamp: Sun Apr 6 02:26:26 MET DST 1997 @@ -222,7 +222,7 @@ int INT123_xfermem_putcmd (int fd, byte cmd) if (errno != EINTR) { debug3("INT123_xfermem_putcmd(%i, %i) = -1 (%s)" - , fd, cmd, strerror(errno)); + , fd, cmd, INT123_strerror(errno)); return (-1); } } diff --git a/src/libsyn123/syn123_int.h b/src/libsyn123/syn123_int.h index 28d1b36c..84703d11 100644 --- a/src/libsyn123/syn123_int.h +++ b/src/libsyn123/syn123_int.h @@ -1,7 +1,7 @@ /* syn123_int: internal header for libsyn123 - copyright 2018-2020 by the mpg123 project, + copyright 2018-2023 by the mpg123 project, licensed under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org @@ -17,7 +17,6 @@ #ifdef LFS_LARGEFILE_64 #define _LARGEFILE64_SOURCE #endif -#include "intsym.h" #include "compat.h" #include "abi_align.h" /* export DLL symbols */ diff --git a/src/mpg123-id3dump.c b/src/mpg123-id3dump.c index 84030555..31121dfb 100644 --- a/src/mpg123-id3dump.c +++ b/src/mpg123-id3dump.c @@ -1,7 +1,7 @@ /* id3dump: Print ID3 tags of files, scanned using libmpg123. - copyright 2007-2021 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright 2007-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Thomas Orgis */ @@ -352,7 +352,7 @@ static void store_pictures(const char* prefix, mpg123_id3v2 *v2) } else { - error1("Unable to fdopen output: %s)", strerror(errno)); + error1("Unable to fdopen output: %s)", INT123_strerror(errno)); ++errors; } } diff --git a/src/mpg123-strip.c b/src/mpg123-strip.c index 7ff1a862..d55a7d38 100644 --- a/src/mpg123-strip.c +++ b/src/mpg123-strip.c @@ -1,7 +1,7 @@ /* extract_frams: utlize the framebyframe API and mpg123_framedata to extract the MPEG frames out of a stream (strip off anything else). - copyright 2011-2013 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright 2011-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Thomas Orgis */ @@ -155,7 +155,7 @@ int do_work(mpg123_handle *m) if( 4 != INT123_unintr_write(STDOUT_FILENO, hbuf, 4) || bodybytes != INT123_unintr_write(STDOUT_FILENO, bodydata, bodybytes) ) { - fprintf(stderr, "Failed to write data: %s\n", strerror(errno)); + fprintf(stderr, "Failed to write data: %s\n", INT123_strerror(errno)); return MPG123_ERR; } if(param.verbose) diff --git a/src/net123_exec.c b/src/net123_exec.c index 988c89fb..f005aa5d 100644 --- a/src/net123_exec.c +++ b/src/net123_exec.c @@ -1,6 +1,11 @@ /* net123_exec: network (HTTP(S)) streaming for mpg123 via fork+exec + copyright 2022-2023 by the mpg123 project + free software under the terms of the LGPL 2.1 + see COPYING and AUTHORS files in distribution or http://mpg123.org + initially written by Thomas Orgis + This avoids linking any network code directly into mpg123, just using external tools at runtime. @@ -254,7 +259,7 @@ static void net123_close(net123_handle *nh) kill(eh->worker, SIGKILL); errno = 0; if(waitpid(eh->worker, NULL, 0) < 0) - merror("failed to wait for worker process: %s", strerror(errno)); + merror("failed to wait for worker process: %s", INT123_strerror(errno)); else if(param.verbose > 1) fprintf(stderr, "Note: network helper %"PRIiMAX" finished\n", (intmax_t)eh->worker); } @@ -320,7 +325,7 @@ net123_handle *net123_open_exec(const char *url, const char * const * client_hea errno = 0; if(pipe(fd)) { - merror("failed creating a pipe: %s", strerror(errno)); + merror("failed creating a pipe: %s", INT123_strerror(errno)); free(nh); return NULL; } @@ -331,7 +336,7 @@ net123_handle *net123_open_exec(const char *url, const char * const * client_hea eh->worker = fork(); if(eh->worker == -1) { - merror("fork failed: %s", strerror(errno)); + merror("fork failed: %s", INT123_strerror(errno)); free(nh); return NULL; } @@ -367,7 +372,7 @@ net123_handle *net123_open_exec(const char *url, const char * const * client_hea dup2(errfd, STDERR_FILENO); } execvp(argv[0], argv); - merror("cannot execute %s: %s", argv[0], strerror(errno)); + merror("cannot execute %s: %s", argv[0], INT123_strerror(errno)); exit(1); } // parent diff --git a/src/out123.c b/src/out123.c index c7427356..730aaed5 100644 --- a/src/out123.c +++ b/src/out123.c @@ -1,7 +1,7 @@ /* out123: stream data from libmpg123 or libsyn123 to an audio output device - copyright 1995-2021 by the mpg123 project, + copyright 1995-2023 by the mpg123 project, free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org @@ -1079,7 +1079,7 @@ void push_output(unsigned char *buf, size_t samples) if(also_stdout && INT123_unintr_fwrite(buf, pcmframe, samples, stdout) < samples) { if(!quiet) - error1( "failed to copy stream to stdout: %s", strerror(errno)); + error1( "failed to copy stream to stdout: %s", INT123_strerror(errno)); safe_exit(133); } } @@ -1114,7 +1114,7 @@ FILE* open_next_file(int argc, char** argv, int firstrun) in = strcmp(filename, "-") ? INT123_compat_fopen(filename, "rb") : stdin; if(!in) merror( "Failed to open input file '%s' (%s), ignoring." - , filename, strerror(errno) ); + , filename, INT123_strerror(errno) ); else had_something = 1; } diff --git a/src/resolver.c b/src/resolver.c index 02ba90f9..4c451eb1 100644 --- a/src/resolver.c +++ b/src/resolver.c @@ -2,7 +2,7 @@ resolver.c: TCP network stuff, for IPv4 and IPv6 Oh, and also some URL parsing... extracting host name and such. - copyright 2008-2010 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright 2008-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written Thomas Orgis (based on httpget.c) @@ -222,13 +222,13 @@ static int timeout_connect(int sockfd, const struct sockaddr *serv_addr, socklen } else { - error1("error from select(): %s", strerror(errno)); + error1("error from select(): %s", INT123_strerror(errno)); return -1; } } else { - error1("connection failed: %s", strerror(errno)); + error1("connection failed: %s", INT123_strerror(errno)); return err; } } @@ -236,7 +236,7 @@ static int timeout_connect(int sockfd, const struct sockaddr *serv_addr, socklen { if(connect(sockfd, serv_addr, addrlen)) { - error1("connection failed: %s", strerror(errno)); + error1("connection failed: %s", INT123_strerror(errno)); return -1; } else return 0; /* _good_ */ @@ -284,7 +284,7 @@ int open_connection(mpg123_string *host, mpg123_string *port) if((sock = socket(PF_INET, SOCK_STREAM, 6)) < 0) { - error1("Cannot create socket: %s", strerror(errno)); + error1("Cannot create socket: %s", INT123_strerror(errno)); return -1; } if(timeout_connect(sock, (struct sockaddr *)&server, sizeof(server))) diff --git a/src/streamdump.c b/src/streamdump.c index 6541b438..d7f8a6b1 100644 --- a/src/streamdump.c +++ b/src/streamdump.c @@ -4,7 +4,7 @@ This evolved into the generic I/O interposer for direct file or http stream access, with explicit buffering for getline. - copyright 2010-2022 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright 2010-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Michael Hipp */ @@ -597,7 +597,7 @@ struct stream *stream_open(const char *url) sd->fd = INT123_compat_open(url, O_RDONLY|O_BINARY); if(sd->fd < 0) { - merror("failed to open file: %s: %s", url, strerror(errno)); + merror("failed to open file: %s: %s", url, INT123_strerror(errno)); stream_close(sd); return NULL; } @@ -662,7 +662,7 @@ int dump_setup(struct stream *sd, mpg123_handle *mh) } if(dump_fd < 0) { - error1("Failed to open dump file: %s\n", strerror(errno)); + error1("Failed to open dump file: %s\n", INT123_strerror(errno)); return -1; } #ifdef WIN32 diff --git a/src/term.c b/src/term.c index da3feb12..792ac6d6 100644 --- a/src/term.c +++ b/src/term.c @@ -88,7 +88,7 @@ int term_init(void) if(term_setup() < 0) { if(errno) - merror("failed to set up terminal: %s", strerror(errno)); + merror("failed to set up terminal: %s", INT123_strerror(errno)); else error("failed to set up terminal"); return -1; diff --git a/src/term_posix.c b/src/term_posix.c index a59a46c1..45813beb 100644 --- a/src/term_posix.c +++ b/src/term_posix.c @@ -3,7 +3,7 @@ HAVE_TERMIOS is a prerequisite. - copyright 2008-2022 by the mpg123 project - free software under the terms of the LGPL 2.1 + copyright 2008-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Thomas Orgis */ @@ -149,7 +149,7 @@ int term_setup(void) term_fd = open(term_name, O_RDONLY); if(term_fd < 0) { - merror("failed to open terminal: %s", strerror(errno)); + merror("failed to open terminal: %s", INT123_strerror(errno)); return -1; } } @@ -159,7 +159,7 @@ int term_setup(void) // For now, this always fails on OS/2, but they might fix things. // So just try to move on. #ifndef __OS2__ - merror("failed to get terminal attributes: %s", strerror(errno)); + merror("failed to get terminal attributes: %s", INT123_strerror(errno)); return -1; #endif } @@ -170,7 +170,7 @@ int term_setup(void) close(term_fd); term_fd = -1; if(errno) - merror("failure setting terminal attributes: %s", strerror(errno)); + merror("failure setting terminal attributes: %s", INT123_strerror(errno)); else error("failure setting terminal attributes"); return -1; diff --git a/src/win32_net.c b/src/win32_net.c index fd9a50d2..4965b726 100755 --- a/src/win32_net.c +++ b/src/win32_net.c @@ -1,3 +1,11 @@ +/* + win32_net: Windows-specific network code + + copyright 2009-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 + see COPYING and AUTHORS files in distribution or http://mpg123.org + initially written by Jonathan Yong (extracting out of httpget.c) +*/ + #include "win32_support.h" #include "mpg123app.h" #include "debug.h" @@ -170,7 +178,7 @@ static int win32_net_timeout_connect(int sockfd, const struct sockaddr *serv_add } else { - /*error1("error from select(): %s", strerror(errno));*/ + /*error1("error from select(): %s", INT123_strerror(errno));*/ debug("error from select():"); msgme1; return -1; @@ -178,7 +186,7 @@ static int win32_net_timeout_connect(int sockfd, const struct sockaddr *serv_add } else { - /*error1("connection failed: %s", strerror(errno));*/ + /*error1("connection failed: %s", INT123_strerror(errno));*/ debug("connection failed: "); msgme1; return err; @@ -188,7 +196,7 @@ static int win32_net_timeout_connect(int sockfd, const struct sockaddr *serv_add { if(connect(ws.local_socket, serv_addr, addrlen) == SOCKET_ERROR) { - /*error1("connection failed: %s", strerror(errno));*/ + /*error1("connection failed: %s", INT123_strerror(errno));*/ debug("connection failed"); msgme1; return -1;