Commit b13877db b13877db6956665d13bf6ed1a4000ac687b13a25 by 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.


And still mail will not compile for QNX ... #&*#$^&#^)(
1 parent d1ba2067
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().
......
......@@ -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
......
......@@ -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
......
......@@ -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. */
......
......@@ -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);
......
......@@ -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
......
......@@ -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
......
......@@ -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;
......
......@@ -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 \
......
......@@ -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 */
......
/* 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>
......
/* 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
......
......@@ -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
......
......@@ -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);
......