1 *** src/protocols/yahoo/yahoo.c.orig Thu Jan 22 09:57:03 2004
2 --- src/protocols/yahoo/yahoo.c Thu Jan 22 10:15:11 2004
6 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 while (pos + 1 < len) {
17 if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
19 + if (x >= sizeof(key)-1) {
24 key[x++] = data[pos++];
26 + if (x >= sizeof(key)-1)
30 pair->key = strtol(key, NULL, 10);
36 #define OUT_CHARSET "utf-8"
38 static char *yahoo_decode(const char *text)
43 ! n = new = g_malloc(strlen (text) + 1);
45 ! for (p = (char *)text; *p; p++, n++) {
47 ! sscanf(p + 1, "%3o\n", (int *)n);
56 converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL);
62 static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt)
64 GaimAccount *account = gaim_connection_get_account(gc);
70 + static void octal(const char **p, const char *end, unsigned char *n)
74 + for (i = 0, c = 0; i < 3 && *p < end; ++i, ++*p) {
78 + case '1': c += 1; break;
79 + case '2': c += 2; break;
80 + case '3': c += 3; break;
81 + case '4': c += 4; break;
82 + case '5': c += 5; break;
83 + case '6': c += 6; break;
84 + case '7': c += 7; break;
96 + *n = (c > UCHAR_MAX) ? '?' : c;
100 #define OUT_CHARSET "utf-8"
102 static char *yahoo_decode(const char *text)
105 ! unsigned char *n, *new;
107 ! const char *p, *end;
109 ! len = strlen (text);
112 ! n = new = g_malloc(len + 1);
122 converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL);
129 static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt)
131 GaimAccount *account = gaim_connection_get_account(gc);
135 static void yahoo_web_pending(gpointer data, gint source, GaimInputCondition cond)
137 GaimConnection *gc = data;
138 GaimAccount *account = gaim_connection_get_account(gc);
139 struct yahoo_data *yd = gc->proto_data;
140 ! char buf[1024], buf2[256], *i = buf, *r = buf2;
143 len = read(source, buf, sizeof(buf));
144 ! if (len <= 0 || strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302"))) {
145 gaim_connection_error(gc, _("Unable to read"));
149 ! while ((i = strstr(i, "Set-Cookie: ")) && 0 < 2) {
150 ! i += strlen("Set-Cookie: ");
151 ! for (;*i != ';'; r++, i++) {
160 ! /* Get rid of that "; " */
162 ! yd->auth = g_strdup(buf2);
163 gaim_input_remove(gc->inpa);
165 /* Now we have our cookies to login with. I'll go get the milk. */
168 static void yahoo_web_pending(gpointer data, gint source, GaimInputCondition cond)
170 + static const char http302[] = "HTTP/1.0 302";
171 + static const char setcookie[] = "Set-Cookie: ";
172 GaimConnection *gc = data;
173 GaimAccount *account = gaim_connection_get_account(gc);
174 struct yahoo_data *yd = gc->proto_data;
175 ! char buf[1024], *i = buf;
179 len = read(source, buf, sizeof(buf));
180 ! if (len <= 0 || (len >= sizeof(http302)-1 &&
181 ! memcmp(http302, buf, sizeof(http302)-1) != 0)) {
182 gaim_connection_error(gc, _("Unable to read"));
185 ! s = g_string_sized_new(len);
187 ! while ((i = strstr(i, setcookie)) != NULL) {
188 ! i += sizeof(setcookie)-1;
189 ! for (;*i != ';'; i++)
190 ! g_string_append_c(s, *i);
191 ! g_string_append(s, "; ");
193 ! yd->auth = g_string_free(s, FALSE);
194 gaim_input_remove(gc->inpa);
196 /* Now we have our cookies to login with. I'll go get the milk. */
201 char name[64], value[64];
202 while ((c < (buf + len)) && (c = strstr(c, "<input "))) {
203 c = strstr(c, "name=\"") + strlen("name=\"");
204 ! for (d = name; *c!='"'; c++, d++)
207 d = strstr(c, "value=\"") + strlen("value=\"");
208 if (strchr(c, '>') < d)
210 ! for (c = d, d = value; *c!='"'; c++, d++)
213 g_hash_table_insert(hash, g_strdup(name), g_strdup(value));
217 char name[64], value[64];
218 + int count = sizeof(name)-1;
219 while ((c < (buf + len)) && (c = strstr(c, "<input "))) {
220 c = strstr(c, "name=\"") + strlen("name=\"");
221 ! for (d = name; *c!='"' && count; c++, d++, count--)
224 + count = sizeof(value)-1;
225 d = strstr(c, "value=\"") + strlen("value=\"");
226 if (strchr(c, '>') < d)
228 ! for (c = d, d = value; *c!='"' && count; c++, d++, count--)
231 g_hash_table_insert(hash, g_strdup(name), g_strdup(value));
232 *** src/proxy.c.orig Thu Jan 22 08:27:26 2004
233 --- src/proxy.c Thu Jan 22 08:28:05 2004
237 gaim_input_remove(phb->inpa);
239 ! while ((nlc != 2) && (read(source, &inputline[pos++], 1) == 1)) {
240 if (inputline[pos - 1] == '\n')
242 else if (inputline[pos - 1] != '\r')
245 gaim_input_remove(phb->inpa);
247 ! while ((pos < sizeof(inputline)-1) && (nlc != 2) && (read(source, &inputline[pos++], 1) == 1)) {
248 if (inputline[pos - 1] == '\n')
250 else if (inputline[pos - 1] != '\r')
251 *** src/util.c.orig Fri Jan 9 22:04:56 2004
252 --- src/util.c Thu Jan 22 08:26:14 2004
255 /**************************************************************************
256 * Quoted Printable Functions
257 **************************************************************************/
259 ! gaim_quotedp_decode(const char *str, char **ret_str, int *ret_len)
263 ! n = new = g_malloc(strlen (str) + 1);
265 ! for (p = (char *)str; *p; p++, n++) {
267 ! sscanf(p + 1, "%2x\n", (int *)n);
270 ! else if (*p == '_')
280 /**************************************************************************
281 * Quoted Printable Functions
282 **************************************************************************/
283 ! static void hex(const char **p, const char *end, unsigned char *n)
287 ! for (i = 0, c = 0; i < 2 && *p < end; ++i, ++*p) {
291 ! case '1': c += 1; break;
292 ! case '2': c += 2; break;
293 ! case '3': c += 3; break;
294 ! case '4': c += 4; break;
295 ! case '5': c += 5; break;
296 ! case '6': c += 6; break;
297 ! case '7': c += 7; break;
298 ! case '8': c += 8; break;
299 ! case '9': c += 9; break;
300 ! case 'a': c += 10; break;
301 ! case 'b': c += 11; break;
302 ! case 'c': c += 12; break;
303 ! case 'd': c += 13; break;
304 ! case 'e': c += 14; break;
305 ! case 'f': c += 15; break;
306 ! case 'A': c += 10; break;
307 ! case 'B': c += 11; break;
308 ! case 'C': c += 12; break;
309 ! case 'D': c += 13; break;
310 ! case 'E': c += 14; break;
311 ! case 'F': c += 15; break;
323 ! *n = (c > UCHAR_MAX) ? '?' : c;
328 ! gaim_quotedp_decode(const char *str, char **ret_str, int *ret_len)
330 ! const char *p, *end;
331 ! unsigned char *n, *new;
334 ! len = strlen (str);
335 ! n = new = g_malloc(len + 1);
342 ! } else if (*p == '_')
359 char host[256], path[256];
367 char host[256], path[256];
372 g_snprintf(scan_info, sizeof(scan_info),
373 ! "%%[%s]:%%[%s]/%%[%s]", addr_ctrl, port_ctrl, page_ctrl);
375 f = sscanf(url, scan_info, host, port_str, path);
379 g_snprintf(scan_info, sizeof(scan_info),
381 addr_ctrl, page_ctrl);
382 f = sscanf(url, scan_info, host, path);
383 g_snprintf(port_str, sizeof(port_str), "80");
389 g_snprintf(scan_info, sizeof(scan_info),
390 ! "%%255[%s]:%%5[%s]/%%255[%s]", addr_ctrl, port_ctrl, page_ctrl);
391 ! addr_ctrl[sizeof(addr_ctrl)-1] = '\0';
392 ! port_ctrl[sizeof(port_ctrl)-1] = '\0';
393 ! page_ctrl[sizeof(page_ctrl)-1] = '\0';
395 f = sscanf(url, scan_info, host, port_str, path);
399 g_snprintf(scan_info, sizeof(scan_info),
400 ! "%%255[%s]/%%255[%s]",
401 addr_ctrl, page_ctrl);
402 f = sscanf(url, scan_info, host, path);
403 + addr_ctrl[sizeof(addr_ctrl)-1] = '\0';
404 + page_ctrl[sizeof(page_ctrl)-1] = '\0';
405 g_snprintf(port_str, sizeof(port_str), "80");
411 parse_content_len(const char *data, size_t data_len)
413 ! size_t content_len = 0;
415 ! sscanf(data, "Content-Length: %d", (int *)&content_len);
421 parse_content_len(const char *data, size_t data_len)
423 ! int content_len = 0;
426 ! tmp = g_malloc(data_len + 1);
427 ! memcpy(tmp, data, data_len);
428 ! tmp[data_len] = '\0';
429 ! sscanf(tmp, "Content-Length: %d", &content_len);