diff options
author | Alain Magloire <alainm@gnu.org> | 2001-04-16 02:26:31 +0000 |
---|---|---|
committer | Alain Magloire <alainm@gnu.org> | 2001-04-16 02:26:31 +0000 |
commit | b13877db6956665d13bf6ed1a4000ac687b13a25 (patch) | |
tree | b73955b3dbcc16588e4b886bbd814a23f445cd24 | |
parent | d1ba2067d0eb2537f3ed7b10d2e22455cf84a740 (diff) | |
download | mailutils-b13877db6956665d13bf6ed1a4000ac687b13a25.tar.gz mailutils-b13877db6956665d13bf6ed1a4000ac687b13a25.tar.bz2 |
Create a argp directory, it contains the necessary
files to build a standalone libargp.a
* argp: New directory.
argp-ba.c, argp-eexst.c, argp-fmtstream.c, argp-fmtstream.h
argp-fs-xinl.c, argp-help.c, argp-namefrob.h, argp-parse.c
argp-pv.c, argp-pvh.c, argp-xinl.c, argp.h, pin.c.
* mail/mail.c: Comment out the code that use readline
specifics WITH_READLINE.
* mail/mail.h: Likewised.
* mail/util.c: Likewised.
And still mail will not compile for QNX ... #&*#$^&#^)(
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | argp/Makefile.am | 4 | ||||
-rw-r--r-- | argp/argp-fmtstream.h | 4 | ||||
-rw-r--r-- | argp/argp-help.c | 40 | ||||
-rw-r--r-- | argp/argp-parse.c | 7 | ||||
-rw-r--r-- | argp/argp.h | 7 | ||||
-rw-r--r-- | configure.in | 3 | ||||
-rw-r--r-- | frm/frm.c | 2 | ||||
-rw-r--r-- | mail/Makefile.am | 6 | ||||
-rw-r--r-- | mail/mail.c | 4 | ||||
-rw-r--r-- | mail/mail.h | 5 | ||||
-rw-r--r-- | mail/util.c | 146 | ||||
-rw-r--r-- | mailbox/Makefile.am | 2 | ||||
-rw-r--r-- | pop3d/pop3d.c | 4 |
15 files changed, 151 insertions, 100 deletions
@@ -1,5 +1,20 @@ 2001-04-15 Alain Magloire + Create a argp directory, it contains the necessary + files to build a standalone libargp.a + + * argp: New directory. + argp-ba.c, argp-eexst.c, argp-fmtstream.c, argp-fmtstream.h + argp-fs-xinl.c, argp-help.c, argp-namefrob.h, argp-parse.c + argp-pv.c, argp-pvh.c, argp-xinl.c, argp.h, pin.c. + + * mail/mail.c: Comment out the code that use readline + specifics WITH_READLINE. + * mail/mail.h: Likewised. + * mail/util.c: Likewised. + +2001-04-15 Alain Magloire + * Makefile.am: Add argp in the list of subdirs. * configure.am: Check for argp.h and look for argp_parse(). diff --git a/Makefile.am b/Makefile.am index 2543cb785..ee00038e2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = gnu 1.4 ACLOCAL_AMFLAGS = -I m4 # imap4d -SUBDIRS = include doc m4 argp lib mailbox frm from pop3d imap4d mail +SUBDIRS = include doc m4 lib argp mailbox frm from pop3d imap4d mail EXTRA_DIST = mailutils.spec mailutils.spec.in README-alpha COPYING.FDL diff --git a/argp/Makefile.am b/argp/Makefile.am index a6a952dcf..934310c9b 100644 --- a/argp/Makefile.am +++ b/argp/Makefile.am @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = ../lib/ansi2knr INCLUDES = -I${top_srcdir}/lib -noinst_LIBRARIES = @ARGPLIB@ +noinst_LIBRARIES = @ARGPLIBS@ libargp_a_SOURCES = argp-ba.c argp-eexst.c argp-fmtstream.c argp-fs-xinl.c \ argp-help.c argp-parse.c argp-pv.c argp-pvh.c argp-xinl.c pin.c @@ -15,4 +15,4 @@ noinst_HEADERS = argp-fmtstream.h argp-namefrob.h argp.h libargp_a_LIBADD = ../lib/libmailutils.a -CFLAGS = -Wall -pedantic -g +CFLAGS = -Wall -g diff --git a/argp/argp-fmtstream.h b/argp/argp-fmtstream.h index 0203c9d5c..914d8373c 100644 --- a/argp/argp-fmtstream.h +++ b/argp/argp-fmtstream.h @@ -34,10 +34,6 @@ #include <string.h> #include <unistd.h> -#ifndef HAVE_PTHREAD_H -# define fwrite_unlocked fwrite -#endif - #if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \ || (defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H)) /* line_wrap_stream is available, so use that. */ diff --git a/argp/argp-help.c b/argp/argp-help.c index d09a50717..942b72db3 100644 --- a/argp/argp-help.c +++ b/argp/argp-help.c @@ -517,7 +517,7 @@ hol_free (struct hol *hol) free (hol); } -static inline int +static int hol_entry_short_iterate (const struct hol_entry *entry, int (*func)(const struct argp_option *opt, const struct argp_option *real, @@ -542,7 +542,7 @@ hol_entry_short_iterate (const struct hol_entry *entry, return val; } -static inline int +static int hol_entry_long_iterate (const struct hol_entry *entry, int (*func)(const struct argp_option *opt, const struct argp_option *real, @@ -566,7 +566,7 @@ hol_entry_long_iterate (const struct hol_entry *entry, } /* Iterator that returns true for the first short option. */ -static inline int +static int until_short (const struct argp_option *opt, const struct argp_option *real, const char *domain, void *cookie) { @@ -1525,15 +1525,12 @@ _help (const struct argp *argp, const struct argp_state *state, FILE *stream, if (! stream) return; - flockfile (stream); - if (! uparams.valid) fill_in_uparams (state); fs = __argp_make_fmtstream (stream, 0, uparams.rmargin, 0); if (! fs) { - funlockfile (stream); return; } @@ -1641,8 +1638,6 @@ Try `%s --help' or `%s --usage' for more information.\n"), anything = 1; } - funlockfile (stream); - if (hol) hol_free (hol); @@ -1700,22 +1695,19 @@ __argp_error (const struct argp_state *state, const char *fmt, ...) { va_list ap; - flockfile (stream); - - fputs_unlocked (state ? state->name : program_invocation_short_name, + fputs (state ? state->name : program_invocation_short_name, stream); - putc_unlocked (':', stream); - putc_unlocked (' ', stream); + putc (':', stream); + putc (' ', stream); va_start (ap, fmt); vfprintf (stream, fmt, ap); va_end (ap); - putc_unlocked ('\n', stream); + putc ('\n', stream); __argp_state_help (state, stream, ARGP_HELP_STD_ERR); - funlockfile (stream); } } } @@ -1741,17 +1733,15 @@ __argp_failure (const struct argp_state *state, int status, int errnum, if (stream) { - flockfile (stream); - - fputs_unlocked (state ? state->name : program_invocation_short_name, - stream); + fputs (state ? state->name : program_invocation_short_name, + stream); if (fmt) { va_list ap; - putc_unlocked (':', stream); - putc_unlocked (' ', stream); + putc (':', stream); + putc (' ', stream); va_start (ap, fmt); vfprintf (stream, fmt, ap); @@ -1760,14 +1750,12 @@ __argp_failure (const struct argp_state *state, int status, int errnum, if (errnum) { - putc_unlocked (':', stream); - putc_unlocked (' ', stream); + putc (':', stream); + putc (' ', stream); fputs (strerror (errnum), stream); } - putc_unlocked ('\n', stream); - - funlockfile (stream); + putc ('\n', stream); if (status && (!state || !(state->flags & ARGP_NO_EXIT))) exit (status); diff --git a/argp/argp-parse.c b/argp/argp-parse.c index cdbc322c5..f04537cba 100644 --- a/argp/argp-parse.c +++ b/argp/argp-parse.c @@ -217,12 +217,7 @@ static struct mutex getopt_lock = MUTEX_INITIALIZER; #define LOCK_GETOPT mutex_lock (&getopt_lock) #define UNLOCK_GETOPT mutex_unlock (&getopt_lock) -#elif defined(HAVE_PTHREAD_H) -static struct pthread_mutex_t getopt_lock = PTHREAD_MUTEX_INITIALIZER; -#define LOCK_GETOPT pthread_mutex_lock (&getopt_lock) -#define UNLOCK_GETOPT pthread_mutex_unlock (&getopt_lock) - -#else /* !HAVE_CTHREADS_H !HAVE_PTHREAD_H */ +#else /* !HAVE_CTHREADS_H */ #define LOCK_GETOPT (void)0 #define UNLOCK_GETOPT (void)0 diff --git a/argp/argp.h b/argp/argp.h index 30402eef6..244265c9a 100644 --- a/argp/argp.h +++ b/argp/argp.h @@ -28,13 +28,6 @@ #define __need_error_t #include <errno.h> -#ifndef HAVE_PTHREAD_H -#define flockfile(arg) -#define funlockfile(arg) -#define fputs_unlocked fputs -#define fwrite_unlocked fwrite -#endif - #ifndef __error_t_defined typedef int error_t; # define __error_t_defined diff --git a/configure.in b/configure.in index f7a8f7f8d..5339cc240 100644 --- a/configure.in +++ b/configure.in @@ -75,7 +75,10 @@ dnl Check for libraries AC_CHECK_FUNCS(argp_parse) if test x"$ac_cv_func_argp_parse" != xyes; then AC_REPLACE_FUNCS(strndup strnlen strchrnul) + ARGPLIBS="libargp.a" + ARGPINCS="-I../argp" AC_SUBST(ARGPLIBS) + AC_SUBST(ARGPINCS) fi dnl Use either PAM or CRYPT, not both. @@ -33,7 +33,6 @@ #include <mailutils/address.h> static int action (observer_t, size_t); -static int counter; static struct option long_options[] = { @@ -59,7 +58,6 @@ static int show_subject = 1; static int show_number; static int show_summary; static int be_quiet; -static int be_silent; static int align = 1; static int show_query; static int have_new_mail; diff --git a/mail/Makefile.am b/mail/Makefile.am index 4723ef89b..86d031294 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -2,13 +2,11 @@ AUTOMAKE_OPTIONS = ../lib/ansi2knr no-dependencies CFLAGS = -Wall -pedantic -g -INCLUDES = -I${top_srcdir}/include -I${top_srcdir}/lib +INCLUDES = -I${top_srcdir}/include -I${top_srcdir}/lib @ARGPINCS@ bin_PROGRAMS = mail -mail_DEPENDENCIES = @ARGPLIB@ ../mailbox/libmailbox.la - -mail_LDADD = @ARGPLIB@ ../mailbox/libmailbox.la ../lib/libmailutils.a +mail_LDADD = @ARGPLIBS@ ../mailbox/libmailbox.la ../lib/libmailutils.a mail_SOURCES = alias.c alt.c cd.c copy.c delete.c discard.c dp.c echo.c \ edit.c eq.c exit.c file.c folders.c followup.c from.c headers.c help.c \ diff --git a/mail/mail.c b/mail/mail.c index 07bdded67..f2ccdda9a 100644 --- a/mail/mail.c +++ b/mail/mail.c @@ -245,8 +245,10 @@ main (int argc, char **argv) else { /* Initialize readline */ +#ifdef WITH_READLINE rl_readline_name = "mail"; rl_attempted_completion_function = (CPPFunction*)util_command_completion; +#endif /* open the mailbox */ if (args.file == NULL) @@ -300,7 +302,9 @@ main (int argc, char **argv) } cmd = util_stripwhite (command); util_do_command (cmd); +#ifdef WITH_READLINE add_history (cmd); +#endif } } /* We should never reach this point */ diff --git a/mail/mail.h b/mail/mail.h index d2fec875a..0980b9e17 100644 --- a/mail/mail.h +++ b/mail/mail.h @@ -1,5 +1,5 @@ /* GNU mailutils - a suite of utilities for electronic mail - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. 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 @@ -31,11 +31,14 @@ #include <sys/types.h> #include <stdarg.h> #include <signal.h> +#include <ctype.h> #include <argp.h> +#ifdef HAVE_READLINE_READLINE_H #include <readline/readline.h> #include <readline/history.h> +#endif #include <mailutils/mailbox.h> #include <mailutils/message.h> diff --git a/mail/util.c b/mail/util.c index 8ab85577a..29a66b3ca 100644 --- a/mail/util.c +++ b/mail/util.c @@ -1,5 +1,5 @@ /* GNU mailutils - a suite of utilities for electronic mail - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. 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 @@ -96,7 +96,7 @@ util_expand_msglist (const int argc, char **argv, int **list) current = util_ll_add (current, n); } else if (!strcmp (argv[i], "-")) - { + { /* previous [un]deleted message */ int n = realcursor - 1; while (n > 0) @@ -321,56 +321,18 @@ util_find_entry (char *cmd) } /* - * readline tab completion - */ -char ** -util_command_completion (char *cmd, int start, int end) -{ - if (start == 0) - return completion_matches (cmd, util_command_generator); - return NULL; -} - -/* - * more readline - */ -char * -util_command_generator (char *text, int state) -{ - static int i, len; - char *name; - - if (!state) - { - i = 0; - len = strlen (text); - } - - while ((name = mail_command_table[i].longname)) - { - if (strlen (mail_command_table[i].shortname) > strlen(name)) - name = mail_command_table[i].shortname; - i++; - if (strncmp (name, text, len) == 0) - return (strdup(name)); - } - - return NULL; -} - -/* * removes whitespace from the beginning and end of a string */ char * util_stripwhite (char *string) { register char *s, *t; - for (s = string; whitespace (*s); s++) + for (s = string; isspace ((unsigned)*s); s++) ; if (*s == 0) return s; t = s + strlen (s) - 1; - while (t > s && whitespace (*t)) + while (t > s && isspace ((unsigned)*t)) t--; *++t = '\0'; return s; @@ -446,7 +408,7 @@ util_find_env (char *variable) } /* - * print the environment + * print the environment */ int util_printenv (int set) @@ -465,7 +427,7 @@ util_printenv (int set) return 0; } -/* +/* * return 1 if a message is deleted */ int @@ -480,3 +442,99 @@ util_isdeleted (int n) return 1; return 0; } + +/* + * readline tab completion + */ +#ifdef WITH_READLINE +char ** +util_command_completion (char *cmd, int start, int end) +{ + if (start == 0) + return completion_matches (cmd, util_command_generator); + return NULL; +} + +/* + * more readline + */ +char * +util_command_generator (char *text, int state) +{ + static int i, len; + char *name; + + if (!state) + { + i = 0; + len = strlen (text); + } + + while ((name = mail_command_table[i].longname)) + { + if (strlen (mail_command_table[i].shortname) > strlen(name)) + name = mail_command_table[i].shortname; + i++; + if (strncmp (name, text, len) == 0) + return (strdup(name)); + } + + return NULL; +} + +#else + +char * +readline (const char *prompt) +{ + char *line; + char *p; + size_t linelen, total; + + if (prompt) + { + printf ("%s",prompt); + fflush(stdout); + } + + p = line = calloc (1, 255); + linelen = 255; + total = 0; + for (;;) + { + size_t len; + p = fgets (p, linelen, stdin); + len = (p) ? strlen (p) : 0; + + total += len; + + /* Error. */ + if (total == 0) + { + free (line); + return NULL; + } + + /* Ok. */ + if (line[total - 1] == '\n') + { + line[total - 1] = '\0'; + return line; + } + else + { + char *tmp; + linelen *= 2; + tmp = realloc (line, linelen); + if (tmp == NULL) + { + free (line); + return NULL; + } + line = tmp; + p = line + total; + total += len; + } + } +} +#endif diff --git a/mailbox/Makefile.am b/mailbox/Makefile.am index d3aec7524..9de6ac328 100644 --- a/mailbox/Makefile.am +++ b/mailbox/Makefile.am @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = ../lib/ansi2knr -INCLUDES = -I${top_srcdir}/include -I${top_srcdir}/mailbox/include +INCLUDES = -I${top_srcdir}/include -I${top_srcdir}/mailbox/include \ -I${top_srcdir}/lib CFLAGS = -Wall -pedantic -g diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c index 1ecf36f5a..6fe172276 100644 --- a/pop3d/pop3d.c +++ b/pop3d/pop3d.c @@ -233,8 +233,8 @@ pop3_mainloop (int infile, int outfile) if (md5shared == NULL) pop3_abquit (ERR_NO_MEM); - snprintf (md5shared, strlen (local_hostname) + 50, "<%d.%ld@%s>", getpid (), - time (NULL), local_hostname); + snprintf (md5shared, strlen (local_hostname) + 50, "<%u.%u@%s>", getpid (), + (int)time (NULL), local_hostname); free (local_hostname); fflush (ofile); |