File indexing completed on 2018-03-02 18:44:59 UTC
view on githubraw file Latest commit ec6cf3b0 on 2003-08-26 20:45:25 UTC
ec6cf3b09d Ed H*0001 /*
0002 * Read MIME body-part, stopping on boundaries.
0003 */
0004 /* (C) Copyright 1994 by Carnegie Mellon University
0005 * All Rights Reserved.
0006 *
0007 * Permission to use, copy, modify, distribute, and sell this software
0008 * and its documentation for any purpose is hereby granted without
0009 * fee, provided that the above copyright notice appear in all copies
0010 * and that both that copyright notice and this permission notice
0011 * appear in supporting documentation, and that the name of Carnegie
0012 * Mellon University not be used in advertising or publicity
0013 * pertaining to distribution of the software without specific,
0014 * written prior permission. Carnegie Mellon University makes no
0015 * representations about the suitability of this software for any
0016 * purpose. It is provided "as is" without express or implied
0017 * warranty.
0018 *
0019 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
0020 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
0021 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
0022 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0023 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
0024 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
0025 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
0026 * SOFTWARE.
0027 */
0028
0029 /* Max length of a MIME "boundary", per RFC 1521 */
0030 #define PART_MAX_BOUNDARY_LEN 70
0031
0032 /* Structure describing an input file from which we read MIME */
0033 struct part {
0034 /* Input file */
0035 FILE *infile;
0036
0037 /* Input buffer */
0038 unsigned char *buf;
0039 int buf_alloc;
0040 unsigned char *ptr;
0041 int cnt;
0042
0043 /* Boundary information */
0044 char (*boundary)[PART_MAX_BOUNDARY_LEN+1];
0045 int *boundary_length;
0046 int boundary_alloc;
0047 int boundary_num;
0048 int boundary_seen; /* Index of boundary last seen, or
0049 * boundary_num if no pending boundary
0050 */
0051 };
0052
0053 #define part_getc(s) (((s)->cnt-- > 0 && (s)->ptr[0]
0054
0055 #define part_ungetc(c, s) ((s)->cnt++, ((s)->boundary_seen = (s)->boundary_num), (*--(s)->ptr = (c)))
0056
0057 extern struct part *part_init(FILE *infile);
0058 extern char *part_gets(char *s, int n, struct part *part);
0059