Filewatcher File Search
FTP Search
  
Directory 
  
Content Search 
   
pkg://fetchpop-1.9-4.src.rpm:43079/fetchpop1.9.tar.gz  info  downloads

fetchpop1.9/ 40774    764    764           0  6164121003  10302 5ustar  ohohfetchpop1.9/COPYING100444    764    764       43150  6157624325  11473 0ustar  ohoh----------------------------------------

		    GNU GENERAL PUBLIC LICENSE
		       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
                          675 Mass Ave, Cambridge, MA 02139, 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

	Appendix: 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.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) 19yy  <name of author>

    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.

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.

  <signature of Ty Coon>, 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.
fetchpop1.9/README100644    764    764       11016  6164116270  11307 0ustar  ohoh  ---+++====   fetchpop 1.9 RELEASE Jun 25 1996   ===+++---

CHANGES FROM 1.8:
1. $HOME/.fetchhost file is encrypted. If you are upgrading from older 
   version of fetchpop, remove the old $HOME/.fetchhost file prior 
   to run this release.
2. The -s flag has been renamed to -m.
3. When Fetchpop was compiled with -DLogShowfrom, 
   it displays the 'From:' and 'Subject:' lines of retrieved messages.
4. $HOME/.lockfetch has been renamed to $HOME/.lockfetch-$HOSTNAME for NFS.
5. Some minor code arrangements.
6. -b option for rewriting local mail IDs in fetched mail into replyable
   addresses. 
7. fixed manual page.
8. Added the preference for Log file in compile-time configuration.
   Now fetchpop works with xbiff and xmailbox for notification of only 
   retrieved mails.

CHANGES 1.8 FROM 1.7 (1.0, 1.3, 1.4, 1.6):
   Too many to mention here.

OVERVIEW:
   fetchpop is a pop3 mail client designed around the concept "I do
not want to lose my mail!"

   By default, fetchpop retrieves new mail from the remote pop mail
server and appends it to your mailbox file, using information in the
file ~/.fetchhost.  Fetchpop has many options to change its default
behavior.

Some of the features of fetchpop are:
   - fetchpop can run as a daemon process (-d flag), 
   - fetchpop can be run in script files, such as ppp-on, dip, 
     and rc.local
   - fetchpop works with procmail and .forward file. (-p and -m flags)
   - fetchpop can be used to mount /var/spool/mail on a subnet
   - fetchpop does mail folder protection with exclusive 
     write-lock on mail folder files.
   - fetchpop retrieves only new unread messages, by default.
   - fetchpop can retrieve only a specific message.
   - fetchpop can be used to check only how many messages are 
     in the remote server. 
   - fetchpop works with xbiff and xmailbox for only retrieved mails from
     remote server.
   - and more.

   Some default behavior of fetchpop in version 1.8 and 1.9 has been changed.
In particular, older versions deleted retrieved messages by default.
For more information about fetchpop and its option, refer to the man
page.  (If you have already installed fetchpop, do 'man fetchpop'. 
Otherwise, do 'nroff -man fetchpop.1L | more')

   YOU DO NOT NEED TO HAVE A MAIL DELIVERY AGENT OR PROCMAIL TO USE FETCHPOP.
The -m and -p options are extra features that can be used to deliver
retrieved mail to you through a mail agent or filter, instead of
directly appending it (by default or -o flag) to a local mail folder
file.  Direct appending is a lot faster, and more reliable because of
file locking, and takes up less of the system's resources than the
mail agent delivery options

   Latest version of fetchpop can be obtained from
	ftp://ohlab.net/pub/fetchpop
	(Currently, seung-hong.ganet.net/pub/linux/fetchpop)
 
   Sites that carry fetchpop
	ftp://tsx-11.mit.edu/pub/linux/sources/usr.bin/
	ftp://sunsite.unc.edu/pub/Linux/system/Mail/pop

HOW TO COMPILE AND INSTALL FETCHPOP:

1. Check the Makefile
  If you want to compile fetchpop with procmail -p flag support or/and -m flag
support, use -DHAVEPROCMAIL or/and -DHAVEMDA as EXTRA_OPTION flags.

2. Check config.h
   IMPORTANT: edit DefaultMDA and/or FORMAIL variables in "config.h"
to where those programs are in your system, if you are compiling with
-DHAVEMDA and/or -DHAVEPROCMAIL and you  plan to use -m and -p flags
for mail delivery.

3. Type 'make' to build the software. 

4. To install it, do 'su root' and then type 'make install'.

AUTHOR:
   fetchpop was written by Seung-Hong Oh <oh@cis.ohio-state.edu>

COPYRIGHT:
   Copyright (C) 1996        Seung-Hong Oh
The  fetchpop code is under GPL.  You can freely use, 
redistribute, modify, and enhance it as long as you acknowledge  
Seung-Hong Oh as the original author.  
If you modify fetchpop, send me a copy of it.

LIMITATION:
   Some  sites  use  old  POP3  mail  servers that are poorly
implemented.  In such servers, POP3 LAST and QUIT command is  
not  working as described in RFC 1225, causing all the messages 
in the remote server to be seen as new.  On these servers,  
always use fetchpop with the -r flag

PLATFORMS:
   Linux, SunOS, HP-UX, and other Unix-like OSs.

BUGS:
   No known bugs. Send bug reports to oh@cis.ohio-state.edu

THANKS TO
   All the people who sent me comments and suggestion, and:

* Franz v. Weizsaecker <franz@p2p.de>
	lots of suggestion and comments. 
* Fritz Heinrichmeyer <fritz.heinrichmeyer@fernuni-hagen.de>
	bug report and suggestion. 
* Eric S. Raymond <esr@thyrsus.com>
	corrected the docs (README and the fetchpop man page) 
        and added the -b option.
fetchpop1.9/RFC1225100444    764    764      107132  6157624321  11324 0ustar  ohoh





Network Working Group                                            M. Rose
Request for Comments: 1225             Performance Systems International
Obsoletes: RFC 1081                                             May 1991


                    Post Office Protocol - Version 3

Status of this Memo

   This memo suggests a simple method for workstations to dynamically
   access mail from a mailbox server.  This RFC specifies an IAB
   standards track protocol for the Internet community, and requests
   discussion and suggestions for improvements.  Please refer to the
   current edition of the "IAB Official Protocol Standards" for the
   standardization state and status of this protocol.  Distribution of
   this memo is unlimited.

Overview

   This memo is a republication of RFC 1081 which was based on RFC 918
   (since revised as RFC 937).  Although similar in form to the original
   Post Office Protocol (POP) proposed for the Internet community, the
   protocol discussed in this memo is similar in spirit to the ideas
   investigated by the MZnet project at the University of California,
   Irvine.

   Further, substantial work was done on examining POP in a PC-based
   environment.  This work, which resulted in additional functionality
   in this protocol, was performed by the ACIS Networking Systems Group
   at Stanford University.  The author gratefully acknowledges their
   interest.

Introduction

   On certain types of smaller nodes in the Internet it is often
   impractical to maintain a message transport system (MTS).  For
   example, a workstation may not have sufficient resources (cycles,
   disk space) in order to permit a SMTP server and associated local
   mail delivery system to be kept resident and continuously running.
   Similarly, it may be expensive (or impossible) to keep a personal
   computer interconnected to an IP-style network for long amounts of
   time (the node is lacking the resource known as "connectivity").

   Despite this, it is often very useful to be able to manage mail on
   these smaller nodes, and they often support a user agent (UA) to aid
   the tasks of mail handling.  To solve this problem, a node which can
   support an MTS entity offers a maildrop service to these less endowed
   nodes.  The Post Office Protocol - Version 3 (POP3) is intended to



Rose                                                            [Page 1]

RFC 1225                          POP3                          May 1991


   permit a workstation to dynamically access a maildrop on a server
   host in a useful fashion.  Usually, this means that the POP3 is used
   to allow a workstation to retrieve mail that the server is holding
   for it.

   For the remainder of this memo, the term "client host" refers to a
   host making use of the POP3 service, while the term "server host"
   refers to a host which offers the POP3 service.

A Short Digression

   This memo does not specify how a client host enters mail into the
   transport system, although a method consistent with the philosophy of
   this memo is presented here:

      When the user agent on a client host wishes to enter a message
      into the transport system, it establishes an SMTP connection to
      its relay host (this relay host could be, but need not be, the
      POP3 server host for the client host).

   If this method is followed, then the client host appears to the MTS
   as a user agent, and should NOT be regarded as a "trusted" MTS entity
   in any sense whatsoever.  This concept, along with the role of the
   POP3 as a part of a split-UA model is discussed later in this memo.

   Initially, the server host starts the POP3 service by listening on
   TCP port 110.  When a client host wishes to make use of the service,
   it establishes a TCP connection with the server host.  When the
   connection is established, the POP3 server sends a greeting.  The
   client and POP3 server then exchange commands and responses
   (respectively) until the connection is closed or aborted.

   Commands in the POP3 consist of a keyword possibly followed by an
   argument.  All commands are terminated by a CRLF pair.

   Responses in the POP3 consist of a success indicator and a keyword
   possibly followed by additional information.  All responses are
   terminated by a CRLF pair.  There are currently two success
   indicators: positive ("+OK") and negative ("-ERR").

   Responses to certain commands are multi-line.  In these cases, which
   are clearly indicated below, after sending the first line of the
   response and a CRLF, any additional lines are sent, each terminated
   by a CRLF pair.  When all lines of the response have been sent, a
   final line is sent, consisting of a termination octet (decimal code
   046, ".") and a CRLF pair.  If any line of the multi-line response
   begins with the termination octet, the line is "byte-stuffed" by
   pre-pending the termination octet to that line of the response.



Rose                                                            [Page 2]

RFC 1225                          POP3                          May 1991


   Hence a multi-line response is terminated with the five octets
   "CRLF.CRLF".  When examining a multi-line response, the client checks
   to see if the line begins with the termination octet.  If so and if
   octets other than CRLF follow, the the first octet of the line (the
   termination octet) is stripped away.  If so and if CRLF immediately
   follows the termination character, then the response from the POP
   server is ended and the line containing ".CRLF" is not considered
   part of the multi-line response.

   A POP3 session progresses through a number of states during its
   lifetime.  Once the TCP connection has been opened and the POP3
   server has sent the greeting, the session enters the AUTHORIZATION
   state.  In this state, the client must identify itself to the POP3
   server.  Once the client has successfully done this, the server
   acquires resources associated with the client's maildrop, and the
   session enters the TRANSACTION state.  In this state, the client
   requests actions on the part of the POP3 server.  When the client has
   finished its transactions, the session enters the UPDATE state.  In
   this state, the POP3 server releases any resources acquired during
   the TRANSACTION state and says goodbye.  The TCP connection is then
   closed.

The AUTHORIZATION State

   Once the TCP connection has been opened by a POP3 client, the POP3
   server issues a one line greeting.  This can be any string terminated
   by CRLF.  An example might be:

      S.  +OK dewey POP3 server ready (Comments to: PostMaster@UDEL.EDU)

   Note that this greeting is a POP3 reply.  The POP3 server should
   always give a positive response as the greeting.

   The POP3 session is now in the AUTHORIZATION state.  The client must
   now issue the USER command.  If the POP3 server responds with a
   positive success indicator ("+OK"), then the client may issue either
   the PASS command to complete the authorization, or the QUIT command
   to terminate the POP3 session.  If the POP3 server responds with a
   negative success indicator ("-ERR") to the USER command, then the
   client may either issue a new USER command or may issue the QUIT
   command.

   When the client issues the PASS command, the POP3 server uses the
   argument pair from the USER and PASS commands to determine if the
   client should be given access to the appropriate maildrop.  If so,
   the POP3 server then acquires an exclusive-access lock on the
   maildrop.  If the lock is successfully acquired, the POP3 server
   parses the maildrop into individual messages (read note below),



Rose                                                            [Page 3]

RFC 1225                          POP3                          May 1991


   determines the last message (if any) present in the maildrop that was
   referenced by the RETR command, and responds with a positive success
   indicator.  The POP3 session now enters the TRANSACTION state.  If
   the lock can not be acquired or the client should is denied access to
   the appropriate maildrop or the maildrop can't be parsed for some
   reason, the POP3 server responds with a negative success indicator.
   (If a lock was acquired but the POP3 server intends to respond with a
   negative success indicator, the POP3 server must release the lock
   prior to rejecting the command.)  At this point, the client may
   either issue a new USER command and start again, or the client may
   issue the QUIT command.

                 NOTE: Minimal implementations of the POP3 need only be
                 able to break a maildrop into its component messages;
                 they need NOT be able to parse individual messages.
                 More advanced implementations may wish to have this
                 capability, for reasons discussed later.

   After the POP3 server has parsed the maildrop into individual
   messages, it assigns a message-id to each message, and notes the size
   of the message in octets.  The first message in the maildrop is
   assigned a message-id of "1", the second is assigned "2", and so on,
   so that the n'th message in a maildrop is assigned a message-id of
   "n".  In POP3 commands and responses, all message-id's and message
   sizes are expressed in base-10 (i.e., decimal).

   It sets the "highest number accessed" to be that of the last message
   referenced by the RETR command.

   Here are summaries for the three POP3 commands discussed thus far:

           USER name
               Arguments: a server specific user-id (required)
               Restrictions: may only be given in the AUTHORIZATION
                   state after the POP3 greeting or after an
                   unsuccessful USER or PASS command
               Possible Responses:
                   +OK name is welcome here
                   -ERR never heard of name
               Examples:
                   C:    USER mrose
                   S:    +OK mrose is a real hoopy frood
                     ...
                   C:    USER frated
                   S:    -ERR sorry, frated doesn't get his mail here

           PASS string
               Arguments: a server/user-id specific password (required)



