EXTRA_DIST = account.h attach.h bcache.h browser.h buffer.h buffy.h \
ChangeLog.md charset.h CODE_OF_CONDUCT.md compress.h copy.h \
- COPYRIGHT extlib.c filter.h functions.h gen_defs globals.h \
+ COPYRIGHT filter.h functions.h gen_defs globals.h \
group.h hash.h history.h init.h keymap.h lib.h LICENSE.md mailbox.h \
mapping.h mbyte.h mime.h mime.types mutt.h mutt_commands.h \
mutt_curses.h mutt_idna.h mutt_lua.h mutt_menu.h mutt_notmuch.h \
EXTRA_SCRIPTS =
-pgpring_SOURCES = extlib.c lib.c pgppubring.c
+pgpring_SOURCES = lib.c pgppubring.c
pgpring_LDADD = $(LIBOBJS) $(NCRYPT_LIBS) $(INTLLIBS) $(LIBLIB)
pgpring_DEPENDENCIES = $(LIBOBJS) $(NCRYPT_DEPS) $(INTLDEPS) $(LIBLIBDEPS)
errno = e;
}
-void mutt_perror(const char *s)
+void mutt_perror_debug(const char *s)
{
char *p = strerror(errno);
#include "sort.h"
#endif /* MAIN_C */
-WHERE void (*mutt_error)(const char *, ...);
-WHERE void (*mutt_message)(const char *, ...);
-
WHERE struct Context *Context;
WHERE char Errorbuf[STRING];
*/
-#ifndef _EXTLIB_C
-extern void (*mutt_error)(const char *, ...);
-#endif
-
#ifdef DEBUG
extern char debugfilename[_POSIX_PATH_MAX];
extern FILE *debugfile;
AUTOMAKE_OPTIONS = 1.6 foreign
-EXTRA_DIST = lib.h lib_ascii.h lib_base64.h lib_date.h lib_exit.h lib_md5.h lib_memory.h lib_sha1.h
+EXTRA_DIST = lib.h lib_ascii.h lib_base64.h lib_date.h lib_exit.h lib_md5.h lib_memory.h lib_message.h lib_sha1.h
AM_CPPFLAGS = -I$(top_srcdir)
noinst_LIBRARIES = liblib.a
noinst_HEADERS =
-liblib_a_SOURCES = lib_ascii.c lib_base64.c lib_date.c lib_exit.c lib_md5.c lib_memory.c lib_sha1.c
+liblib_a_SOURCES = lib_ascii.c lib_base64.c lib_date.c lib_exit.c lib_md5.c lib_memory.c lib_message.c lib_sha1.c
* -# @subpage exit
* -# @subpage md5
* -# @subpage memory
+ * -# @subpage message
* -# @subpage sha1
*/
#include "lib_exit.h"
#include "lib_md5.h"
#include "lib_memory.h"
+#include "lib_message.h"
#include "lib_sha1.h"
#endif /* _LIB_LIB_H */
#include <unistd.h>
#include "lib_memory.h"
#include "lib_exit.h"
-// #include "lib_message.h"
-void mutt_error(const char *, ...);
+#include "lib_message.h"
/**
* safe_calloc - Allocate zeroed memory on the heap
--- /dev/null
+/**
+ * @file
+ * Message logging
+ *
+ * @authors
+ * Copyright (C) 2017 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @page message Message logging
+ *
+ * Display informational messages for the user.
+ *
+ * These library stubs print the messages to stdout/stderr.
+ *
+ * | Function | Description
+ * | :---------------- | :--------------------------------------------
+ * | default_error() | Display an error message
+ * | default_message() | Display an informative message
+ * | default_perror() | Lookup a standard error message (using errno)
+ */
+
+#include "config.h"
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include "lib_memory.h"
+
+/**
+ * default_error - Display an error message
+ * @param format printf-like formatting string
+ * @param ... Arguments to format
+ *
+ * This stub function writes to stderr.
+ */
+static void default_error(const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ vfprintf(stderr, format, ap);
+ va_end(ap);
+ fputc('\n', stderr);
+}
+
+void (*mutt_error)(const char *, ...) = default_error;
+
+/**
+ * default_message - Display an informative message
+ * @param format printf-like formatting string
+ * @param ... Arguments to format
+ *
+ * This stub function writes to stdout.
+ */
+static void default_message(const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ vfprintf(stdout, format, ap);
+ va_end(ap);
+ fputc('\n', stdout);
+}
+
+void (*mutt_message)(const char *, ...) = default_message;
+
+/**
+ * default_perror - Lookup a standard error message (using errno)
+ * @param message Prefix message to display
+ *
+ * This stub function writes to stderr.
+ */
+static void default_perror(const char *message)
+{
+ char *p = strerror(errno);
+
+ mutt_error("%s: %s (errno = %d)", message, p ? p : _("unknown error"), errno);
+}
+
+void (*mutt_perror)(const char *) = default_perror;
/**
* @file
- * Helper function for standalone tools
+ * Message logging
*
* @authors
- * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
+ * Copyright (C) 2017 Richard Russon <rich@flatcap.org>
*
* @copyright
* This program is free software: you can redistribute it and/or modify it under
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/*
- * Some simple dummies, so we can reuse the routines from
- * lib.c in external programs.
- */
-
-#define WHERE
-#define _EXTLIB_C
-
-#include "config.h"
-#include <stdlib.h>
-#include "lib.h"
+#ifndef _LIB_MESSAGE_H
+#define _LIB_MESSAGE_H
-void (*mutt_error)(const char *, ...) = mutt_nocurses_error;
+void (*mutt_error) (const char *format, ...);
+void (*mutt_message)(const char *format, ...);
+void (*mutt_perror) (const char *message);
+#endif /* _LIB_MESSAGE_H */
}
#endif
- mutt_error = mutt_nocurses_error;
- mutt_message = mutt_nocurses_error;
+ mutt_message = mutt_error; /* send messages to stderr, too */
+ mutt_perror = mutt_perror_debug;
(void) mutt_rand32();
umask(077);
edit.c
editmsg.c
enter.c
-extlib.c
filter.c
flags.c
from.c
lib/lib_exit.c
lib/lib_md5.c
lib/lib_memory.c
+lib/lib_message.c
lib/lib_sha1.c
main.c
mbox.c
void mutt_paddstr(int n, const char *s);
void mutt_parse_mime_message(struct Context *ctx, struct Header *cur);
void mutt_parse_part(FILE *fp, struct Body *b);
-void mutt_perror(const char *s);
+void mutt_perror_debug(const char *s);
void mutt_prepare_envelope(struct Envelope *env, int final);
void mutt_unprepare_envelope(struct Envelope *env);
void mutt_pretty_mailbox(char *s, size_t buflen);