1 /* spool.h -- Routines for spooling/parsing messages from a prot stream
2  *
3  * Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in
14  *    the documentation and/or other materials provided with the
15  *    distribution.
16  *
17  * 3. The name "Carnegie Mellon University" must not be used to
18  *    endorse or promote products derived from this software without
19  *    prior written permission. For permission or any legal
20  *    details, please contact
21  *      Carnegie Mellon University
22  *      Center for Technology Transfer and Enterprise Creation
23  *      4615 Forbes Avenue
24  *      Suite 302
25  *      Pittsburgh, PA  15213
26  *      (412) 268-7393, fax: (412) 268-7395
27  *      innovation@andrew.cmu.edu
28  *
29  * 4. Redistributions of any form whatsoever must retain the following
30  *    acknowledgment:
31  *    "This product includes software developed by Computing Services
32  *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
33  *
34  * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
35  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
36  * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
37  * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
38  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
39  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
40  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
41  */
42 
43 #ifndef INCLUDED_SPOOL_H
44 #define INCLUDED_SPOOL_H
45 
46 #include <stdio.h>
47 #include "prot.h"
48 
49 typedef struct hdrcache_t *hdrcache_t;
50 
51 hdrcache_t spool_new_hdrcache(void);
52 void spool_prepend_header(char *name, char *body, hdrcache_t cache);
53 void spool_prepend_header_raw(char *name, char *body, char *raw, hdrcache_t cache);
54 void spool_append_header(char *name, char *body, hdrcache_t cache);
55 void spool_append_header_raw(char *name, char *body, char *raw, hdrcache_t cache);
56 #define spool_cache_header(n, b, c) spool_append_header(n, b, c)
57 void spool_replace_header(char *name, char *newvalue, hdrcache_t cache);
58 /* remove all instances of header 'name' */
59 void spool_remove_header(char *name, hdrcache_t cache);
60 /* remove nth instance of header 'name'.  1 = first, -1 = last */
61 void spool_remove_header_instance(char *name, int n, hdrcache_t cache);
62 int spool_fill_hdrcache(struct protstream *fin, FILE *fout, hdrcache_t cache,
63                         const char **skipheaders);
64 const char **spool_getheader(hdrcache_t cache, const char *phead);
65 void spool_free_hdrcache(hdrcache_t cache);
66 void spool_enum_hdrcache(hdrcache_t cache,
67                          void (*proc)(const char *, const char *, const char *, void *),
68                          void *rock);
69 int spool_copy_msg(struct protstream *fin, FILE *fout);
70 
71 #endif
72