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 ... #&*#$^&#^)(
Showing
15 changed files
with
151 additions
and
100 deletions
1 | 2001-04-15 Alain Magloire | 1 | 2001-04-15 Alain Magloire |
2 | 2 | ||
3 | Create a argp directory, it contains the necessary | ||
4 | files to build a standalone libargp.a | ||
5 | |||
6 | * argp: New directory. | ||
7 | argp-ba.c, argp-eexst.c, argp-fmtstream.c, argp-fmtstream.h | ||
8 | argp-fs-xinl.c, argp-help.c, argp-namefrob.h, argp-parse.c | ||
9 | argp-pv.c, argp-pvh.c, argp-xinl.c, argp.h, pin.c. | ||
10 | |||
11 | * mail/mail.c: Comment out the code that use readline | ||
12 | specifics WITH_READLINE. | ||
13 | * mail/mail.h: Likewised. | ||
14 | * mail/util.c: Likewised. | ||
15 | |||
16 | 2001-04-15 Alain Magloire | ||
17 | |||
3 | * Makefile.am: Add argp in the list of subdirs. | 18 | * Makefile.am: Add argp in the list of subdirs. |
4 | * configure.am: Check for argp.h and look for | 19 | * configure.am: Check for argp.h and look for |
5 | argp_parse(). | 20 | argp_parse(). | ... | ... |
... | @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = gnu 1.4 | ... | @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = gnu 1.4 |
2 | ACLOCAL_AMFLAGS = -I m4 | 2 | ACLOCAL_AMFLAGS = -I m4 |
3 | 3 | ||
4 | # imap4d | 4 | # imap4d |
5 | SUBDIRS = include doc m4 argp lib mailbox frm from pop3d imap4d mail | 5 | SUBDIRS = include doc m4 lib argp mailbox frm from pop3d imap4d mail |
6 | 6 | ||
7 | EXTRA_DIST = mailutils.spec mailutils.spec.in README-alpha COPYING.FDL | 7 | EXTRA_DIST = mailutils.spec mailutils.spec.in README-alpha COPYING.FDL |
8 | 8 | ... | ... |
... | @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = ../lib/ansi2knr | ... | @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = ../lib/ansi2knr |
2 | 2 | ||
3 | INCLUDES = -I${top_srcdir}/lib | 3 | INCLUDES = -I${top_srcdir}/lib |
4 | 4 | ||
5 | noinst_LIBRARIES = @ARGPLIB@ | 5 | noinst_LIBRARIES = @ARGPLIBS@ |
6 | 6 | ||
7 | libargp_a_SOURCES = argp-ba.c argp-eexst.c argp-fmtstream.c argp-fs-xinl.c \ | 7 | libargp_a_SOURCES = argp-ba.c argp-eexst.c argp-fmtstream.c argp-fs-xinl.c \ |
8 | argp-help.c argp-parse.c argp-pv.c argp-pvh.c argp-xinl.c pin.c | 8 | 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 | ... | @@ -15,4 +15,4 @@ noinst_HEADERS = argp-fmtstream.h argp-namefrob.h argp.h |
15 | 15 | ||
16 | libargp_a_LIBADD = ../lib/libmailutils.a | 16 | libargp_a_LIBADD = ../lib/libmailutils.a |
17 | 17 | ||
18 | CFLAGS = -Wall -pedantic -g | 18 | CFLAGS = -Wall -g | ... | ... |
... | @@ -34,10 +34,6 @@ | ... | @@ -34,10 +34,6 @@ |
34 | #include <string.h> | 34 | #include <string.h> |
35 | #include <unistd.h> | 35 | #include <unistd.h> |
36 | 36 | ||
37 | #ifndef HAVE_PTHREAD_H | ||
38 | # define fwrite_unlocked fwrite | ||
39 | #endif | ||
40 | |||
41 | #if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \ | 37 | #if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \ |
42 | || (defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H)) | 38 | || (defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H)) |
43 | /* line_wrap_stream is available, so use that. */ | 39 | /* line_wrap_stream is available, so use that. */ | ... | ... |
... | @@ -517,7 +517,7 @@ hol_free (struct hol *hol) | ... | @@ -517,7 +517,7 @@ hol_free (struct hol *hol) |
517 | free (hol); | 517 | free (hol); |
518 | } | 518 | } |
519 | 519 | ||
520 | static inline int | 520 | static int |
521 | hol_entry_short_iterate (const struct hol_entry *entry, | 521 | hol_entry_short_iterate (const struct hol_entry *entry, |
522 | int (*func)(const struct argp_option *opt, | 522 | int (*func)(const struct argp_option *opt, |
523 | const struct argp_option *real, | 523 | const struct argp_option *real, |
... | @@ -542,7 +542,7 @@ hol_entry_short_iterate (const struct hol_entry *entry, | ... | @@ -542,7 +542,7 @@ hol_entry_short_iterate (const struct hol_entry *entry, |
542 | return val; | 542 | return val; |
543 | } | 543 | } |
544 | 544 | ||
545 | static inline int | 545 | static int |
546 | hol_entry_long_iterate (const struct hol_entry *entry, | 546 | hol_entry_long_iterate (const struct hol_entry *entry, |
547 | int (*func)(const struct argp_option *opt, | 547 | int (*func)(const struct argp_option *opt, |
548 | const struct argp_option *real, | 548 | const struct argp_option *real, |
... | @@ -566,7 +566,7 @@ hol_entry_long_iterate (const struct hol_entry *entry, | ... | @@ -566,7 +566,7 @@ hol_entry_long_iterate (const struct hol_entry *entry, |
566 | } | 566 | } |
567 | 567 | ||
568 | /* Iterator that returns true for the first short option. */ | 568 | /* Iterator that returns true for the first short option. */ |
569 | static inline int | 569 | static int |
570 | until_short (const struct argp_option *opt, const struct argp_option *real, | 570 | until_short (const struct argp_option *opt, const struct argp_option *real, |
571 | const char *domain, void *cookie) | 571 | const char *domain, void *cookie) |
572 | { | 572 | { |
... | @@ -1525,15 +1525,12 @@ _help (const struct argp *argp, const struct argp_state *state, FILE *stream, | ... | @@ -1525,15 +1525,12 @@ _help (const struct argp *argp, const struct argp_state *state, FILE *stream, |
1525 | if (! stream) | 1525 | if (! stream) |
1526 | return; | 1526 | return; |
1527 | 1527 | ||
1528 | flockfile (stream); | ||
1529 | |||
1530 | if (! uparams.valid) | 1528 | if (! uparams.valid) |
1531 | fill_in_uparams (state); | 1529 | fill_in_uparams (state); |
1532 | 1530 | ||
1533 | fs = __argp_make_fmtstream (stream, 0, uparams.rmargin, 0); | 1531 | fs = __argp_make_fmtstream (stream, 0, uparams.rmargin, 0); |
1534 | if (! fs) | 1532 | if (! fs) |
1535 | { | 1533 | { |
1536 | funlockfile (stream); | ||
1537 | return; | 1534 | return; |
1538 | } | 1535 | } |
1539 | 1536 | ||
... | @@ -1641,8 +1638,6 @@ Try `%s --help' or `%s --usage' for more information.\n"), | ... | @@ -1641,8 +1638,6 @@ Try `%s --help' or `%s --usage' for more information.\n"), |
1641 | anything = 1; | 1638 | anything = 1; |
1642 | } | 1639 | } |
1643 | 1640 | ||
1644 | funlockfile (stream); | ||
1645 | |||
1646 | if (hol) | 1641 | if (hol) |
1647 | hol_free (hol); | 1642 | hol_free (hol); |
1648 | 1643 | ||
... | @@ -1700,22 +1695,19 @@ __argp_error (const struct argp_state *state, const char *fmt, ...) | ... | @@ -1700,22 +1695,19 @@ __argp_error (const struct argp_state *state, const char *fmt, ...) |
1700 | { | 1695 | { |
1701 | va_list ap; | 1696 | va_list ap; |
1702 | 1697 | ||
1703 | flockfile (stream); | 1698 | fputs (state ? state->name : program_invocation_short_name, |
1704 | |||
1705 | fputs_unlocked (state ? state->name : program_invocation_short_name, | ||
1706 | stream); | 1699 | stream); |
1707 | putc_unlocked (':', stream); | 1700 | putc (':', stream); |
1708 | putc_unlocked (' ', stream); | 1701 | putc (' ', stream); |
1709 | 1702 | ||
1710 | va_start (ap, fmt); | 1703 | va_start (ap, fmt); |
1711 | vfprintf (stream, fmt, ap); | 1704 | vfprintf (stream, fmt, ap); |
1712 | va_end (ap); | 1705 | va_end (ap); |
1713 | 1706 | ||
1714 | putc_unlocked ('\n', stream); | 1707 | putc ('\n', stream); |
1715 | 1708 | ||
1716 | __argp_state_help (state, stream, ARGP_HELP_STD_ERR); | 1709 | __argp_state_help (state, stream, ARGP_HELP_STD_ERR); |
1717 | 1710 | ||
1718 | funlockfile (stream); | ||
1719 | } | 1711 | } |
1720 | } | 1712 | } |
1721 | } | 1713 | } |
... | @@ -1741,17 +1733,15 @@ __argp_failure (const struct argp_state *state, int status, int errnum, | ... | @@ -1741,17 +1733,15 @@ __argp_failure (const struct argp_state *state, int status, int errnum, |
1741 | 1733 | ||
1742 | if (stream) | 1734 | if (stream) |
1743 | { | 1735 | { |
1744 | flockfile (stream); | 1736 | fputs (state ? state->name : program_invocation_short_name, |
1745 | 1737 | stream); | |
1746 | fputs_unlocked (state ? state->name : program_invocation_short_name, | ||
1747 | stream); | ||
1748 | 1738 | ||
1749 | if (fmt) | 1739 | if (fmt) |
1750 | { | 1740 | { |
1751 | va_list ap; | 1741 | va_list ap; |
1752 | 1742 | ||
1753 | putc_unlocked (':', stream); | 1743 | putc (':', stream); |
1754 | putc_unlocked (' ', stream); | 1744 | putc (' ', stream); |
1755 | 1745 | ||
1756 | va_start (ap, fmt); | 1746 | va_start (ap, fmt); |
1757 | vfprintf (stream, fmt, ap); | 1747 | vfprintf (stream, fmt, ap); |
... | @@ -1760,14 +1750,12 @@ __argp_failure (const struct argp_state *state, int status, int errnum, | ... | @@ -1760,14 +1750,12 @@ __argp_failure (const struct argp_state *state, int status, int errnum, |
1760 | 1750 | ||
1761 | if (errnum) | 1751 | if (errnum) |
1762 | { | 1752 | { |
1763 | putc_unlocked (':', stream); | 1753 | putc (':', stream); |
1764 | putc_unlocked (' ', stream); | 1754 | putc (' ', stream); |
1765 | fputs (strerror (errnum), stream); | 1755 | fputs (strerror (errnum), stream); |
1766 | } | 1756 | } |
1767 | 1757 | ||
1768 | putc_unlocked ('\n', stream); | 1758 | putc ('\n', stream); |
1769 | |||
1770 | funlockfile (stream); | ||
1771 | 1759 | ||
1772 | if (status && (!state || !(state->flags & ARGP_NO_EXIT))) | 1760 | if (status && (!state || !(state->flags & ARGP_NO_EXIT))) |
1773 | exit (status); | 1761 | exit (status); | ... | ... |
... | @@ -217,12 +217,7 @@ static struct mutex getopt_lock = MUTEX_INITIALIZER; | ... | @@ -217,12 +217,7 @@ static struct mutex getopt_lock = MUTEX_INITIALIZER; |
217 | #define LOCK_GETOPT mutex_lock (&getopt_lock) | 217 | #define LOCK_GETOPT mutex_lock (&getopt_lock) |
218 | #define UNLOCK_GETOPT mutex_unlock (&getopt_lock) | 218 | #define UNLOCK_GETOPT mutex_unlock (&getopt_lock) |
219 | 219 | ||
220 | #elif defined(HAVE_PTHREAD_H) | 220 | #else /* !HAVE_CTHREADS_H */ |
221 | static struct pthread_mutex_t getopt_lock = PTHREAD_MUTEX_INITIALIZER; | ||
222 | #define LOCK_GETOPT pthread_mutex_lock (&getopt_lock) | ||
223 | #define UNLOCK_GETOPT pthread_mutex_unlock (&getopt_lock) | ||
224 | |||
225 | #else /* !HAVE_CTHREADS_H !HAVE_PTHREAD_H */ | ||
226 | 221 | ||
227 | #define LOCK_GETOPT (void)0 | 222 | #define LOCK_GETOPT (void)0 |
228 | #define UNLOCK_GETOPT (void)0 | 223 | #define UNLOCK_GETOPT (void)0 | ... | ... |
... | @@ -28,13 +28,6 @@ | ... | @@ -28,13 +28,6 @@ |
28 | #define __need_error_t | 28 | #define __need_error_t |
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | 30 | ||
31 | #ifndef HAVE_PTHREAD_H | ||
32 | #define flockfile(arg) | ||
33 | #define funlockfile(arg) | ||
34 | #define fputs_unlocked fputs | ||
35 | #define fwrite_unlocked fwrite | ||
36 | #endif | ||
37 | |||
38 | #ifndef __error_t_defined | 31 | #ifndef __error_t_defined |
39 | typedef int error_t; | 32 | typedef int error_t; |
40 | # define __error_t_defined | 33 | # define __error_t_defined | ... | ... |
... | @@ -75,7 +75,10 @@ dnl Check for libraries | ... | @@ -75,7 +75,10 @@ dnl Check for libraries |
75 | AC_CHECK_FUNCS(argp_parse) | 75 | AC_CHECK_FUNCS(argp_parse) |
76 | if test x"$ac_cv_func_argp_parse" != xyes; then | 76 | if test x"$ac_cv_func_argp_parse" != xyes; then |
77 | AC_REPLACE_FUNCS(strndup strnlen strchrnul) | 77 | AC_REPLACE_FUNCS(strndup strnlen strchrnul) |
78 | ARGPLIBS="libargp.a" | ||
79 | ARGPINCS="-I../argp" | ||
78 | AC_SUBST(ARGPLIBS) | 80 | AC_SUBST(ARGPLIBS) |
81 | AC_SUBST(ARGPINCS) | ||
79 | fi | 82 | fi |
80 | 83 | ||
81 | dnl Use either PAM or CRYPT, not both. | 84 | dnl Use either PAM or CRYPT, not both. | ... | ... |
... | @@ -33,7 +33,6 @@ | ... | @@ -33,7 +33,6 @@ |
33 | #include <mailutils/address.h> | 33 | #include <mailutils/address.h> |
34 | 34 | ||
35 | static int action (observer_t, size_t); | 35 | static int action (observer_t, size_t); |
36 | static int counter; | ||
37 | 36 | ||
38 | static struct option long_options[] = | 37 | static struct option long_options[] = |
39 | { | 38 | { |
... | @@ -59,7 +58,6 @@ static int show_subject = 1; | ... | @@ -59,7 +58,6 @@ static int show_subject = 1; |
59 | static int show_number; | 58 | static int show_number; |
60 | static int show_summary; | 59 | static int show_summary; |
61 | static int be_quiet; | 60 | static int be_quiet; |
62 | static int be_silent; | ||
63 | static int align = 1; | 61 | static int align = 1; |
64 | static int show_query; | 62 | static int show_query; |
65 | static int have_new_mail; | 63 | static int have_new_mail; | ... | ... |
... | @@ -2,13 +2,11 @@ AUTOMAKE_OPTIONS = ../lib/ansi2knr no-dependencies | ... | @@ -2,13 +2,11 @@ AUTOMAKE_OPTIONS = ../lib/ansi2knr no-dependencies |
2 | 2 | ||
3 | CFLAGS = -Wall -pedantic -g | 3 | CFLAGS = -Wall -pedantic -g |
4 | 4 | ||
5 | INCLUDES = -I${top_srcdir}/include -I${top_srcdir}/lib | 5 | INCLUDES = -I${top_srcdir}/include -I${top_srcdir}/lib @ARGPINCS@ |
6 | 6 | ||
7 | bin_PROGRAMS = mail | 7 | bin_PROGRAMS = mail |
8 | 8 | ||
9 | mail_DEPENDENCIES = @ARGPLIB@ ../mailbox/libmailbox.la | 9 | mail_LDADD = @ARGPLIBS@ ../mailbox/libmailbox.la ../lib/libmailutils.a |
10 | |||
11 | mail_LDADD = @ARGPLIB@ ../mailbox/libmailbox.la ../lib/libmailutils.a | ||
12 | 10 | ||
13 | mail_SOURCES = alias.c alt.c cd.c copy.c delete.c discard.c dp.c echo.c \ | 11 | mail_SOURCES = alias.c alt.c cd.c copy.c delete.c discard.c dp.c echo.c \ |
14 | edit.c eq.c exit.c file.c folders.c followup.c from.c headers.c help.c \ | 12 | 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) | ... | @@ -245,8 +245,10 @@ main (int argc, char **argv) |
245 | else | 245 | else |
246 | { | 246 | { |
247 | /* Initialize readline */ | 247 | /* Initialize readline */ |
248 | #ifdef WITH_READLINE | ||
248 | rl_readline_name = "mail"; | 249 | rl_readline_name = "mail"; |
249 | rl_attempted_completion_function = (CPPFunction*)util_command_completion; | 250 | rl_attempted_completion_function = (CPPFunction*)util_command_completion; |
251 | #endif | ||
250 | 252 | ||
251 | /* open the mailbox */ | 253 | /* open the mailbox */ |
252 | if (args.file == NULL) | 254 | if (args.file == NULL) |
... | @@ -300,7 +302,9 @@ main (int argc, char **argv) | ... | @@ -300,7 +302,9 @@ main (int argc, char **argv) |
300 | } | 302 | } |
301 | cmd = util_stripwhite (command); | 303 | cmd = util_stripwhite (command); |
302 | util_do_command (cmd); | 304 | util_do_command (cmd); |
305 | #ifdef WITH_READLINE | ||
303 | add_history (cmd); | 306 | add_history (cmd); |
307 | #endif | ||
304 | } | 308 | } |
305 | } | 309 | } |
306 | /* We should never reach this point */ | 310 | /* We should never reach this point */ | ... | ... |
1 | /* GNU mailutils - a suite of utilities for electronic mail | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -31,11 +31,14 @@ | ... | @@ -31,11 +31,14 @@ |
31 | #include <sys/types.h> | 31 | #include <sys/types.h> |
32 | #include <stdarg.h> | 32 | #include <stdarg.h> |
33 | #include <signal.h> | 33 | #include <signal.h> |
34 | #include <ctype.h> | ||
34 | 35 | ||
35 | #include <argp.h> | 36 | #include <argp.h> |
36 | 37 | ||
38 | #ifdef HAVE_READLINE_READLINE_H | ||
37 | #include <readline/readline.h> | 39 | #include <readline/readline.h> |
38 | #include <readline/history.h> | 40 | #include <readline/history.h> |
41 | #endif | ||
39 | 42 | ||
40 | #include <mailutils/mailbox.h> | 43 | #include <mailutils/mailbox.h> |
41 | #include <mailutils/message.h> | 44 | #include <mailutils/message.h> | ... | ... |
1 | /* GNU mailutils - a suite of utilities for electronic mail | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | 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) | ... | @@ -96,7 +96,7 @@ util_expand_msglist (const int argc, char **argv, int **list) |
96 | current = util_ll_add (current, n); | 96 | current = util_ll_add (current, n); |
97 | } | 97 | } |
98 | else if (!strcmp (argv[i], "-")) | 98 | else if (!strcmp (argv[i], "-")) |
99 | { | 99 | { |
100 | /* previous [un]deleted message */ | 100 | /* previous [un]deleted message */ |
101 | int n = realcursor - 1; | 101 | int n = realcursor - 1; |
102 | while (n > 0) | 102 | while (n > 0) |
... | @@ -321,56 +321,18 @@ util_find_entry (char *cmd) | ... | @@ -321,56 +321,18 @@ util_find_entry (char *cmd) |
321 | } | 321 | } |
322 | 322 | ||
323 | /* | 323 | /* |
324 | * readline tab completion | ||
325 | */ | ||
326 | char ** | ||
327 | util_command_completion (char *cmd, int start, int end) | ||
328 | { | ||
329 | if (start == 0) | ||
330 | return completion_matches (cmd, util_command_generator); | ||
331 | return NULL; | ||
332 | } | ||
333 | |||
334 | /* | ||
335 | * more readline | ||
336 | */ | ||
337 | char * | ||
338 | util_command_generator (char *text, int state) | ||
339 | { | ||
340 | static int i, len; | ||
341 | char *name; | ||
342 | |||
343 | if (!state) | ||
344 | { | ||
345 | i = 0; | ||
346 | len = strlen (text); | ||
347 | } | ||
348 | |||
349 | while ((name = mail_command_table[i].longname)) | ||
350 | { | ||
351 | if (strlen (mail_command_table[i].shortname) > strlen(name)) | ||
352 | name = mail_command_table[i].shortname; | ||
353 | i++; | ||
354 | if (strncmp (name, text, len) == 0) | ||
355 | return (strdup(name)); | ||
356 | } | ||
357 | |||
358 | return NULL; | ||
359 | } | ||
360 | |||
361 | /* | ||
362 | * removes whitespace from the beginning and end of a string | 324 | * removes whitespace from the beginning and end of a string |
363 | */ | 325 | */ |
364 | char * | 326 | char * |
365 | util_stripwhite (char *string) | 327 | util_stripwhite (char *string) |
366 | { | 328 | { |
367 | register char *s, *t; | 329 | register char *s, *t; |
368 | for (s = string; whitespace (*s); s++) | 330 | for (s = string; isspace ((unsigned)*s); s++) |
369 | ; | 331 | ; |
370 | if (*s == 0) | 332 | if (*s == 0) |
371 | return s; | 333 | return s; |
372 | t = s + strlen (s) - 1; | 334 | t = s + strlen (s) - 1; |
373 | while (t > s && whitespace (*t)) | 335 | while (t > s && isspace ((unsigned)*t)) |
374 | t--; | 336 | t--; |
375 | *++t = '\0'; | 337 | *++t = '\0'; |
376 | return s; | 338 | return s; |
... | @@ -446,7 +408,7 @@ util_find_env (char *variable) | ... | @@ -446,7 +408,7 @@ util_find_env (char *variable) |
446 | } | 408 | } |
447 | 409 | ||
448 | /* | 410 | /* |
449 | * print the environment | 411 | * print the environment |
450 | */ | 412 | */ |
451 | int | 413 | int |
452 | util_printenv (int set) | 414 | util_printenv (int set) |
... | @@ -465,7 +427,7 @@ util_printenv (int set) | ... | @@ -465,7 +427,7 @@ util_printenv (int set) |
465 | return 0; | 427 | return 0; |
466 | } | 428 | } |
467 | 429 | ||
468 | /* | 430 | /* |
469 | * return 1 if a message is deleted | 431 | * return 1 if a message is deleted |
470 | */ | 432 | */ |
471 | int | 433 | int |
... | @@ -480,3 +442,99 @@ util_isdeleted (int n) | ... | @@ -480,3 +442,99 @@ util_isdeleted (int n) |
480 | return 1; | 442 | return 1; |
481 | return 0; | 443 | return 0; |
482 | } | 444 | } |
445 | |||
446 | /* | ||
447 | * readline tab completion | ||
448 | */ | ||
449 | #ifdef WITH_READLINE | ||
450 | char ** | ||
451 | util_command_completion (char *cmd, int start, int end) | ||
452 | { | ||
453 | if (start == 0) | ||
454 | return completion_matches (cmd, util_command_generator); | ||
455 | return NULL; | ||
456 | } | ||
457 | |||
458 | /* | ||
459 | * more readline | ||
460 | */ | ||
461 | char * | ||
462 | util_command_generator (char *text, int state) | ||
463 | { | ||
464 | static int i, len; | ||
465 | char *name; | ||
466 | |||
467 | if (!state) | ||
468 | { | ||
469 | i = 0; | ||
470 | len = strlen (text); | ||
471 | } | ||
472 | |||
473 | while ((name = mail_command_table[i].longname)) | ||
474 | { | ||
475 | if (strlen (mail_command_table[i].shortname) > strlen(name)) | ||
476 | name = mail_command_table[i].shortname; | ||
477 | i++; | ||
478 | if (strncmp (name, text, len) == 0) | ||
479 | return (strdup(name)); | ||
480 | } | ||
481 | |||
482 | return NULL; | ||
483 | } | ||
484 | |||
485 | #else | ||
486 | |||
487 | char * | ||
488 | readline (const char *prompt) | ||
489 | { | ||
490 | char *line; | ||
491 | char *p; | ||
492 | size_t linelen, total; | ||
493 | |||
494 | if (prompt) | ||
495 | { | ||
496 | printf ("%s",prompt); | ||
497 | fflush(stdout); | ||
498 | } | ||
499 | |||
500 | p = line = calloc (1, 255); | ||
501 | linelen = 255; | ||
502 | total = 0; | ||
503 | for (;;) | ||
504 | { | ||
505 | size_t len; | ||
506 | p = fgets (p, linelen, stdin); | ||
507 | len = (p) ? strlen (p) : 0; | ||
508 | |||
509 | total += len; | ||
510 | |||
511 | /* Error. */ | ||
512 | if (total == 0) | ||
513 | { | ||
514 | free (line); | ||
515 | return NULL; | ||
516 | } | ||
517 | |||
518 | /* Ok. */ | ||
519 | if (line[total - 1] == '\n') | ||
520 | { | ||
521 | line[total - 1] = '\0'; | ||
522 | return line; | ||
523 | } | ||
524 | else | ||
525 | { | ||
526 | char *tmp; | ||
527 | linelen *= 2; | ||
528 | tmp = realloc (line, linelen); | ||
529 | if (tmp == NULL) | ||
530 | { | ||
531 | free (line); | ||
532 | return NULL; | ||
533 | } | ||
534 | line = tmp; | ||
535 | p = line + total; | ||
536 | total += len; | ||
537 | } | ||
538 | } | ||
539 | } | ||
540 | #endif | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | 2 | ||
3 | AUTOMAKE_OPTIONS = ../lib/ansi2knr | 3 | AUTOMAKE_OPTIONS = ../lib/ansi2knr |
4 | 4 | ||
5 | INCLUDES = -I${top_srcdir}/include -I${top_srcdir}/mailbox/include | 5 | INCLUDES = -I${top_srcdir}/include -I${top_srcdir}/mailbox/include \ |
6 | -I${top_srcdir}/lib | 6 | -I${top_srcdir}/lib |
7 | CFLAGS = -Wall -pedantic -g | 7 | CFLAGS = -Wall -pedantic -g |
8 | 8 | ... | ... |
... | @@ -233,8 +233,8 @@ pop3_mainloop (int infile, int outfile) | ... | @@ -233,8 +233,8 @@ pop3_mainloop (int infile, int outfile) |
233 | if (md5shared == NULL) | 233 | if (md5shared == NULL) |
234 | pop3_abquit (ERR_NO_MEM); | 234 | pop3_abquit (ERR_NO_MEM); |
235 | 235 | ||
236 | snprintf (md5shared, strlen (local_hostname) + 50, "<%d.%ld@%s>", getpid (), | 236 | snprintf (md5shared, strlen (local_hostname) + 50, "<%u.%u@%s>", getpid (), |
237 | time (NULL), local_hostname); | 237 | (int)time (NULL), local_hostname); |
238 | free (local_hostname); | 238 | free (local_hostname); |
239 | 239 | ||
240 | fflush (ofile); | 240 | fflush (ofile); | ... | ... |
-
Please register or sign in to post a comment