diff options
| author | Markus Uhlin <markus@nifty-networks.net> | 2026-03-22 22:15:46 +0100 |
|---|---|---|
| committer | Markus Uhlin <markus@nifty-networks.net> | 2026-03-22 22:15:46 +0100 |
| commit | ccc018887c443bf06482632d41798ec914a1df53 (patch) | |
| tree | 67596d708e63d498e33e0af286c48dd8dd891335 /FICS/maxxes-utils.c | |
| parent | 3cdba75bb55c7310950523e2cd66bbcf1d6d5992 (diff) | |
Added fprintf_logerr() and defined mfprintf()
Diffstat (limited to 'FICS/maxxes-utils.c')
| -rw-r--r-- | FICS/maxxes-utils.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/FICS/maxxes-utils.c b/FICS/maxxes-utils.c index 987be47..344a4fb 100644 --- a/FICS/maxxes-utils.c +++ b/FICS/maxxes-utils.c @@ -12,6 +12,31 @@ #include "maxxes-utils.h" +void +fprintf_logerr(const char *file, const long int line, + FILE *fp, const char *format, ...) +{ + int ret; + va_list ap; + + if (fp == NULL) { + warnx("%s:%ld: error: invalid argument (null pointer)", + file, line); + return; + } else if (fp == stdin || fp == stdout || fp == stderr) { + warnx("%s:%ld: error: invalid stream (stdin, stdout or stderr)", + file, line); + return; + } + + va_start(ap, format); + ret = vfprintf(fp, format, ap); + va_end(ap); + + if (ret < 0) + warnx("%s:%ld: warning: vfprintf() error", file, line); +} + bool is_too_long(const int p_ret, const size_t p_maxlen) { |
