Mercurial > pidgin
annotate src/protocols/zephyr/ZhmStat.c @ 10976:be22eb8fa671
[gaim-migrate @ 12802]
Fix encoding of filename
committer: Tailor Script <tailor@pidgin.im>
| author | Daniel Atallah <daniel.atallah@gmail.com> |
|---|---|
| date | Mon, 06 Jun 2005 22:38:11 +0000 |
| parents | 5727afad0fb8 |
| children | 64895571248f |
| rev | line source |
|---|---|
| 2419 | 1 /* This file is part of the Project Athena Zephyr Notification System. |
| 2 * It contains the ZhmStat() function. | |
| 3 * | |
| 4 * Created by: Marc Horowitz | |
| 5 * | |
| 10867 | 6 * $Id: ZhmStat.c 12553 2005-04-25 01:53:01Z thekingant $ |
| 2419 | 7 * |
| 8 * Copyright (c) 1996 by the Massachusetts Institute of Technology. | |
| 9 * For copying and distribution information, see the file | |
| 10 * "mit-copyright.h". | |
| 11 */ | |
| 12 | |
|
8792
43d6c08d7e96
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2419
diff
changeset
|
13 #include "internal.h" |
| 10867 | 14 |
| 15 #ifdef WIN32 | |
| 16 #include <winsock2.h> | |
| 17 #else | |
| 2419 | 18 #include <sys/socket.h> |
| 10867 | 19 #endif |
| 2419 | 20 |
| 21 #ifndef INADDR_LOOPBACK | |
| 22 #define INADDR_LOOPBACK 0x7f000001 | |
| 23 #endif | |
| 24 | |
| 25 Code_t ZhmStat(hostaddr, notice) | |
| 26 struct in_addr *hostaddr; | |
| 27 ZNotice_t *notice; | |
| 28 { | |
| 29 struct servent *sp; | |
| 30 struct sockaddr_in sin; | |
| 31 ZNotice_t req; | |
| 32 Code_t code; | |
| 33 struct timeval tv; | |
| 34 fd_set readers; | |
| 35 | |
| 36 (void) memset((char *)&sin, 0, sizeof(struct sockaddr_in)); | |
| 37 | |
| 38 sp = getservbyname(HM_SVCNAME, "udp"); | |
| 39 | |
| 40 sin.sin_port = (sp) ? sp->s_port : HM_SVC_FALLBACK; | |
| 41 sin.sin_family = AF_INET; | |
| 42 | |
| 43 if (hostaddr) | |
| 44 sin.sin_addr = *hostaddr; | |
| 45 else | |
| 46 sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); | |
| 47 | |
| 48 (void) memset((char *)&req, 0, sizeof(req)); | |
| 49 req.z_kind = STAT; | |
| 50 req.z_port = 0; | |
| 51 req.z_class = HM_STAT_CLASS; | |
| 52 req.z_class_inst = HM_STAT_CLIENT; | |
| 53 req.z_opcode = HM_GIMMESTATS; | |
| 54 req.z_sender = ""; | |
| 55 req.z_recipient = ""; | |
| 56 req.z_default_format = ""; | |
| 57 req.z_message_len = 0; | |
| 58 | |
| 59 if ((code = ZSetDestAddr(&sin)) != ZERR_NONE) | |
| 60 return(code); | |
| 61 | |
| 62 if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE) | |
| 63 return(code); | |
| 64 | |
| 65 /* Wait up to ten seconds for a response. */ | |
| 66 FD_ZERO(&readers); | |
| 67 FD_SET(ZGetFD(), &readers); | |
| 68 tv.tv_sec = 10; | |
| 69 tv.tv_usec = 0; | |
| 70 code = select(ZGetFD() + 1, &readers, NULL, NULL, &tv); | |
| 71 if (code < 0 && errno != EINTR) | |
| 72 return(errno); | |
| 73 if (code == 0 || (code < 0 && errno == EINTR) || ZPending() == 0) | |
| 74 return(ZERR_HMDEAD); | |
| 75 | |
| 76 return(ZReceiveNotice(notice, (struct sockaddr_in *) 0)); | |
| 77 } |
