Mercurial > pidgin
comparison src/html.c @ 4322:a789969fc198
[gaim-migrate @ 4577]
I decided that the callback for grab_url should return a length, too.
committer: Tailor Script <tailor@pidgin.im>
| author | Rob Flynn <gaim@robflynn.com> |
|---|---|
| date | Fri, 17 Jan 2003 04:24:29 +0000 |
| parents | 988485669631 |
| children | bbd7b12986a8 |
comparison
equal
deleted
inserted
replaced
| 4321:1cfad48b7d93 | 4322:a789969fc198 |
|---|---|
| 113 sscanf(port, "%d", &test->port); | 113 sscanf(port, "%d", &test->port); |
| 114 return test; | 114 return test; |
| 115 } | 115 } |
| 116 | 116 |
| 117 struct grab_url_data { | 117 struct grab_url_data { |
| 118 void (* callback)(gpointer, char *); | 118 void (* callback)(gpointer, char *, unsigned long); |
| 119 gpointer data; | 119 gpointer data; |
| 120 struct g_url *website; | 120 struct g_url *website; |
| 121 char *url; | 121 char *url; |
| 122 gboolean full; | 122 gboolean full; |
| 123 | 123 |
| 125 | 125 |
| 126 gboolean sentreq; | 126 gboolean sentreq; |
| 127 gboolean newline; | 127 gboolean newline; |
| 128 gboolean startsaving; | 128 gboolean startsaving; |
| 129 char *webdata; | 129 char *webdata; |
| 130 int len; | 130 unsigned long len; |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 static void grab_url_callback(gpointer dat, gint sock, GaimInputCondition cond) | 133 static void grab_url_callback(gpointer dat, gint sock, GaimInputCondition cond) |
| 134 { | 134 { |
| 135 struct grab_url_data *gunk = dat; | 135 struct grab_url_data *gunk = dat; |
| 136 char data; | 136 char data; |
| 137 | 137 |
| 138 if (sock == -1) { | 138 if (sock == -1) { |
| 139 gunk->callback(gunk->data, NULL); | 139 gunk->callback(gunk->data, NULL, 0); |
| 140 g_free(gunk->website); | 140 g_free(gunk->website); |
| 141 g_free(gunk->url); | 141 g_free(gunk->url); |
| 142 g_free(gunk); | 142 g_free(gunk); |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 184 | 184 |
| 185 debug_printf(_("Received: '%s'\n"), gunk->webdata); | 185 debug_printf(_("Received: '%s'\n"), gunk->webdata); |
| 186 | 186 |
| 187 gaim_input_remove(gunk->inpa); | 187 gaim_input_remove(gunk->inpa); |
| 188 close(sock); | 188 close(sock); |
| 189 gunk->callback(gunk->data, gunk->webdata); | 189 gunk->callback(gunk->data, gunk->webdata, gunk->len); |
| 190 if (gunk->webdata) | 190 if (gunk->webdata) |
| 191 g_free(gunk->webdata); | 191 g_free(gunk->webdata); |
| 192 g_free(gunk->website); | 192 g_free(gunk->website); |
| 193 g_free(gunk->url); | 193 g_free(gunk->url); |
| 194 g_free(gunk); | 194 g_free(gunk); |
| 195 } else { | 195 } else { |
| 196 gaim_input_remove(gunk->inpa); | 196 gaim_input_remove(gunk->inpa); |
| 197 close(sock); | 197 close(sock); |
| 198 gunk->callback(gunk->data, NULL); | 198 gunk->callback(gunk->data, NULL, 0); |
| 199 if (gunk->webdata) | 199 if (gunk->webdata) |
| 200 g_free(gunk->webdata); | 200 g_free(gunk->webdata); |
| 201 g_free(gunk->website); | 201 g_free(gunk->website); |
| 202 g_free(gunk->url); | 202 g_free(gunk->url); |
| 203 g_free(gunk); | 203 g_free(gunk); |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 void grab_url(char *url, gboolean full, void callback(gpointer, char *), gpointer data) | 207 void grab_url(char *url, gboolean full, void callback(gpointer, char *, unsigned long), gpointer data) |
| 208 { | 208 { |
| 209 int sock; | 209 int sock; |
| 210 struct grab_url_data *gunk = g_new0(struct grab_url_data, 1); | 210 struct grab_url_data *gunk = g_new0(struct grab_url_data, 1); |
| 211 | 211 |
| 212 gunk->callback = callback; | 212 gunk->callback = callback; |
| 218 if ((sock = proxy_connect(gunk->website->address, gunk->website->port, | 218 if ((sock = proxy_connect(gunk->website->address, gunk->website->port, |
| 219 grab_url_callback, gunk)) < 0) { | 219 grab_url_callback, gunk)) < 0) { |
| 220 g_free(gunk->website); | 220 g_free(gunk->website); |
| 221 g_free(gunk->url); | 221 g_free(gunk->url); |
| 222 g_free(gunk); | 222 g_free(gunk); |
| 223 callback(data, g_strdup(_("g003: Error opening connection.\n"))); | 223 callback(data, g_strdup(_("g003: Error opening connection.\n")), 0); |
| 224 } | 224 } |
| 225 } | 225 } |