Rose                                                            [Page 4]

RFC 1225                          POP3                          May 1991


               Restrictions: may only be given in the AUTHORIZATION
                   state after a successful USER command
               Possible Responses:
                   +OK maildrop locked and ready
                   -ERR invalid password
                   -ERR unable to lock maildrop
               Examples:
                   C:    USER mrose
                   S:    +OK mrose is a real hoopy frood
                   C:    PASS secret
                   S:    +OK mrose's maildrop has 2 messages
                         (320 octets)
                     ...
                   C:    USER mrose
                   S:    +OK mrose is a real hoopy frood
                   C:    PASS secret
                   S:    -ERR unable to lock mrose's maildrop, file
                         already locked

           QUIT
               Arguments: none
               Restrictions: none
               Possible Responses:
                   +OK
               Examples:
                   C:    QUIT
                   S:    +OK dewey POP3 server signing off


The TRANSACTION State

   Once the client has successfully identified itself to the POP3 server
   and the POP3 server has locked and burst the appropriate maildrop,
   the POP3 session is now in the TRANSACTION state.  The client may now
   issue any of the following POP3 commands repeatedly.  After each
   command, the POP3 server issues a response.  Eventually, the client
   issues the QUIT command and the POP3 session enters the UPDATE state.

   Here are the POP3 commands valid in the TRANSACTION state:

           STAT
               Arguments: none
               Restrictions: may only be given in the TRANSACTION state.
               Discussion:

                 The POP3 server issues a positive response with a line
                 containing information for the maildrop.  This line is
                 called a "drop listing" for that maildrop.



Rose                                                            [Page 5]

RFC 1225                          POP3                          May 1991


                 In order to simplify parsing, all POP3 servers are
                 required to use a certain format for drop listings.
                 The first octets present must indicate the number of
                 messages in the maildrop.  Following this is the size
                 of the maildrop in octets.  This memo makes no
                 requirement on what follows the maildrop size.
                 Minimal implementations should just end that line of
                 the response with a CRLF pair.  More advanced
                 implementations may include other information.

                      NOTE: This memo STRONGLY discourages
                      implementations from supplying additional
                      information in the drop listing.  Other,
                      optional, facilities are discussed later on
                      which permit the client to parse the messages
                      in the maildrop.

                 Note that messages marked as deleted are not counted in
                 either total.

               Possible Responses:
                   +OK nn mm
               Examples:
                   C:    STAT
                   S:    +OK 2 320

           LIST [msg]
               Arguments: a message-id (optionally)  If a message-id is
                   given, it may NOT refer to a message marked as
                   deleted.
               Restrictions: may only be given in the TRANSACTION state.
               Discussion:

                 If an argument was given and the POP3 server issues a
                 positive response with a line containing information
                 for that message.  This line is called a "scan listing"
                 for that message.

                 If no argument was given and the POP3 server issues a
                 positive response, then the response given is
                 multi-line.  After the initial +OK, for each message
                 in the maildrop, the POP3 server responds with a line
                 containing information for that message.  This line
                 is called a "scan listing" for that message.

                 In order to simplify parsing, all POP3 servers are
                 required to use a certain format for scan listings.
                 The first octets present must be the message-id of



Rose                                                            [Page 6]

RFC 1225                          POP3                          May 1991


                 the message.  Following the message-id is the size of
                 the message in octets.  This memo makes no requirement
                 on what follows the message size in the scan listing.
                 Minimal implementations should just end that line of
                 the response with a CRLF pair.  More advanced
                 implementations may include other information, as
                 parsed from the message.

                      NOTE: This memo STRONGLY discourages
                      implementations from supplying additional
                      information in the scan listing.  Other, optional,
                      facilities are discussed later on which permit
                      the client to parse the messages in the maildrop.

                 Note that messages marked as deleted are not listed.

               Possible Responses:
                   +OK scan listing follows
                   -ERR no such message
               Examples:
                   C:    LIST
                   S:    +OK 2 messages (320 octets)
                   S:    1 120
                   S:    2 200
                   S:    .
                     ...
                   C:    LIST 2
                   S:    +OK 2 200
                     ...
                   C:    LIST 3
                   S:    -ERR no such message, only 2 messages in
                         maildrop

           RETR msg
               Arguments: a message-id (required)  This message-id may
                   NOT refer to a message marked as deleted.
               Restrictions: may only be given in the TRANSACTION state.
               Discussion:

                 If the POP3 server issues a positive response, then the
                 response given is multi-line.  After the initial +OK,
                 the POP3 server sends the message corresponding to the
                 given message-id, being careful to byte-stuff the
                 termination character (as with all multi-line
                 responses).

                 If the number associated with this message is higher
                 than the "highest number accessed" in the maildrop, the



Rose                                                            [Page 7]

RFC 1225                          POP3                          May 1991


                 POP3 server updates the "highest number accessed" to
                 the number associated with this message.

               Possible Responses:
                   +OK message follows
                   -ERR no such message
               Examples:
                   C:    RETR 1
                   S:    +OK 120 octets
                   S:    <the POP3 server sends the entire message here>
                   S:    .

           DELE msg
               Arguments: a message-id (required)  This message-id
                   may NOT refer to a message marked as deleted.
               Restrictions: may only be given in the TRANSACTION state.
               Discussion:

                 The POP3 server marks the message as deleted.  Any
                 future reference to the message-id associated with the
                 message in a POP3 command generates an error.  The POP3
                 server does not actually delete the message until the
                 POP3 session enters the UPDATE state.

                 If the number associated with this message is higher
                 than the "highest number accessed" in the maildrop,
                 the POP3 server updates the "highest number accessed"
                 to the number associated with this message.

               Possible Responses:
                   +OK message deleted
                   -ERR no such message
               Examples:
                   C:    DELE 1
                   S:    +OK message 1 deleted
                     ...
                   C:    DELE 2
                   S:    -ERR message 2 already deleted

           NOOP
               Arguments: none
               Restrictions: may only be given in the TRANSACTION state.
               Discussion:

                 The POP3 server does nothing, it merely replies with a
                 positive response.

               Possible Responses:



Rose                                                            [Page 8]

RFC 1225                          POP3                          May 1991


                   +OK
               Examples:
                   C:    NOOP
                   S:    +OK

           LAST
               Arguments: none
               Restrictions: may only be issued in the TRANSACTION state.
               Discussion:

                 The POP3 server issues a positive response with a line
                 containing the highest message number which accessed.
                 Zero is returned in case no message in the maildrop has
                 been accessed during previous transactions.  A client
                 may thereafter infer that messages, if any, numbered
                 greater than the response to the LAST command are
                 messages not yet accessed by the client.

             Possible Response:
                   +OK nn

             Examples:
                   C:      STAT
                   S:      +OK 4 320
                   C:      LAST
                   S:      +OK 1
                   C:      RETR 3
                   S:      +OK 120 octets
                   S:      <the POP3 server sends the entire message
                           here>
                   S:      .
                   C:      LAST
                   S:      +OK 3
                   C:      DELE 2
                   S:      +OK message 2 deleted
                   C:      LAST
                   S:      +OK 3
                   C:      RSET
                   S:      +OK
                   C:      LAST
                   S:      +OK 1

           RSET
               Arguments: none
               Restrictions: may only be given in the TRANSACTION
                   state.
               Discussion:




Rose                                                            [Page 9]

RFC 1225                          POP3                          May 1991


                 If any messages have been marked as deleted by the POP3
                 server, they are unmarked.  The POP3 server then
                 replies with a positive response.  In addition, the
                 "highest number accessed" is also reset to the value
                 determined at the beginning of the POP3 session.

               Possible Responses:
                   +OK
               Examples:
                   C:    RSET
                   S:    +OK maildrop has 2 messages (320 octets)



The UPDATE State

   When the client issues the QUIT command from the TRANSACTION state,
   the POP3 session enters the UPDATE state.  (Note that if the client
   issues the QUIT command from the AUTHORIZATION state, the POP3
   session terminates but does NOT enter the UPDATE state.)

           QUIT
               Arguments: none
               Restrictions: none
               Discussion:

                 The POP3 server removes all messages marked as deleted
                 from the maildrop.  It then releases the
                 exclusive-access lock on the maildrop and replies as
                 to the success of
                 these operations.  The TCP connection is then closed.

               Possible Responses:
                   +OK
               Examples:
                   C:    QUIT
                   S:    +OK dewey POP3 server signing off (maildrop
                         empty)
                     ...
                   C:    QUIT
                   S:    +OK dewey POP3 server signing off (2 messages
                         left)
                     ...


Optional POP3 Commands

   The POP3 commands discussed above must be supported by all minimal



Rose                                                           [Page 10]

RFC 1225                          POP3                          May 1991


   implementations of POP3 servers.

   The optional POP3 commands described below permit a POP3 client
   greater freedom in message handling, while preserving a simple POP3
   server implementation.

                 NOTE: This memo STRONGLY encourages implementations to
                 support these commands in lieu of developing augmented
                 drop and scan listings.  In short, the philosophy of
                 this memo is to put intelligence in the part of the
                 POP3 client and not the POP3 server.

           TOP msg n
               Arguments: a message-id (required) and a number.  This
                   message-id may NOT refer to a message marked as
                   deleted.
               Restrictions: may only be given in the TRANSACTION state.
               Discussion:

                 If the POP3 server issues a positive response, then
                 the response given is multi-line.  After the initial
                 +OK, the POP3 server sends the headers of the message,
                 the blank line separating the headers from the body,
                 and then the number of lines indicated message's body,
                 being careful to byte-stuff the termination character
                 (as with all multi-line responses).

                 Note that if the number of lines requested by the POP3
                 client is greater than than the number of lines in the
                 body, then the POP3 server sends the entire message.

               Possible Responses:
                   +OK top of message follows
                   -ERR no such message
               Examples:
                   C:    TOP 10
                   S:    +OK
                   S:    <the POP3 server sends the headers of the
                          message, a blank line, and the first 10 lines
                          of the body of the message>
                   S:    .
                     ...
                   C:    TOP 100
                   S:    -ERR no such message

           RPOP user
               Arguments: a client specific user-id (required)
               Restrictions: may only be given in the AUTHORIZATION



Rose                                                           [Page 11]

RFC 1225                          POP3                          May 1991


                   state after a successful USER command; in addition,
                   may only be given if the client used a reserved
                   (privileged) TCP port to connect to the server.
               Discussion:

                 The RPOP command may be used instead of the PASS
                 command to authenticate access to the maildrop.  In
                 order for this command to be successful, the POP3
                 client must use a reserved TCP port (port < 1024) to
                 connect tothe server.  The POP3 server uses the
                 argument pair from the USER and RPOP commands to
                 determine if the client should be given access to
                 the appropriate maildrop.  Unlike the PASS command
                 however, the POP3 server considers if the remote user
                 specified by the RPOP command who resides on the POP3
                 client host is allowed to access the maildrop for the
                 user specified by the USER command (e.g., on Berkeley
                 UNIX, the .rhosts mechanism is used).  With the
                 exception of this differing in authentication, this
                 command is identical to the PASS command.

                 Note that the use of this feature has allowed much wider
                 penetration into numerous hosts on local networks (and
                 sometimes remote networks) by those who gain illegal
                 access to computers by guessing passwords or otherwise
                 breaking into the system.

               Possible Responses:
                   +OK maildrop locked and ready
                   -ERR permission denied
               Examples:
                   C:    USER mrose
                   S:    +OK mrose is a real hoopy frood
                   C:    RPOP mrose
                   S:    +OK mrose's maildrop has 2 messages (320
                         octets)

       Minimal POP3 Commands:
           USER name               valid in the AUTHORIZATION state
           PASS string
           QUIT

           STAT                    valid in the TRANSACTION state
           LIST [msg]
           RETR msg
           DELE msg
           NOOP
           LAST



Rose                                                           [Page 12]

RFC 1225                          POP3                          May 1991


           RSET

           QUIT                    valid in the UPDATE state

       Optional POP3 Commands:
           RPOP user               valid in the AUTHORIZATION state

           TOP msg n               valid in the TRANSACTION state

       POP3 Replies:
           +OK
           -ERR

       Note that with the exception of the STAT command, the reply given
       by the POP3 server to any command is significant only to "+OK"
       and "-ERR".  Any text occurring after this reply may be ignored
       by the client.

Example POP3 Session

    S: <wait for connection on TCP port 110>
        ...
    C: <open connection>
    S:    +OK dewey POP3 server ready (Comments to: PostMaster@UDEL.EDU)
    C:    USER mrose
    S:    +OK mrose is a real hoopy frood
    C:    PASS secret
    S:    +OK mrose's maildrop has 2 messages (320 octets)
    C:    STAT
    S:    +OK 2 320
    C:    LIST
    S:    +OK 2 messages (320 octets)
    S:    1 120
    S:    2 200
    S:    .
    C:    RETR 1
    S:    +OK 120 octets
    S:    <the POP3 server sends message 1>
    S:    .
    C:    DELE 1
    S:    +OK message 1 deleted
    C:    RETR 2
    S:    +OK 200 octets
    S:    <the POP3 server sends message 2>
    S:    .
    C:    DELE 2
    S:    +OK message 2 deleted
    C:    QUIT



Rose                                                           [Page 13]

