annotate src/vbuf.h @ 172:6954d315aaa8

move version-info into main configure.in, and set it properly. prefix all external symbols in the shared library with pst_ to avoid symbol clashes with other shared libraries.
author Carl Byington <carl@five-ten-sg.com>
date Sat, 04 Apr 2009 16:00:48 -0700
parents cda7c812ec01
children ac6e22c8a9cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
1 /* vbuf.h - variable length buffer functions
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
2 *
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
3 * Functions that try to make dealing with buffers easier.
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
4 *
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
5 * vbuf
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
6 *
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
7 * vstr
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
8 * - should always contain a valid string
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
9 *
70
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
10 */
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
11
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
12 #ifndef VBUF_H
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
13 #define VBUF_H
132
5e4d6faada34 fix from Fridrich Strba for parallel make
Carl Byington <carl@five-ten-sg.com>
parents: 130
diff changeset
14
5e4d6faada34 fix from Fridrich Strba for parallel make
Carl Byington <carl@five-ten-sg.com>
parents: 130
diff changeset
15 #include "common.h"
5e4d6faada34 fix from Fridrich Strba for parallel make
Carl Byington <carl@five-ten-sg.com>
parents: 130
diff changeset
16
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
17 #define SZ_MAX 4096
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
18 /***************************************************/
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
19
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
20
70
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
21 // Variable-length buffers
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
22 struct varbuf {
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
23 size_t dlen; //length of data stored in buffer
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
24 size_t blen; //length of buffer
70
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
25 char *buf; //buffer
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
26 char *b; //start of stored data
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
27 };
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
28
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
29
70
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
30 // The exact same thing as a varbuf but should always contain at least '\0'
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
31 struct varstr {
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
32 size_t dlen; //length of data stored in buffer
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
33 size_t blen; //length of buffer
70
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
34 char *buf; //buffer
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
35 char *b; //start of stored data
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
36 };
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
37
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
38
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
39 typedef struct varbuf vbuf;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
40 typedef struct varstr vstr;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
41
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
42 #define VBUF_STATIC(x,y) static vbuf *x = NULL; if(!x) x = pst_vballoc(y);
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
43 #define VSTR_STATIC(x,y) static vstr *x = NULL; if(!x) x = pst_vsalloc(y);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
44
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
45 int pst_skip_nl( char *s ); // returns the width of the newline at s[0]
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
46 int pst_find_nl( vstr *vs ); // find newline of type type in b
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
47
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
48 // vbuf functions
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
49 vbuf *pst_vballoc( size_t len );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
50 void pst_vbfree( vbuf *vb );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
51 void pst_vbclear( vbuf *vb ); //ditch the data, keep the buffer
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
52 void pst_vbresize( vbuf *vb, size_t len );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
53 size_t pst_vbavail( vbuf *vb );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
54 void pst_vbdump( vbuf *vb );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
55 void pst_vbgrow( vbuf *vb, size_t len ); // grow buffer by len bytes, data are preserved
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
56 void pst_vbset( vbuf *vb, void *data, size_t len );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
57 void pst_vbskipws( vbuf *vb );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
58 void pst_vbappend( vbuf *vb, void *data, size_t length );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
59 void pst_vbskip( vbuf *vb, size_t skip );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
60 void pst_vboverwrite( vbuf *vbdest, vbuf *vbsrc );
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
61
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
62 // vstr functions
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
63 vstr *pst_vsalloc( size_t len );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
64 char *pst_vsb( vstr *vs );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
65 size_t pst_vslen( vstr *vs ); //strlen
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
66 void pst_vsfree( vstr *vs );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
67 void pst_vsset( vstr *vs, char *s ); // Store string s in vb
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
68 void pst_vsnset( vstr *vs, char *s, size_t n ); // Store string s in vb
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
69 void pst_vsgrow( vstr *vs, size_t len ); // grow buffer by len bytes, data are preserved
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
70 size_t pst_vsavail( vstr *vs );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
71 void pst_vscat( vstr *vs, char *str );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
72 void pst_vsncat( vstr *vs, char *str, size_t len );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
73 void pst_vsnprepend( vstr *vs, char *str, size_t len ) ;
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
74 void pst_vsskip( vstr *vs, size_t len );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
75 int pst_vscmp( vstr *vs, char *str );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
76 void pst_vsskipws( vstr *vs );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
77 void pst_vs_printf( vstr *vs, char *fmt, ... );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
78 void pst_vs_printfa( vstr *vs, char *fmt, ... );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
79 void pst_vshexdump( vstr *vs, const char *b, size_t start, size_t stop, int ascii );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
80 int pst_vscatprintf( vstr *vs, char *fmt, ... );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
81 void pst_vsvprintf( vstr *vs, char *fmt, va_list ap );
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
82 void pst_vstrunc( vstr *vs, size_t off ); // Drop chars [off..dlen]
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
83 int pst_vslast( vstr *vs ); // returns the last character stored in a vstr string
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
84 void pst_vscharcat( vstr *vs, int ch );
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
85
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
86
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
87 void pst_unicode_init();
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
88 void pst_unicode_close();
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
89 size_t pst_vb_utf16to8(vbuf *dest, const char *inbuf, int iblen);
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
90 size_t pst_vb_utf8to8bit(vbuf *dest, const char *inbuf, int iblen, const char* charset);
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
91 size_t pst_vb_8bit2utf8(vbuf *dest, const char *inbuf, int iblen, const char* charset);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
92
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
93 int pst_vb_skipline( struct varbuf *vb ); // in: vb->b == "stuff\nmore_stuff"; out: vb->b == "more_stuff"
129
fc11b1d1ad34 fix initial from header in mbox format.
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
94
fc11b1d1ad34 fix initial from header in mbox format.
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
95
fc11b1d1ad34 fix initial from header in mbox format.
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
96 #endif // VBUF_H