home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume36 / unpost / part02 / unpost.doc < prev   
Encoding:
Text File  |  1993-04-18  |  40.0 KB  |  1,038 lines

  1. UNPOST
  2.  
  3. Name:
  4.  
  5.     unpost - Extract binary files from multi-segment uuencoded USENET
  6.              postings or Email.
  7.  
  8. Synopsis:
  9.  
  10.     unpost [-b[-]] [-c <configuration file>] [-d[-]] [-e <error file>]
  11.            [-f[-]] [-h|-s|-u] [-i <incompletes file>] [-t <text file>]
  12.            <source file>
  13.  
  14.     Where everything but the source file is optional.
  15.  
  16. Description:
  17.  
  18.     UNPOST is a tool designed primarily to extract binaries from USENET
  19.     binaries postings such as those made to alt.binaries.pictures.misc
  20.     and comp.binaries.ibm.pc.  As well as extracting binaries from USENET
  21.     postings, UNPOST can extract binaries from multi-segment uuencoded
  22.     mailings as well, however, to simplify this documentation only
  23.     USENET article postings will be discussed.  The principles are the
  24.     same for multi-segment mailings.
  25.  
  26.     To avoid confusion, this documentation will refer to a single letter
  27.     OR article as a 'segment'.  For clarification on what a segment means
  28.     to UNPOST, see Theory of Operations.
  29.  
  30. Features:
  31.  
  32. 1)  PORTABILITY!  UNPOST has been compiled and sucessfully run on
  33.     MS-DOS, OS/2, Windows, Unix workstations, MacIntoshes, Amiga's
  34.     and VAX/VMS systems.
  35.  
  36.     The code is written to be pure ANSI C, within reasonable limits.
  37.     (some ANSI C capabilities are not used where they would be
  38.     appropriate due to lagging compliance in most compilers.  Hey,
  39.     Unix types!  MS-DOS (Borland C++ 3.1) is a MUCH better compiler
  40.     than anything I've seen on a Unix workstation!  And their debugger
  41.     is the best I've used, as well).  Unfortunately, there are still
  42.     a lot of Unix boxes that have only a K&R compiler, so it may
  43.     not port well to those.  I personally check to make sure that it
  44.     will compile and run on an MS-DOS box running MS-DOS 5 and Windows
  45.     3.1, using the Borland 3.1 C++ compiler, as well as a Sun (running
  46.     SunOs 4.1.1 sun4c) using the gcc compiler (version 2.1).  I know
  47.     for a fact that the Sun cc compiler will NOT compile UNPOST
  48.     succesfully.
  49.  
  50.     K&R compatibility is being considered, but it is a low priority
  51.     feature.
  52.  
  53. 2)  CONFIGURABILITY!  UNPOST comes with a default set of rules for
  54.     detecting and parsing a VERY wide range of possible Subject:
  55.     line formats, but no configuration can be correct for every
  56.     situation.
  57.  
  58.     With that in mind, UNPOST can be configured by the user by creating
  59.     a text file that contains the regular expressions, etc. that
  60.     UNPOST uses to recognize, parse, etc.  WARNING!  UNPOST depends
  61.     almost ENTIRELY on the contents of it's configuration file for
  62.     correct operation.
  63.  
  64.     Regular expressions are complex, and writing one that works the
  65.     way you expect it to takes care and, most importantly,
  66.     experimentation.
  67.  
  68.     To this end, the standard UNPOST installation creates both the
  69.     UNPOST executable and a regular expression test program called
  70.     RETEST.  RETEST is like grep, feed it a regular expression and
  71.     a file, and RETEST will tell you what it matched and the sub
  72.     strings that it extracted.
  73.  
  74. 3)  INTELLIGENCE!  UNPOST uses every trick in the book to try to
  75.     guess what the poster/sender REALLY meant.
  76.  
  77.     Also, UNPOST is not limited to finding all of it's information
  78.     on a single line, or even in the header of a posting/letter.
  79.  
  80.     UNPOST has succesfully extracted binaries from postings that had,
  81.     as a subject line,
  82.  
  83.     Subject: aaaa
  84.  
  85.     because UNPOST recognized the signature placed into the body of
  86.     the article by a uuencode/split program.
  87.  
  88. 4)  FLEXIBILITY!  UNPOST has switches that allow it to be configured
  89.     to do different things for different tastes.  For instance, UNPOST
  90.     will intelligently sort out articles into four different classes:
  91.  
  92.     1)  Articles that are part of a complete and correct binary in
  93.         the input file.  These are sorted, concatenated, uudecoded
  94.         and written out to a file name that is the same as that
  95.         on the uuencode begin line.
  96.  
  97.         Depending on the setting of the file name switch, the file
  98.         name of the binary may be modified.  See below.
  99.  
  100.     2)  Articles that are pure text (no uuencoded data in them).
  101.  
  102.         If the -t switch and a file name are specified, these
  103.         articles will be written out to the file for reading.
  104.  
  105.         Obviously, these articles should NEVER be encountered in
  106.         a binaries news group, but not a single day has ever gone
  107.         by that I did not see non-binary postings to binary news
  108.         groups.
  109.  
  110.     3)  Articles that are part of incomplete postings (four parts,
  111.         but only three have shown up so far), or that comprise
  112.         a complete binary, but one that had an error in uudecoding,
  113.         interpretation, etc.
  114.  
  115.         If the -i flag and a file name are specified, these articles
  116.         will be written out to the file.  If the -b switch is
  117.         on, incompletes will be written to separate files.  If
  118.         both are on, those incompletes that can be guessed at
  119.         as having a file name will be written to a separate file,
  120.         all else will be written to the file named by the -i
  121.         switch.
  122.  
  123.         In my experience, two types of articles end up in an
  124.         incompletes file, those that have missing parts, and
  125.         those that have been misinterpreted by UNPOST as belonging
  126.         to a different binary than they really do.
  127.  
  128.     4)  Articles that are pure text that describe a posting
  129.         (these are usually found only in the pictures groups).
  130.  
  131.         If the -d flag is set, and the binary to which they
  132.         belong is correct and complete, this article, as well as
  133.         the header and body up to the uuencode begin line of the
  134.         first article, will be written to a file that has the same
  135.         base name as the binary, but with the extension .inf.
  136.  
  137.     UNPOST automatically mungles binary file names to be MS-DOS
  138.     compatible (the lowest common denominator).  This is switch
  139.     controllable, and can be turned on or off (depending on the
  140.     default setting selected by the person who compiled UNPOST).
  141.  
  142.     UNPOST also has two lesser modes, sorted mode and uudecode mode.
  143.  
  144.     In sorted mode, UNPOST assumes that the articles still have
  145.     headers, and that there may be un-uuencoded lines in the middle
  146.     of a uuencoded file that have to be filtered out, but it assumes
  147.     that all parts are present, and that they are in order.  Header
  148.     information, however, is ignored.
  149.  
  150.     If you use the incompletes file capability of UNPOST, you will
  151.     notice that it writes out the segments that it did interpret
  152.     correctly in sorted order.
  153.  
  154.     In uudecode mode, UNPOST acts like a simple uudecoder.  UUencoded
  155.     files must be complete, with a begin and end line, and no
  156.     un-uuencoded lines can appear between the begin and end lines.
  157.  
  158.     However, uudecode mode is the ONLY mode where UNPOST will accept
  159.     a short line (one that was space terminated, but had the spaces
  160.     chopped off) as a legal uuencoded line and properly decode it.
  161.  
  162. 5)  INFORMATIVE!  UNPOST is a very talkative program.  It detects
  163.     and reports many kinds of problems, tells you what it thinks
  164.     is going on, and tells you what it is doing.  All this information
  165.     is written to standard error, or if the -e switch and a file
  166.     name are specified, written to that file.
  167.  
  168. Theory of Operations:
  169.  
  170.     UNPOST assumes that the source file that is given to it will have the
  171.     following format:
  172.  
  173.     SEGMENT begin line
  174.     ...
  175.     HEADER ID line
  176.     ...
  177.     BODY ID line
  178.     ...
  179.     UUENCODED line
  180.  
  181.     Where the lines are:
  182.  
  183.         SEGMENT begin line - Is the line that identifies the begining of a
  184.                              segment.
  185.         HEADER ID line     - One or more lines that contain segment number,
  186.                              total number of segments or the ID string in
  187.                              the article or mail header.
  188.         BODY ID line       - One or more lines that contain segment number,
  189.                              total number of segments or the ID string in
  190.                              the article or mail message body.
  191.         UUENCODED line     - Is the first uuencoded line in the file.
  192.                              UUencoded lines include the begin and end lines.
  193.         ...                - Indicates zero or more lines that can contain
  194.                              any information so long as they CANNOT be
  195.                              misidentified as SEGMENT begin, ID or UUENCODED
  196.                              lines.
  197.  
  198.     Notice that the ID information can be spread across multiple lines.  A
  199.     segment is assumed to end at the begining of the next segment, or at
  200.     the end of the source file.  An UNPOST source file contains one or more
  201.     segments.
  202.  
  203.     UNPOST has three different modes, interpretation mode, concatenation
  204.     mode and UU decoder mode.  In all three modes, UNPOST can accept one
  205.     or more input files.
  206.  
  207.     In the first mode, interpretation mode, UNPOST looks at segment header
  208.     and body lines before the first UU encoded line, and attempts to extract
  209.     three pieces of information from them: segment number, total number
  210.     of segments that the binary was split into, and an ID string that is
  211.     common to all segments.  If UNPOST finds something that it considers
  212.     to be an ID string, and a uuencoded line in the segment, but it does
  213.     not find a segment number and number of segments, UNPOST assumes that
  214.     the segment is a single segment binary posting (part 1 of 1).
  215.  
  216.     To aid in finding out what happened, in interpretation mode UNPOST
  217.     will write a list of all the different ID strings and their respective
  218.     segment lists to standard error or the file specified as the error
  219.     file (see Standards section for details of what an ID string is).
  220.     Any errors or warnings detected during processing will also be
  221.     written to standard error or error file.
  222.  
  223.     In interpretation mode three other files can optionally be created.
  224.     All three of these files will contain segments copied out of the source
  225.     file, and none of these files will be created unless they are turned
  226.     on and named by a command line switch.
  227.  
  228.     The first optional file that UNPOST can create for the user in
  229.     interpretation mode is the text file (-t switch).  This file will have
  230.     copied to it all segments from the source file that do not contain
  231.     uuencoded data.
  232.  
  233.     Segments that are part 0/# type segments that do not contain uuencoded
  234.     data will NOT be copied to the text file.  They are considered to be
  235.     description segments, and they will be copied to the description file
  236.     only if the -d switch is turned on.  Also, all binary postings that
  237.     have all of their segments present will have the segment header
  238.     and body of segment #1 (up to and including the uuencode begin line)
  239.     copied into the description file.
  240.  
  241.     The third optional file that can be created in interpretation mode is
  242.     the incomplete or unused uuencode data segments file.  This file
  243.     contains all segments that have uuencoded data, that were not used in
  244.     a succesful uudecoding.  This file will only be created if the -i
  245.     switch is present.
  246.  
  247.     The incompletes file allows the user to hand decode those binarys which
  248.     could not be interpreted or decoded by UNPOST.  Often times, a binary
  249.     will have all of it's parts, but UNPOST will not be able to put them
  250.     together because of differences in the ID string between segments, or
  251.     problems with the part numbering information.  The simplest way to
  252.     solve these problems is to collect the incompletes, edit the ID
  253.     lines to correct the problem, and rerun UNPOST on the incompletes
  254.     file.
  255.  
  256.     In the second mode, catentation mode, UNPOST assumes that all of the
  257.     segments in the source file between a uuencode begin and a uuencode
  258.     end line are part of one binary posting and that the segments are in
  259.     order.  UNPOST scans from the begining of the file until it finds a
  260.     uuencode begin line, and decodes from there (skipping over non-
  261.     uuencoded lines such as segment header lines and signatures) until
  262.     it finds a uuencode end line.
  263.  
  264.     In the last mode, UU decoder mode, UNPOST assumes that the source
  265.     file contains one or more UU encoded files.  Only UU encoded lines
  266.     are allowed between the uuencode begin line and the uuencode end line
  267.     of any single uuencoded file.
  268.  
  269.     Example header:
  270.  
  271.     (1) Article 2096 of alt.binaries.pictures.misc:
  272.         Newsgroups: alt.binaries.pictures.misc
  273.         Path: csn!csn!convex!cs.utexas.edu!
  274.         From: a43xz@brain.ac.da (Joe User)
  275.     (2) Subject: ship.gif (1/3)
  276.         Organization: Somewhere Near The Sea.
  277.         Date: Fri, 19 Feb 1993 06:43:48 GMT
  278.         Message-ID: <21128@brain.ac.da>
  279.         Sender: news@dep.rnsft.ac.da (Usenet)
  280.         Lines: 761
  281.  
  282.  
  283.         Picture of a ship in a bottle, full rigged.  How did it get there?
  284.  
  285.     (3) section 1 of uuencode 5.20 of file ship.gif    by R.E.M.
  286.  
  287.     (4) begin 644 ship.gif
  288.         M1TE&.#=A@`+@`9<```0$!`0$!",G,"LG)RLG,"LG.30G,#TG)RLP,"LP.3TG
  289.  
  290.     In the above example, line (1) is the SEGMENT begin line, line (2) is
  291.     a HEADER ID line, line (3) is a BODY ID line and line (4) is the first
  292.     UUENCODED line in the body.
  293.  
  294. Options:
  295.  
  296.     -b[-]       Set this flag to make UNPOST write the incomplete
  297.                 uuencoded segments to separate files.  This defaults
  298.                 to off.
  299.  
  300.     -c  <file>  To read and use a different configuration than the
  301.                 default configuration.  The default configuration is
  302.                 stored in a file called def.cfg.
  303.  
  304.     -d[-]       Turns on description capturing and writes descriptions
  305.                 to a file that has the same name as the output but with
  306.                 a .inf extension.  This defaults to on.
  307.  
  308.     -e  <file>  Redirects error and information output from standard
  309.                 error to <file>.
  310.  
  311.     -f[-]       Modify file names to be MS-DOS/USENET compatible.  Use
  312.                 of -f turns file name modification on if the default is off,
  313.                 and -f- turns file name modification off if the default
  314.                 is on.  File name modification is currently the default.
  315.  
  316.     -h          Turns on full interpretation mode.  This is the default.
  317.  
  318.     -i  <file>  Turns on incomplete binaries capturing and writes the
  319.                 segments to file <file>.
  320.  
  321.     -s          Switch to ordered segment mode.  This mode ignores segment
  322.                 headers, and assumes that the segments are in order.
  323.  
  324.     -t  <file>  Turns on text only segment capturing and writes the segments
  325.                 to <file>.
  326.  
  327.     -u          Switch to uudecoder mode.  Assume only uuencoded data
  328.                 between begin and end lines.  Multiple uuencoded files
  329.                 are allowed.
  330.  
  331.     -v          Show version number and quit.
  332.  
  333.     -?          Show a summary of the command line switches.
  334.  
  335.     It is important to realize that UNPOST parses the command line in
  336.     parallel with operations, so the order of the switches on the
  337.     command line is VERY important.  For example:
  338.  
  339.     unpost -d -e errors -i abpm.inc abpm.uue -c cbip.cfg -d- cbip.uue
  340.  
  341.     This will use the default configuration to process the file abpm.uue,
  342.     writing out description files, writing errors to the file errors,
  343.     and writing incompletes to the file abpm.inc.  After UNPOST finishes
  344.     processing abpm.uue, it will read in the cbip.cfg configuration,
  345.     turn off writing description files and process cbip.uue.
  346.  
  347.     Note that the errors will continue to be written to the file errors,
  348.     and that the incomplete binaries will continue to be written to the
  349.     file abpm.inc.  Since we are switching configurations, this is
  350.     probably not a good idea.
  351.  
  352. Standards:
  353.  
  354.     In all modes, UNPOST recognizes and decodes only uuencoded data.
  355.  
  356.     In interpretation mode UNPOST requires that:
  357.  
  358.         1)  The uuencoded lines be true uuencoded lines.  This means
  359.             that if trailing spaces are truncated by a mailer, editor
  360.             or news node, UNPOST will not consider those lines to
  361.             be uuencoded lines.  Also, the uuencode character set
  362.             recognized by UNPOST is ' ' - '`', with no other characters
  363.             being legal.
  364.  
  365.         2)  That all segments of the same binary file posting have
  366.             the same, recognizable ID string.
  367.  
  368.         3)  Segments have a recognizable SEGMENT begin line as the
  369.             first line in the segment (denoting the begining of a
  370.             segment).
  371.  
  372.         4)  That all ID lines follow the SEGMENT begin line in the
  373.             segment.
  374.  
  375.         5)  That the first UUencoded line of the segment follows the
  376.             last ID line.
  377.  
  378.         6)  That the first uuencode line in the first segment be a
  379.             begin line.
  380.  
  381.         7)  That the last segment contain a uuencode end line.
  382.  
  383.     In sorted segment mode, UNPOST requires that:
  384.  
  385.         1)  The uuencoded lines be true uuencoded lines.  This means
  386.             that if trailing spaces are truncated by a mailer, editor
  387.             or news node, UNPOST will not consider those lines to
  388.             be uuencoded lines.  Also, the uuencode character set
  389.             recognized by UNPOST is ' ' - '`', with no other characters
  390.             being legal.
  391.  
  392.         2)  That the segments be stored in the file in order.
  393.  
  394.         3)  That the first uuencode line in the first segment be a
  395.             begin line.
  396.  
  397.         4)  That the last segment contain a uuencode end line.
  398.  
  399.     In uudecoder mode, UNPOST requires that:
  400.  
  401.         1)  There be only uuencoded lines between a uuencode begin and
  402.             a uuencode end line.  In this mode, UNPOST will recognize
  403.             and attempt to repair lines that had trailing spaces
  404.             truncated.
  405.  
  406. Examples:
  407.  
  408.     To extract a single binary that had all of it's segments saved in order
  409.     to a single file:
  410.  
  411.     unpost -s binary.uue
  412.  
  413.     To extract all binaries that have had all of their segments saved
  414.     to a single file:
  415.  
  416.     unpost multiple.uue 2> errors
  417.         Or
  418.     unpost -e errors multiple.uue
  419.  
  420.     The file errors will contain a list of all the ID strings that UNPOST
  421.     found and thought could have been binary files, and any errors
  422.     that occurred during processing.
  423.  
  424.     To capture the incomplete or unused segments that have uuencoded
  425.     data in them:
  426.  
  427.     unpost -e errors -i multiple.inc multiple.uue
  428.  
  429.     To capture descriptions and text only segments as well:
  430.  
  431.     unpost -d -e errors -t text -i multiple.inc multiple.uue
  432.  
  433.     To process two different files, one in uuencode mode, one in interpretation
  434.     mode:
  435.  
  436.     unpost -e errors -u uuencode.uue -h multiple.uue
  437.  
  438.     To process a file that requires a different configuration:
  439.  
  440.     unpost -c -e errors multiple.uue
  441.  
  442. Output:
  443.  
  444.     UNPOST will write diagnostic and informative messages to either
  445.     standard error or the error file.  The error file has three
  446.     parts, interpretation errors (duplicate segments, missing
  447.     uuencode begin lines, missing ID string, segment number or
  448.     number of segments, etc.), a dump of the binaries found, the
  449.     number of segments in each binary and the segment number and
  450.     offset of each segment in the source file.  The last part
  451.     is a mixture of information (the name of the binary that UNPOST
  452.     is attempting to decode) and any errors encountered during
  453.     decoding.
  454.  
  455.     In the example below, UNPOST found one segment that had uuencoded
  456.     data, the Subject: line had barber.gif as the ID string, the
  457.     binary has one segment, and in the list of segments below,
  458.     we see that segment number 1 starts at offset 583 in the source file.
  459.  
  460.     If there is a missing segment, it's segment number will be zero,
  461.     and it's file offset will be zero.
  462.  
  463.     There were no interpretation errors, and there were no decoding
  464.     errors.
  465.  
  466.     File ID                         Segments
  467.     ----------------------------------------
  468.     barber.gif                      1
  469.         1  583
  470.  
  471.     Decoding Binary ID: 'barber.gif'
  472.  
  473. Notes:
  474.  
  475.     To use this program to collect all of the binaries posted to, say,
  476.     the alt.binaries.misc group on a daily basis, start up rn, go to
  477.     the alt.binaries.misc newsgroup, and save all of the unread segments
  478.     by using this command:
  479.  
  480.     .-$smisc.uue:j
  481.  
  482.     This will save all segments from the current number to the last to
  483.     the file misc.uue, then junk them.  After exiting rn, run UNPOST
  484.     on the file misc.uue in interpretation mode (default mode):
  485.  
  486.     unpost -e errors -i misc.1 misc.uue
  487.  
  488.     Make sure to check the errors and/or misc.1 file for segments
  489.     that UNPOST couldn't extract.
  490.  
  491. Diagnostics:
  492.  
  493.     Error - file 'filename' already exists.
  494.  
  495.         UNPOST will not overwrite an existing file.  Delete the file or
  496.         rename it and try again.
  497.  
  498.     Error - missing begin line.
  499.  
  500.         UNPOST expected to find a uuencode begin line in this segment,
  501.         but did not.
  502.  
  503.     Error - missing file name.
  504.  
  505.         The binary that UNPOST was attempting to decode does not
  506.         seem to have a uuencode begin line in the first segment,
  507.         so UNPOST has no idea what the file name is.
  508.  
  509.     Error - Could not open description file 'filename' for writing.
  510.  
  511.         UNPOST could not open a file of that name for some reason.
  512.         Possibly a permission problem, or the file exists and is not
  513.         writeable.
  514.  
  515.     Error - Bad write to binary file.
  516.  
  517.         A file write failed for some unknown reason.  Possibly a full
  518.         disk?
  519.  
  520.     Error - missing segment #
  521.         Binary ID: 'binaryID'
  522.  
  523.         In attempting to decode a file whose ID string is binaryID,
  524.         one or more segments are missing.
  525.  
  526.     Error - Missing UU end line.
  527.  
  528.         As this is the last segment, it ought to have a uuencode end
  529.         line in it, but UNPOST did not find one.
  530.  
  531.     Warning - Early uuencode end line.
  532.  
  533.         UNPOST found a uuencode end line, but this was not the last
  534.         segment, so we found it early.  Did the poster screw up and
  535.         misnumber his segments?
  536.  
  537.     Error - Unexpected UU begin line.
  538.  
  539.         We found an unexpected (read: this is not the first line of the
  540.         first segment, so what is this doing here?) UU begin line.
  541.  
  542.     Error - cannot identify string '' in line #
  543.  
  544.         In reading in a configuration file, the configuration file
  545.         lexical analyzer could not recognize this string.
  546.  
  547.  
  548.     Error - Out of memory.
  549.  
  550.             Yup.  Out of memory.  Split the source file into smaller
  551.             pieces and try again.
  552.  
  553.     Error - Could not modify file name to be MS-DOS conformant.
  554.  
  555.         File name mungling is turned on, and the name of one of the
  556.         files cannot be made conformant (probably due to having to
  557.         many numbers in it).
  558.  
  559.     Warning - Unexpected end of file in segment:
  560.         Segment: 'segment line'
  561.  
  562.          File name mungling is turned on, and UNPOST is attempting to
  563.         identify the file type (so it can use the proper extension
  564.         when modifying the file name) but the UU begin line was the
  565.         last line in the file.
  566.  
  567.     Warning - No UU line after begin.
  568.         Segment: 'segment line'
  569.  
  570.         File name mungling is turned on, and UNPOST is attempting to
  571.         identify the file type (so it can use the proper extension
  572.         when modifying the file name) but the UU begin line was not
  573.         followed by a line of UU encoded binary data.
  574.  
  575.     Error - Got number of segments but not segment number.
  576.     Error - Got segment number but not number of segments.
  577.  
  578.         UNPOST must have all three pieces of relevant data, but if
  579.         UNPOST has at least an ID string, UNPOST will attempt to
  580.         assume a one part binary.
  581.  
  582.     Error - Could not get ID string.
  583.  
  584.         Fatal error, with no ID string, there is no way to collect
  585.         the pieces together.
  586.  
  587.     Error - No begin line in first segment:
  588.         Segment: 'segment line'
  589.  
  590.         UNPOST did not find a UU begin line in the first segment.
  591.  
  592.     Error - missing '}' in regular expression.
  593.  
  594.         In a regular expression of the type abc{1, 2}, the closing curly
  595.         brace is missing.
  596.  
  597.     Error - To many sub-expressions.
  598.  
  599.         UNPOST has a limit on the number of sub-expressions it
  600.         allows.  This is a compile time option that can be changed
  601.         by modifying the value of MAX_SUB_EXPRS in regexp.h.
  602.  
  603.     Error - missing ')' in regular expression.
  604.  
  605.         Mismatched parentheses.
  606.  
  607.     Error - badly formed regular expression.
  608.         Unexpected character 'c'
  609.  
  610.         I give up!  What is this character doing at this point in
  611.         a regular expression?
  612.  
  613.     Error, can not enumerate a sub expression.
  614.  
  615.         Regular expressions of the type: (...)* are not allowed.
  616.  
  617.     Error - illegal regular expression node type.
  618.  
  619.         Whoops, we have an internal programmers error here.  Let
  620.         me know if you see this.
  621.  
  622.     Error - Sub expression # extraction failed.
  623.  
  624.         Another internal error that needs to be brought to my attention.
  625.  
  626.     Error - could not open file 'filename' for reading.
  627.  
  628.          UNPOST could not open file 'filename' for processing.  Did you
  629.         spellit right?
  630.  
  631.     Error - Unexpected end of file.
  632.  
  633.     Error - Unexpected UU begin line.
  634.  
  635.     Error - Segment number # greater than number of segments in:
  636.         Segment: 'segment line'
  637.  
  638.         Either UNPOST got screwed up somehow or the poster posted
  639.         something like (Part 10/9).
  640.  
  641.     Warning - duplicate segment # in:
  642.         Binary ID: 'binaryID'
  643.  
  644.         UNPOST found two segments with the same binary ID and the
  645.         same segment number.
  646.  
  647.     Error - reading source file.
  648.  
  649.         Could not read a line from the source file.
  650.  
  651.     Error - Could not open file 'filename' for output.
  652.  
  653.         Could not open one of the text, incomplete or error files
  654.         for writing.
  655.  
  656. Regular Expressions:
  657.  
  658.     Operands
  659.     --------
  660.  
  661.     UNPOST regular expressions have three types of operands, character
  662.     strings (one or more characters), character sets and match any
  663.     single character.  A character string is any series of adjacent
  664.     characters that are not not meta-characters (special characters).
  665.     A data set is a string of characters enclosed in square braces with
  666.     an optional caret (^) as the first character following the open
  667.     square brace.  The match any character operand matches any single
  668.     character except the end of line character.
  669.  
  670.     A character string in a regular expression matches the exact string
  671.     in the source, including case.
  672.  
  673.     Example of character strings:
  674.  
  675.     AirPlane    - Matches the string 'AirPlane', but not the strings
  676.                   'airPlane' or 'Airplane'.
  677.  
  678.     A character set will match any single character in the source if
  679.     that character is a member of the set.  If the first character
  680.     of the set is the caret, the character set will match any
  681.     character that is NOT a member of the set (including control
  682.     characters!) except for NUL and LF.
  683.  
  684.     A character set can be described using ranges.
  685.  
  686.     Examples of character sets:
  687.  
  688.     [abcd]      - Matches either a, b, c or d.
  689.  
  690.     [0-9]       - Matches any decimal character.
  691.  
  692.     [^a-z]      - Matches any character that is NOT a lower
  693.                   case alphabetic.
  694.  
  695.     The match any character operand does just that, it matches any
  696.     character.  But it does not match the case of no character, NUL
  697.     or LF.
  698.  
  699.     Example of match any character:
  700.  
  701.     .       - Matches any character.
  702.  
  703.     Operators
  704.     ---------
  705.  
  706.     UNPOST regular expressions also contain operators.  The operators that
  707.     upost recognizes are the alternation operator, the span operators, the
  708.     concatenation operator and the enumeration operators.
  709.  
  710.     The alternation operator has the lowest precedence of all the operators
  711.     and its action is to attempt to match one of two alternatives.
  712.  
  713.     Example of alternation:
  714.  
  715.     Airplane|drigible   - Matches either the string Airplane or the string
  716.                           drigible.
  717.  
  718.     The next higher precedence operator is the catenation operator.  The
  719.     catenation operator specifies that both the left and right hand
  720.     regular expressions must match.  The catenation operator does not
  721.     have a special character, it is assumed to exist between two
  722.     different operands that have no other operator between them.
  723.  
  724.     Example of catenation:
  725.  
  726.     [Aa]irplane - Matches either a 'A' or an 'a' followed by the string
  727.                   irplane.  This is a catenation of the two regular
  728.                   expressions [Aa] and irplane.
  729.  
  730.     The next higher precedence operator is the enumeration operator.
  731.     The enumeration operator specifies how many instances of a regular
  732.     expression must be matched.
  733.  
  734.     Examples of Enumeration:
  735.  
  736.     abc*    - Matches zero or more occurences of the string abc.
  737.     [A-Z]+  - Matches one or more occurences of an upper case
  738.               alphabetic character.
  739.     [ ]?    - Matches zero or one occurences of the space character.
  740.     very{1} - Matches one or more occurences of the string very.
  741.     b{1,3}  - Matches a minimum of one to a maximum of three occurences
  742.               of the string b.
  743.  
  744.     An enumeration operator attempts to match the largest source sub-
  745.     string possible, except in the case of the . (match any character)
  746.     followed by an enumeration operator.  In this case, the smallest
  747.     possible sub-string is matched.
  748.  
  749.     The precedence of the operators can be modified with the use of
  750.     parentheses.  Parentheses have another meaning as well, described
  751.     below.
  752.  
  753.     Example of parenthesis use:
  754.  
  755.     Death( defying|wish)    - Will match either the string 'Death defying'
  756.                               or the string 'Deathwish'.  Without the
  757.                               parentheses, the regular expression would
  758.                               match either the string 'Death defying'
  759.                               or the string 'wish'.
  760.     Sub Expressions
  761.     ---------------
  762.  
  763.     UNPOST regular expressions are used primarily for identifying a
  764.     particular line and extracting substrings from that line.  To
  765.     this end, UNPOST regular expressions support sub-expression
  766.     marking.  Subexpressions are marked by parentheses.
  767.  
  768.     To determine the sub-expression number of a sub-expression, scan
  769.     the regular expression from left to right, counting the number
  770.     of left parentheses.  Start with one, and whatever the count for
  771.     that sub-expression, is it's subexpression number.
  772.  
  773.     Example:
  774.  
  775.     .*((abcd)((0-9)+/(0-9)+))
  776.  
  777.     Sub-expression ((abcd)((0-9)+/(0-9)+)) is sub-expression #1.
  778.     Sub-expression (abcd) is #2.  Sub-expression ((0-9)+/(0-9)+) is #3.
  779.     Sub-expression (0-9)+ is #4.  Sub-expression (0-9)+ is #5.
  780.  
  781.     Anchoring
  782.     ---------
  783.  
  784.     Normally, a regular expression will match a sub-string any where in
  785.     the source string.  If you want to specify that the matching sub-string
  786.     must start at the begining of the source string, you may use a caret
  787.     character as the first character of the regular expression.  This
  788.     anchors the regular expression match to the start of the line.
  789.  
  790.     To anchor a regular expression to the end of a line, use the dollar
  791.     sign character.  This effectively matches the end of line or end
  792.     of string character.
  793.  
  794.     Anchor operators have a higher precedence than alternation, but lower
  795.     than catenation.
  796.  
  797. Configuration:
  798.  
  799.     Ok, here's how to configure UNPOST to work for you.  UNPOST relies
  800.     heavily on regular expressions.  These regular expressions may
  801.     not be correct for your news reader, or system.
  802.  
  803.     There are five classes of regular expressions:
  804.  
  805.     1)  The SEGMENT begin line regular expression.
  806.  
  807.     2)  The ID line prefix regular expression.
  808.  
  809.     3)  The ID line with part description regular expression list.
  810.  
  811.     4)  The begin line regular expression.
  812.  
  813.     5)  The end line regular expression.
  814.  
  815.     Of these five, I don't expect you to have to modify the regular
  816.     expressions for handling begin and end lines, because they should
  817.     be correct for all uuencoders that follow the standard format.
  818.  
  819.     Be aware that UNPOST has a hierarchy of regular expressions.
  820.     Each SEGMENT begin line regular expression has underneath it two
  821.     lists of regular expressions that recognize ID line prefixes,
  822.     and each element in the list of ID line prefix regular expressions
  823.     has a list under it that attempts to parse the ID line.
  824.  
  825.     The two lists immediately under the SEGMENT begin line regular
  826.     expression are for 1) the header and 2) the body.
  827.  
  828.     The ID line prefix regular expression exists for the sake of
  829.     efficiency.  It is used to find an ID line before we attempt
  830.     to parse it.  Modify or add one of these if you wish to change
  831.     whether or not a line is recognized by UNPOST as being an ID line.
  832.     If you modify this, you must modify the list of segment description
  833.     regular expressions to match.
  834.  
  835.     The SEGMENT begin line regular expressions are used to find the begining
  836.     of a SEGMENT, or the end of a previous segment.  Modify these to change
  837.     the line or lines that UNPOST recognizes as the begining of a segment.
  838.  
  839.     If you get an error message that indicates that the Subject line
  840.     has no identifiable part description, and you see that some bright
  841.     boy/girl has come up with a brand new part description format, then
  842.     you have two choices, modify the source and hope they don't post
  843.     again, or add a new ID line regular expression to the list of
  844.     ID line regular expressions in the segment.c source file.
  845.  
  846.     Be aware that the lists of regular expressions are searched in order
  847.     from top to bottom to find a match.  This means that less specific
  848.     regular expressions should be placed later in the list.  For example:
  849.     the regular expression '\((0-9)+/(0-9)+\)' should come before the
  850.     regular expression '(0-9)+ (0-9)+' in the part syntax parsing regular
  851.     expression list.  This reduces the number of misparses that occur.
  852.  
  853.     Remember that C uses the backslash (\) as an escape character in
  854.     strings, so to put a backslash into a regular expression you
  855.     need to put two into the C source string.
  856.  
  857.     All regular expressions can be found at the top of the parse.c source
  858.     file.  Before you modify the actual source code and recompile, I
  859.     strongly suggest that you test your new regular expression using the
  860.     regular expression test harness (retest) that was compiled by the
  861.     makefile when you compiled UNPOST.  Then, when you are sure that
  862.     it is correct, copy the def.cfg file to a new name, make your changes
  863.     there and use that configuration file for a while.  If after all this,
  864.     you are sure that it works, go in and change the source code in
  865.     parse.c.
  866.  
  867.     Before you add or modify a regular expression, you have to know the
  868.     syntax of the regular expressions used in this program.  The syntax
  869.     is very similiar to that used by UN*X style regular expressions,
  870.     but is not exactly the same.  See the section titled Regular
  871.     Expressions before attempting to configure UNPOST.
  872.  
  873. Configuration Files:
  874.  
  875.     If you don't want to make permanent changes to UNPOST's configuration,
  876.     you can make a configuration file.  Configuration files are parsed by
  877.     UNPOST, the regular expressions compiled, and these regular expressions
  878.     control the operation of UNPOST completely.
  879.  
  880.     A configuration file must have the following syntax:
  881.  
  882.     segment "..."
  883.     {
  884.         header
  885.         {
  886.             "...."
  887.             {
  888.                 "..."
  889.                 {
  890.                     id #
  891.                     segment number #
  892.                     segments #
  893.                     alternate id #
  894.                     case ignore|sensitive
  895.                 }
  896.             }
  897.         }
  898.         body
  899.         {
  900.             "...."
  901.             {
  902.                 "..."
  903.                 {
  904.                     id #
  905.                     segment number #
  906.                     segments #
  907.                     alternate id #
  908.                     case ignore|sensitive
  909.                 }
  910.             }
  911.         }
  912.     }
  913.  
  914.     Where "..." is a regular expression string, # is a sub expression
  915.     number (See the section on regular expressions), and case is
  916.     either ignored in regular expression string matching, or string
  917.     matching is case sensitive.
  918.  
  919.     The outer most construct, starting with the segment "..." line
  920.     is used to describe how to recognize the begining of a segment.
  921.  
  922.     The two constructs at the first level within the segment construct
  923.     are used to identify lines that are expected to contain part # of
  924.     # of parts information in the header, or the body of an article.
  925.  
  926.     Within each header or body group are regular expressions that
  927.     are used to parse out the part # of # of parts information from
  928.     an identified information line.
  929.  
  930.     A very simple example (taken directly out of the MUFUD
  931.     documentation):
  932.  
  933.     segment "^Article[:]?"
  934.     {
  935.         header
  936.         {
  937.             "^Subject:"
  938.             {
  939.                 "^Subject:(.*)part[ ]+([0-9]+)[ ]*(of|/)[ ]*([0-9]+)(.*)"
  940.                 {
  941.                     id 1
  942.                     segment number 2
  943.                     segments 4
  944.                     alternate id 5
  945.                     case ignore
  946.                 }
  947.                 "^Subject:(.*)([0-9]+)[ ]*(of|/)[ ]*([0-9]+)(.*)"
  948.                 {
  949.                     id 1
  950.                     segment number 2
  951.                     segments 4
  952.                     alternate id 5
  953.                     case ignore
  954.                 }
  955.             }
  956.         }
  957.         body
  958.         {
  959.         }
  960.     }
  961.  
  962.     Where:
  963.  
  964.     id 1                Specifies the sub expression number of the
  965.                         sub expression that is used to extract the
  966.                         binary ID string.
  967.  
  968.     segment number 2    Specifies the sub expression number of the
  969.                         sub expression that is used to extract the
  970.                         segment number.
  971.  
  972.     segments 3          Specifies the sub expression number of the
  973.                         sub expression that is used to extract the
  974.                         number of segments that this binary was split
  975.                         into.
  976.  
  977.     alternate id 4      Specifies the alternate sub expression
  978.                         number.  If the first ID sub expression extracts
  979.                         only an empty string (or one with all white
  980.                         space), the string extracted by this sub expression
  981.                         is used to generate the binary ID string.
  982.  
  983.     case ignore         Specifies that the case of alphabetical
  984.                         characters is to be ignored in regular
  985.                         expression string matching.
  986.  
  987.     See the def.cfg file for another (more complete) example.
  988.  
  989. Default Binary Switch Settings:
  990.  
  991.     To modify the default values of the binary switches, edit the
  992.     file compiler.h, and change the value of the defines.  There
  993.     are defines for file name mungling, breaking incompletes
  994.     into separate files and for dumping out description files.
  995.  
  996. Bugs:
  997.  
  998.     This program has been pretty extensively tested in interpretation mode,
  999.     and it appears to be both robust and flexible.
  1000.  
  1001.     Unfortunately, about once a week, somebody comes up with a new and
  1002.     unusual way to encode the parts description on the Subject line.
  1003.  
  1004.     Bugs, after being found, are chased unmercifully and terminated with
  1005.     extreme prejudice.  If you think you've found one, send all information
  1006.     opinions, prejudices and  critcisms to me, and the hunt will begin
  1007.     (just as soon as I can put on my safari hat and grab my debugger. . .).
  1008.  
  1009. Rights, Copyright, Legal stuff, etc:
  1010.  
  1011.     This program is distributed free of charge, but it has NOT been placed
  1012.     in the public domain!  I retain copyright.
  1013.  
  1014.     Why?  Because I am pathologically commited to producing and maintaining
  1015.     a quality product, and if every Tom, Dick and Susan modifies UNPOST
  1016.     and redistributes, I will not be able to respond to bug reports or
  1017.     continue to upgrade the product (branch revision problem, and all
  1018.     that. . .).
  1019.  
  1020.     My job isn't done so long as a single bug exists, or even one user
  1021.     is unhappy (or even one system is uninfected. . . er, that is to
  1022.     say, supported :-).
  1023.  
  1024.     However, I am also dedicated to the principle of maximum use.  If
  1025.     you wish, you may modify anything in this program you want to.  That's
  1026.     why I distribute source.  BUT, you may NOT distribute your changes,
  1027.     unless you can be legally sure that you have made so many as to make
  1028.     what you distribute a new work.
  1029.  
  1030.     If you learn any bad habits from reading my source code, tough luck.
  1031.  
  1032.     And if anything in this section is not legally supportable, the
  1033.     joke's on me.  Don't bother telling me, I'm to busy coding (So THERE!).
  1034.  
  1035. Author:
  1036.  
  1037.     John W. M. Stevens  -   jstevens@csn.org
  1038.