RFC 1225                          POP3                          May 1991


    S:    +OK dewey POP3 server signing off (maildrop empty)
    C:  <close connection>
    S:  <wait for next connection>

Message Format

   All messages transmitted during a POP3 session are assumed to conform
   to the standard for the format of Internet text messages [RFC822].

   It is important to note that the byte count for a message on the
   server host may differ from the octet count assigned to that message
   due to local conventions for designating end-of-line.  Usually,
   during the AUTHORIZATION state of the POP3 session, the POP3 client
   can calculate the size of each message in octets when it parses the
   maildrop into messages.  For example, if the POP3 server host
   internally represents end-of-line as a single character, then the
   POP3 server simply counts each occurrence of this character in a
   message as two octets.  Note that lines in the message which start
   with the termination octet need not be counted twice, since the POP3
   client will remove all byte-stuffed termination characters when it
   receives a multi-line response.

The POP and the Split-UA model

   The underlying paradigm in which the POP3 functions is that of a
   split-UA model.  The POP3 client host, being a remote PC based
   workstation, acts solely as a client to the message transport system.
   It does not provide delivery/authentication services to others.
   Hence, it is acting as a UA, on behalf of the person using the
   workstation.  Furthermore, the workstation uses SMTP to enter mail
   into the MTS.

   In this sense, we have two UA functions which interface to the
   message transport system: Posting (SMTP) and Retrieval (POP3).  The
   entity which supports this type of environment is called a split-UA
   (since the user agent is split between two hosts which must
   interoperate to provide these functions).

                 ASIDE:  Others might term this a remote-UA instead.
                 There are arguments supporting the use of both terms.

   This memo has explicitly referenced TCP as the underlying transport
   agent for the POP3.  This need not be the case.  In the MZnet split-
   UA, for example, personal micro-computer systems are used which do
   not have IP-style networking capability.  To connect to the POP3
   server host, a PC establishes a terminal connection using some simple
   protocol (PhoneNet).  A program on the PC drives the connection,
   first establishing a login session as a normal user.  The login shell



Rose                                                           [Page 14]

RFC 1225                          POP3                          May 1991


   for this pseudo-user is a program which drives the other half of the
   terminal protocol and communicates with one of two servers.  Although
   MZnet can support several PCs, a single pseudo-user login is present
   on the server host.  The user-id and password for this pseudo-user
   login is known to all members of MZnet.  Hence, the first action of
   the login shell, after starting the terminal protocol, is to demand a
   USER/PASS authorization pair from the PC.  This second level of
   authorization is used to ascertain who is interacting with the MTS.
   Although the server host is deemed to support a "trusted" MTS entity,
   PCs in MZnet are not.  Naturally, the USER/PASS authorization pair
   for a PC is known only to the owner of the PC (in theory, at least).

   After successfully verifying the identity of the client, a modified
   SMTP server is started, and the PC posts mail with the server host.
   After the QUIT command is given to the SMTP server and it terminates,
   a modified POP3 server is started, and the PC retrieves mail from the
   server host.  After the QUIT command is given to the POP3 server and
   it terminates, the login shell for the pseudo-user terminates the
   terminal protocol and logs the job out.  The PC then closes the
   terminal connection to the server host.

   The SMTP server used by MZnet is modified in the sense that it knows
   that it's talking to a user agent and not a "trusted" entity in the
   message transport system.  Hence, it does performs the validation
   activities normally performed by an entity in the MTS when it accepts
   a message from a UA.

   The POP3 server used by MZnet is modified in the sense that it does
   not require a USER/PASS combination before entering the TRANSACTION
   state.  The reason for this (of course) is that the PC has already
   identified itself during the second-level authorization step
   described above.

                 NOTE: Truth in advertising laws require that the author
                 of this memo state that MZnet has not actually been
                 fully implemented.  The concepts presented and proven
                 by the project led to the notion of the MZnet
                 split-slot model.  This notion has inspired the
                 split-UA concept described in this memo, led to the
                 author's interest in the POP, and heavily influenced
                 the the description of the POP3 herein.

   In fact, some UAs present in the Internet already support the notion
   of posting directly to an SMTP server and retrieving mail directly
   from a POP server, even if the POP server and client resided on the
   same host!

                 ASIDE: this discussion raises an issue which this memo



Rose                                                           [Page 15]

RFC 1225                          POP3                          May 1991


                 purposedly avoids: how does SMTP know that it's talking
                 to a "trusted" MTS entity?

References

     [MZnet]   Stefferud, E., J. Sweet, and T. Domae, "MZnet: Mail
               Service for Personal Micro-Computer Systems",
               Proceedings, IFIP 6.5 International Conference on
               Computer Message Systems, Nottingham, U.K., May 1984.

     [RFC821]  Postel, J., "Simple Mail Transfer Protocol",
               USC/Information Sciences Institute, August 1982.

     [RFC822]  Crocker, D., "Standard for the Format of ARPA-Internet
               Text Messages", University of Delaware, August 1982.

     [RFC937]  Butler, M., J. Postel, D. Chase, J. Goldberger, and J.
               Reynolds, "Post Office Protocol - Version 2", RFC 937,
               USC/Information Sciences Institute, February 1985.

     [RFC1060] Reynolds, J., and J. Postel, "Assigned Numbers", RFC
               1060, USC/Information Sciences Institute, March 1990.

Security Considerations

   Security issues are not discussed in this memo.

Author's Address:

   Marshall T. Rose
   Performance Systems International
   5201 Great America Parkway
   Suite 3106
   Santa Clara, CA  95054

   Phone: +1 408 562 6222

   EMail: mrose@psi.com
   X.500:  rose, psi, us












Rose                                                           [Page 16]
fetchpop1.9/TODO100444    764    764        2166  6164070424  11103 0ustar  ohoh1. Add support for multiple hosts in a single host info file.
2. Use autoconf? I am not sure it is neccesary because fetchpop uses
   only libraries that most of Unix-like OSs have. 
   Well, telling users to edit a few variables in config.h is no big deal,
   I guess.
3. In .fetchhost file, make fifth column for favorite command line flags, 
   such as 
      pop3.mail.host.name encrypted_userid encrypted_password sleep 
      "-d -r -o /var/spool/mail/sexy"

All of above will be implemented next release. Probably 1.10 or 2.1.
So in upcoming fetchpop1.10 (2.1) version, the $HOME/.fetchhost file should
look something like;

 mail.ohlab.net encrypted_userid encrypted_password 900  "-d -o ~/mail/from_ohlab"
 pop.cis.ohio-state.edu encrypted_userid encrypted_password 600  "-d -r -o ~/mail/from_osu"
 postbox.acs.ohio-state.edu encrypted_userid encrypted_password 1200 "-d -r -p"


You are free to hack the fetchpop codes, if you want. 
If you hacked fetchpop, please send me any modification you made 
and you will get credit for your work, of course.
Also, I am also looking for a maintainer.

	seung-hong oh <oh@cis.ohio-state.edu>
fetchpop1.9/fetchpop.1L100644    764    764       23256  6164117110  12440 0ustar  ohoh.TH fetchpop 1L
.SH NAME
fetchpop \- client to retrieve mail from pop3 server.
.SH SYNOPSIS
.B fetchpop
[\fB-v\fR]  [\fB-k\fI | \fB-q\fR\|] [\fB-x\fR] [\fB-c\fR]
.br
.B fetchpop
[\fB-d\fR]  [\fB-a\fI | \fB-g\fI msg ID\fR\|] [\fB-t\fI limit\fR\|] [\fB-r\fR] [\fB-b\fR] [\fB-e msg ID\fR\] [\fB-f\fI alternative rcfile\fR\|] [\fB-m\fI | \fB-p\fI | \fB-o\fI alternative mailbox\fR\|] [\fB-l\fI log file\fR\|]

.SH DESCRIPTION
The 
.I fetchpop 
program retrieves mail from a remote host using the POP3 mail
transfer protocol as described in RFC1225 and RFC1081.
.PP
By default, 
.I fetchpop 
retrieves new unread mail and appends it to your mailbox
file using information specified in the file
.I $HOME/.fetchhost.
If the environment variable
.I $MAIL
is set, 
.I fetchpop 
appends to the file named.  Otherwise it 
appends the mail to \fBMAILSPOOLDIR/\fI$USER.\fR
The retrieved messages will be appended to the mail folder file with
an 
.I exclusive write lock, 
which means that the mailbox is protected
from other processes writing to it while a 
.I fetchpop 
session is
modifying it.  If there are more than one mail host that you want to
retrieve mail from, the
.B -f 
flag can be used. Check the
.B FILES
and
.B OPTIONS
sections for information.
.PP
For shell scripts users, check the 
.B SCRIPT USERS 
section for information.
.SH OPTIONS
.TP
.B \-v
Show version and identification information as well as compile-time
configuration. This mode displays the value of
.B MINSLEEPSECOND 
(the minimum of the sleep time users may set), and what
.B MAILSPOOLDIR 
is set to, and whether -m and -p flags are enabled or disabled, and the preference of logging method.
In this mode no mail is retrieved.
.TP
.B \-q, \-k
Kill the fetchpop daemon process.
.TP
.B \-d
Use to run fetchpop as a 
.I daemon process. 
In this mode, fetchpop will connect to
the pop server, retrieve mail, sleep for some number of seconds, and then
repeat, using information specified in the
$HOME/.fetchhost file or the file specified with the  
.B -f 
option. Without the
.B -d 
flag, fetchpop
will run in foreground and exit immediately after retrieving mail.
.TP
.B \-a
Retrieve all mail found in your mailbox on the remote mail server. By
default, fetchpop retrieves only new unread messages and skips read messages.
See the
.B LIMITATIONS
section for discussion.
.TP
.B \-c
Check how many new messages and how many total messages are waiting on the
remote server. In this mode fetchpop won't actually retrieve mail.
.TP
.B \-g
Get (retrieve) a specific message.  The argument is the message ID number
in POP3 server. Be careful to use the -g flag to fetch a new message, since
fetchpop assumes that only messages that are greater than the last read
message number are new messages.
.TP
.B \-b
Rewrite From, Cc, Bcc, and Reply-To headers.  If this option is on, when
mail is fetched these headers are scanned for email IDs that are local to
the POP server host, that is do not contain a @ and hostname.  These local
IDs get @ and the hostname from  $HOME/.fetchhost appended to them, so you
can reply to them without having to edit the headers.  Note: this option
does \fInot\fR mix well with sendmail delivery, as mail with its headers
rewritten this way will just be shipped right back to the POP host!
.TP
.B \-t
Tell fetchpop to retrieve only the given number of lines for each message.
The number must be positive. All the header lines will be retrieved no matter
what value is given.
.TP
.B \-r
Remove messages in your mailbox on the remote mail server after fetching them.
Normally, messages are kept in the mailbox on the mail server. Specifying
.B \-r 
causes the retrieved messages to be deleted from your mailbox on the remote mail
server.
.TP
.B \-x
Delete all the old messages from your mailbox on the remote mail server.
In this mode, fetchpop does not delete new unread messages and  does not
retrieve mail.
.TP
.B \-e
Delete(eliminate) a specific message. The argument is the message ID number
in POP3 server. 
.TP
.B \-f
Specify an alternative config file, other than $HOME/.fetchhost. It is
used to retrieve mail from another mail host.
.TP
.B \-o
Write the fetched messages to the mailbox file specified as argument. The
mailbox file that is being written by fetchpop will be write-locked, to prevent
mailbox corruption. The options
.B \-o -
or
.B \-o stdout
have special meanings. The retrieved messages will be sent to the
.B standard output device. 
Using default and
.B \-o
is 
.I faster
than using MDA. 
Mail filtering tools and the $HOME/.forward file will not work with 
.B \-o
and
.B default
, though.
.TP
.B \-l 
Specifies that the fetchpop
session is to be logged in the file 
named.
It is meant to be used with 
.B -d 
flag for debugging. Check the log file preference with
.B -v 
option.
.PP
.SH EXTRA OPTIONS
These options below might not be available depending on how the
.I fetchpop 
was compiled. You can check this with the
.B \-v
option.  When these options are used, the retrieved mail is delivered
by local mail delivery agent, instead of appended to the
.I $MAIL
mailbox. These flags are useful when you do mail filtering. 
.B \-o 
cannot be used with these flags.
.TP
.B \-m
uses one of deliver, sendmail or mail as a MDA. Check with
.B -v
flag to see what the MDA for fetchpop is set to.
.TP
.B \-p
uses 
.I procmail/formail 
as mail delivery and formatting tool. Good, if you have procmail and
do intensive mail filtering.
.SH EXAMPLE
.nf
fetchpop
fetchpop -x
fetchpop -d -l ~/fetch.log
fetchpop -c -f  ~/.anotherhost
fetchpop -o - -t 10 -g 1
fetchpop -dp -l ~/fetch.log 
fetchpop -dprl ~/fetch.log
fetchpop -dr -o /var/spool/mail/me -l ~/.log 
 or
whatever
.fi
.PP
.SH FILES
.TP
.B $HOME/.fetchhost
When this file does not exist, 
.I fetchpop 
will prompt for the host, login information and sleep_time interactively, and create the $HOME/.fetchhost file for you. 
$HOME/.fetchpop
consists of 4 fields, separated by spaces:
.nf

.B pop_server_name login_name password sleeptime_in_seconds

