mailcheck-1.91.2/0000755000175000017500000000000010572770074012547 5ustar kevinkevinmailcheck-1.91.2/Makefile0000644000175000017500000000057210557206554014213 0ustar kevinkevinall: mailcheck debug: mailcheck.c netrc.c netrc.h socket.c $(CC) -Wall -O0 mailcheck.c netrc.c socket.c -g -o mailcheck mailcheck: mailcheck.c netrc.c netrc.h socket.c $(CC) -Wall -O2 mailcheck.c netrc.c socket.c -s -o mailcheck install: mailcheck install mailcheck $(prefix)/usr/bin install -m 644 mailcheckrc $(prefix)/etc distclean: clean clean: rm -f mailcheck *~ mailcheck-1.91.2/mailcheck.10000644000175000017500000000707710557206555014565 0ustar kevinkevin.TH MAILCHECK 1 .SH NAME mailcheck \- Check multiple mailboxes and/or Maildirs for mail .SH SYNOPSIS .B mailcheck .I "[-l]" .SH "DESCRIPTION" .B mailcheck is a simple, configurable tool that allows multiple mailboxes to be checked for the existence of mail. For local mail, it supports both the traditional mbox format and the newer Maildir (qmail) format. Mail can also be checked for on remote servers using either the POP3 or IMAP protocol. .PP Typically, one would invoke .BR mailcheck in /etc/profile or a user-specific login script. E-mail junkies may also find it useful to invoke .BR mailcheck occasionally to check for new mail in alternate mailboxes. .PP The author uses .BR mailcheck to keep track of messages arriving in mailboxes corresponding to several mailing lists he subscribes to. .SH OPTIONS .TP .B \-l Runs .B mailcheck in login mode. If a .B ~/.hushlogin file exists, mailcheck will exit silently. This option is intended to be used on systems that invoke mailcheck from a global login script such as .B /etc/profile. .SH CONFIGURATION .PP Configuring .B mailcheck is simple. Upon startup, .B mailcheck looks for a file called .B .mailcheckrc in the user's home directory. If that file does not exist, the default configuration file .B /etc/mailcheckrc is used instead. .PP Lines beginning with a hash sign ( .B # ) are treated as comments and will not be processed. Lines beginning with .B pop3: or .B imap: are parsed like URLs and used to connect to network mail servers. All other lines are treated as pathnames to mailbox files or Maildir directories. .PP Environment variables in the format .B $(NAME) will be expanded inline. For example: .TP .B /var/spool/mail/$(USER) Will check the user's mailbox in .B /var/spool/mail. .TP .B $(HOME)/Mailbox Will check the default Maildir used by qmail installations. .PP When connecting to POP3 or IMAP servers, the account password is not stored in the mailcheckrc file. Instead, the .B .netrc file in the user's home directory is used. This file, originally intended for use with .IR ftp (1) and later used by .IR fetchmail (1), should be readable only by the user owning it. It stores server/user/password combinations in the form: machine .I servername login .I username password .I password .SH FILES .TP .B /etc/mailcheckrc This is the site-default mailcheck configuration file. It should be edited by the system administrator to meet the needs of most users on the system. .TP .B ~/.mailcheckrc This is the user-specific mailcheck configuration file. If it exists for a particular user, the site-default configuration file will not be used. .TP .B ~/.netrc This tells .B mailcheck what password to use for a given server/user combination when checking POP3 or IMAP mail. .SH COPYRIGHT Copyright (C) 1996, 1997, 1998, 2001, Jefferson E. Noxon. .PP Portions Copyright (C) 1996, Free Software Foundation, Inc. .PP Portions Copyright (C) 1996, Gordon Matzigkeit. .PP Portions Copyright (C) 1998, Trent Piepho. .PP Other copyrights may apply. .PP 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. .PP On Debian GNU/Linux see /usr/doc/copyright/GPL .SH AUTHOR Mailcheck was written for Debian GNU/Linux by Jefferson E. Noxon . .SH ACKNOWLEDGEMENTS POP3 and IMAP support was added by Rob Funk . .SH BUGS It is probably not a good idea to store passwords in a .netrc file. .SH SEE ALSO biff(1), mail(1), fetchmail(1), netrc(5), ftp(1) mailcheck-1.91.2/mailcheck.c0000644000175000017500000002546310557207011014632 0ustar kevinkevin/* mailcheck.c * * Copyright 1996, 1997, 1998, 2001 Jefferson E. Noxon * * This file may be copied under the terms of the GNU Public License * version 2, incorporated herein by reference. */ /* Command line parameters: * -l: login mode; program exits quietly if ~/.hushlogin exists. */ #include #include #include #include #include #include #include #include #include #include #include #include #include "netrc.h" extern int sock_connect (char *hostname, int port); /* Global variables */ char *Homedir; /* Home directory pathname */ int Login_mode; /* TRUE if the '-l' switch is set */ #define BUF_SIZE (2048) /* Open an rc file. Return NULL if we can't find one. */ FILE * open_rcfile (void) { char namebuf[256]; snprintf (namebuf, sizeof (namebuf), "%s/.mailcheckrc", Homedir); if (!access (namebuf, R_OK)) return fopen (namebuf, "r"); return fopen ("/etc/mailcheckrc", "r"); } /* Expand environment variables. Input buffer must be long enough * to hold output. Nested $()'s don't work. */ char * expand_envstr (char *path) { char *srcptr, *envptr, *tmpptr, *dup, *envname; int len; srcptr = strstr (path, "$("); if (!srcptr) return path; len = strlen (path); if (!len) return path; dup = malloc (len + 1); if (!dup) return path; strcpy (dup, path); envptr = strstr (dup, "$(") + 2; tmpptr = strchr (envptr, ')'); if (!tmpptr) { free (dup); return path; } *tmpptr = 0; *srcptr = 0; envname = getenv (envptr); if (envname) strcat (srcptr, envname); strcat (srcptr, tmpptr + 1); free (dup); return expand_envstr (path); } int count_entries (char *path) { DIR *mdir; struct dirent *entry; int count = 0; mdir = opendir (path); if (!mdir) return -1; while ((entry = readdir (mdir))) ++count; return count - 2; } char * getpw (char *host, char *account) { char file[256]; struct stat sb; netrc_entry *head, *a; snprintf (file, sizeof (file), "%s/.netrc", Homedir); if (stat (file, &sb)) return 0; if (sb.st_mode & 077) { static int issued_warning = 0; if (!issued_warning++) fprintf (stderr, "mailcheck: WARNING! %s may be readable by other users.\n" "mailcheck: Type \"chmod 0600 %s\" to correct the permissions.\n", file, file); } head = parse_netrc (file); if (!head) { static int issued_warning = 0; if (!issued_warning++) fprintf (stderr, "mailcheck: WARNING! %s could not be read.\n", file); return 0; } if (host && account) { a = search_netrc (head, host, account); if (a && a->password) return (a->password); } return 0; } /* returns port number, or zero on error */ /* returns hostname, box, user, and pass through pointers */ int getnetinfo (const char *path, char *hostname, char *box, char *user, char *pass) { char buf[BUF_SIZE]; int port = 0; char *p, *q, *h, *proto; strncpy (buf, path, BUF_SIZE - 1); /* first separate "protocol:" part */ p = strchr (buf, ':'); if (!p) return (0); *p = '\0'; proto = buf; h = p + 1; if (!strcmp (proto, "pop3")) port = 110; else if (!strcmp (proto, "imap")) port = 143; /* handle "pop3://hostname" form */ while (*h == '/') h++; /* change "hostname/" or "hostname/something" to "hostname" */ p = strchr (h, '/'); if (p) { *p = '\0'; p++; if (*p != '\0') strncpy (box, p, BUF_SIZE - 1); else strcpy (box, "INBOX"); } else strcpy (box, "INBOX"); /* determine username -- look for user@hostname, else use USER */ p = strchr (h, '@'); if (p) { *p = '\0'; p++; q = h; h = p; } else { /* default to getenv("USER") */ q = getenv ("USER"); if (!q) return (0); } strncpy (user, q, 127); /* check for port specification */ p = strchr (h, ':'); if (p) { *p = '\0'; p++; if (isdigit (*p)) { int n = atoi (p); if (n > 0) port = n; } } strncpy (hostname, h, 127); /* get password for this hostname and username from $HOME/.netrc */ p = getpw (hostname, user); if (p) strncpy (pass, p, 127); return (port); } int check_pop3 (char *path, int *new_p, int *cur_p) { int port; int fd; FILE *fp; char buf[BUF_SIZE]; char hostname[BUF_SIZE]; char box[BUF_SIZE]; /* not actually used for pop3 */ char user[128]; char pass[128]; int total = 0; port = getnetinfo (path, hostname, box, user, pass); /* connect to host */ if ((fd = sock_connect (hostname, port)) == -1) return 1; fp = fdopen (fd, "r+"); fgets (buf, BUF_SIZE, fp); fflush (fp); fprintf (fp, "USER %s\r\n", user); fflush (fp); fgets (buf, BUF_SIZE, fp); if (buf[0] != '+') { fprintf (stderr, "mailcheck: Invalid User Name '%s@%s:%d'\n", user, hostname, port); #ifdef DEBUG_POP3 fprintf (stderr, "%s\n", buf); #endif fprintf (fp, "QUIT\r\n"); fclose (fp); return 1; }; fflush (fp); fprintf (fp, "PASS %s\r\n", pass); fflush (fp); fgets (buf, BUF_SIZE, fp); if (buf[0] != '+') { fprintf (stderr, "mailcheck: Incorrect Password for user '%s@%s:%d'\n", user, hostname, port); fprintf (stderr, "mailcheck: Server said %s", buf); fprintf (fp, "QUIT\r\n"); fclose (fp); return 1; }; fflush (fp); fprintf (fp, "STAT\r\n"); fflush (fp); fgets (buf, BUF_SIZE, fp); if (buf[0] != '+') { fprintf (stderr, "mailcheck: Error Receiving Stats '%s@%s:%d'\n", user, hostname, port); return 1; } else { sscanf (buf, "+OK %d", &total); } fflush (fp); fprintf (fp, "LAST\r\n"); fflush (fp); fgets (buf, BUF_SIZE, fp); if (buf[0] != '+') { fprintf (stderr, "mailcheck: Error Receiving Stats '%s@%s:%d'\n", user, hostname, port); return 1; } else { sscanf (buf, "+OK %d", cur_p); *new_p = total - *cur_p; } fprintf (fp, "QUIT\r\n"); fclose (fp); return 0; } int check_imap (char *path, int *new_p, int *cur_p) { int port; int fd; FILE *fp; char buf[BUF_SIZE]; char hostname[BUF_SIZE]; char box[BUF_SIZE]; char user[128]; char pass[128]; int total = 0; port = getnetinfo (path, hostname, box, user, pass); if (port == 0) { fprintf (stderr, "mailcheck: Unable to get login information for %s\n", path); return 1; } if ((fd = sock_connect (hostname, port)) == -1) { fprintf (stderr, "mailcheck: Not Connected To Server '%s:%d'\n", hostname, port); return 1; } fp = fdopen (fd, "r+"); fgets (buf, BUF_SIZE, fp); /* Login to the server */ fflush (fp); fprintf (fp, "a001 LOGIN %s %s\r\n", user, pass); /* Ensure that the buffer is not an informational line */ do { fflush (fp); fgets (buf, BUF_SIZE, fp); } while (buf[0] == '*'); if (buf[5] != 'O') { /* Looking for "a001 OK" */ fprintf (fp, "a002 LOGOUT\r\n"); fclose (fp); fprintf (stderr, "mailcheck: Unable to check IMAP mailbox '%s@%s:%d'\n", user, hostname, port); fprintf (stderr, "mailcheck: Server said %s", buf); return 1; }; fflush (fp); fprintf (fp, "a003 STATUS %s (MESSAGES UNSEEN)\r\n", box); fflush (fp); fgets (buf, BUF_SIZE, fp); if (buf[0] != '*') { /* Looking for "* STATUS ..." */ fprintf (stderr, "mailcheck: Error Receiving Stats '%s@%s:%d'\n\t%s\n", user, hostname, port, buf); fclose (fp); return 1; } else { sscanf (buf, "* STATUS %*s (MESSAGES %d UNSEEN %d)", &total, new_p); #ifdef DEBUG_IMAP4 fprintf (stderr, "[%s:%d] %s", __FILE__, __LINE__, buf); #endif fgets (buf, BUF_SIZE, fp); #ifdef DEBUG_IMAP4 fprintf (stderr, "[%s:%d] %s", __FILE__, __LINE__, buf); #endif *cur_p = total - *new_p; } fflush (fp); fprintf (fp, "a004 LOGOUT\r\n"); fclose (fp); return 0; } void check_for_mail (char *tmppath) { struct stat st; char *mailpath = expand_envstr (tmppath); char maildir[BUF_SIZE]; int new = 0, cur = 0; int retval = 1; if (!stat (mailpath, &st)) { /* Is it a maildir? */ if (S_ISDIR (st.st_mode)) { sprintf (maildir, "%s/cur", mailpath); cur = count_entries (maildir); sprintf (maildir, "%s/new", mailpath); new = count_entries (maildir); if ((cur < 0) || (new < 0)) { fprintf (stderr, "mailcheck: %s is not a valid maildir -- skipping.\n", mailpath); return; } if (cur && new) { printf ("You have %d new and %d saved messages in %s\n", new, cur, mailpath); return; } if (cur) { printf ("You have %d saved messages in %s\n", cur, mailpath); return; } if (new) { printf ("You have %d new messages in %s\n", new, mailpath); return; } } /* It's an mbox. */ else if (st.st_size != 0) printf ("You have %smail in %s\n", (st.st_mtime > st.st_atime) ? "new " : "", mailpath); } else { /* Is it POP3 or IMAP? */ if (!strncmp (mailpath, "pop3:", 5)) retval = check_pop3 (mailpath, &new, &cur); else if (!strncmp (mailpath, "imap:", 5)) retval = check_imap (mailpath, &new, &cur); if (!retval) { if (cur && new) printf ("You have %d new and %d saved messages in %s\n", new, cur, mailpath); else if (cur) printf ("You have %d saved messages in %s\n", cur, mailpath); else if (new) printf ("You have %d new messages in %s\n", new, mailpath); } } } /* Process command-line options */ void process_options (int argc, char *argv[]) { int result; while (1) { result = getopt (argc, argv, "l"); switch (result) { case EOF: return; case 'l': Login_mode = 1; break; } } } int main (int argc, char *argv[]) { char buf[1024], *ptr; FILE *rcfile; struct stat st; Homedir = getenv ("HOME"); if (!Homedir) { fprintf (stderr, "%s: couldn't read environment variable HOME.\n", argv[0]); return 1; } process_options (argc, argv); if (Login_mode) { /* If we can stat .hushlogin successfully, we should exit. */ snprintf (buf, sizeof (buf), "%s/.hushlogin", Homedir); if (!stat (buf, &st)) return 0; } rcfile = open_rcfile (); if (!rcfile) { fprintf (stderr, "%s: couldn't open /etc/mailcheckrc " "or %s/.mailcheckrc.\n", argv[0], Homedir); return 1; } while (fgets (buf, sizeof (buf), rcfile)) { /* eliminate newline */ ptr = strchr (buf, '\n'); if (ptr) *ptr = 0; /* If it's not a blank line or comment, look for mail in it */ if (strlen (buf) && (*buf != '#')) check_for_mail (buf); } return 0; } mailcheck-1.91.2/mailcheckrc0000644000175000017500000000253110557206555014741 0ustar kevinkevin# mailcheckrc Default configuration for Mailcheck program # # This is a sample mailcheckrc file. It provies a good starting point, # but it probably isn't exactly what you want. See mailcheck(1) for # more information. # If you edit /etc/login.defs to turn off mailbox checking, you'll # probably want to enable this next line: #/var/spool/mail/$(USER) # If you're using qmail's Maildir feature, you'll probably want to # enable this line: #$(HOME)/Mailbox # Mailcheck also supports remote POP3 and IMAP mailboxes. Most users # will want to set these up in a .mailcheckrc file in their home # directory, not here. # If you have a remote POP3 mailbox, use a line like the following # if your username is the same there as here. #pop3://servername # If your POP3 username is different there than here: #pop3://username@servernameint # In either case, you need to put an entry in $HOME/.netrc for the password. # .netrc is in the form: # machine mail.example.com login rmf1 password MyPasWrd # where mail.example.com, rmf1, and MyPasWrd are the values for your account, # and machine, login, and password are literal text in the file. # An IMAP account is similar to a POP account, but you can specify a # mailbox path: #imap://servername/inbox # For both POP3 and IMAP, you can specify a nonstandard port: #pop3://servername:1110 #imap://servername:1143/inbox mailcheck-1.91.2/netrc.c0000644000175000017500000002006510557206575014034 0ustar kevinkevin/* netrc.c -- parse the .netrc file to get hosts, accounts, and passwords Gordon Matzigkeit , 1996 For license terms, see the file COPYING in this directory. Compile with -DSTANDALONE to test this module. */ #include #include #include #include #include "netrc.h" #define BUFSIZE 2048 #ifndef _ # define _(x) (x) #endif /* Normally defined in xstrdup.c. */ #ifndef xstrdup # define xstrdup strdup #endif /* Normally defined in xmalloc.c */ #ifndef xmalloc # define xmalloc malloc #endif #ifndef xrealloc # define xrealloc realloc #endif # ifdef STANDALONE char *program_name = "netrc"; #endif /* Maybe add NEWENTRY to the account information list, LIST. NEWENTRY is set to a ready-to-use netrc_entry, in any event. */ static void maybe_add_to_list (netrc_entry ** newentry, netrc_entry ** list) { netrc_entry *a, *l; a = *newentry; l = *list; /* We need an account name in order to add the entry to the list. */ if (a && !a->account) { /* Free any allocated space. */ if (a->host) free (a->host); if (a->password) free (a->password); } else { if (a) { /* Add the current machine into our list. */ a->next = l; l = a; } /* Allocate a new netrc_entry structure. */ a = (netrc_entry *) xmalloc (sizeof (netrc_entry)); } /* Zero the structure, so that it is ready to use. */ memset (a, 0, sizeof (*a)); /* Return the new pointers. */ *newentry = a; *list = l; return; } /* Parse FILE as a .netrc file (as described in ftp(1)), and return a list of entries. NULL is returned if the file could not be parsed. */ netrc_entry * parse_netrc (file) char *file; { FILE *fp; char buf[BUFSIZE + 1], *p, *tok; const char *premature_token; netrc_entry *current, *retval; int ln; /* The latest token we've seen in the file. */ enum { tok_nothing, tok_account, tok_login, tok_macdef, tok_machine, tok_password } last_token = tok_nothing; current = retval = NULL; fp = fopen (file, "r"); if (!fp) { /* Just return NULL if we can't open the file. */ return NULL; } /* Initialize the file data. */ ln = 0; premature_token = NULL; /* While there are lines in the file... */ while (fgets (buf, BUFSIZE, fp)) { ln++; /* Strip trailing CRLF */ for (p = buf + strlen (buf) - 1; (p >= buf) && isspace (*p); p--) *p = '\0'; /* Parse the line. */ p = buf; /* If the line is empty... */ if (!*p) { if (last_token == tok_macdef) /* end of macro */ last_token = tok_nothing; else continue; /* otherwise ignore it */ } /* If we are defining macros, then skip parsing the line. */ while (*p && last_token != tok_macdef) { char quote_char = 0; char *pp; /* Skip any whitespace. */ while (*p && isspace (*p)) p++; /* Discard end-of-line comments. */ if (*p == '#') break; tok = pp = p; /* Find the end of the token. */ while (*p && (quote_char || !isspace (*p))) { if (quote_char) { if (quote_char == *p) { quote_char = 0; p++; } else { *pp = *p; p++; pp++; } } else { if (*p == '"' || *p == '\'') quote_char = *p; else { *pp = *p; pp++; } p++; } } /* Null-terminate the token, if it isn't already. */ if (*p) *p++ = '\0'; *pp = 0; switch (last_token) { case tok_login: if (current) current->account = (char *) xstrdup (tok); else premature_token = "login"; break; case tok_machine: /* Start a new machine entry. */ maybe_add_to_list (¤t, &retval); current->host = (char *) xstrdup (tok); break; case tok_password: if (current) current->password = (char *) xstrdup (tok); else premature_token = "password"; break; /* We handle most of tok_macdef above. */ case tok_macdef: if (!current) premature_token = "macdef"; break; /* We don't handle the account keyword at all. */ case tok_account: if (!current) premature_token = "account"; break; /* We handle tok_nothing below this switch. */ case tok_nothing: break; } if (premature_token) { #ifdef HAVE_ERROR error_at_line (0, file, ln, _("warning: found \"%s\" before any host names"), premature_token); #else fprintf (stderr, _ ("mailcheck: %s:%d: warning: found \"%s\" before any host names\n"), file, ln, premature_token); #endif premature_token = NULL; } if (last_token != tok_nothing) /* We got a value, so reset the token state. */ last_token = tok_nothing; else { /* Fetch the next token. */ if (!strcmp (tok, "default")) { maybe_add_to_list (¤t, &retval); } else if (!strcmp (tok, "login")) last_token = tok_login; else if (!strcmp (tok, "user")) last_token = tok_login; else if (!strcmp (tok, "macdef")) last_token = tok_macdef; else if (!strcmp (tok, "machine")) last_token = tok_machine; else if (!strcmp (tok, "password")) last_token = tok_password; else if (!strcmp (tok, "passwd")) last_token = tok_password; else if (!strcmp (tok, "account")) last_token = tok_account; else { fprintf (stderr, _("mailcheck: %s:%d: warning: unknown token \"%s\"\n"), file, ln, tok); } } } } fclose (fp); /* Finalize the last machine entry we found. */ maybe_add_to_list (¤t, &retval); free (current); /* Reverse the order of the list so that it appears in file order. */ current = retval; retval = NULL; while (current) { netrc_entry *saved_reference; /* Change the direction of the pointers. */ saved_reference = current->next; current->next = retval; /* Advance to the next node. */ retval = current; current = saved_reference; } return retval; } /* Return the netrc entry from LIST corresponding to HOST. NULL is returned if no such entry exists. */ netrc_entry * search_netrc (list, host, account) netrc_entry *list; char *host, *account; { /* Look for the HOST in LIST. */ while (list) { if (list->host && !strcmp (list->host, host)) if (!list->account || !strcmp (list->account, account)) /* We found a matching entry. */ break; list = list->next; } /* Return the matching entry, or NULL. */ return list; } #ifdef STANDALONE #include #include extern int errno; int main (argc, argv) int argc; char **argv; { struct stat sb; char *program_name, *file, *host, *account; netrc_entry *head, *a; program_name = argv[0]; file = argv[1]; host = argv[2]; account = argv[3]; if (stat (file, &sb)) { fprintf (stderr, "%s: cannot stat %s: %s\n", argv[0], file, strerror (errno)); exit (1); } head = parse_netrc (file); if (!head) { fprintf (stderr, "%s: no entries found in %s\n", argv[0], file); exit (1); } if (host && account) { int i, status; status = 0; printf ("Host: %s, Account: %s\n", host, account); a = search_netrc (head, host, account); if (a) { /* Print out the password (if any). */ if (a->password) { fputc (' ', stdout); fputs (a->password, stdout); } } fputc ('\n', stdout); exit (status); } /* Print out the entire contents of the netrc. */ a = head; while (a) { /* Print the host name. */ if (a->host) fputs (a->host, stdout); else fputs ("DEFAULT", stdout); fputc (' ', stdout); /* Print the account name. */ fputs (a->account, stdout); if (a->password) { /* Print the password, if there is any. */ fputc (' ', stdout); fputs (a->password, stdout); } fputc ('\n', stdout); a = a->next; } exit (0); } #endif /* STANDALONE */ mailcheck-1.91.2/netrc.h0000644000175000017500000000410310557206575014034 0ustar kevinkevin/* netrc.h -- declarations for netrc.c Copyright (C) 1996, Free Software Foundation, Inc. Gordon Matzigkeit , 1996 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. */ #ifndef _NETRC_H_ #define _NETRC_H_ 1 # undef __BEGIN_DECLS # undef __END_DECLS #ifdef __cplusplus # define __BEGIN_DECLS extern "C" { # define __END_DECLS } #else # define __BEGIN_DECLS /* empty */ # define __END_DECLS /* empty */ #endif #undef __P #if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32) || defined(__cplusplus) # define __P(protos) protos #else # define __P(protos) () #endif /* The structure used to return account information from the .netrc. */ typedef struct _netrc_entry { /* The exact host name given in the .netrc, NULL if default. */ char *host; /* The name of the account. */ char *account; /* Password for the account (NULL, if none). */ char *password; /* Pointer to the next entry in the list. */ struct _netrc_entry *next; } netrc_entry; __BEGIN_DECLS /* Parse FILE as a .netrc file (as described in ftp(1)), and return a list of entries. NULL is returned if the file could not be parsed. */ netrc_entry *parse_netrc __P((char *file)); /* Return the netrc entry from LIST corresponding to HOST. NULL is returned if no such entry exists. */ netrc_entry *search_netrc __P((netrc_entry *list, char *host, char *account)); __END_DECLS #endif /* _NETRC_H_ */ mailcheck-1.91.2/COPYING0000644000175000017500000004312710557206576013615 0ustar kevinkevin 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) 19yy 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) 19yy 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. mailcheck-1.91.2/socket.c0000644000175000017500000000320110557206576014203 0ustar kevinkevin/* Copyright (C) 1998 Trent Piepho * (C) 1999 Trent Piepho * * 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; version 2 of the License. * * 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 int sock_connect (char *hostname, int port) { struct hostent *host; struct sockaddr_in addr; int fd, i; host = gethostbyname (hostname); if (host == NULL) { herror ("gethostbyname"); return (-1); }; fd = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { perror ("Error opening socket"); return (-1); }; addr.sin_family = AF_INET; addr.sin_addr.s_addr = *(u_long *) host->h_addr_list[0]; addr.sin_port = htons (port); i = connect (fd, (struct sockaddr *) &addr, sizeof (struct sockaddr)); if (i == -1) { perror ("Error connecting"); close (fd); return (-1); }; return (fd); } /* vim:set ts=4: */