Mercurial > pidgin
annotate src/protocols/msn/utils.c @ 7667:30593bf56e71
[gaim-migrate @ 8311]
(23:56:25) shx: LSchiere: there's something wrong in my patch
(23:56:34) Luke: okay
(23:56:38) Luke: what's that
(23:57:45) shx: I forgot to add a '0' a the end of a string
(23:57:56) shx: in the gaim_mime_decode_field funcition
(23:59:35) Luke: where in that?
(00:00:16) shx: at the end, just before this
(00:00:18) shx: if (*unencoded_start)
(00:00:19) shx: n = strcpy(n, unencoded_start);
(00:00:27) shx: whould be this
(00:00:28) shx: *n = '\0';
(00:01:05) Luke: so you are just setting it to NULL
(00:01:53) Luke: i don't understand why you need that n set at all inside
that if, since you just return new on the next line down
(00:03:35) shx: I doing some test right now, but I remember I added that
because I had of some errors
(00:05:04) Luke: i think what you may be hitting is a functional work
around for not properly initializing variables, something that shouldn't
work but does. because you shouldn't need to set something just before you
return unless you are returning IT (or unless you are using staticly
declared memory, in which case you might concievably be using that variable
again when you next enter the function
(00:05:55) shx: no
(00:06:18) shx: n is a pointer to the end of the string, and changes as the
while goes on
(00:06:37) Luke: ah
(00:06:42) shx: n doesn't matter
(00:07:01) Luke: so should the *n = '\0' be inside the if or outside it?
(00:07:30) shx: before the if
(00:07:44) shx: *n = '\0';
(00:07:45) shx: if (*unencoded_start)
(00:07:45) shx: n = strcpy(n, unencoded_start);
(00:08:07) shx: in the case there is no *unencoded_start
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Sun, 30 Nov 2003 05:10:24 +0000 |
| parents | 67f9b43c402a |
| children | 06f57183e29f |
| rev | line source |
|---|---|
| 5309 | 1 /** |
|
5312
89948fedf782
[gaim-migrate @ 5684]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
2 * @file utils.c Utility functions |
| 5309 | 3 * |
| 4 * gaim | |
| 5 * | |
| 6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
|
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6359
diff
changeset
|
7 * |
| 5309 | 8 * This program is free software; you can redistribute it and/or modify |
| 9 * it under the terms of the GNU General Public License as published by | |
| 10 * the Free Software Foundation; either version 2 of the License, or | |
| 11 * (at your option) any later version. | |
| 12 * | |
| 13 * This program is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 * GNU General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU General Public License | |
| 19 * along with this program; if not, write to the Free Software | |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 */ | |
| 22 #include "msn.h" | |
| 23 | |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
24 void |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
25 msn_parse_format(const char *mime, char **pre_ret, char **post_ret) |
| 5309 | 26 { |
| 27 char *cur; | |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
28 GString *pre = g_string_new(NULL); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
29 GString *post = g_string_new(NULL); |
|
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
30 unsigned int colors[3]; |
| 5309 | 31 |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
32 if (pre_ret != NULL) *pre_ret = NULL; |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
33 if (post_ret != NULL) *post_ret = NULL; |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
34 |
| 5309 | 35 cur = strstr(mime, "FN="); |
| 36 | |
| 37 if (cur && (*(cur = cur + 3) != ';')) { | |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
38 pre = g_string_append(pre, "<FONT FACE=\""); |
| 5309 | 39 |
| 40 while (*cur && *cur != ';') { | |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
41 pre = g_string_append_c(pre, *cur); |
| 5309 | 42 cur++; |
| 43 } | |
| 44 | |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
45 pre = g_string_append(pre, "\">"); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
46 post = g_string_prepend(post, "</FONT>"); |
| 5309 | 47 } |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
48 |
| 5309 | 49 cur = strstr(mime, "EF="); |
| 50 | |
| 51 if (cur && (*(cur = cur + 3) != ';')) { | |
| 52 while (*cur && *cur != ';') { | |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
53 pre = g_string_append_c(pre, '<'); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
54 pre = g_string_append_c(pre, *cur); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
55 pre = g_string_append_c(pre, '>'); |
| 5309 | 56 cur++; |
| 57 } | |
| 58 } | |
| 59 | |
| 60 cur = strstr(mime, "CO="); | |
| 61 | |
| 62 if (cur && (*(cur = cur + 3) != ';')) { | |
|
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
63 int i; |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
64 |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
65 i = sscanf(cur, "%02x%02x%02x;", &colors[0], &colors[1], &colors[2]); |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
66 |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
67 if (i > 0) { |
| 5309 | 68 char tag[64]; |
|
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
69 |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
70 if (i == 1) { |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
71 colors[2] = colors[0]; |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
72 colors[1] = 0; |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
73 colors[0] = 0; |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
74 } |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
75 else if (i == 2) { |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
76 colors[2] = colors[1]; |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
77 colors[1] = colors[0]; |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
78 colors[0] = 0; |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
79 } |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
80 |
| 5309 | 81 g_snprintf(tag, sizeof(tag), |
| 82 "<FONT COLOR=\"#%02hhx%02hhx%02hhx\">", | |
|
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
83 colors[2], colors[1], colors[0]); |
| 5309 | 84 |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
85 pre = g_string_append(pre, tag); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
86 post = g_string_prepend(post, "</FONT>"); |
| 5309 | 87 } |
| 88 } | |
| 89 | |
| 7134 | 90 cur = g_strdup(gaim_url_decode(pre->str)); |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
91 g_string_free(pre, TRUE); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
92 |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
93 if (pre_ret != NULL) |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
94 *pre_ret = cur; |
|
6359
dfde69e105ae
[gaim-migrate @ 6863]
Christian Hammond <chipx86@chipx86.com>
parents:
6358
diff
changeset
|
95 else |
|
dfde69e105ae
[gaim-migrate @ 6863]
Christian Hammond <chipx86@chipx86.com>
parents:
6358
diff
changeset
|
96 g_free(cur); |
| 5309 | 97 |
| 7134 | 98 cur = g_strdup(gaim_url_decode(post->str)); |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
99 g_string_free(post, TRUE); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
100 |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
101 if (post_ret != NULL) |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
102 *post_ret = cur; |
|
6359
dfde69e105ae
[gaim-migrate @ 6863]
Christian Hammond <chipx86@chipx86.com>
parents:
6358
diff
changeset
|
103 else |
|
dfde69e105ae
[gaim-migrate @ 6863]
Christian Hammond <chipx86@chipx86.com>
parents:
6358
diff
changeset
|
104 g_free(cur); |
| 5309 | 105 } |