.fi
.I pop_server_name
is the name of the host from which mail is to be retrieved.
.I login_name
and
.I password
are your login and password on the pop mail server. These 2 fields are 
.I encrypted 
with simple conversion method.
.I sleeptime_in_seconds
sets how long 
.I fetchpop 
will wait between mail checks when run as a daemon
process.  Because it contains password information, $HOME/.fetchhost got
permission 600.  The 
.I fetchpop 
startup will ask you to remove the $HOME/.fetchhost
file if it has the wrong permission or is in the wrong format, and will make
the new $HOME/.fetchhost for you next time you run fetchpop.

This rule applies to the file supplied with
.B -f 
flag, also.  
.TP
.B $HOME/.lockfetch-$HOSTNAME
When
.I fetchpop
runs as a 
.I daemon process, 
it creates a lock file
.I .lockfetch-$HOSTNAME
containing the PID of the session. When you use 
.B \-q
flag, 
.I fetchpop
is killed and this file is removed. Note that you cannot run more
than one fetchpop daemon, but you can run as many non-daemon fetchpop
sessions as you want.
.PP
.SH SCRIPT USERS
.I fetchpop
works nicely with shell scripts, such as 
.I dip, ppp-on and rc.local.
Simply add a line to invoke the fetchpop daemon. For example (using GNU
\fIsu\fR(1) under Linux):

	su user -l -c "fetchpop -d -r -l ~/fetch.log"

for a user name 'user'.  Before you use this command on a non-Linux system,
check the behavior of your su command.  You need it to either set
.I $MAIL
for the user's environment or leave it unset; if it sets the variable
for root, mail will go to root's box.  If your su has a -l option it
may help. Otherwise you can use
.B \-o
flag with a full path to your mailbox; or you can use the -m flag or
.I procmail 
-p flag.  Refer to
.I su(1)
for more information about your su command.
.PP
Also keep in mind that when 
.I fetchpop 
runs as a daemon process, it creates 
.I .lockfetch-$HOSTNAME 
file under user home directory. The 
.I fetchpop 
daemon will not run when it sees that the 
.I .lockfetch-$HOSTNAME
file exists. The lock will be removed when the
.B \-q
flag is used. So, you might want to put 'su user -c "fetchpop -q"' in the
shutdown procedure of your connection, such as dipoff, ppp-off, and etc.
See also the
.B ENVIRONMENT 
section.
.PP
.SH EXIT CODES
.I fetchpop
does not return meaningful exit codes, since it is meant to be used as a
daemon. fetchpop daemon never exits unless it is killed by 
.B -q
flag.  Basically, 0 is returned when there is no error. Otherwise, !0 (not 0)
is returned. 
.PP
.SH ENVIRONMENT
.IP MAIL
the full pathname for the mailbox that 
.I fetchpop
appends the mail to.
If
.I $MAIL
is not set, MAILSPOOLDIR/\fI$USER\fR is used, where MAILSPOOLDIR is determined by compile-time configuration and $USER is a real user. When -o, -p, or -m flag is used,
fetchpop does not use this environment variable. 
.PP
.SH LIMITATION
Some sites use old POP3 mail servers that are poorly implemented.  In such
servers, POP3 LAST and QUIT command is not working as described in RFC 1225,
causing all the messages in the remote server to be seen as new.  Always use 
.I fetchpop 
with the -r flag on these servers.
.PP
.SH COPYRIGHT
The fetchpop code is under GPL.  You can freely use, redistribute, modify and  enhance it as long as you acknowledge Seung-Hong Oh as the original author.
If you modify fetchpop, send me a copy of it.
.PP
.SH BUGS
No known bugs.
.PP
If you find bugs, please send reports to oh@cis.ohio-state.edu. 
.PP
.SH AUTHOR
.I fetchpop
was written by 
.B Seung-Hong Oh <oh@cis.ohio-state.edu> <http://www.cis.ohio-state.edu/~oh">
.PP
Please send comments, suggestion, complaints, bug fixes, and porting
experiences to me, including the version number of fetchpop in your mail. 
.PP
.SH SEE ALSO
RFC 1225, \fIsendmail\fR(8), \fIdeliver\fR(8), \fIfcntl\fR(2), \fIflock\fR(2), \fIlockf\fR(3), \fIsu\fR(1), \fIprocmail\fR(1), \fIformail\fR(1).
fetchpop1.9/FAQ.fetchpop100644    764    764       17411  6164110142  12565 0ustar  ohohMini FAQ on fetchpop
--------------------

$Id: FAQ.fetchpop,v 0.1 1996/06/25 11:18:46 oh Exp oh $

        This is a mini FAQ covering fetchpop. 
    The purpose of this FAQ is to help you using fetchpop.
        The question are based on most frequent topics 
       that are sent to me over last 4 months, concerning
          from fetchpop1.0 version up to 1.8.2
      If you've read fetchpop man page, you wouldn't have
	asked these questions. For those who don't read
	manual pages, here are some answers to FAQ.

--
Seung-Hong Oh
oh@seung-hong.ganet.net

-------------------------------------------------------------------------
Q1. If one runs it from rc.local as a daemon Fetchpop tries once,
    and then dies.  
Q2. I have added the following line to my /etc/ppp/ip-up script:
    su myid -c "fetchpop -d -l ~/.fetchlog 2>&1 > ~/.fetcherr"
    fetchpop works fine if there is no mail at the POP host when
    ip-up is called. Fetchpop fails (dies) without any messages in
    .fetchlog or .fetcherr if there is some mail on the POP server 
    when ip-up is called.
Q3. Recently I have installed Linux and fetchpop, I like to use
    dip to connect to my university with slip or ppp mode. How can I
    start up fetchpop whenever dip is invoked, where and which file
    should I config it?
Q4. How do I have fetchpop to retrieve mails from multiple hosts? 
    Can I just add additional lines in $HOME/.fetchhost file?
Q5. Fetchpop doesn't seem to recognize which messages are new and
    which are read in my ISP server(it always retrieves all of them). 
    What is the deal?
Q6. How do I make fetchpop to work with xmailbox? (fetchpop version1.9)
-------------------------------------------------------------------------
 
A1, A2.
     The problem with Q1 and Q2 are that 'su' command does not change most 
environment variables over to those of 'sued' users. 
Both rc.local and ip-up are run with root ownership. 
'su' from root to a user named 'myid' does not change
the $MAIL environment variable 
so that $MAIL is still defined for root's mailbox, where you
do not have write permission. The solution to this is mentioned in the 
man page. To remind you, you might want to use su with -l flag if 
your version of su has the -l flag. If not, use -o with full path to
you mailbox; -m or -p works fine,too.

A3. Recently I have installed Linux and fetchpop, I like to use
   dip to connect to my university with slip or ppp mode. How can I
   start up fetchpop whenever dip is invoked, where and which file
   should I config it?

     To use dip, you need to get a sample dip script and edit it. 
Also you need a script that execute dip and fetchpop.
In the example below, you can type 'slip' to connect to your university and
'slipff' to disconnect.

Here are examples.

----- your dip script named '/etc/dip.scr' may look like this -----------
# Edit this.
#This is from slackware 1.2, but it should still work...
#
# Author:       Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
# -----------------------------------------------------------------

main:
  default

  # make sure we don't get some weird address
  netmask 255.255.255.0

  # This address doesn't matter all that much, really
  # xxx.xxx.xxx.xxx is your ISP's IP address.
  get $remote xxx.xxx.xx.xxx 

  # Set the desired serial port and speed.
  port /dev/modem
  speed 57600

  # Reset the modem and terminal line.
  # This seems to cause trouble for some people!
  reset

  # Prepare for dialing.
  print Resetting modem
  init ATZ
  if $errlvl != 0 goto modem_trouble

  print Initializing modem
  # put a good init string here.  Apparently no spaces allowed.
  init ATM0X4S11=65
  if $errlvl != 0 goto modem_trouble

#13. Please note, "dial" command in DIP script is slightly different
#    now - it "eats" the string the modem responds with to your dial!
#    Thus, DON'T expect "CONNECT" after successful dial, not any more.
#    Instead - check "$errlevel" value, just like this:
#
#        dial 555-1212
#        if $errlevel != 1 goto error
#
#    Note, that standardly,
#        0 - OK
#        1 - CONNECT
#        2 - ERROR
#        3 - BUSY
#        4 - NO CARRIER
#        5 - NO DIALTONE
#    [These can be modified/added to with dip's CHATKEY command]

dial_number:
  print Dialing....

  dial T4470164

  if $errlvl == 3 goto busy
  if $errlvl == 4 goto no_carrier
  if $errlvl == 5 goto no_dialtone
  if $errlvl != 1 goto modem_trouble
  print Connected!  Logging in....

  # We are connected.  Login to the system.
login:
  sleep 3
  send \r\n\r\n
  wait name: 10
  if $errlvl != 0 goto login_error
  sleep 1
# Insert your username here
  send MYUSERNAME\n
  wait ord: 5
  if $errlvl != 0 goto password_error
  sleep 1
# Insert your password here
  send MYPASSWORD\n
  wait ACS> 30
  if $errlvl != 0 goto connection_error 

loggedin:
  sleep 1
  # We are now logged in. Start the slip connection up.
  send slip\r
  print Trying to get slip
  wait is 30
  if $errlvl != 0 goto prompt_error
  get $locip remote
# print Local IP is $locip

  # Set up the SLIP operating parameters.
  get $mtu 296
# print MTU is $mtu

  # Say hello and fire up!
done:
  print CONNECTED with $locip ( $local )
  mode CSLIP
  goto exit

prompt_error:
  print TIME-OUT waiting for SLIPlogin to fire up...
  goto error

login_error:
  print Trouble waiting for the Login: prompt...
  goto error

password_error:
  print Trouble waiting for the Password: prompt...
  goto error

connection_error:
  print Trouble waiting for the MYU> prompt...
  goto error

modem_trouble:
  print Trouble occurred with the modem...
  goto error

no_carrier:
  print NO CARRIER
  # redial indefinitely
  goto dial_number

busy:
  print BUSY
  goto dial_number

no_dialtone:
  print NO DIALTONE
  quit 2

error:
  print ERROR, connect failed
  quit 1

exit:
  exit
-------------------- end of dip script 'dip.scr' -------------------------

-------------------- slip ------------------------------------------------
#!/bin/sh
dip /etc/dip.scr || exit 1
sleep 5
su you -c "fetchpop -d -o /var/spool/mail/you -l /home/you/fetch.log"
------------------- end of slip -----------------------------------------

------------------ slipoff ----------------------------------------------
#!/bin/sh
(( su you -c "fetchpop -q" ; sleep 2 ; dip -k)) > /dev/null 2>&1 )" > /dev/null 2>&1 &
echo "Done."
------------------ end of slipoff --------------------------------------

A4. How do I have fetchpop to retrieve mails from multiple hosts? 
    Can I just add additional lines in $HOME/.fetchhost file?

     Up-to fetchpop1.9, host info file should contain only a single host 
information. You cannot add more lines than one line there. 
You can create several host info files with -f flag and use them 
to fetch from other pop3 hosts.
1.10 or 2.1 will have entries for multiple hosts in a single host info file.

A5. Fetchpop doesn't seem to recognize which messages are new and
    which are read in my ISP server(it always retrieves all of them). 
    What is the deal?

     Please read the manual page. There are some sites that still use
old pop mail server. Those are not implemented for RFC1225, causing all
the mails in the remote server to be seen as new. Such servers are
in.popd version 1.004 and the one displays greeting '+OK "BOP 'til ya drop" 
mailer version 0.9alpha'
Always use fetchpop with -r flags to remove the retrieved mails from 
such servers.

A6. How do I make fetchpop to work with xmailbox? (fetchpop version1.9)

    xmailbox usually watchs for the last access date and modification date 
on your $MAIL mailbox folder. If you compiled fetchpop with -DLogOnlyNew,
add 'xmailbox -file your_fetchpop_log_file' in .xinitrc or etc.

--
Seung-Hong Oh                      email: oh@cis.ohio-state.edu oh@ohlab.net
The Ohio State University CIS Dept phone: (614) 447-0164
3440 Olentangy River Rd. #8-L      http://www.cis.ohio-state.edu/~oh 
Columbus, OH 430202

EOT
fetchpop1.9/Makefile100644    764    764        5373  6164117267  12067 0ustar  ohoh# $Id: Makefile,v 1.9 1996/06/25 21:42:32 oh Exp $
#
# Take look at EXTRA OPTION below
# and also edit config.h file if you need.
# if you don't know what to do, don't worry about it. Just type 'make'

BINDIR=/usr/local/bin
MANDIR=/usr/local/man/man1

CC=gcc

CFLAGS= -g 
#CFLAGS= -O2 -m486 -pipe 
#CFLAGS= -O2 -m486 -fno-strength-reduce -Wall -pipe

#--------------------------------------------------------------
# Valid flags for EXTRA_OPTION
# -DHAVEMDA		- if you want to enable -m flag MDA.
# -DHAVEPROCMAIL	- if you want to enable -p flag 
#                         procmail support.
# -------------------------------------------------------------
# Log file preference
# -DLogShowfrom		- Shows From: and Subject: lines 
#			  of fetched messages in logging. 
# -DLogOnlyNew		- logging to a file only when there is
#                         new mails. don't log when there is no new mails. 
#                         Useful if you want to use biff or xmailbox
#                         with fetchpop.
#--------------------------------------------------------------
# For example,

#EXTRA_OPTION = 
#EXTRA_OPTION = -DHAVEMDA -DLogShowfrom 
#EXTRA_OPTION = -DHAVEPROCMAIL -DLogShowfrom 
EXTRA_OPTION = -DHAVEPROCMAIL -DHAVEMDA -DLogShowfrom -DLogOnlyNew 
#EXTRA_OPTION = -DHAVEPROCMAIL -DHAVEMDA -DLogShowfrom  

