annotate src/vbuf.c @ 174:9bbc834d5f3e

new debianization from hggdh
author Carl Byington <carl@five-ten-sg.com>
date Tue, 07 Apr 2009 13:45:20 -0700
parents 6954d315aaa8
children ac6e22c8a9cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
73
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
1
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
2 #include "define.h"
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
3
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
4
73
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
5 #define ASSERT(x,...) { if( !(x) ) DIE(( __VA_ARGS__)); }
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
6
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
7
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
8 int pst_skip_nl(char *s)
43
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 if (s[0] == '\n')
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
11 return 1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
12 if (s[0] == '\r' && s[1] == '\n')
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
13 return 2;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
14 if (s[0] == '\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
15 return 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
16 return -1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
17 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
18
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
19
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
20 int pst_find_nl(vstr * vs)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
21 {
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
22 char *nextr, *nextn;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
23
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
24 nextr = memchr(vs->b, '\r', vs->dlen);
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 nextn = memchr(vs->b, '\n', vs->dlen);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
26
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
27 //case 1: UNIX, we find \n first
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
28 if (nextn && (!nextr || (nextr > nextn))) {
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
29 return nextn - vs->b;
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 }
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 //case 2: DOS, we find \r\n
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
32 if (nextr && nextn && (nextn-nextr == 1)) {
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
33 return nextr - vs->b;
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 }
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 //case 3: we find nothing
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
36
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
37 return -1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
38 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
39
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
40
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
41 // UTF8 <-> UTF16 <-> ISO8859 Character set conversion functions and (ack) their globals
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
42
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
43 static int unicode_up = 0;
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
44 static iconv_t i16to8;
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
45 static const char *target_charset = NULL;
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
46 static int target_open_from = 0;
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
47 static int target_open_to = 0;
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
48 static iconv_t i8totarget = (iconv_t)-1;
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
49 static iconv_t target2i8 = (iconv_t)-1;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
50
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
51
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
52 void pst_unicode_init()
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
53 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
54 if (unicode_up) pst_unicode_close();
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
55 i16to8 = iconv_open("utf-8", "utf-16le");
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
56 if (i16to8 == (iconv_t)-1) {
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
57 WARN(("Couldn't open iconv descriptor for utf-16le to utf-8.\n"));
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
58 exit(1);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
59 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
60 unicode_up = 1;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
61 }
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
62
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
63
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
64 void pst_unicode_close()
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
65 {
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
66 iconv_close(i16to8);
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
67 if (target_open_from) iconv_close(i8totarget);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
68 if (target_open_to) iconv_close(target2i8);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
69 if (target_charset) free((char *)target_charset);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
70 target_charset = NULL;
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
71 target_open_from = 0;
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
72 target_open_to = 0;
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
73 unicode_up = 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
74 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
75
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
76
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
77 static int utf16_is_terminated(const char *str, int length);
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
78 static int utf16_is_terminated(const char *str, int length)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
79 {
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
80 VSTR_STATIC(errbuf, 100);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
81 int len = -1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
82 int i;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
83 for (i = 0; i < length; i += 2) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
84 if (str[i] == 0 && str[i + 1] == 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
85 len = i;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
86 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
87 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
88
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
89 if (-1 == len) {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
90 pst_vshexdump(errbuf, str, 0, length, 1);
120
6395ced2b8b2 disable building pst2dii on cygwin
Carl Byington <carl@five-ten-sg.com>
parents: 116
diff changeset
91 DEBUG_WARN(("String is not zero terminated (probably broken data from registry) %s.\n", errbuf->b));
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
92 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
93
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
94 return (-1 == len) ? 0 : 1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
95 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
96
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
97
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
98 size_t pst_vb_utf16to8(vbuf *dest, const char *inbuf, int iblen)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
99 {
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
100 size_t inbytesleft = iblen;
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
101 size_t icresult = (size_t)-1;
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
102 size_t outbytesleft = 0;
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
103 char *outbuf = NULL;
164
ab384fed78c5 Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
104 int myerrno;
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
105
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
106 ASSERT(unicode_up, "vb_utf16to8() called before unicode started.");
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
107 pst_vbresize(dest, iblen);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
108
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
109 //Bad Things can happen if a non-zero-terminated utf16 string comes through here
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
110 if (!utf16_is_terminated(inbuf, iblen))
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
111 return (size_t)-1;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
112
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
113 do {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
114 outbytesleft = dest->blen - dest->dlen;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
115 outbuf = dest->b + dest->dlen;
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
116 icresult = iconv(i16to8, (ICONV_CONST char**)&inbuf, &inbytesleft, &outbuf, &outbytesleft);
164
ab384fed78c5 Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
117 myerrno = errno;
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
118 dest->dlen = outbuf - dest->b;
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
119 if (inbytesleft) pst_vbgrow(dest, inbytesleft);
164
ab384fed78c5 Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
120 } while ((size_t)-1 == icresult && E2BIG == myerrno);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
121
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
122 if (icresult == (size_t)-1) {
164
ab384fed78c5 Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
123 DEBUG_WARN(("iconv failure: %s\n", strerror(myerrno)));
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
124 pst_unicode_init();
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
125 return (size_t)-1;
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
126 }
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
127 return (icresult) ? (size_t)-1 : 0;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
128 }
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
129
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
130
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
131 static void open_targets(const char* charset);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
132 static void open_targets(const char* charset)
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
133 {
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
134 if (!target_charset || strcasecmp(target_charset, charset)) {
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
135 if (target_open_from) iconv_close(i8totarget);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
136 if (target_open_to) iconv_close(target2i8);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
137 if (target_charset) free((char *)target_charset);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
138 target_charset = strdup(charset);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
139 target_open_from = 1;
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
140 target_open_to = 1;
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
141 i8totarget = iconv_open(target_charset, "utf-8");
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
142 if (i8totarget == (iconv_t)-1) {
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
143 target_open_from = 0;
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
144 WARN(("Couldn't open iconv descriptor for utf-8 to %s.\n", target_charset));
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
145 }
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
146 target2i8 = iconv_open("utf-8", target_charset);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
147 if (target2i8 == (iconv_t)-1) {
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
148 target_open_to = 0;
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
149 WARN(("Couldn't open iconv descriptor for %s to utf-8.\n", target_charset));
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
150 }
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
151 }
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
152 }
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
153
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
154
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
155 static size_t sbcs_conversion(vbuf *dest, const char *inbuf, int iblen, iconv_t conversion);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
156 static size_t sbcs_conversion(vbuf *dest, const char *inbuf, int iblen, iconv_t conversion)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
157 {
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
158 size_t inbytesleft = iblen;
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
159 size_t icresult = (size_t)-1;
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
160 size_t outbytesleft = 0;
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
161 char *outbuf = NULL;
164
ab384fed78c5 Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
162 int myerrno;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
163
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
164 pst_vbresize(dest, 2*iblen);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
165
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
166 do {
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
167 outbytesleft = dest->blen - dest->dlen;
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
168 outbuf = dest->b + dest->dlen;
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
169 icresult = iconv(conversion, (ICONV_CONST char**)&inbuf, &inbytesleft, &outbuf, &outbytesleft);
164
ab384fed78c5 Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
170 myerrno = errno;
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
171 dest->dlen = outbuf - dest->b;
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
172 if (inbytesleft) pst_vbgrow(dest, 2*inbytesleft);
164
ab384fed78c5 Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
173 } while ((size_t)-1 == icresult && E2BIG == myerrno);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
174
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
175 if (icresult == (size_t)-1) {
164
ab384fed78c5 Compensate for iconv conversion to utf-7 that produces strings that are not null terminated.
Carl Byington <carl@five-ten-sg.com>
parents: 151
diff changeset
176 DEBUG_WARN(("iconv failure: %s\n", strerror(myerrno)));
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
177 pst_unicode_init();
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
178 return (size_t)-1;
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
179 }
116
ed2a260bbb98 improve handling of content-type charset values in mime parts
Carl Byington <carl@five-ten-sg.com>
parents: 93
diff changeset
180 return (icresult) ? (size_t)-1 : 0;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
181 }
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
182
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
183
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
184 size_t pst_vb_utf8to8bit(vbuf *dest, const char *inbuf, int iblen, const char* charset)
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
185 {
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
186 open_targets(charset);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
187 if (!target_open_from) return (size_t)-1; // failure to open the target
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
188 return sbcs_conversion(dest, inbuf, iblen, i8totarget);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
189 }
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
190
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
191
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
192 size_t pst_vb_8bit2utf8(vbuf *dest, const char *inbuf, int iblen, const char* charset)
151
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
193 {
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
194 open_targets(charset);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
195 if (!target_open_to) return (size_t)-1; // failure to open the target
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
196 return sbcs_conversion(dest, inbuf, iblen, target2i8);
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
197 }
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
198
cda7c812ec01 track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents: 142
diff changeset
199
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
200 vbuf *pst_vballoc(size_t len)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
201 {
73
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
202 struct varbuf *result = malloc(sizeof(struct varbuf));
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
203 if (result) {
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
204 result->dlen = 0;
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
205 result->blen = 0;
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
206 result->buf = NULL;
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
207 pst_vbresize(result, len);
73
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
208 }
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
209 else DIE(("malloc() failure"));
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
210 return result;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
211 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
212
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
213
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
214 void pst_vbcheck(vbuf * vb)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
215 {
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
216 ASSERT(vb->b >= vb->buf, "vbcheck(): data not inside 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
217 ASSERT((size_t)(vb->b - vb->buf) <= vb->blen, "vbcheck(): vb->b outside of buffer range.");
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
218 ASSERT(vb->dlen <= vb->blen, "vbcheck(): data length > buffer length.");
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
219 ASSERT(vb->blen < 1024 * 1024, "vbcheck(): blen is a bit large...hmmm.");
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
220 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
221
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
222
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
223 void pst_vbfree(vbuf * vb)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
224 {
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
225 free(vb->buf);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
226 free(vb);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
227 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
228
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
229
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
230 void pst_vbclear(struct varbuf *vb) // ditch the data, keep the buffer
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
231 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
232 pst_vbresize(vb, 0);
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
233 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
234
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
235
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
236 void pst_vbresize(struct varbuf *vb, size_t len) // DESTRUCTIVELY grow or shrink buffer
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
237 {
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
238 vb->dlen = 0;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
239
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
240 if (vb->blen >= len) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
241 vb->b = vb->buf;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
242 return;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
243 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
244
73
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
245 vb->buf = realloc(vb->buf, len);
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
246 vb->b = vb->buf;
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
247 vb->blen = len;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
248 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
249
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
250
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
251 size_t pst_vbavail(vbuf * vb)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
252 {
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
253 return vb->blen - vb->dlen - (size_t)(vb->b - vb->buf);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
254 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
255
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
256
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
257 void pst_vbgrow(struct varbuf *vb, size_t len) // out: vbavail(vb) >= len, data are preserved
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
258 {
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
259 if (0 == len)
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
260 return;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
261
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
262 if (0 == vb->blen) {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
263 pst_vbresize(vb, len);
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
264 return;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
265 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
266
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
267 if (vb->dlen + len > vb->blen) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
268 if (vb->dlen + len < vb->blen * 1.5)
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
269 len = vb->blen * 1.5;
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
270 char *nb = pst_malloc(vb->blen + len);
73
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
271 if (!nb) DIE(("malloc() failure"));
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
272 vb->blen = vb->blen + len;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
273 memcpy(nb, vb->b, vb->dlen);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
274
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
275 free(vb->buf);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
276 vb->buf = nb;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
277 vb->b = vb->buf;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
278 } else {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
279 if (vb->b != vb->buf)
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
280 memcpy(vb->buf, vb->b, vb->dlen);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
281 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
282
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
283 vb->b = vb->buf;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
284
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
285 ASSERT(pst_vbavail(vb) >= len, "vbgrow(): I have failed in my mission.");
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
286 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
287
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
288
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
289 void pst_vbset(vbuf * vb, void *b, size_t len) // set vbuf b size=len, resize if necessary, relen = how much to over-allocate
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
290 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
291 pst_vbresize(vb, len);
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
292 memcpy(vb->b, b, len);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
293 vb->dlen = len;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
294 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
295
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
296
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
297 void pst_vsskipws(vstr * vs)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
298 {
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
299 char *p = vs->b;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
300 while ((size_t)(p - vs->b) < vs->dlen && isspace(p[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
301 p++;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
302
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
303 pst_vbskip((vbuf *) vs, p - vs->b);
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
304 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
305
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
306
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
307 // append len bytes of b to vbuf, resize if necessary
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
308 void pst_vbappend(struct varbuf *vb, void *b, size_t len)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
309 {
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
310 if (0 == vb->dlen) {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
311 pst_vbset(vb, b, len);
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
312 return;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
313 }
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
314 pst_vbgrow(vb, len);
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
315 memcpy(vb->b + vb->dlen, b, len);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
316 vb->dlen += len;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
317 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
318
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
319
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
320 // dumps the first skip bytes from vbuf
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
321 void pst_vbskip(struct varbuf *vb, size_t skip)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
322 {
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
323 ASSERT(skip <= vb->dlen, "vbskip(): Attempt to seek past end of 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
324 vb->b += skip;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
325 vb->dlen -= skip;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
326 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
327
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
328
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
329 // overwrite vbdest with vbsrc
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
330 void pst_vboverwrite(struct varbuf *vbdest, struct varbuf *vbsrc)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
331 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
332 pst_vbresize(vbdest, vbsrc->blen);
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
333 memcpy(vbdest->b, vbsrc->b, vbsrc->dlen);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
334 vbdest->blen = vbsrc->blen;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
335 vbdest->dlen = vbsrc->dlen;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
336 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
337
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
338
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
339 vstr *pst_vsalloc(size_t len)
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
340 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
341 vstr *result = (vstr *) pst_vballoc(len + 1);
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
342 pst_vsset(result, "");
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
343 return result;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
344 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
345
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
346
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
347 static char *pst_vsstr(vstr * vs);
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
348 static char *pst_vsstr(vstr * vs)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
349 {
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
350 return vs->b;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
351 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
352
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
353
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
354 size_t pst_vslen(vstr * vs)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
355 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
356 return strlen(pst_vsstr(vs));
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
357 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
358
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
359
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
360 void pst_vsfree(vstr * vs)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
361 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
362 pst_vbfree((vbuf *) vs);
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
363 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
364
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
365
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
366 void pst_vscharcat(vstr * vb, int ch)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
367 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
368 pst_vbgrow((vbuf *) vb, 1);
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
369 vb->b[vb->dlen - 1] = ch;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
370 vb->b[vb->dlen] = '\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
371 vb->dlen++;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
372 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
373
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
374
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
375 // prependappend string str to vbuf, vbuf must already contain a valid string
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
376 void pst_vsnprepend(vstr * vb, char *str, size_t len)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
377 {
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
378 ASSERT(vb->b[vb->dlen - 1] == '\0', "vsncat(): attempt to append string to non-string.");
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
379 size_t sl = strlen(str);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
380 size_t n = (sl < len) ? sl : len;
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
381 pst_vbgrow((vbuf *) vb, n + 1);
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
382 memmove(vb->b + n, vb->b, vb->dlen - 1);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
383 memcpy(vb->b, str, n);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
384 vb->dlen += n;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
385 vb->b[vb->dlen - 1] = '\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
386 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
387
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
388
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
389 // len < dlen-1 -> skip len chars, else DIE
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
390 void pst_vsskip(vstr * vs, size_t len)
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
391 {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
392 ASSERT(len < vs->dlen - 1, "Attempt to skip past end of string");
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
393 pst_vbskip((vbuf *) vs, len);
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
394 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
395
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
396
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
397 // in: vb->b == "stuff\nmore_stuff"; out: vb->b == "more_stuff"
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
398 int pst_vsskipline(vstr * vs)
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
399 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
400 int nloff = pst_find_nl(vs);
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
401 int nll = pst_skip_nl(vs->b + nloff);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
402
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
403 if (nloff < 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
404 //TODO: error
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
405 printf("vb_skipline(): there seems to be no newline here.\n");
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
406 return -1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
407 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
408 if (nll < 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
409 //TODO: error
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
410 printf("vb_skipline(): there seems to be no newline here...except there should be. :P\n");
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
411 return -1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
412 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
413
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
414 memmove(vs->b, vs->b + nloff + nll, vs->dlen - nloff - nll);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
415
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
416 vs->dlen -= nloff + nll;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
417
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
418 return 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
419 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
420
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
421
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
422 int pst_vscatprintf(vstr * vs, char *fmt, ...)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
423 {
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
424 int size;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
425 va_list ap;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
426
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
427 /* Guess we need no more than 100 bytes. */
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
428 //vsresize( vb, 100 );
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
429 if (!vs->b || vs->dlen == 0) {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
430 pst_vsset(vs, "");
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
431 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
432
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
433 while (1) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
434 /* Try to print in the allocated space. */
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
435 va_start(ap, fmt);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
436 size = vsnprintf(vs->b + vs->dlen - 1, vs->blen - vs->dlen, fmt, ap);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
437 va_end(ap);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
438
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
439 /* If that worked, return the string. */
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
440 if ((size > -1) && ((size_t)size < vs->blen - vs->dlen)) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
441 vs->dlen += size;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
442 return size;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
443 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
444 /* Else try again with more space. */
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
445 if (size >= 0) /* glibc 2.1 */
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
446 pst_vbgrow((vbuf *) vs, size + 1); /* precisely what is needed */
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
447 else /* glibc 2.0 */
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
448 pst_vbgrow((vbuf *) vs, vs->blen);
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
449 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
450 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
451
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
452
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
453 // returns the last character stored in a vstr
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
454 int pst_vslast(vstr * vs)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
455 {
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
456 if (vs->dlen < 1)
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
457 return -1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
458 if (vs->b[vs->dlen - 1] != '\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
459 return -1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
460 if (vs->dlen == 1)
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
461 return '\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
462 return vs->b[vs->dlen - 2];
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
463 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
464
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
465
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
466 // print over vb
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
467 void pst_vs_printf(vstr * vs, char *fmt, ...)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
468 {
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
469 int size;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
470 va_list ap;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
471
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
472 /* Guess we need no more than 100 bytes. */
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
473 pst_vbresize((vbuf *) vs, 100);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
474
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
475 while (1) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
476 /* Try to print in the allocated space. */
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
477 va_start(ap, fmt);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
478 size = vsnprintf(vs->b, vs->blen, fmt, ap);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
479 va_end(ap);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
480
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
481 /* If that worked, return the string. */
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
482 if ((size > -1) && ((size_t)size < vs->blen)) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
483 vs->dlen = size + 1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
484 return;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
485 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
486 /* Else try again with more space. */
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
487 if (size >= 0) /* glibc 2.1 */
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
488 pst_vbresize((vbuf *) vs, size + 1); /* precisely what is needed */
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
489 else /* glibc 2.0 */
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
490 pst_vbresize((vbuf *) vs, vs->blen * 2);
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
491 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
492 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
493
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
494
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
495 // printf append to vs
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
496 void pst_vs_printfa(vstr * vs, char *fmt, ...)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
497 {
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
498 int size;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
499 va_list ap;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
500
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
501 if (vs->blen - vs->dlen < 50)
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
502 pst_vbgrow((vbuf *) vs, 100);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
503
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
504 while (1) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
505 /* Try to print in the allocated space. */
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
506 va_start(ap, fmt);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
507 size = vsnprintf(vs->b + vs->dlen - 1, vs->blen - vs->dlen + 1, fmt, ap);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
508 va_end(ap);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
509
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
510 /* If that worked, return the string. */
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
511 if ((size > -1) && ((size_t)size < vs->blen)) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
512 vs->dlen += size;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
513 return;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
514 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
515 /* Else try again with more space. */
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
516 if (size >= 0) /* glibc 2.1 */
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
517 pst_vbgrow((vbuf *) vs, size + 1 - vs->dlen); /* precisely what is needed */
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
518 else /* glibc 2.0 */
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
519 pst_vbgrow((vbuf *) vs, size);
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
520 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
521 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
522
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
523
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
524 void pst_vshexdump(vstr * vs, const char *b, size_t start, size_t stop, int ascii)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
525 {
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
526 char c;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
527 int diff, i;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
528
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
529 while (start < stop) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
530 diff = stop - start;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
531 if (diff > 16)
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
532 diff = 16;
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
533
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
534 pst_vs_printfa(vs, ":%08X ", start);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
535
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
536 for (i = 0; i < diff; i++) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
537 if (8 == i)
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
538 pst_vs_printfa(vs, " ");
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
539 pst_vs_printfa(vs, "%02X ", (unsigned char) *(b + start + i));
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
540 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
541 if (ascii) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
542 for (i = diff; i < 16; i++)
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
543 pst_vs_printfa(vs, " ");
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
544 for (i = 0; i < diff; i++) {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
545 c = *(b + start + i);
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
546 pst_vs_printfa(vs, "%c", isprint(c) ? c : '.');
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
547 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
548 }
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
549 pst_vs_printfa(vs, "\n");
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
550 start += 16;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
551 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
552 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
553
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
554
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
555 void pst_vsset(vstr * vs, char *s) // Store string s in vs
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
556 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
557 pst_vsnset(vs, s, strlen(s));
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
558 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
559
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
560
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
561 void pst_vsnset(vstr * vs, char *s, size_t n) // Store string s in vs
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
562 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
563 pst_vbresize((vbuf *) vs, n + 1);
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
564 memcpy(vs->b, s, n);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
565 vs->b[n] = '\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
566 vs->dlen = n + 1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
567 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
568
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
569
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
570 void pst_vsgrow(vstr * vs, size_t len) // grow buffer by len bytes, data are preserved
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
571 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
572 pst_vbgrow((vbuf *) vs, len);
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
573 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
574
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
575
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
576 size_t pst_vsavail(vstr * vs)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
577 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
578 return pst_vbavail((vbuf *) vs);
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
579 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
580
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
581
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
582 void pst_vsnset16(vstr * vs, char *s, size_t len) // Like vbstrnset, but for UTF16
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
583 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
584 pst_vbresize((vbuf *) vs, len + 1);
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
585 memcpy(vs->b, s, len);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
586
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
587 vs->b[len] = '\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
588 vs->dlen = len + 1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
589 vs->b[len] = '\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
590 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
591
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
592
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
593 void pst_vscat(vstr * vs, char *str)
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
594 {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
595 pst_vsncat(vs, str, strlen(str));
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
596 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
597
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
598
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
599 int pst_vscmp(vstr * vs, char *str)
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
600 {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
601 return strcmp(vs->b, str);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
602 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
603
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
604
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
605 void pst_vsncat(vstr * vs, char *str, size_t len) // append string str to vstr, vstr must already contain a valid string
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
606 {
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
607 ASSERT(vs->b[vs->dlen - 1] == '\0', "vsncat(): attempt to append string to non-string.");
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
608 size_t sl = strlen(str);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
609 size_t n = (sl < len) ? sl : len;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
610 //string append
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
611 pst_vbgrow((vbuf *) vs, n + 1);
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
612 memcpy(vs->b + vs->dlen - 1, str, n);
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
613 vs->dlen += n;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
614 vs->b[vs->dlen - 1] = '\0';
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents:
diff changeset
615 }
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
616
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
617
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 164
diff changeset
618 void pst_vstrunc(vstr * v, size_t off) // Drop chars [off..dlen]
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
619 {
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
620 if (off >= v->dlen - 1)
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
621 return; //nothing to do
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
622 v->b[off] = '\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
623 v->dlen = off + 1;
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
624 }
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
625
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 43
diff changeset
626