newmail-0.5/0000755000076500007650000000000011007017502011513 5ustar joeyjoeynewmail-0.5/newmail.c0000644000076500007650000000463110721367034013331 0ustar joeyjoey/* Copyright (c) 2004,6 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include "charset.h" #include "folder.h" #include "optdefs.h" #include "version.h" void usage() { printf("%s %s -- %s\n", PROGNAME, VERSION, COPYRIGHT); printf("\n%s [options] [mailbox [mailbox [..]]]\n", PROGNAME); printf("-b Ring a bell when a new set of mails arrived\n"); printf("-i Interval between checking the mailbox(es)\n"); printf("-r Raw output, i.e. no character conversion\n"); printf("-w Run as window application in foreground\n"); } int main(int argc, char *argv[]) { int opt_flags = 0; unsigned int opt_interval = 60; int c; int tmp_i; while ((c = getopt(argc, argv, "bhi:rw")) != -1) { switch (c) { case 'b': opt_flags |= OPT_BELL; break; case 'h': usage(); return 0; case 'i': tmp_i = atoi(optarg); if (tmp_i > 0) opt_interval = tmp_i; else fprintf (stderr, "Interval not greater as zero, ignoring\n"); break; case 'r': opt_flags |= OPT_RAW; break; case 'w': opt_flags |= OPT_WINDOW; break; } } if (optind == argc) add_default_folder(); else while (optind < argc) add_folder (argv[optind++]); fix_prefix(); if (!(opt_flags & OPT_WINDOW)) { if (fork()) return 0; signal (SIGINT, SIG_IGN); signal (SIGQUIT, SIG_IGN); } set_charset(); while (1) { /* Loop over all files */ watch_folders (opt_flags); /* wait for the next incarnation */ sleep (opt_interval); /* Terminate if we lost out tty */ if (!isatty(1)) return 1; } /* Not reached */ return 0; } newmail-0.5/AUTHORS0000644000076500007650000000004110150323161012555 0ustar joeyjoeyJoey Schulze newmail-0.5/output.h0000644000076500007650000000152710150410767013241 0ustar joeyjoey/* Copyright (c) 2004 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void emit(char *prefix, char *realname, char *subject, int priority, int opt_flags); newmail-0.5/optdefs.h0000644000076500007650000000150610150401766013341 0ustar joeyjoey/* Copyright (c) 2004 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define OPT_BELL 0x01 #define OPT_WINDOW 0x02 #define OPT_RAW 0x04 newmail-0.5/folder.h0000644000076500007650000000156310150402001013132 0ustar joeyjoey/* Copyright (c) 2004 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void add_folder(char *path); void add_default_folder(); void fix_prefix(); void watch_folders(int opt_flags); newmail-0.5/mbox.h0000644000076500007650000000151210150402051012623 0ustar joeyjoey/* Copyright (c) 2004 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ off_t watch_mbox(char *path, char *prefix, off_t *size, int opt_flags); newmail-0.5/coding-style.txt0000644000076500007650000000104410156322540014661 0ustar joeyjoey 1. Delimit multiple parameters with comma and space (i.e. (foo, bar) instead of (foo,bar) 2. In terms delimit the list of parameters from the function name with a single space (i.e. func (foo) instead of func(foo)) 3. Don't use a space between a function name and an empty argument list. 4. In expressions leave out that space 5. In short expressions feel free to leave out the spaces 6. In longer and more complicated expressions spaces should be used between operands 7. Lines should not be longer than 79 characters newmail-0.5/rfc2047.c0000644000076500007650000001574111007016664012766 0ustar joeyjoey/* Copyright (c) 2006-8 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include "charset.h" /* * Index_hex and Index_64 imported from Mutt:handler.c * decode_quotedprintable() and decode_base64() as well */ int Index_hex[128] = { -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1, -1,-1,-1,-1, -1,10,11,12, 13,14,15,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,10,11,12, 13,14,15,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1 }; int Index_64[128] = { -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63, 52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14, 15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1, -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40, 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1 }; #define hexval(c) Index_hex[(unsigned int)(c)] #define base64val(c) Index_64[(unsigned int)(c)] /* * Decode a string from quoted printable */ char *decode_quotedprintable(char *buf) { char *inp, *outp; char *endp; endp = buf+strlen(buf); for (inp = outp = buf; inp < endp; inp++) { if (*inp == '_') *(outp++) = ' '; else if (*inp == '=' && inp+2 < endp && (!(*(inp+1) & ~127) && hexval(*(inp+1)) != -1) && (!(*(inp+2) & ~127) && hexval(*(inp+2)) != -1)) { *(outp++) = (hexval(*(inp+1)) << 4) | hexval(*(inp+2)); inp += 2; } else *(outp++) = *inp; } *outp = '\0'; return buf; } /* * Decode a string from base43 */ char *decode_base64(char *buf) { char *inp, *outp; char *endp; int c, b = 0, k = 0; endp = buf+strlen(buf); for (inp = outp = buf; inp < endp; inp++) { if (*inp == '=') break; if ((*inp & ~127) || (c = base64val(*inp)) == -1) continue; if (k + 6 >= 8) { k -= 2; *(outp++) = b | (c >> k); b = c << (8 - k); } else { b |= c << (k + 2); k += 6; } *outp = '\0'; } return buf; } /* * converts a header line into the current character set if required */ char *convert_header(char *buf) { char *charset; int encoding; char *inp, *outp, *encstart, *wordp, *encp, *endp; char *decode; char *output; size_t size; size_t outlen; endp = buf+strlen(buf); inp = buf; outlen = strlen(buf)+1; if ((output = (char *)malloc(outlen)) == NULL) { perror ("malloc"); return buf; } memset(output, 0, outlen); outp = output; while ((encstart = strstr (inp, "=?"))) { if (encstart != inp) { // -1 nur falls vorher kein encoded-word memcpy (outp, inp, encstart-inp); outp += encstart-inp; } charset = encstart+2; if ((encp = strchr (charset, '?')) == NULL) { memcpy (outp, inp, strlen(inp)+1); break; } *encp = '\0'; if ((encp + 3 >= endp) || !strchr ("BbQq", *encp) || (*(encp+2) != '?')) { *encp = '?'; memcpy (outp, inp, strlen(inp)+1); outp += strlen(inp)+1; inp += strlen(inp)+1; break; } encoding = toupper(*(encp+1)); inp = encp + 3; if ((wordp = strstr (inp, "?=")) == NULL) { memcpy (outp, inp, strlen(inp)+1); outp += strlen(inp)+1; inp += strlen(inp)+1; break; } *wordp = '\0'; wordp += 2; /* Look for next =?, spaces will be eaten between two encoded-words */ if (*wordp && *wordp == ' ' && *(wordp+1) && *(wordp+1) == '=' && *(wordp+2) && *(wordp+2) == '?') wordp++; switch (encoding) { case 'B': decode = decode_base64 (inp); break; case 'Q': decode = decode_quotedprintable (inp); break; default: decode = inp; break; } size = outlen - strlen(output); decode = convert_word (charset, decode, outp, size); outp += strlen(decode); inp = wordp; } if (strlen(inp)) memcpy (outp, inp, strlen(inp)+1); memcpy (buf, output, strlen(output)+1); free (output); return buf; } /* * Needs to be called with LANG=de_DE.ISO-8859-1 #include void test_rfc2047() { char *qp; char *b64; char *subject; set_charset(); qp = strdup ("f=FCr"); printf ("\t%s -> ", qp); b64 = decode_quotedprintable (qp); printf ("%s\n", qp); if (!strcmp (qp, "für")) printf ("rfc2047.c: decode_quotedprintable() passed\n"); else printf ("rfc2047.c: decode_quotedprintable() failed\n"); free (qp); qp = strdup ("f=FCr_Umlaute_=EFm_Sub"); printf ("\t%s -> ", qp); b64 = decode_quotedprintable (qp); printf ("%s\n", qp); if (!strcmp (qp, "für Umlaute ïm Sub")) printf ("rfc2047.c: decode_quotedprintable() passed\n"); else printf ("rfc2047.c: decode_quotedprintable() failed\n"); free (qp); b64 = strdup ("ZvxyINxtbOT8dOs="); printf ("\t%s -> ", b64); b64 = decode_base64 (b64); printf ("%s\n", b64); if (!strcmp (b64, "für Ümläütë")) printf ("rfc2047.c: decode_base64() passed\n"); else printf ("rfc2047.c: decode_base64() failed\n"); free (b64); subject = strdup ("Vorschlag =?ISO-8859-1?Q?f=FCr?= ein Eintrittskonzept"); printf ("\t%s\n", subject); subject = convert_header (subject); printf ("\t%s\n", subject); if (!strcmp (subject, "Vorschlag für ein Eintrittskonzept")) printf ("rfc2047.c: convert_header() passed\n"); else printf ("rfc2047.c: convert_header() failed\n"); free (subject); subject = strdup ("=?utf-8?q?Google=3A_Chat_f=C3=BCr_die_Ewigkeit?="); printf ("\t%s\n", subject); subject = convert_header (subject); printf ("\t%s\n", subject); if (!strcmp (subject, "Google: Chat für die Ewigkeit")) printf ("rfc2047.c: convert_header() passed\n"); else printf ("rfc2047.c: convert_header() failed\n"); free (subject); subject = strdup ("=?iso-8859-1?B?ZvxyINxtbOT8dOs=?= testen"); printf ("\t%s\n", subject); subject = convert_header (subject); printf ("\t%s\n", subject); if (!strcmp (subject, "für Ümläütë testen")) printf ("rfc2047.c: convert_header() passed\n"); else printf ("rfc2047.c: convert_header() failed\n"); free (subject); } */ newmail-0.5/version.h0000644000076500007650000000160711007016540013356 0ustar joeyjoey/* Copyright (c) 2004,8 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define PROGNAME "newmail" #define VERSION "0.5" #define COPYRIGHT "(c) Copyright 2004-2008, Joey Schulze " newmail-0.5/README0000644000076500007650000000560110526133121012376 0ustar joeyjoeynemail is a small program that puts itself in the background and watches mailboxes in order to report when new mail has been arrived. This will be reported on the terminal it was started. The output can also be integrated in graphical programs. This package was inspired by the Elm component newmail. The Elm Mail System was a great mail program until Michael Elkins started writing Mutt which quickly became faster, more flexible and easier to use. However, there has been no replacement for the ``newmail'' program which is subject of this package. Due to the Elm license which is not compatible with the GNU General Public License (GPL) it was not possible to combine the old code with code licensed under the GNU GPL. As a result this project had to be started from scratch. Many thanks go to the Elm Development Group who have provided me with a great mail program for several years. Many thanks to Dave Taylor who started the program back in 1986 and has even moved away from programming altogether. Installation ------------ On a GNU/Linux system running 'make' as user and 'make install' as root is sufficient. If you don't want to install the program in /usr install it with 'make prefix=/usr/local install'. On other systems you may have to tweak the code a little bit since some include files may not be present on these systems. Feel free to contact the author with details. Automake (and thus configure) is not used intentionally. More Information ---------------- I have set up a couple of web pages describing the newmail package and will publish additional information that may be useful to newmail users. Please check out: There is a mailing list set up on lists.infodrom.org that deals with development and discussions of the newmail utility. If you have questions or suggestions please subscribe to the list and post there. The source code for this package is also available through anonymous CVS at :pserver:anonymous@cvs.infodrom.org:/var/cvs/infodrom using the module newmail. Accessing this is described in detail at the web pages mentioned above. Please don't contact me personally if you don't have confidential questions or information. Please use the mailing list from above instead. Using the mailing list has a couple of advantages. Your question and comments are archived publically and properly so they can be used later as well. As another bonus somebody else than me could answer a question, hence not incrementing my workload and it's more difficult to forget about it. The submission address for the mailing list is: infodrom-newmail@lists.infodrom.org To subscribe, send a mail to majordomo@lists.infodrom.org with the body "subscribe infodrom-newmail" -- or send a mail to SmartList at infodrom-newmail-request@lists.infodrom.org with the subject "subscribe". Good luck! Enjoy the software! Joey Schulze joey@infodrom.org newmail-0.5/output.c0000644000076500007650000000400310372331022013214 0ustar joeyjoey/* Copyright (c) 2004 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* From Elm 2.4pl25ME+43: The output format is either: newmail: >> New mail from - >> Priority mail from - >> : from - >> : Priority from - newmail -w: - Priority: - : - : Priority: - */ #include #include "rfc2047.h" #include "optdefs.h" #define MAIL_FROM "Mail from" #define PRIO_FROM "Priority mail from" #define PRIO_WIN "Priority" void emit(char *prefix, char *realname, char *subject, int priority, int opt_flags) { if (!(opt_flags & OPT_RAW)) { realname = convert_header (realname); subject = convert_header (subject); } if (opt_flags & OPT_WINDOW) { if (prefix != NULL) printf ("%s: ", prefix); if (priority) printf ("%s: ", PRIO_WIN); printf ("%s - %s\n", realname, subject); } else { printf ("\r>> "); if (prefix != NULL) printf ("%s: ", prefix); if (priority) printf ("%s %s - %s\n", PRIO_FROM, realname, subject); else printf ("%s %s - %s\n", MAIL_FROM, realname, subject); } } newmail-0.5/folder.c0000644000076500007650000000750211007016614013141 0ustar joeyjoey/* Copyright (c) 2004,7 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #include #include #include #ifdef linux #include #else #define _PATH_MAILDIR "/var/spool/mail" #endif #include "mbox.h" #include "optdefs.h" #define FOLDERS_DELTA 5 struct folder { char *path; char *prefix; off_t size; }; struct folder **folders = NULL; unsigned int numfolders = 0; unsigned int maxfolders = 0; void add_folder(char *path) { struct folder *thisfolder; struct stat st; char *cp; int sh; if (numfolders == maxfolders) { if ((folders = (struct folder **) realloc(folders, (maxfolders + FOLDERS_DELTA) * sizeof(struct folder *))) == NULL) { perror("realloc"); exit(1); } maxfolders += FOLDERS_DELTA; } if ((thisfolder = (struct folder *)malloc(sizeof(struct folder))) == NULL) { perror ("malloc"); exit (1); } if ((cp = index(path, '=')) != NULL) { *cp++ = '\0'; if ((thisfolder->prefix = (char *)strdup(cp)) == NULL) { perror ("strdup"); exit (1); } strcpy(thisfolder->prefix, cp); } else { if (numfolders > 0) { /* More than one mailbox to monitor --> need prefix anyway */ if ((cp = rindex(path, '/')) != NULL) { cp++; if ((thisfolder->prefix = (char *)strdup(cp)) == NULL) { perror ("strdup"); exit (1); } } else { if ((thisfolder->prefix = (char *)strdup(path)) == NULL) { perror ("strdup"); exit (1); } } } else thisfolder->prefix = NULL; } if ((thisfolder->path = (char *)strdup(path)) == NULL) { perror ("strdup"); exit (1); } sh = stat(path, &st); if (sh == 0) { thisfolder->size = st.st_size; } else if (sh == -1 && errno == ENOENT) { thisfolder->size = 0; } else { free (thisfolder->path); free (thisfolder); return; } folders[numfolders++] = thisfolder; } void add_default_folder() { char path[128]; char *env; uid_t uid; struct passwd *pw; if ((env = getenv("MAIL")) == NULL) { uid = getuid(); if ((pw = getpwuid(uid)) == NULL) { perror ("getpwuid"); exit (1); } snprintf (path, sizeof(path), "%s/%s", _PATH_MAILDIR, pw->pw_name); } else { snprintf (path, sizeof(path), env); } add_folder(path); } void fix_prefix() { char *cp; if (numfolders < 2) return; if (folders[0]->prefix != NULL) return; if ((cp = rindex(folders[0]->path, '/')) != NULL) { cp++; if ((folders[0]->prefix = (char *)strdup(cp)) == NULL) { perror ("strdup"); exit (1); } } else { if ((folders[0]->prefix = (char *)strdup(folders[0]->path)) == NULL) { perror ("strdup"); exit (1); } } } void watch_folders(int opt_flags) { unsigned int i; int newmail = 0; for (i=0; i < numfolders; i++) newmail |= watch_mbox(folders[i]->path, folders[i]->prefix, &folders[i]->size, opt_flags); if (newmail) { if (!(opt_flags & OPT_WINDOW)) { if (opt_flags & OPT_BELL) putchar ('\007'); putchar ('\n'); } fflush (stdout); } } newmail-0.5/newmail.10000644000076500007650000001027610372331713013246 0ustar joeyjoey.\" Copyright (c) 2004,6 Joey Schulze .\" .\" 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, write to the Free Software .\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. .\" .TH NEWMAIL 1 "February 8th, 2006" "Infodrom Oldenburg" "Mail Utilities" .SH NAME newmail \- biff like tool for the terminal .SH SYNOPSIS .B newmail .RB [ \-b ] .RB [ \-h ] .RB [ "\-i \fIinterval\fB" ] .RB [ \-r ] .RB [ \-w ] .RI [ " mbox " [...]] .SH DESCRIPTION The newmail program monitors a given set of mailboxes and looks for new mail. If new mail is received the sender and subject will be written on the terminal it was started from. By default .B newmail puts itself in the background so the console is still usable. .B newmail is able to monitor arbitrary numbers of mailbox files. If no mailbox was specified on the commandline it will monitor the default mailbox, which may be overwritten by the .B MAIL environment variable. If more than one mailbox is being monitored, a prefix is printed for each mail line so the user can distinguish between the different mailbox files. By default the prefix is the name of the mailbox without its path. If a mailbox is specified as .IR path = string then .I string will be used as prefix for mails received in the mailbox denoted by .IR path . .B newmail is able to decode header lines when non-ascii characters are transported. They will be displayed properly if the locale .RB ( LC_CTYPE ) is set accordingly. .SH OPTIONS .TP .B \-b Ring a bell after one or more incoming mails have been detected for at least one mailbox. .TP .B \-h Print a help message. .TP .BI \-i " interval" Set the interval between two mailbox checks to .IR interval " seconds." The default is 60 seconds which is suffient for the terminal. For the use inside of a window or dock application a lower value may be prudent. .TP .B \-r Emit raw data from the mail. This will bypass routines to decode character encodings used for mail headers as described in RFC 2047. This may be useful for window applications that want to decode the strings on their own. .TP .B \-w Run as window application. This will prevent .B newmail from moving itself into the background so its output can be used as input for a window application. This will also change the output format slightly and prevent a bell to be rung after new mail has been received. .SH "OUTPUT FORMAT" The output format differs from being read by humans and programs .RB ( \-w ). newmail: >> Mail from - >> Priority mail from - >> : Mail from - >> : Priority mail from - newmail -w: - Priority: - : - : Priority: - It should be easy for third party programs which are interested in such information to parse the output when .B newmail is running with the .B \-w option. .SH ENVIRONMENT .B newmail supports the following environment variables: .TP LANG Locale setting for the output character set. .TP LC_CTYPE Locale setting only for the output character set. .TP MAIL Full path of the user's spool mailbox. .SH NOTES This program is inspired by the .B newmail program from the Elm interactive mail program. It is a rewrite from scratch though. Many thanks go to Dave Taylor and the Elm Development Group who have provided me with a great mail program for several years. Many additional thanks go to the former lead developer Dave Taylor who started the program back in 1986. .SH "SEE ALSO" .BR locale (7). .SH AUTHOR Joey Schulze newmail-0.5/charset.c0000644000076500007650000000504711003113127013312 0ustar joeyjoey/* Copyright (c) 2006,8 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include char *charset = NULL; /* * Determine the output character set */ void set_charset() { setlocale (LC_CTYPE, ""); charset = strdup (nl_langinfo(CODESET)); } /* * Convert a word from an arbitrary charset into the output character set * * No conversion is performed when both charsets are equal */ char *convert_word(const char *encoding, char *inbuf, char *outbuf, size_t outbytesleft) { iconv_t cd; char *inptr, *outptr; size_t inbytesleft; size_t nconv; size_t outsize; if (!charset || !strcasecmp (encoding, charset)) { memmove (outbuf, inbuf, strlen(inbuf)= 0 && outbytesleft > 1) { outbuf[outsize-outbytesleft] = '?'; outbuf[outsize-outbytesleft+1] = '\0'; outbytesleft--; inbytesleft--; outptr++; inptr++; } else break; } iconv_close(cd); if (nconv == -1 && outsize-outbytesleft >= 0) outbuf[outsize-outbytesleft] = '\0'; return outbuf; } /* * Needs to be called with LANG=de_DE.ISO-8859-1 void test_charset() { char outbuf[100]; size_t size = 99; memset (outbuf, 0, sizeof (outbuf)); printf ("%s\n", convert_word ("UTF-8", "für ein", outbuf, size)); printf ("%s\n", outbuf); if (!strcmp(outbuf, "für ein")) printf ("charset.c: test passed\n"); else printf ("charset.c: test failed\n"); } */ newmail-0.5/mbox.c0000644000076500007650000001651311003122513012625 0ustar joeyjoey/* Copyright (c) 2004,8 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #include #include #include "output.h" /* #define FROM_DETECTION */ #define HDR_LEN 1024 struct mail { char from[HDR_LEN]; char subject[HDR_LEN]; int priority; off_t size; }; #define TAB 0x09 #define LWSP 0x20 /* * Like strncpy() but with terminated result. */ char *stringcopy(char *dest, const char *src, size_t n) { strncpy (dest, src, n-1); dest[n-1] = '\0'; return dest; } /* * Strips balanced quotes in the middle of the realname */ char *strip_quotes(char *name) { static char realname[HDR_LEN]; char *cpl, *cpr; char *cp, *xp; if ((cpl = index(name, '"')) != NULL && (cpr = index(cpl+1, '"')) != NULL) { for (cp=name,xp=realname; *cp && xp < realname+sizeof(realname)-1; cp++) { if (cp != cpl && cp != cpr) *xp++ = *cp; } *xp = '\0'; return realname; } else return name; } /* * Extract the realname from a mail address * * From: "Log Kristian Koehntopp" * From: "Jérôme" ATHIAS * From: frank@kuesterei.ch (=?iso-8859-1?q?Frank_K=FCster?=) * From: root@luonnotar.infodrom.org (Cron Daemon) * From: * From: root@luonnotar.infodrom.org */ char *realname(char *from) { static char name[HDR_LEN]; char *cpl, *cpr; name[0] = '\0'; /* From: REALNAME */ if ((cpr = index(from, '<')) != NULL && index(from, '>') != NULL) { if (cpr > from) cpr--; /* Strip trailing spaces */ while (cpr > from && isspace(*cpr)) cpr--; /* Strip leading spaces */ cpl=from;while (*cpl && isspace(*cpl)) cpl++; /* Strip balanced surrounding quotes */ if (*cpl == '"' && *cpr == '"') { cpl++;cpr--; } if (cpr > cpl) { stringcopy (name, cpl, sizeof(name) < cpr-cpl+2?sizeof(name):cpr-cpl+2); if (index(name, '"') != NULL) stringcopy (name, strip_quotes(name), sizeof(name)); } else { /* Apparently no realname included */ cpl = index(from, '<'); cpr = index(from, '>'); stringcopy (name, cpl+1, sizeof(name) < cpr-cpl?sizeof(name):cpr-cpl); } /* From: login@host.domain (REALNAME) */ } else if ((cpl = index(from, '(')) != NULL && (cpr = index(from, ')')) != NULL) { stringcopy (name, cpl+1, sizeof(name) < cpr-cpl?sizeof(name):cpr-cpl); /* From: login@host.domain */ } else { /* Strip leading spaces */ cpl=from;while (*cpl && isspace(*cpl)) cpl++; for (cpr=cpl; *cpr && !isspace(*cpr); cpr++); stringcopy (name, cpl, sizeof(name) < cpr-cpl+1?sizeof(name):cpr-cpl+1); } return name; } /* * Tries to extract useful content from the From_ line */ char *reduce_from_(char *from_) { static char name[HDR_LEN]; char *cpl, *cpr; for (cpl=from_; *cpl && isspace(*cpl); cpl++); for (cpr=cpl; *cpr && !isspace(*cpr); cpr++); if (cpr > cpl) stringcopy (name, cpl, sizeof(name) < cpr-cpl+1?sizeof(name):cpr-cpl+1); return name; } int inspect_mbox(char *path, char *prefix, off_t size, int opt_flags) { FILE *f; char buf[HDR_LEN]; char tmp[512]; char *cp; int inheader = 1; int readnewline = 0; int newmail = 0; int lookahead; char from_[HDR_LEN] = ""; char from[HDR_LEN] = ""; char realfrom[HDR_LEN] = ""; #ifdef FROM_DETECTION char to[HDR_LEN] = ""; #endif char subject[HDR_LEN] = ""; int priority = 0; if ((f = fopen(path, "r")) == NULL) return 0; if (size > 0 && fseek(f, size, SEEK_SET) != 0) return 0; while (!feof(f)) { if ((cp = fgets(buf, sizeof(buf), f)) == NULL) continue; if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n') { buf[strlen(buf)-1] = '\0'; if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = '\0'; if (inheader && !feof(f)) { while ((lookahead=fgetc(f)) == TAB || lookahead == LWSP) { if (buf[strlen(buf)-1] != LWSP) strncat (buf, " ", sizeof(buf)-strlen(buf)-1); if ((cp = fgets(tmp, sizeof(tmp), f)) != NULL) { strncat (buf, tmp, sizeof(buf)-strlen(buf)-1); if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = '\0'; if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = '\0'; if (strlen(tmp) > 0 && buf[strlen(tmp)-1] == '\n') { /* Read the remainder */ while (!feof(f) && fgets(tmp, sizeof(tmp), f) != NULL) { if (strlen(tmp) > 0 && tmp[strlen(tmp)-1] == '\n') break; } } } } /* Rewind by one character for next read */ if (lookahead != EOF) fseek(f, -1, SEEK_CUR); } } else { /* Read the remainder */ while (!feof(f) && fgets(tmp, sizeof(tmp), f) != NULL) { if (strlen(tmp) > 0 && tmp[strlen(tmp)-1] == '\n') break; } } if (inheader) { if (strlen(buf) == 0) { inheader = 0; if (strlen(from)) stringcopy (realfrom, realname(from), sizeof(realfrom)); else if (strlen(from_)) stringcopy (realfrom, reduce_from_(from_), sizeof(realfrom)); else realfrom[0] = '\0'; if (realfrom[0] != '\0' || subject[0] != '\0') { emit (prefix, realfrom, subject, priority, opt_flags); newmail = 1; } #ifdef FROM_DETECTION from_[0] = from[0] = to[0] = subject[0] = '\0'; #else from_[0] = from[0] = subject[0] = '\0'; #endif priority = 0; } else { if (strncasecmp(buf, "From ", 5) == 0) stringcopy (from_, buf+5, sizeof(from_)); else if (strncasecmp(buf, "From: ", 6) == 0) stringcopy (from, buf+6, sizeof(from)); #ifdef FROM_DETECTION else if (strncasecmp(buf, "To: ", 4) == 0) stringcopy (to, buf+4, sizeof(to)); #endif else if (strncasecmp(buf, "Subject: ", 9) == 0) stringcopy (subject, buf+9, sizeof(subject)); else if (strncasecmp(buf, "Priority: urgent", 16) == 0 && buf[16] == '\0') priority = 1; else if (strncasecmp(buf, "X-Priority: 1", 13) == 0 && buf[13] == '\0') priority = 1; } } else if (strlen(buf) == 0) { readnewline = 1; } else if (readnewline && strncasecmp(buf, "From ", 5) == 0) { inheader = 1; readnewline = 0; stringcopy (from_, buf+5, sizeof(from_)); } else readnewline = 0; } fclose(f); return newmail; } int watch_mbox(char *path, char *prefix, off_t *size, int opt_flags) { struct stat st; struct utimbuf timbuf; int newmail = 0; if (stat(path, &st) == 0) { if (st.st_size > *size) if (access(path, R_OK) == 0) { timbuf.actime = st.st_atime; timbuf.modtime = st.st_mtime; newmail = inspect_mbox(path, prefix, *size, opt_flags); utime(path, &timbuf); } *size = st.st_size; return newmail; } else { *size = 0; } return 0; } newmail-0.5/rfc2047.h0000644000076500007650000000144310372330764012771 0ustar joeyjoey/* Copyright (c) 2006 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ char *convert_header(char *buf); newmail-0.5/COPYING0000644000076500007650000004311010150323161012544 0ustar joeyjoey GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. newmail-0.5/charset.h0000644000076500007650000000161010372330736013326 0ustar joeyjoey/* Copyright (c) 2006 Joey Schulze 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ extern char *charset; void set_charset(); char *convert_word(const char *encoding, char *inbuf, char *outbuf, size_t outbytesleft); newmail-0.5/Makefile0000644000076500007650000000213311007016547013162 0ustar joeyjoey# Copyright (c) 2004,6 Joey Schulze # # 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, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. prefix = /usr SOURCE = $(wildcard *.c) OBJS = $(SOURCE:%.c=%.o) # DEFINES = -DDEBUG CFLAGS = -O2 -Wall $(DEFINES) # CFLAGS = -g -Wall $(DEFINES) newmail: $(OBJS) clean: rm -f newmail $(OBJS) *~ install: newmail install -s -o root -g root -m 755 newmail $(prefix)/bin install -o root -g root -m 644 newmail.1 $(prefix)/share/man/man1