LIBS=

# -------- No need to edit anything below here ---------------------------
DEFTARGET=notes
OBJECTS=fetchpop.o pop.o retrieve.o socket.o 
start: $(DEFTARGET)
notes: 
	@echo "Did you check config.h?"
	@echo "If you did, just type:"
	@echo ""
	@echo "   make fetchpop       compile fetchpop."
	@echo "   su root"
	@echo "   make install        install the fetchpop and the man page."
	@echo "------------------------------------------------------------"
	@echo "   make all            compile both fetchpop and truncate."
	@echo "   make truncate       compile trucate."
	@echo "   make install.truncate  install truncate and the man page"
	@echo "   make clean          clean up object files."
	@echo "   make distclean      clean up everything except source codes"
all: fetchpop truncate
fetchpop: $(OBJECTS)
	$(CC) $(CFLAGS) ${EXTRA_OPTION} $(OBJECTS) -o fetchpop $(LIBS)
truncate: truncate.c
	$(CC) $(CFLAGS) truncate.c -o truncate
.c.o:
	$(CC) $(CFLAGS) ${EXTRA_OPTION} -c $<
fetchpop.o: fetchpop.c fetchpop.h config.h pop.h retrieve.h socket.h
pop.o: pop.c socket.h fetchpop.h config.h pop.h retrieve.h
retrieve.o: retrieve.c retrieve.h pop.h config.h
socket.o: socket.c socket.h 
install:
	install -c -s -m 0755 fetchpop $(BINDIR)
	install -c -m 0444 fetchpop.1L $(MANDIR)
install.truncate:
	install -c -s -m 0755 truncate $(BINDIR)
	install -c -m 0444 truncate.1L $(MANDIR)
clean:
	rm -f $(OBJECTS)
	rm -f core 
distclean:
	rm -f fetchpop truncate
	rm -f $(OBJECTS)
	rm -f core *~ 
fetchpop1.9/config.h100644    764    764        2141  6164112601  12016 0ustar  ohoh/*
 * $Id: config.h,v 1.9 1996/06/25 01:37:33 oh Exp $
 */

#define POP_PORT 110

  /* If you want 180 or 600 seconds, put "180" or "600" here. Don't put too 
   * low value.
   */
#define MINSLEEPSECOND	"300" 

  /* This is used only if the environment variable $MAIL is not defined.
   * Under HP-UX, it might be "/usr/mail" and under SUN, it might be "/var/mail"
   */
#define MAILSPOOLDIR "/var/spool/mail"

  /* If you want to compile fetchpop with -DHAVEMDA (-m flag support), 
   * change this to one of MDAs, such as deliver, sendmail, mail. 
   * Using mail is not recommended under Linux. 
   * Best of all, if you have the procmail package, 
   * don't worry about this and edit FORMAIL below. On most systems,
   * deliver is /usr/bin/deliver, sendmail is /usr/lib/sendmail, and
   * mail is /bin/mail
   */
#define DefaultMDA "/usr/lib/sendmail" 

  /* If you want to complie fetchpop with -DHAVEPROCMAIL  
   * (-p flag procmail support),
   * edit the FORMAIL to where the formail is. (Formail is the mail
   * (re)formatter that comes with the procmail package)
   */
#define FORMAIL "/usr/bin/formail" 

fetchpop1.9/fetchpop.c100444    764    764       37026  6164111040  12400 0ustar  ohoh/*
 * $Id: fetchpop.c,v 1.9 1996/06/26 01:27:09 oh Exp $
 *
 *    Copyright (C) 1996	Seung-Hong Oh
 *
 *  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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include "config.h"
#include "fetchpop.h"
#include "pop.h"

int readcfg(struct optrep *options, char rcfile[]);
int daemon_init(char *lockfile);
int do_kill(char *lockfile);
int cmdline(int argc, char **argv, struct optrep *options,char *lockfile);
int makecfg(struct optrep options);
void encryptit(char *to, char *from);
int decryptit(char *to, char *from);

#define VERSION "fetchpop 1.9 release"
#define DATE "Jun 1996"

int main(int argc, char** argv)
{
  char localhost[HOSTLEN];
  struct optrep options;
  char *lockfile;
  int prevmask, rpy;
  
  prevmask = umask(0077);

  gethostname(localhost,HOSTLEN);
  if ((lockfile = (char *) malloc( strlen(getenv("HOME")) + strlen("/.lockfetch-") + strlen(localhost)+ 1)) == NULL) {
    fprintf(stderr,"[-Error-] Cannot allocate memory for .lockfetch... Exiting.\n");
    exit(1);
  }
  strcpy(lockfile, getenv("HOME"));
  strcat(lockfile,"/.lockfetch-");
  strcat(lockfile,localhost);
  
  if ( (rpy = cmdline(argc, argv, &options,lockfile)) != 0 ) {
    free(lockfile);
    if (rpy == KILLED )
      exit(0);
    else
      exit(1);
  }
  
  if (makecfg(options) != 0) { 
    fprintf(stderr,"[-Error-] creating config file for you.\nPerhaps you don't have write permission?\n");
    free(lockfile);
    exit(1);
  }
  
  if (readcfg(&options, options.rcfile) != 0) {
    fprintf(stderr,"Run fetchpop again to create the new correct host info file.\n");
    if (options.daemon)
      remove(lockfile); 
    free(lockfile);
    exit(2);
  }
  
  if (options.whichdeliver != 4) {
    fprintf(stderr,"\r%s, by Seung-Hong Oh.\n", VERSION);
    if ((options.whichdeliver==0) || (options.whichdeliver==1))
      fprintf(stderr,"using mailbox folder %s\n",options.output);
#ifdef HAVEMDA
    else if ( options.whichdeliver == 2) 
      fprintf(stderr,"using %s for mail delivery.\n",DefaultMDA);
#endif
#ifdef HAVEPROCMAIL
    else if ( options.whichdeliver == 3)
      fprintf(stderr,"using procmail for mail  delivery.\n");
#endif
    else
      ;
    if ( options.check == 2)
      fprintf(stderr,"Fetching all mail from the remote server.\n");
    else if ( options.check == 1)
      fprintf(stderr,"Checking mail, not fetching.\n");
    else if ( options.check == 3)
      fprintf(stderr,"Fetching message #%d only.\n",options.msgnum);
    else
      ;
    if (options.toplines)
      fprintf(stderr,"Retrieving at most %d lines of each mail message.\n",options.toplines);
    
    if (options.daemon)     
      fprintf(stderr,"Running fetchpop in the background every %d seconds.\r\n", options.sleep_time);
  }
  if (options.daemon) 
    if (daemon_init(lockfile) != 0) {
      free(lockfile);
      exit(1);
    }
  while (1) {
    rpy = pop(&options);
    if ( options.daemon )
      sleep(options.sleep_time);
    else 
      break; 
  }
  free(lockfile);
  umask(prevmask);
  exit(rpy);
}

int cmdline(int argc, char **argv, struct optrep *options, char *lockfile)
{
  int c;
  signed char iserror = 0 ;
  signed char flag1 = 0;
  signed char flag2 = 0;
  int version = 0;
  extern int optind, opterr;
  extern char *optarg;
  FILE *tmpfd;

  bzero(options,sizeof(struct optrep));

  while( !(iserror) && (c=getopt(argc,argv,"kqrdcampvhxbe:t:f:o:g:l:")) != EOF) {
    switch(c) {
    case 'k': case 'q':
      do_kill(lockfile);
      return(KILLED);
      break;
    case 'r':
      options->remove = 1;
      break;
    case 'x':
      if (!flag1 && !flag2) {
	options->remove = 2;
	if (!flag1)
	  ++flag1;
	else
	  ++flag2;
      } else
	iserror++;
      break;
    case 'd':
      options->daemon = 1;
      break;
    case 'c':
      if ( !flag2 ) {
	flag2++;
	options->check = 1;
      } else
	iserror++;
      break;
    case 'a':
      if ( !flag2 ) {
	flag2++;
	options->check = 2;
      } else
	iserror++;
      break;
    case 'b':
      options->hack_addresses = 1;
      break;
#ifdef HAVEMDA
    case 'm':
      if ( !flag1 ) {
	flag1++;
	options->whichdeliver = 2;
      } else
	iserror++;
      break;
#endif
#ifdef HAVEPROCMAIL
    case 'p':
      if (!flag1) {
	flag1++;
	options->whichdeliver = 3;
      } else
	iserror++;
      break;
#endif
    case 'v':
      version = 1;
      break;
    case 'h':
      iserror++;
      break;
    case 'e':
      options->remove = 3;
      options->msgnum2 = atoi(optarg);
      break;
    case 't':
      options->toplines = atoi(optarg);
      if ( options->toplines <= 0 ) {
	fprintf(stderr,"The number must be positive.\n");
	iserror++; 
      }
      break;
    case 'f':
      options->altrc = 1;
      strcpy(options->rcfile,optarg);
      break;
    case 'o':
      if  (!flag1) { 
	strcpy(options->output,optarg);
	if ( (strcmp(options->output,"stdout") == 0 ) ||( (strcmp(options->output,"-") == 0 )))
	  options->whichdeliver = 4;
	else
	  options->whichdeliver = 1;
	flag1++;
      } else {
	fprintf(stderr,"-o can not be used with -m, -p and -c flag.\n");
	iserror++;
      }
      break;
    case 'g':
      if (!flag2) {
	flag2++;
	options->check = 3;
	options->msgnum = atoi(optarg);
	if ((options->msgnum ) < 1 )
	  iserror++;
      } else
	iserror++;
      break;
    case 'l':
      options->logging = 1;
      strcpy(options->logfile,optarg);
      /* fopen with "a" does not create the file on my system. Strange.
         so I create here if the log file does not exist. */
      if ( access(options->logfile,F_OK) != 0 ) {
	if ( (tmpfd=fopen(options->logfile,"w")) != NULL )
	  fclose(tmpfd);
      }
      break;
    default:
      iserror++;
      break;
    }
  }

  if (options->whichdeliver == 0) {
    if (getenv("MAIL") != NULL)
      strcpy(options->output,getenv("MAIL"));
    else {
      strcpy(options->output,MAILSPOOLDIR);
      strcat(options->output,"/");
      strcat(options->output,whoami);
    }
  }
  
  if ( options->altrc == 0 ) {
    strcpy(options->rcfile,getenv("HOME"));
    strcat(options->rcfile,"/.fetchhost");
  }
  
  if ( version ) {
    fprintf(stderr,"FETCHPOP Version and Compile-time Configuration Information:\n\n");
    fprintf(stderr,"\t%s, %s\n",VERSION,DATE);
    fprintf(stderr,"\tCopyrigt (c) 1996 Seung-Hong Oh \n");
    fprintf(stderr,"\t------------------------------------------\n");
    fprintf(stderr,"\t Default deliver: ");
    fprintf(stderr,"Direct modifying mailbox\n");
    fprintf(stderr,"\t MDA (-m flag) support: ");
#ifdef HAVEMDA
    fprintf(stderr,"Use %s\n",DefaultMDA);
#else
    fprintf(stderr,"DISABLED\n");
#endif
    fprintf(stderr,"\t Procmail(-p flag) support: ");
#ifdef HAVEPROCMAIL
    fprintf(stderr,"Use %s\n",FORMAIL);
#else
    fprintf(stderr,"DISABLED\n");
#endif
    fprintf(stderr,"\t Mail spool directory: %s\n",MAILSPOOLDIR);
    fprintf(stderr,"\t Log file: ");
#ifdef LogShowfrom
    fprintf(stderr,"Show From and Subject lines.\n");
#else
    fprintf(stderr,"Don't show from and subject lines.\n");
#endif
#ifdef LogOnlyNew
    fprintf(stderr,"\t           Logging only when there is new mail.\n");
#else
    fprintf(stderr,"\t           Logging all the time.\n");
#endif    
    fprintf(stderr,"\t Minimum sleep second: %s\n",MINSLEEPSECOND);
    return(1);
  }

  if (optind < argc )
    iserror++;
  else
    ;
  
  if (iserror) {
    fprintf(stderr,"usage: fetchpop [-v] [-k | -q] [-d] [-r] [-x | -e msgID] [-c | -a | -g msg ID] [-h] [-t limit] [-f alternative rcfile] [-l log file] [");
#ifdef HAVEMDA
    fprintf(stderr," -m | ");
#endif
#ifdef HAVEPROCMAIL
    fprintf(stderr,"-p | ");
#endif
    fprintf(stderr,"-o user mailfolder]\n");
    fprintf(stderr,"  -v   : show version and compile-time configuration information.\n");
    fprintf(stderr,"  -k,-q: kill the fetchpop daemon process.\n");
    fprintf(stderr,"  -d   : run fetchpop as a daemon process.\n");
    fprintf(stderr,"  -r   : removes the mail messages from remote server after retrieving them.\n");
    fprintf(stderr,"  -x   : delete all the old messages. No retrieval is done.\n");
    fprintf(stderr,"  -e   : delete a specific message.\n");
    fprintf(stderr,"  -c   : check how many messages are in the pop server. No retrueval is done.\n");
    fprintf(stderr,"  -a   : retrieve all the messages, including old mails.\n");
    fprintf(stderr,"  -g   : get a specific message only. Number must be positive.\n");
    fprintf(stderr,"  -t   : retrieve only the given number of lines for each message.\n");
    fprintf(stderr,"  -b   : hack local addresses in From and Cc lines.\n"); 
    fprintf(stderr,"  -f   : specify different config file other than $HOME/.fetchhost.\n");
#ifdef HAVEMDA
    fprintf(stderr,"  -m   : use %s for mail delivery.\n",DefaultMDA);
#endif
#ifdef HAVEPROCMAIL
    fprintf(stderr,"  -p   : use procmail for mail delivery.\n");
#endif
    fprintf(stderr,"  -o   : write the fetched message to user defined mail folder.\n");
    fprintf(stderr,"  -o - : (-o stdout) write the fetched message to standard output device.\n");
    fprintf(stderr,"  -l   : log fetchpop session to log file.\n");
    fprintf(stderr,"  -h   : show usage help.\n");
  }
  return iserror;
}

