ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/util.C
(Generate patch)

Comparing gvpe/src/util.C (file contents):
Revision 1.5 by pcg, Wed Apr 2 03:25:17 2003 UTC vs.
Revision 1.7 by pcg, Mon Apr 7 01:12:56 2003 UTC

144 int pid; 144 int pid;
145 145
146 if ((pid = fork ()) == 0) 146 if ((pid = fork ()) == 0)
147 { 147 {
148 char *filename; 148 char *filename;
149 asprintf (&filename, "%s/%s", confbase, cb(0)); 149 asprintf (&filename, "%s/%s", confbase, cb());
150 execl (filename, filename, (char *) 0); 150 execl (filename, filename, (char *) 0);
151 exit (255); 151 exit (255);
152 } 152 }
153 else if (pid > 0) 153 else if (pid > 0)
154 { 154 {
157 waitpid (pid, 0, 0); 157 waitpid (pid, 0, 0);
158 /* TODO: check status */ 158 /* TODO: check status */
159 } 159 }
160 } 160 }
161} 161}
162
163#if ENABLE_HTTP_PROXY
164// works like strdup
165u8 *
166base64_encode (const u8 *data, unsigned int len)
167{
168 const static char base64[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
169
170 unsigned int t, i;
171 const u8 *end = data + len;
172 u8 *res = new u8 [4 * ((len + 2) / 3) + 1];
173 u8 *out = res;
174
175 while (data <= end - 3)
176 {
177 t = (((data[0] << 8) | data[1]) << 8) | data[2];
178 data += 3;
179
180 *out++ = base64[(t >> 18) & 0x3f];
181 *out++ = base64[(t >> 12) & 0x3f];
182 *out++ = base64[(t >> 6) & 0x3f];
183 *out++ = base64[(t ) & 0x3f];
184 }
185
186 for (t = 0, i = 0; data < end; i++)
187 t = (t << 8) | *data++;
188
189 switch (i)
190 {
191 case 2:
192 *out++ = base64[(t >> 10) & 0x3f];
193 *out++ = base64[(t >> 4) & 0x3f];
194 *out++ = base64[(t << 2) & 0x3f];
195 *out++ = '=';
196 break;
197 case 1:
198 *out++ = base64[(t >> 2) & 0x3f];
199 *out++ = base64[(t << 4) & 0x3f];
200 *out++ = '=';
201 *out++ = '=';
202 break;
203 }
204
205 *out++ = 0;
206
207 return res;
208}
209#endif
210

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines