comparison mcabber/src/server.c @ 27:77e6bd2ccde6

[/trunk] Changeset 43 by mikael * Some more very small fixes, nothing serious.
author mikael
date Mon, 28 Mar 2005 09:18:01 +0000
parents 8588f5a4b638
children 0cd8025eebee
comparison
equal deleted inserted replaced
26:8588f5a4b638 27:77e6bd2ccde6
48 * 48 *
49 * Note: - 49 * Note: -
50 */ 50 */
51 static u_long srv_resolve(const char *host) 51 static u_long srv_resolve(const char *host)
52 { 52 {
53 long i; 53 in_addr_t i;
54 struct hostent *he; 54 struct hostent *he;
55 55
56 if ((i = inet_addr(host)) == -1) { 56 if ((i = inet_addr(host)) == INADDR_NONE) {
57 if (!(he = gethostbyname(host))) 57 if (!(he = gethostbyname(host)))
58 return 0; 58 return 0;
59 else 59 else
60 return (*(u_long *) he->h_addr); // XXX Memory leak 60 return (*(u_long *) he->h_addr); // XXX Memory leak
61 } 61 }
155 free(response); 155 free(response);
156 free(idsession); 156 free(idsession);
157 free(stringtosend); 157 free(stringtosend);
158 return NULL; 158 return NULL;
159 } 159 }
160 strncpy(idsession, aux, pos); 160 strncpy(idsession, aux, (size_t)pos);
161 161
162 free(response); 162 free(response);
163 163
164 strcpy(stringtosend, "<iq type='set' id='1000'>"); 164 strcpy(stringtosend, "<iq type='set' id='1000'>");
165 strcat(stringtosend, "<query xmlns='jabber:iq:auth'>"); 165 strcat(stringtosend, "<query xmlns='jabber:iq:auth'>");
272 { 272 {
273 char *stringtosend = malloc(2048); 273 char *stringtosend = malloc(2048);
274 char *utf8inputline = utf8_encode(text); 274 char *utf8inputline = utf8_encode(text);
275 275
276 sprintf(stringtosend, 276 sprintf(stringtosend,
277 "<message from='%s' to='%s' type='chat'><body>%s</body></message>", 277 "<message from='%s' to='%s' type='chat'><body>%.1536s</body></message>",
278 from, to, utf8inputline); 278 from, to, utf8inputline);
279 if (!sk_send(sock, stringtosend)) { 279 if (!sk_send(sock, stringtosend)) {
280 perror("senddata (server.c:247)"); 280 perror("senddata (server.c:247)");
281 free(stringtosend); 281 free(stringtosend);
282 free(utf8inputline); 282 free(utf8inputline);