int readcfg(struct optrep *options, char rcfile[])
{
  FILE *cfg;
  char buffer[MSGBUFLEN];
  struct stat statbuf;
  char host[HOSTLEN];
  char user[USERIDLEN];
  char password[PASSWORDLEN];
  char decrypted[ENCRYPTLEN];

  
  if (lstat(rcfile, &statbuf) < 0 ) {
    fprintf(stderr,"The file %s not found.\n", rcfile);
    return(-1);
  } else
    if (statbuf.st_mode & ~(S_IFREG | S_IRUSR | S_IWUSR )) {
      fprintf(stderr,"%s: file permission is dangerous. Remove %s first.\n",rcfile,rcfile);
      return -1 ;
    }
  
  if ((cfg = fopen(rcfile,"r")) == NULL) {
    fprintf(stderr,"can not open file %s\n", rcfile);
    return -1;
  }
  
  if ((fgets(buffer, MSGBUFLEN, cfg)) == NULL) {
    fprintf(stderr, "\rCannot get content of %s. Remove %s first.\n", rcfile, rcfile);
    fclose(cfg);
    return -1;
  }
  
  if (sscanf(buffer,"%s %s %s %d", host, user, password, &(options->sleep_time)) != 4 ) {
    fclose(cfg);
    fprintf(stderr,"\r%s is in the wrong format. Remove %s first.\n",rcfile,rcfile);
    return -1;
  }

  strcpy(options->host,host);

  decryptit(decrypted,user);
  strcpy(options->userid, decrypted);

  decryptit(decrypted,password);
  strcpy(options->password, decrypted);

  if (options->sleep_time < atoi(MINSLEEPSECOND)) {
    fprintf(stderr,"\r\nsleepsecond %d seconds is BELOW MINSLEEPSECOND.\nContact Adminstrator for this issue.\nAssuming sleepsecond to be %s\n", options->sleep_time,MINSLEEPSECOND);
    options->sleep_time = atoi(MINSLEEPSECOND);
  }

  fclose(cfg);
  return 0;
}

int makecfg(struct optrep options)
{
  FILE *fd;
  char rcfile[PATHLEN];
  char host[HOSTLEN];
  char user[USERIDLEN];
  char password[PASSWORDLEN];
  char sleeptime[32];
  char encrypted[ENCRYPTLEN];
  
  if ( options.altrc ) 
    strcpy(rcfile,options.rcfile);
  else {
    strcpy(rcfile,getenv("HOME"));
    strcat(rcfile,"/.fetchhost");
  }
  
  if (access (rcfile, F_OK)) {
    fprintf(stderr,"The %s file does not exit. I will make it for you.\n",rcfile);
    printf("Enter the pop server address.\nPop3 Host: ");
    fgets(host,HOSTLEN,stdin);
    host[strlen(host)-1] = '\0';
    printf("Enter login name on %s\nUser: ",host);
    fgets(user,USERIDLEN,stdin);
    user[strlen(user)-1] = '\0';
    printf("Enter the password for user %s\nPassword: ",user);
    fgets(password,PASSWORDLEN,stdin);
    password[strlen(password)-1] = '\0';
    printf("Enter time for fetchpop to sleep(>=%s) when running as daemon (-d flag).\nSleep time(in seconds): ",MINSLEEPSECOND);
    fgets(sleeptime,32,stdin);
    
    if (atoi(sleeptime) < atoi(MINSLEEPSECOND)) {
      fprintf(stderr,"\r\nThe sleep time you entered is below MINSLEEPSECOND %s.\nSaving it as %s\n",MINSLEEPSECOND,MINSLEEPSECOND);
      strcpy(sleeptime, MINSLEEPSECOND);
    }

    if (( fd = fopen(rcfile,"w") ) == NULL ) {
      return 2;
    }
    fputs(host,fd); fputc(' ',fd);
    encryptit(encrypted,user); fputs(encrypted,fd); fputc(' ',fd);
    encryptit(encrypted,password); fputs(encrypted,fd); fputc(' ',fd);
    fputs(sleeptime,fd);
    
    fclose(fd);
  }
  return 0;
}

int do_kill(char *lockfile)
{
  pid_t pid;
  FILE* fd;
  
  if ( (fd = fopen(lockfile, "r")) == NULL ) {
    fprintf(stderr,"No daemon is running\n");
    return(KILLED);
  }
  
  fscanf(fd,"%d",&pid);
  fprintf(stderr,"Killing fetchpop at PID %d\n",pid);
  if ( kill(pid,SIGKILL) < 0 )
    fprintf(stderr,"Error killing the process %d\n.",pid);
  else
    fprintf(stderr,"Done. See you later...\n");
  
  fclose(fd);
  remove(lockfile);
  return KILLED;
}

int daemon_init(char *lockfile)
{
  pid_t pid;
  FILE *tmpfd;
  
  if (( pid = fork () ) < 0 )
    return (1);
  else if ( pid >0 )
    exit (0); 
  else
    ;
  
  if ( (pid = setsid()) == -1 ) {
    fprintf(stderr,"\r\nError calling setsid\n");
    return(1);
  }
  
  if (!access(lockfile,F_OK)) {
    tmpfd = fopen(lockfile, "r");
    fscanf(tmpfd,"%d",&pid);
    fprintf(stderr,"\r\nI found that another fetchpop daemon is running at PID %d.\nIf you are sure that this is incorrect, remove the file %s.\n",(int) pid, lockfile);
    return 1;
  }
  if ((tmpfd = fopen(lockfile,"w")) != NULL) {
    fprintf(tmpfd,"%d",pid);
    fclose(tmpfd);
  }
  return 0;
}

/* 
   There are public libraries for encrytion and decrytion. Those are
   too big and too complicated for simple encrytions, though.
   I wrote encryptit and decryptit functions by hacking
   uuencode and uudecode, which are written by Ian Lance Taylor.
   So I believe the credit for these 2 functions should go to him.
   I will implement these functions with my own algorithm sometime later.
   Actually, it is not necessary to encrypt $HOME/.fetchhost file 
   because it already has permission 600, though. 
*/

#define ENC(c) ((c) ? ((c) & 077) + ' ' +2 : '`' + 2)
#define DEC(c) ((((c) - ' ') & 077) -2)

void encryptit(char to[], char from[])
{
  
  int ch,n;
  char *p;
  int index = 0;
  
  bzero(to,ENCRYPTLEN);
  n = strlen(from);
  to[index++] = ENC(n);
  for (p = from; n > 0; n -= 3, p += 3) {
    ch = *p >> 2;
    ch = ENC (ch);
    to[index++] = ch;
    ch = ((*p << 4) & 060) | ((p[1] >> 4) & 017);
    ch = ENC (ch);
    to[index++] = ch;
    ch = ((p[1] << 2) & 074) | ((p[2] >> 6) & 03);
    ch = ENC (ch);
    to[index++] = ch;
    ch = p[2] & 077;
    ch = ENC (ch);    to[index++] = ch;
  }
}

int decryptit(char to[], char from[])
{
  int ch,n;
  char *p;
  int index = 0;
   
  bzero(to,ENCRYPTLEN);
  p = from;
  n = DEC (*p);
  if (n <= 0)
    return 1;
  for (++p; n > 0; p += 4, n -= 3) {
    if (n >= 3) {
      ch = DEC (p[0]) << 2 | DEC (p[1]) >> 4;
      to[index++] = ch;
      ch = DEC (p[1]) << 4 | DEC (p[2]) >> 2;
      to[index++] = ch;
      ch = DEC (p[2]) << 6 | DEC (p[3]);
      to[index++] = ch;
    } else {
      if (n >= 1) {
	ch = DEC (p[0]) << 2 | DEC (p[1]) >> 4;
	to[index++] = ch;
      }
      if (n >= 2) {
	ch = DEC (p[1]) << 4 | DEC (p[2]) >> 2;
	to[index++] = ch;
      }
    }
  }
  return 0;
}

fetchpop1.9/fetchpop.h100444    764    764        3006  6164111042  12356 0ustar  ohoh/*
 * $Id: fetchpop.h,v 1.9 1996/06/26 01:27:12 oh Exp $
 *
 *    Copyright (C) 1996	Seung-Hong Oh
 *
 *  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.
 *
 */

#define POPBUFLEN	512
#define MSGBUFLEN	1024
#define POP_ERROR	6
#define WRONG_PROTOCOL 	7
#define	DOWN		8
#define SHIT		-6
#define KILLED          20
#define	PATHLEN		256
#define HOSTLEN         128 
#define USERIDLEN       32
#define PASSWORDLEN     32
#define ENCRYPTLEN      45

struct optrep {
  signed char top;
  int toplines;
  signed char check; /* 1 = check, 2 = all ,3 = specific msg */
  unsigned int msgnum;
  unsigned int msgnum2;
  signed char whichdeliver;
  char output[PATHLEN];
  signed char logging;
  char logfile[PATHLEN];
  signed char altrc;
  char rcfile[PATHLEN];
  signed char remove;
  signed char daemon;
  unsigned int sleep_time;
  char host[HOSTLEN];
  char userid[USERIDLEN];
  char password[PASSWORDLEN];
  signed char hack_addresses;
};


