NNTP_INCLUDES = -I$(top_srcdir)/nntp
endif
-SUBDIRS = m4 po intl doc contrib $(IMAP_SUBDIR) $(POP_SUBDIR) $(NNTP_SUBDIR)
+SUBDIRS = m4 po intl doc contrib lib $(IMAP_SUBDIR) $(POP_SUBDIR) $(NNTP_SUBDIR)
bin_SCRIPTS = muttngbug fleang
url.c ascii.c mutt_idna.c sidebar.c hcache.c crypt-mod.c crypt-mod.h
muttng_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(LIBPOP) $(LIBNNTP) \
- $(MUTTLIBS) $(INTLLIBS) $(LIBICONV)
+ -Llib -lsane $(MUTTLIBS) $(INTLLIBS) $(LIBICONV)
muttng_DEPENDENCIES = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAPDEPS) $(LIBPOPDEPS) $(LIBNNTPDEPS) \
$(INTLDEPS)
AC_OUTPUT(Makefile intl/Makefile m4/Makefile
po/Makefile.in doc/Makefile contrib/Makefile
muttbug.sh
+ lib/Makefile
imap/Makefile
pop/Makefile
nntp/Makefile
fputc ('\n', stderr);
}
-void *safe_calloc (size_t nmemb, size_t size)
-{
- void *p;
-
- if (!nmemb || !size)
- return NULL;
-
- if (((size_t) - 1) / nmemb <= size) {
- mutt_error _("Integer overflow -- can't allocate memory!");
-
- sleep (1);
- mutt_exit (1);
- }
-
- if (!(p = calloc (nmemb, size))) {
- mutt_error _("Out of memory!");
-
- sleep (1);
- mutt_exit (1);
- }
- return p;
-}
-
-void *safe_malloc (size_t siz)
-{
- void *p;
-
- if (siz == 0)
- return 0;
- if ((p = (void *) malloc (siz)) == 0) { /* __MEM_CHECKED__ */
- mutt_error _("Out of memory!");
-
- sleep (1);
- mutt_exit (1);
- }
- return (p);
-}
-
-void safe_realloc (void *ptr, size_t siz)
-{
- void *r;
- void **p = (void **) ptr;
-
- if (siz == 0) {
- if (*p) {
- free (*p); /* __MEM_CHECKED__ */
- *p = NULL;
- }
- return;
- }
-
- if (*p)
- r = (void *) realloc (*p, siz); /* __MEM_CHECKED__ */
- else {
- /* realloc(NULL, nbytes) doesn't seem to work under SunOS 4.1.x --- __MEM_CHECKED__ */
- r = (void *) malloc (siz); /* __MEM_CHECKED__ */
- }
-
- if (!r) {
- mutt_error _("Out of memory!");
-
- sleep (1);
- mutt_exit (1);
- }
-
- *p = r;
-}
-
-void safe_free (void *ptr)
-{
- void **p = (void **) ptr;
-
- if (*p) {
- free (*p); /* __MEM_CHECKED__ */
- *p = 0;
- }
-}
-
int safe_fclose (FILE ** f)
{
int r = 0;
# include <posix1_lim.h>
# endif
-# ifdef ENABLE_NLS
-# include <libintl.h>
-# define _(a) (gettext (a))
-# ifdef gettext_noop
-# define N_(a) gettext_noop (a)
-# else
-# define N_(a) (a)
-# endif
-# else
-# define _(a) (a)
-# define N_(a) a
-# endif
-
# define TRUE 1
# define FALSE 0
# define MUTT_FORMAT(a) _MUTT_FORMAT_1(a, "s")
# define MUTT_FORMAT2(a,b) _MUTT_FORMAT_1(a, b)
-
-# define FREE(x) safe_free(x)
-# define NONULL(x) x?x:""
# define ISSPACE(c) isspace((unsigned char)c)
# define strfcpy(A,B,C) strncpy(A,B,C), *(A+(C)-1)=0
# define MAX(a,b) ((a) < (b) ? (b) : (a))
# define MIN(a,b) ((a) < (b) ? (a) : (b))
-
#define FOREVER while (1)
/* this macro must check for *c == 0 since isspace(0) has unreliable behavior
size_t mutt_quote_filename (char *, size_t, const char *);
size_t mutt_strlen (const char *);
-void *safe_calloc (size_t, size_t);
-void *safe_malloc (size_t);
void mutt_nocurses_error (const char *, ...);
void mutt_remove_trailing_ws (char *);
void mutt_sanitize_filename (char *, short);
void mutt_str_replace (char **p, const char *s);
void mutt_str_adjust (char **p);
void mutt_unlink (const char *);
-void safe_free (void *);
-void safe_realloc (void *, size_t);
#endif
--- /dev/null
+## Process this file with automake to produce Makefile.in
+
+AR=@AR@
+
+AUTOMAKE_OPTIONS = foreign
+
+INCLUDES = -I$(top_srcdir) -I../intl
+
+noinst_LIBRARIES = libsane.a
+noinst_HEADERS = mem.h str.h exit.h intl.h
+
+libsane_a_SOURCES = mem.c exit.c \
+ mem.h exit.h str.h intl.h
--- /dev/null
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "exit.h"
+#include "str.h"
+#include "intl.h"
+
+/* XXX remove after modularization*/
+extern void mutt_endwin (void*);
+
+void exit_fatal (const char* func, const char* msg, int line,
+ const char* fname, int code) {
+ mutt_endwin (NULL);
+ fprintf (stderr, _("Fatal error in function '%s' called from "
+ "file '%s', line '%d': %s\n"
+ "(please report this error to "
+ "<mutt-ng-devel@lists.berlios.de>\n"),
+ NONULL(func), NONULL(fname), line, NONULL(msg));
+ exit (code);
+}
--- /dev/null
+#ifndef _LIB_EXIT_H
+#define _LIB_EXIT_H
+
+void exit_fatal (const char*, const char*, int, const char*, int);
+
+#endif /* !_LIB_EXIT_H */
--- /dev/null
+#ifndef _LIB_INTL_H
+#define _LIB_INTL_H
+
+/*
+ * config.h must be included by source file!
+ */
+
+# ifdef ENABLE_NLS
+# include <libintl.h>
+# define _(a) (gettext (a))
+# ifdef gettext_noop
+# define N_(a) gettext_noop (a)
+# else
+# define N_(a) (a)
+# endif
+# else
+# define _(a) (a)
+# define N_(a) a
+# endif
+
+#endif /* !_LIB_INTL_H */
--- /dev/null
+/*
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+
+#include <stdlib.h>
+
+#include "mem.h"
+#include "exit.h"
+#include "intl.h"
+
+void *_safe_calloc (size_t nmemb, size_t size, int line, const char* fname) {
+ void *p;
+
+ if (!nmemb || !size)
+ return NULL;
+
+ if (((size_t) - 1) / nmemb <= size) {
+ exit_fatal ("safe_calloc", _("Integer overflow -- can't allocate memory!"),
+ line, fname, 1);
+ return (NULL);
+ }
+
+ if (!(p = calloc (nmemb, size))) {
+ exit_fatal ("safe_calloc", _("Out of memory!"), line, fname, 1);
+ return (NULL);
+ }
+ return p;
+}
+
+void *_safe_malloc (size_t siz, int line, const char* fname) {
+ void *p;
+
+ if (siz == 0)
+ return 0;
+ if ((p = (void *) malloc (siz)) == 0) { /* __MEM_CHECKED__ */
+ exit_fatal ("safe_malloc", _("Out of memory!"), line, fname, 1);
+ return (NULL);
+ }
+ return (p);
+}
+
+void _safe_realloc (void *ptr, size_t siz, int line, const char* fname) {
+ void *r;
+ void **p = (void **) ptr;
+
+ if (siz == 0) {
+ if (*p) {
+ free (*p); /* __MEM_CHECKED__ */
+ *p = NULL;
+ }
+ return;
+ }
+
+ if (*p)
+ r = (void *) realloc (*p, siz); /* __MEM_CHECKED__ */
+ else {
+ /* realloc(NULL, nbytes) doesn't seem to work under SunOS 4.1.x --- __MEM_CHECKED__ */
+ r = (void *) malloc (siz); /* __MEM_CHECKED__ */
+ }
+
+ if (!r)
+ exit_fatal ("safe_realloc", _("Out of memory!"), line, fname, 1);
+
+ *p = r;
+}
+
+void safe_free (void *ptr) {
+ void **p = (void **) ptr;
+
+ if (*p) {
+ free (*p); /* __MEM_CHECKED__ */
+ *p = 0;
+ }
+}
--- /dev/null
+/*
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+
+#ifndef _LIB_MEM_H
+#define _LIB_MEM_H
+
+void* _safe_malloc (size_t, int, const char*);
+void* _safe_calloc (size_t, size_t, int, const char*);
+void _safe_realloc (void*, size_t, int, const char*);
+void _safe_free (void*);
+
+#define safe_malloc(s) _safe_malloc(s,__LINE__,__FILE__)
+#define safe_calloc(s,c) _safe_calloc(s,c,__LINE__,__FILE__)
+#define safe_realloc(p,c) _safe_realloc(p,c,__LINE__,__FILE__)
+#define FREE(x) _safe_free(x)
+
+#endif /* !_LIB_MEM_H */
--- /dev/null
+/*
+ * Copyright notice from original mutt:
+ * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
+ * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
+ *
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+
+/* mutt functions which are generally useful. */
+
+#ifndef _LIB_STR_H
+#define _LIB_STR_H
+
+#define NONULL(x) x?x:""
+
+#endif /* !_LIB_STR_H */
#include "rfc1524.h"
#include "rfc2047.h"
+#include "lib/mem.h"
+#include "lib/str.h"
+#include "lib/intl.h"
+
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include "smime.h"
#endif
+#include "lib/mem.h"
+#include "lib/str.h"
+#include "lib/intl.h"
+
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include "pop.h"
#include "mutt_crypt.h"
+#include "lib/mem.h"
+#include "lib/str.h"
+#include "lib/intl.h"
+
#include <string.h>
#include <unistd.h>
#include "md5.h"
#include "pop.h"
+#include "lib/mem.h"
+#include "lib/intl.h"
+
#include <string.h>
#include <unistd.h>
# include "mutt_ssl.h"
#endif
+#include "lib/mem.h"
+#include "lib/intl.h"
+
#include <string.h>
#include <unistd.h>
#include <ctype.h>