Mercurial > pidgin
annotate src/protocols/msn/httpmethod.h @ 8436:4bb3d8dc717e
[gaim-migrate @ 9166]
" If getaddrinfo() is used, the addrlen and addr returned
through that function are written through the pipe to
the child Gaim processes. getaddrinfo() sets the
addrlen and addr fields through the following
structure, defined in <netdb.h>:
struct addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
size_t ai_addrlen;
char *ai_canonname;
struct sockaddr *ai_addr;
struct addrinfo *ai_next;
};
This is from FreeBSD/amd64 5.2.1-RELEASE. This
structure is defined differently on different systems.
Take, for example, this OpenBSD/i386 3.5-beta system:
struct addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
socklen_t ai_addrlen;
struct sockaddr *ai_addr;
char *ai_canonname;
struct addrinfo *ai_next;
};
After being read, the addrlen and addr of each host is
written through the descriptor:
src/proxy.c:
466 rc =
getaddrinfo(dns_params.hostname, servname, &hints, &res);
...
478 while(res) {
479
write(child_out[1], &(res->ai_addrlen),
sizeof(res->ai_addrlen));
480
write(child_out[1], res->ai_addr, res->ai_addrlen);
481 res =
res->ai_next;
482 }
And later subsequently read:
286 rc=read(req->fd_out,
&addrlen, sizeof(addrlen));
287 if(rc>0 && addrlen > 0) {
288
addr=g_malloc(addrlen);
289
rc=read(req->fd_out, addr, addrlen);
So hence, the type of addrlen that is used in
host_resolved() must match that of the addrlen used in
the addrinfo structure, or they must at least be
guarenteed to be the same size." --jarady
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Fri, 12 Mar 2004 16:59:22 +0000 |
| parents | c719f9a181d4 |
| children | 06f57183e29f |
| rev | line source |
|---|---|
| 7288 | 1 /** |
| 2 * @file httpmethod.h HTTP connection method | |
| 3 * | |
| 4 * gaim | |
| 5 * | |
| 6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
| 7 * | |
| 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 #ifndef _MSN_HTTP_METHOD_H_ | |
| 23 #define _MSN_HTTP_METHOD_H_ | |
| 24 | |
| 25 typedef struct _MsnHttpMethodData MsnHttpMethodData; | |
| 26 | |
| 27 #include "servconn.h" | |
| 28 | |
| 29 struct _MsnHttpMethodData | |
| 30 { | |
| 31 char *session_id; | |
| 32 char *old_gateway_ip; | |
| 33 char *gateway_ip; | |
| 34 const char *server_type; | |
| 35 | |
| 36 int timer; | |
| 37 | |
| 38 gboolean virgin; | |
| 39 gboolean waiting_response; | |
|
8298
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
40 gboolean dirty; |
| 7288 | 41 |
| 42 GList *queue; | |
| 43 }; | |
| 44 | |
| 45 /** | |
|
8298
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
46 * Initializes the HTTP data for a session. |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
47 * |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
48 * @param session The session. |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
49 */ |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
50 void msn_http_session_init(MsnSession *session); |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
51 |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
52 /** |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
53 * Uninitializes the HTTP data for a session. |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
54 * |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
55 * @param session The session. |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
56 */ |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
57 void msn_http_session_uninit(MsnSession *session); |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
58 |
|
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
59 /** |
| 7288 | 60 * Writes data to the server using the HTTP connection method. |
| 61 * | |
| 62 * @param servconn The server connection. | |
| 63 * @param buf The data to write. | |
| 64 * @param size The size of the data to write. | |
| 65 * @param server_type The optional server type. | |
| 66 * | |
| 67 * @return The number of bytes written. | |
| 68 */ | |
| 69 size_t msn_http_servconn_write(MsnServConn *servconn, const char *buf, | |
| 70 size_t size, const char *server_type); | |
| 71 | |
| 72 /** | |
| 73 * Polls the server for data. | |
| 74 * | |
| 75 * @param servconn The server connection. | |
| 76 */ | |
| 77 void msn_http_servconn_poll(MsnServConn *servconn); | |
| 78 | |
| 79 /** | |
| 80 * Processes an incoming message and returns a string the rest of MSN | |
| 81 * can deal with. | |
| 82 * | |
| 83 * @param servconn The server connection. | |
| 84 * @param buf The incoming buffer. | |
| 85 * @param size The incoming size. | |
| 86 * @param ret_buf The returned buffer. | |
| 87 * @param ret_len The returned length. | |
| 88 * @param error TRUE if there was an HTTP error. | |
| 89 * | |
| 90 * @return TRUE if the returned buffer is ready to be processed. | |
| 91 * FALSE otherwise. | |
| 92 */ | |
| 93 gboolean msn_http_servconn_parse_data(MsnServConn *servconn, | |
| 94 const char *buf, size_t size, | |
| 95 char **ret_buf, size_t *ret_size, | |
| 96 gboolean *error); | |
| 97 | |
| 98 #endif /* _MSN_HTTP_METHOD_H_ */ |
