Mercurial > pidgin
annotate src/protocols/msn/page.c @ 8718:6ab61697426e
[gaim-migrate @ 9473]
simguy wants this
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 20 Apr 2004 04:04:41 +0000 |
parents | 1e211dde3cae |
children | 9e5a709c30a8 |
rev | line source |
---|---|
5370 | 1 /** |
2 * @file page.c Paging functions | |
3 * | |
4 * gaim | |
5 * | |
8475
06f57183e29f
[gaim-migrate @ 9208]
Christian Hammond <chipx86@chipx86.com>
parents:
7468
diff
changeset
|
6 * Copyright (C) 2003-2004 Christian Hammond <chipx86@gnupdate.org> |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5370
diff
changeset
|
7 * |
5370 | 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 #include "page.h" | |
24 | |
25 #define GET_NEXT(tmp) \ | |
26 while (*(tmp) && *(tmp) != ' ' && *(tmp) != '\r') \ | |
27 (tmp)++; \ | |
28 if (*(tmp) != '\0') *(tmp)++ = '\0'; \ | |
29 if (*(tmp) == '\n') *(tmp)++; \ | |
30 while (*(tmp) && *(tmp) == ' ') \ | |
31 (tmp)++ | |
32 | |
33 #define GET_NEXT_LINE(tmp) \ | |
34 while (*(tmp) && *(tmp) != '\r') \ | |
35 (tmp)++; \ | |
36 if (*(tmp) != '\0') *(tmp)++ = '\0'; \ | |
37 if (*(tmp) == '\n') *(tmp)++ | |
38 | |
39 /* | |
7468
4ab8ec97576c
[gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
40 * <TEXT xml:space="preserve" enc="utf-8"> == 39 |
4ab8ec97576c
[gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
41 * </TEXT> == 7 |
4ab8ec97576c
[gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
42 * ---- |
4ab8ec97576c
[gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
43 * 46 |
5370 | 44 */ |
7468
4ab8ec97576c
[gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
45 #define MSN_PAGE_BASE_SIZE 46 |
5370 | 46 |
47 MsnPage * | |
48 msn_page_new(void) | |
49 { | |
50 MsnPage *page; | |
51 | |
52 page = g_new0(MsnPage, 1); | |
53 | |
54 page->size = MSN_PAGE_BASE_SIZE; | |
55 | |
56 return page; | |
57 } | |
58 | |
59 void | |
60 msn_page_destroy(MsnPage *page) | |
61 { | |
62 g_return_if_fail(page != NULL); | |
63 | |
64 if (page->body != NULL) | |
65 g_free(page->body); | |
66 | |
67 if (page->from_location != NULL) | |
68 g_free(page->from_location); | |
69 | |
70 if (page->from_phone != NULL) | |
71 g_free(page->from_phone); | |
72 | |
73 g_free(page); | |
74 } | |
75 | |
76 char * | |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
77 msn_page_gen_payload(const MsnPage *page, size_t *ret_size) |
5370 | 78 { |
79 char *str; | |
80 | |
81 g_return_val_if_fail(page != NULL, NULL); | |
82 | |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
83 str = |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
84 g_strdup_printf("<TEXT xml:space=\"preserve\" enc=\"utf-8\">%s</TEXT>", |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
85 msn_page_get_body(page)); |
5370 | 86 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
87 if (page->size != strlen(str)) |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
88 { |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
89 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
90 "Outgoing page size (%d) and string length (%d) " |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
91 "do not match!\n", page->size, strlen(str)); |
5370 | 92 } |
93 | |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
94 if (ret_size != NULL) |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
95 *ret_size = page->size - 1; |
5370 | 96 |
97 return str; | |
98 } | |
99 | |
100 void | |
101 msn_page_set_body(MsnPage *page, const char *body) | |
102 { | |
103 g_return_if_fail(page != NULL); | |
104 g_return_if_fail(body != NULL); | |
105 | |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
106 if (page->body != NULL) |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
107 { |
5370 | 108 page->size -= strlen(page->body); |
109 g_free(page->body); | |
110 } | |
111 | |
112 page->body = g_strdup(body); | |
113 | |
114 page->size += strlen(body); | |
115 } | |
116 | |
117 const char * | |
118 msn_page_get_body(const MsnPage *page) | |
119 { | |
120 g_return_val_if_fail(page != NULL, NULL); | |
121 | |
122 return page->body; | |
123 } | |
124 |