fetchpop1.9/pop.c100444    764    764       21107  6164111046  11365 0ustar  ohoh/* $Id: pop.c,v 1.9 1996/06/26 01:27:17 oh Exp $
 *
 *  Copyright (C) 1996	Seung-Hong Oh
 *
 *  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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <pwd.h>

#include "fetchpop.h"
#include "socket.h"
#include "config.h"
#include "pop.h"
#include "retrieve.h"

int pop(struct optrep *options)
{
  int rpy,newmsg;
  int sockfd;
  int howmany, last, index;
  time_t now;
  FILE *logfd = NULL;
  char buf[POPBUFLEN];
  
  if ( options->logging ) 
    if ( (logfd = fopen(options->logfile,"a")) == NULL ) {
      perror("opening logfile");
      fprintf(stderr,"continuing without logging.\n");
      options->logging = 0;
    }

  now = time(NULL);
  if ( (sockfd=get_connect(options->host, POP_PORT)) < 0 )  {
    if ( sockfd == SOCK_NOEXIST ) 
      sprintf(buf,"[-Error-] %s does not exist.\n",options->host);
    else
      sprintf(buf,"[-Error-] %s is not responding at %s",options->host,ctime(&now));
    printmsg(buf,options->logging, options->daemon, logfd, 1, options->whichdeliver==4);
    return DOWN;
  }
  if ( (rpy = get_reply(sockfd, buf) ) ) {
    sprintf(buf,"[-Error-] Problem with host %s. Server closed connection.\n",options->host);
    printmsg(buf, options->logging, options->daemon, logfd, 1, options->whichdeliver == 4);
    close(sockfd);	
    return rpy;
  }

#ifndef LogOnlyNew
  sprintf(buf,"Connected to pop server %s at %s",options->host,ctime(&now));
  printmsg(buf, options->logging, options->daemon, logfd, 0, options->whichdeliver == 4);
#endif

  if ((rpy = pop_auth(sockfd, options->userid, options->password, options->logging, options->daemon, logfd)))  {
    printmsg("[-Error-] Authentication failed. Disconnecting from pop server.\n",options->logging, options->daemon, logfd, 1, options->whichdeliver==4);
    pop_quit(sockfd);
    close(sockfd);
    return rpy;
  }

  if ( (rpy = pop_stat (sockfd, &howmany)) )  {
    printmsg("[-Error-] Getting POP status. Disconnecting from pop server.\n",options->logging, options->daemon, logfd,1, options->whichdeliver==4);
    pop_quit(sockfd);
    close(sockfd);
    return rpy;
  }

  if ( (rpy=pop_last(sockfd,&last)) != 0 ) {
    printmsg("[-Error-] Getting status of LAST read mail. Disconnecting from the pop server.\n",options->logging, options->daemon, logfd,1, options->whichdeliver==4);
    pop_quit(sockfd);
    close(sockfd);
    return rpy;
  }

  newmsg = howmany-last;

#ifndef LogOnlyNew
  sprintf(buf,"There are %d new messages and total of %d messages.\n",newmsg,howmany);
  printmsg(buf,options->logging, options->daemon, logfd, 0, options->whichdeliver == 4);
  rpy = 0;
#else
  if (!options->daemon)
    printf("There are %d new messages and total of %d messages.\n",newmsg,howmany);
#endif
  if ((options->remove == 2) && (last > 0)) {
    sprintf(buf,"[Remove] Removing old messages from  #1 to #%d in the remote server.\n",last);
    printmsg(buf,options->logging,options->daemon,logfd,0, options->whichdeliver == 4);
    for ( index = 1 ; index <= last ; index++ ) {
      if ( ( rpy = pop_dele(sockfd, index)) != 0) {
	printmsg("[-Error-] deleting old messages. Reseting and Disconnecting.\n",options->logging,options->daemon,logfd,1,options->whichdeliver == 4);
	pop_rset(sockfd);
	pop_quit(sockfd);
	close(sockfd);
	return rpy;
      }
      sprintf(buf,"[Remove #%2d] old message #%2d was removed in the remote server.\n",index,index);
      printmsg(buf,options->logging,options->daemon,logfd,0, options->whichdeliver == 4);
    }
  } else if ( (options->remove == 2 ) && ( last <= 0 ) ) 
    printmsg("[-Warning-] You do not have old messages. I won't delete new messages.\n",options->logging,options->daemon,logfd,0, options->whichdeliver == 4);
  else if ( (options->check == 0) && ( newmsg > 0) )
    rpy = fetchmail( options, sockfd, howmany, last, logfd);
  else if ( ( options->check == 2 )&&  ( howmany>0 ) )
    rpy = fetchmail( options, sockfd, howmany, last, logfd);
  else if ( ( options->check == 3 ) && ( howmany>=options->msgnum) )
    rpy = fetchmail( options, sockfd, options->msgnum, options->msgnum-1, logfd);
  else
    ;
  if ( rpy ) 
    return 1;
  if ((options->remove == 3) && (last > 0)) {
    sprintf(buf,"[Remove #%2d] Removing the specific message #%2d in the remote server.\n",options->msgnum2, options->msgnum2);
    printmsg(buf,options->logging,options->daemon,logfd,0, options->whichdeliver == 4);
    if ((rpy = pop_dele(sockfd, options->msgnum2)) != 0) {
      printmsg("[-Error-] deleting old messages. Reseting and Disconnecting.\n",options->logging,options->daemon,logfd,1,options->whichdeliver == 4);
      pop_rset(sockfd);
      pop_quit(sockfd);
      close(sockfd);
      return rpy;
    }
  }

  if ((rpy=pop_quit(sockfd)))
    printmsg("[-Error-] Disconnecting.\n",options->logging, options->daemon, logfd, 1, options->whichdeliver==4);
  
  if (options->logging)
    fclose(logfd);
  close(sockfd);
  return 0;
}


int get_reply(int sockfd, char *argbuf)
{ 
  int rpy;
  
  if (!readsock(sockfd, argbuf, POPBUFLEN)) {
#ifdef DEBUG
    printf("argbuf is %s\n", argbuf);
#endif
    if ( argbuf[0] != '+' && argbuf[0] !='-' )
      return 1;
    
    if (!strncmp(argbuf,"+OK",3))
      rpy = 0;
    else if (!strncmp(argbuf,"-ERR",4))
      rpy= POP_ERROR;
    else
      rpy = WRONG_PROTOCOL;
  } else
    rpy = DOWN;
  return rpy;
}

int pop_auth(int sockfd, char *userid, char *passwd, short int logging, short int daemon, FILE *fd)
{
  int rpy;
  char buf[POPBUFLEN];
  
    sockprintf(sockfd, "USER %s\r\n",userid);
    if ((rpy= get_reply(sockfd, buf)) == 0 ) {
      sockprintf( sockfd, "PASS %s\r\n",passwd);
      rpy= get_reply(sockfd, buf);
    } else 
	;
    if ( rpy ) 
      printmsg(buf,logging,daemon,fd, 0, 0);
    return rpy;
}

int pop_quit (int sockfd)
{
  /*  fd_set rfds;
    struct timeval tv; 

     FD_ZERO(&rfds);
     FD_SET(sockfd, &rfds);
     tv.tv_sec =0;
     tv.tv_usec=0;
     retval = select(10,NULL,&rfds,&rfds,&tv);
     */
    
  if (writeln(sockfd,"QUIT\r\n")) 
    return 1;
  else 
    return 0;
}

int pop_rset (int sockfd)
{
  if (writeln(sockfd,"RSET\r\n")) 
    return 1;
  else 
    return 0;
}

int pop_stat ( int sockfd, int *msgcount)
{
  int rpy;
  char buf[POPBUFLEN];
  
  writeln(sockfd, "STAT\r\n");
  rpy = get_reply(sockfd, buf);
  if (! rpy )
    sscanf(buf,"%*s %d %*d", msgcount);
  
  return rpy;
}

int pop_retr ( int sockfd, int msgnum)
{
  char buf[POPBUFLEN];
  
  sockprintf(sockfd, "RETR %d\r\n", msgnum);
  return(get_reply(sockfd, buf));
}

int pop_dele ( int sockfd, int msgnum)
{
  char buf[POPBUFLEN];
  
  sockprintf(sockfd, "DELE %d\r\n", msgnum);
  return(get_reply(sockfd, buf));
}

int openmbox (signed char deliver, char *output)
{
  int fd;
  struct flock lock;
  
  if (deliver == 4 )
    fd = 1;
  else 
    if ((fd=open(output, O_CREAT | O_WRONLY | O_APPEND, 0600) ) >= 0 ) {
      lock.l_type = F_WRLCK;
      lock.l_start = 0;
      lock.l_whence = SEEK_SET;
      lock.l_len = 0;
      if  (fcntl(fd,F_SETLKW,&lock) < 0 ) { /* No deadlock */
	close(fd);
	fd = -1;
      }
    }
  return fd;
}

int closembox ( int fd )
{
  int err=0;
  
  if ( fd != 1 )
    err = close(fd);
  
  if ( err )
    perror ("closembox");
  return err;
}

int pop_top(int sockfd, int num, int lines)
{
  char buf[POPBUFLEN];
  
  sockprintf(sockfd,"TOP %d %d\r\n", num, lines);
  return get_reply(sockfd,buf);
}

int pop_last(int sockfd, int *lastread)
{
  int rpy;
  char buf[POPBUFLEN];
  
  writeln(sockfd,"LAST\r\n");
  rpy=get_reply(sockfd,buf);
  if (!rpy)
    sscanf(buf,"%*s %d",lastread);
  return rpy;
}

void printmsg(char *msg, signed char logging, signed char daemon, FILE *logfd, unsigned short int err, short int tostdout)
{
  if ( logging == 1) {
    fprintf(logfd,"%s",msg);
    if ( err )
      fclose(logfd);
  }
  else if (tostdout != 0 ) ; 
  /* if mails are directed to standard output, fetchpop should not print anything to stdout besides the fetched mails */
  else if ( !daemon ) {
    if ( err )
      fprintf(stderr,"%s",msg);
    else 
      printf("%s",msg);
  } else
    ;
}
fetchpop1.9/pop.h100444    764    764        2630  6164111047  11353 0ustar  ohoh/*
 * $Id: pop.h,v 1.9 1996/06/26 01:27:19 oh Exp $
 *
 *  Copyright (C) 1996	seung-hong oh
 *
 *  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.
 */

#define whoami (getpwuid(getuid())->pw_name)

int pop(struct optrep *options);
int get_reply(int sockfd, char *argbuf);
int pop_auth(int sockfd, char *userid, char *passwd, short int logging, short int daemon, FILE *fd);
int pop_quit(int sockfd );
int pop_stat(int sockfd, int *howmany);
int pop_retr(int sockfd, int msgnum);
int openmbox(signed char deliver, char *output);
int closembox(int fd );
int pop_dele(int sockfd, int msgnum);
int pop_top(int sockfd, int num, int lines);
int pop_last(int sockfd, int *lastread);
void printmsg(char *msg, signed char logging, signed char daemon, FILE *logfd, unsigned short int err, short int tostdout);
int pop_rset(int sockfd);

fetchpop1.9/retrieve.c100444    764    764       23214  6164111054  12414 0ustar  ohoh/*
 * $Id: retrieve.c,v 1.9 1996/06/26 01:27:22 oh Exp $
 *
 *  Copyright (C) 1996	Seung-Hong Oh
 *
 *  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 <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <pwd.h>
#include <sys/types.h>

#include "fetchpop.h"
#include "socket.h"
#include "pop.h"
#include "config.h"
#include "retrieve.h"
#include "ctype.h"

static void reply_hack(char *after, const char *before, const char *host); 

int fetchmail(struct optrep *options, int sockfd, int howmany, int lastread, FILE *logfd)
{
  int rpy, index; 
  int start = lastread+1;
  char buf[POPBUFLEN];
  unsigned long int howlong;
#ifdef LogOnlyNew
  time_t now;
#endif

  if ( options->check == 2 ) 
    start = 1;
  for ( index = start ; index <= howmany ; index ++ ) {
    if ( options->toplines )
      rpy = pop_top(sockfd,index,options->toplines);
    else
      rpy = pop_retr(sockfd,index);
    if ( rpy != 0 ) {
      sprintf(buf,"[-Error-] RETR/TOP command. Your mail remains in %s.\nDisconnecting from the pop server.\n",options->host);
      printmsg(buf,options->logging,options->daemon,logfd,1, options->whichdeliver==4);
      pop_quit(sockfd);
      close(sockfd);
      return 1;
    }
    rpy=pop_delivermsg(options,sockfd, logfd, &howlong,index);
    if ( rpy < 0 ) {
      if ( rpy == SHIT )
	printmsg("[-Error-] Shit happened while sending mail with MDA. You will get a bogus message. Just disregard it. Disconnecting from the pop server\n",options->logging,options->daemon, logfd, 1, options->whichdeliver==4);
      else
	printmsg("[-Error-] Retrieving mail. Resetting mail status. Disconnecting from the pop server\n",options->logging,options->daemon, logfd, 1, options->whichdeliver==4);
      rpy =pop_rset(sockfd);
      pop_quit(sockfd);
      close(sockfd);
      return 1;
    }

#ifndef LogOnlyNew
    sprintf(buf,"[Message #%2d] fetched (%d lines %lu characters).\n",index,rpy,howlong);
    printmsg(buf,options->logging, options->daemon, logfd, 0, options->whichdeliver == 4);
#else
    now = time(NULL);
    sprintf(buf,"[Message #%2d] fetched (%d lines %lu characters). %s",index,rpy,howlong,ctime(&now));
    printmsg(buf,options->logging, options->daemon, logfd, 0, options->whichdeliver == 4);
#endif

    if ( options->remove==1 ) {
      if ((rpy = pop_dele(sockfd, index)) ) {
	printmsg("[-Error-] Deleting mail on the remote server.\n",options->logging, options->daemon, logfd, 1, options->whichdeliver==4);
	pop_quit(sockfd);
	close(sockfd);
	return 1;
      } else {
	sprintf(buf,"[Remove #%2d] Message #%d was removed on the remote server.\n",index,index);
	printmsg(buf,options->logging,options->daemon,logfd,0, options->whichdeliver == 4);
      }
    }
  }
  
#ifndef NODETAILLOG
  if ( options->whichdeliver == 2 ) {
    sprintf(buf,"%s was used to deliver mail.\n",DefaultMDA);
    printmsg(buf,options->logging, options->daemon, logfd, 0, options->whichdeliver == 4);
  } else if ( options->whichdeliver == 3 )
    printmsg("procmail/formail was used to deliver mail.\n",options->logging, options->daemon, logfd,0, options->whichdeliver == 4);
  else {
    sprintf(buf,"Mail was appended to mailbox folder %s.\n",options->output);
    printmsg(buf,options->logging, options->daemon, logfd,0, options->whichdeliver == 4);
  }
#endif
  
  return 0;
}

/* This function reply_hack was written by Eric S. Raymond. Also He fixed 
   my Enlish in the man page.
   He made patches to popclient3.0b4 to add fetchpop's features and behavior.
   Now, he is a new maintainer of popclinet. So don't get suprised when you
   see fetchpop and upcomming popclient are similar in terms of
   behavior and features.
*/
static void reply_hack(char *after, const char *before, const char *host)
/* hack local mail IDs -- code by Eric S. Raymond 20 Jun 1996 */
{
  const char *from;
  int state = 0;

  for (from = before; *from; from++)
  {
    switch (state)
      {
      case 0:   /* before header colon */
        if (*from == ':')
          state = 1;
        break;

      case 1:   /* we've seen the colon, we're looking for addresses */
        if (*from == '"')
          state = 2;
        else if (*from == '(')
          state = 3;    
        else if (*from == '<' || isalnum(*from))
          state = 4;
        break;

      case 2:   /* we're in a quoted human name, copy and ignore */
        if (*from == '"')
          state = 1;
        break;

      case 3:   /* we're in a parenthesized human name, copy and ignore */
        if (*from == ')')
          state = 1;
        break;

      case 4:   /* the real work gets done here */
        /*
         * We're in something that might be an address part,
         * either a bare unquoted/unparenthesized text or text
         * enclosed in <> as per RFC822.
         */
        /* if the address part contains an @, don't mess with it */
        if (*from == '@')
          state = 5;

        /* If the address token is not properly terminated, ignore it. */
        else if (*from == ' ' || *from == '\t')
          state = 1;

        /*
         * On proper termination with no @, insert hostname.
         * Case '>' catches <>-enclosed mail IDs.  Case ',' catches
         * comma-separated bare IDs.  Cases \r and \n catch the case
         * of a single ID alone on the line.
         */
        else if (strchr(">,\r\n", *from))
        {
          strcpy(after, "@");
          strcat(after, host);
          after += strlen(after);
          state = 1;
        }

        /* everything else, including alphanumerics, just passes through */
        break;

      case 5:   /* we're in a remote mail ID, no need to append hostname */
        if (*from == '>' || *from == ',' || isspace(*from))
          state = 1;
        break;
      }

    /* all characters from the old buffer get copied to the new one */
    *after++ = *from;
  }
  *after++ = '\0';
}

