Tue, 21 Jan 2025 10:44:24 -0600
zephyr: Modernize K&R function prototypes
This is a backport of 811f82db29dd, as GCC and/or Clang is warning how these are outdated and unsupported for C23.
Testing Done:
Compiled with GCC 15 without `-Wold-style-prototype` warnings raised.
Reviewed at https://reviews.imfreedom.org/r/3775/
| 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 | * | |
| 6 | * Copyright (c) 1996 by the Massachusetts Institute of Technology. | |
| 7 | * For copying and distribution information, see the file | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
8 | * "mit-copyright.h". |
| 2419 | 9 | */ |
| 10 | ||
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2419
diff
changeset
|
11 | #include "internal.h" |
| 10867 | 12 | |
| 13 | #ifdef WIN32 | |
| 14 | #include <winsock2.h> | |
| 15 | #else | |
| 2419 | 16 | #include <sys/socket.h> |
| 10867 | 17 | #endif |
| 2419 | 18 | |
| 19 | #ifndef INADDR_LOOPBACK | |
| 20 | #define INADDR_LOOPBACK 0x7f000001 | |
| 21 | #endif | |
| 22 | ||
|
43153
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
31294
diff
changeset
|
23 | Code_t |
|
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
31294
diff
changeset
|
24 | ZhmStat(struct in_addr *hostaddr, ZNotice_t *notice) |
| 2419 | 25 | { |
| 26 | struct servent *sp; | |
| 27 | struct sockaddr_in sin; | |
| 28 | ZNotice_t req; | |
| 29 | Code_t code; | |
| 30 | struct timeval tv; | |
| 31 | fd_set readers; | |
| 32 | ||
| 33 | (void) memset((char *)&sin, 0, sizeof(struct sockaddr_in)); | |
| 34 | ||
| 35 | sp = getservbyname(HM_SVCNAME, "udp"); | |
| 36 | ||
| 37 | sin.sin_port = (sp) ? sp->s_port : HM_SVC_FALLBACK; | |
| 38 | sin.sin_family = AF_INET; | |
| 39 | ||
| 40 | if (hostaddr) | |
| 41 | sin.sin_addr = *hostaddr; | |
| 42 | else | |
| 43 | sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); | |
| 44 | ||
| 45 | (void) memset((char *)&req, 0, sizeof(req)); | |
| 46 | req.z_kind = STAT; | |
| 47 | req.z_port = 0; | |
| 48 | req.z_class = HM_STAT_CLASS; | |
| 49 | req.z_class_inst = HM_STAT_CLIENT; | |
| 50 | req.z_opcode = HM_GIMMESTATS; | |
| 51 | req.z_sender = ""; | |
| 52 | req.z_recipient = ""; | |
| 53 | req.z_default_format = ""; | |
| 54 | req.z_message_len = 0; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
55 | |
| 2419 | 56 | if ((code = ZSetDestAddr(&sin)) != ZERR_NONE) |
| 57 | return(code); | |
| 58 | ||
| 59 | if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE) | |
| 60 | return(code); | |
| 61 | ||
| 62 | /* Wait up to ten seconds for a response. */ | |
| 63 | FD_ZERO(&readers); | |
| 64 | FD_SET(ZGetFD(), &readers); | |
| 65 | tv.tv_sec = 10; | |
| 66 | tv.tv_usec = 0; | |
| 67 | code = select(ZGetFD() + 1, &readers, NULL, NULL, &tv); | |
| 68 | if (code < 0 && errno != EINTR) | |
| 69 | return(errno); | |
| 70 | if (code == 0 || (code < 0 && errno == EINTR) || ZPending() == 0) | |
| 71 | return(ZERR_HMDEAD); | |
| 72 | ||
| 73 | return(ZReceiveNotice(notice, (struct sockaddr_in *) 0)); | |
| 74 | } |