int pop_delivermsg(struct optrep *options, int sockfd, FILE *logfd, unsigned long int *howlong, int index)
{
  char msgbuf[MSGBUFLEN];
  int lines = 0;
  time_t now;
  FILE *fp =NULL;
  int mfd=1;
  char deliverycommand[80];
  int length;
  int inheaders = 1;
  char msg[POPBUFLEN];

  (*howlong) = 0ul;
  signal(SIGINT,SIG_IGN);

  if ( ( options->whichdeliver == 0 ) || (options->whichdeliver == 1) || (options->whichdeliver==4)) {
    if ( (mfd=openmbox(options->whichdeliver,options->output)) < 0 ) {
      printmsg("[-Error-] opening mailbox folder.\n",options->logging, options->daemon, logfd, 0, options->whichdeliver==4);
      return -2;
    }
  } else { 
    if ( options->whichdeliver == 2 ) {
#ifdef HAVEMDA
      strcpy(deliverycommand, DefaultMDA);
      strcat(deliverycommand," ");
      strcat(deliverycommand, whoami);
#endif    
    }
    if ( options->whichdeliver == 3 ) {
#ifdef HAVEPROCMAIL
      strcpy(deliverycommand, FORMAIL);
      strcat(deliverycommand, " -s procmail");
#endif
    }
    
    if ((fp = popen(deliverycommand, "w")) == NULL ) {
      printmsg("[-Error-] Opening pipe to MDA.\n",options->logging, options->daemon, logfd, 0, options->whichdeliver==4);
      return -1;
    }
  }

  while (1) {
    if (sockgetline(sockfd,msgbuf,MSGBUFLEN) < 0) {
      return -10;
    }
    
    if (inheaders && msgbuf[0] == '\0')
      inheaders = 0;

    if (msgbuf[0] == '.') 
      if (msgbuf[1] == 0)
	break; 
    
    strcat(msgbuf,"\n");
    if (options->hack_addresses && inheaders) {
      if (!strncmp("From: ", msgbuf, 6)
	  || !strncmp("To: ", msgbuf, 4)
	  || !strncmp("Reply-", msgbuf, 6)
	  || !strncmp("Cc: ", msgbuf, 4)
	  || !strncmp("Bcc: ", msgbuf, 5)) {
	sprintf(msg, "[Message #%2d] Hacking header: %s", index,msgbuf);
#ifdef LogShowfrom
	printmsg(msg, options->logging, options->daemon, logfd, 0, options->whichdeliver==4);
#endif
	reply_hack(msg, msgbuf, options->host);
	(void) strcpy(msgbuf, msg);
      }
    }

    length = strlen(msgbuf);
    if ((options->whichdeliver==2) || (options->whichdeliver == 3)) { 
      if (fwrite(msgbuf,length,1,fp) != 1) {
	/* need to prevent sending bogus mails here. flush*/
	pclose(fp);
	return(SHIT);
      }
    } else {
      if ( ( lines==0 ) && (strncmp(msgbuf,"From ",5)) != 0 ) {
	now = time(NULL);
	sprintf(msg,"From fetchpop %s",ctime(&now));
	if (write(mfd, msg, strlen(msg)) < 0) {
	  return -1;
	}
      }
      
      if (write(mfd,msgbuf,length) < 0 ) {
	printmsg("[-Error-] Can not write to mail folder.\n",options->logging, options->daemon, logfd, 0, options->whichdeliver==4);
	return SHIT;
      }
    }
#ifdef LogShowfrom
    if ( inheaders && 
	 (!strncmp(msgbuf,"Subject: ",9) || ((!options->hack_addresses) && !strncmp(msgbuf,"From: ",6))) ) {
      sprintf(msg,"[Message #%2d] %s",index,msgbuf);
      printmsg(msg,options->logging, options->daemon, logfd, 0, options->whichdeliver==4);
    }
#endif
    
    lines++;
    (*howlong) += length;
  }
  
  if ((options->whichdeliver == 2) || (options->whichdeliver ==3))
    pclose(fp);
  else {
    if (write(mfd,"\n",1) < 0 ) { 
      printmsg("[-Error-] Can not write to mail folder.\n",options->logging, options->daemon, logfd, 0, options->whichdeliver==4);
      lines = -1;
    }
    closembox(mfd);
  }
  
  signal(SIGINT,SIG_DFL);  
  return lines;
}
fetchpop1.9/retrieve.h100444    764    764        1700  6164111056  12377 0ustar  ohoh/*
 * $Id: retrieve.h,v 1.9 1996/06/26 01:27:25 oh Exp $
 *
 *  Copyright (C) 1996	seung-hong oh
 *
 *  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.
 */


int fetchmail(struct optrep *options, int sockfd, int howmany, int last, FILE *logfd);
int pop_delivermsg(struct optrep *options, int sockfd, FILE *logfd, unsigned long int *howlong, int index);

fetchpop1.9/truncate.c100444    764    764        4407  6164100425  12377 0ustar  ohoh/* $Id: truncate.c,v 1.1 1996/02/12 23:58:15 oh Exp $
 *  Very Simple Program That Truncate File(s). 
 *
 *  There are many shell or perl scripts that do 'truncate'.
 *  If you already have it, use that.
 *  Just in case you don't have truncate,
 *  I included this to truncate the log file fetchpop creates with -l flag
 *
 *    Copyright (C) 1996        Seung-Hong Oh
 *
 *  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 <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
#include <sys/types.h>

#define whoami (getpwuid(getuid())->pw_name)

int main(int argc, char **argv)
{
    struct stat statbuf;
    int count = 1;
    int length = 0;

    if ( argc < 2 ) {    /* When there are no arguments, display usage info */
	fprintf(stderr,"Usages: %s [-l bytes] FILE...\nTruncate FILE(s).\n",argv[0]);
	return 1;
    }
    for ( ; count < argc; count ++) {
	if (!strcmp(argv[count],"-l")) { 
	    if ((length = atoi(argv[++count])) < 0 )
		length = 0;
	    ++count;
	}
	if (stat(argv[count], &statbuf) < 0) {
	    fprintf(stderr,"%s: %s: No such file.\n",argv[0],argv[count]);
	    return 1;
	} else {
	    if ((getuid() != 0) && (statbuf.st_uid != getuid())) /* checking ownership of the file */
		fprintf(stderr,"%s: %s: Not owned by %s.\n",argv[0],argv[count],whoami);
	    else if (S_ISLNK(statbuf.st_mode) /* is it really a regular file? */
		     || S_ISDIR(statbuf.st_mode) 
		     || S_ISBLK(statbuf.st_mode) 
		     || !S_ISREG(statbuf.st_mode))
		fprintf(stderr,"%s: %s: Not a regular file.\n",argv[0], argv[count]);
	    else 
		if (truncate(argv[count], length) < 0) {
		    perror("truncate");
		    return 1;
		}
	}
    }
    return 0;
}
fetchpop1.9/socket.c100444    764    764        7100  6164111061  12031 0ustar  ohoh/*
 * $Id: socket.c,v 1.9 1996/06/26 01:27:29 oh Exp $
 *
 *  Copyright (C) 1996	Seung-Hong Oh
 *
 *  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 <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <time.h>
#include <unistd.h>
#include <stdarg.h>
#include "socket.h"


int get_connect(char *serv_name, unsigned short  port_num)
{
    struct hostent *hp;
    struct sockaddr_in sa;
    int sockfd;

#ifdef SOCKDEBUG
    printf("FUNC get_connect: getting IP address of server %s\n", serv_name);
#endif
    if ((hp = gethostbyname( serv_name )) == NULL)
    {
#ifdef SOCKDEBUG
	printf("FUNC get_connect: Server does not exist: %s\n", serv_name);
#endif
	return SOCK_NOEXIST;
    }
#ifdef SOCKDEBUG
    printf("FUNC get_connect: initializing the socket address of server.\n");
#endif
    bzero(&sa, sizeof(sa));
    bcopy(hp->h_addr, (char *) &(sa.sin_addr), hp->h_length);
    sa.sin_family = AF_INET; 
    sa.sin_port = htons(port_num);

    if (( sockfd = socket(AF_INET, SOCK_STREAM, 0 )) < 0) {
#ifdef SOCKDEBUG
	perror(" FUNC: get_connect: socket cannot be opened\n");
#endif	
	return SOCK_ERROR;
    }
    if (connect(sockfd, (struct sockaddr *) &sa, sizeof(sa)) < 0 ) {
#ifdef SOCKDEBUG
	printf("FUNC: get_connect: can't connect to server: %s\n",serv_name );
#endif
	close(sockfd);
	return SOCK_NORESPOND;
    }
#ifdef SOCKDEBUG
    printf("FUNC get_connect: Successfully connected to server %s\n", serv_name);
    printf("FUNC get_connect: Socket number is %d\n", sockfd);
#endif
    return sockfd;
}

int writesock(int sockfd, char* buff, int bufflen)
{
#ifdef SOCKDEBUG
    printf("FUNC writesock: the buffer is %s\n", buff);
    printf("FUNC writesock: the bufferlen is %d\n", bufflen);
    printf("FUNC writesock: the sockfd is %d\n", sockfd);
#endif
    if ((send(sockfd, buff, bufflen, 0)) < 0) {
	printf("FUNC writesock: ERROR in writing line to socket.\n");
	return SOCK_ERROR;
    }
    return 0;
}


int readsock( int sockfd, char* buff, int bufflen)
{
    int count, len_of_line = 1;

    if (recv(sockfd, buff, bufflen, MSG_PEEK) < 1) {
#ifdef SOCKDEBUG
      printf( "FUNC readsock: Error in reading line from socket.\n");
#endif
      return SOCK_ERROR;
    }
    for ( count = 0; ( buff[count] != '\n' ) && ( count < ( bufflen -2 ) ) ; count++, len_of_line++)
      ;
    
    recv( sockfd, buff, len_of_line, 0 );
    buff[len_of_line] = '\0' ;
    
    return 0;
}

int writeln( int sockfd, char* buf)
{
  
  if ( (writesock(sockfd, buf, strlen(buf))) == 0 )
    return 0;
  else
    return SOCK_ERROR;
}

int sockprintf(int socket,char* format, ...)
{
  va_list ap;
  char buf[8192];
  
  va_start(ap, format);
  vsprintf(buf, format, ap);
  va_end(ap);
  return writesock(socket, buf, strlen(buf));
}

int sockgetline(int socket, char *buf, int len)
{
  while (--len)
    {
      if (read(socket, buf, 1) != 1)
	return -1;
      if (*buf == '\n')
	break;
      if (*buf != '\r') 
	buf++;
    }
  *buf = 0;
  return 0;
}
fetchpop1.9/truncate.1L100444    764    764         727  6164025213  12413 0ustar  ohoh.TH truncate 1L
.SH NAME
truncate \- truncate file(s).
.SH SYNOPSIS
.B truncate 
[\fB-l\fI size\fR\|] [file...]
.SH DESCRIPTION
The 
.I truncate 
program truncates the given file(s) to size 0 or given bytes.
.SH OPTIONS
.TP
.B \-l
truncate file(s) to given size of bytes.
.SH COPYRIGHT
The truncate is under GPL. 
.PP
.SH AUTHOR
.I truncate
was written by 
.B Seung-Hong Oh <oh@cis.ohio-state.edu> <http://www.cis.ohio-state.edu/~oh">
.PP
.SH SEE ALSO
\fItruncate\fR(2).
fetchpop1.9/socket.h100444    764    764        2165  6164111063  12046 0ustar  ohoh/*
 * $Id: socket.h,v 1.9 1996/06/26 01:27:31 oh Exp $
 *
 *    Copyright (C) 1996	seung-hong oh
 *
 *  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.
 */

#define SOCK_ERROR -1
#define SOCK_NOEXIST	-2
#define SOCK_NORESPOND -3 

int get_connect(char* serv_name, unsigned short  port_num);
int writesock( int sockfd, char* buff, int bufflen );
int readsock( int sockfd, char* buff, int bufflen);
int writeln(int sockfd, char* buf);
int sockprintf(int sockfd, char* format, ...);
int sockgetline(int sockfd, char* buff, int bufflen);
fetchpop1.9/fetchpop1.9.lsm100444    764    764        1442  6163704645  13174 0ustar  ohohBegin3
Title:         		fetchpop 
Version:       		1.9
Entered-date:  		Tue Jun 25 23:19:48 EDT 1996 
Description:    	Stable and feature-rich POP3 mail retrieval client.
			It can be run as a daemon process and can be used
			with ppp-on, sliplogin, rc.local scripts. Works with
			procmail and .forward file.
Keywords:       	mail, POP client, POP3, pop, procmail, fetchpop
Author:         	Seung-Hong Oh oh@cis.ohio-state.edu
Maintained-by:  	Seung-Hong Oh oh@cis.ohio-state.edu
Primary-site:   	sunsite.unc.edu /pub/Linux/system/Mail/pop	
Alternate-site:		ohlab.net /pub/linux 
Alternate-site:		tsx-11.mit.edu /pub/linux/sources/usr.bin/
Original-site:  	seung-hong.ganet.net /pub/linux (ohlab.net/pub/linux)
Platforms:      	Linux, HP-UX, SunOS, and other Unix-like OSs.
Copying-policy: 	GPL 
End
Results 1 - 1
Help - FTP Sites List - Software Dir.
Searching half a billion files worldwide
© 1997-2009 MARUHN Internet Solutions