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/
| 2086 | 1 | /* This file is part of the Project Athena Zephyr Notification System. |
| 2 | * It contains source for the ZSetLocation, ZUnsetLocation, and | |
| 3 | * ZFlushMyLocations functions. | |
| 4 | * | |
| 5 | * Created by: Robert French | |
| 6 | * | |
| 7 | * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of Technology. | |
| 8 | * For copying and distribution information, see the file | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
18220
diff
changeset
|
9 | * "mit-copyright.h". |
| 2086 | 10 | */ |
| 11 | ||
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
7475
diff
changeset
|
12 | #include "internal.h" |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
31294
diff
changeset
|
13 | #include "util.h" |
| 2086 | 14 | |
| 10867 | 15 | #ifndef WIN32 |
| 2086 | 16 | #include <pwd.h> |
| 10867 | 17 | #endif |
| 2086 | 18 | |
|
13583
29c0a756c086
[gaim-migrate @ 15964]
Richard Laager <rlaager@pidgin.im>
parents:
11105
diff
changeset
|
19 | #include <stdlib.h> |
|
29c0a756c086
[gaim-migrate @ 15964]
Richard Laager <rlaager@pidgin.im>
parents:
11105
diff
changeset
|
20 | #include <errno.h> |
| 2086 | 21 | |
|
43153
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
38259
diff
changeset
|
22 | Code_t |
|
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
38259
diff
changeset
|
23 | ZSetLocation(char *exposure) |
| 2086 | 24 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
18220
diff
changeset
|
25 | return (Z_SendLocation(LOGIN_CLASS, exposure, ZAUTH, |
| 2086 | 26 | "$sender logged in to $1 on $3 at $2")); |
| 27 | } | |
| 28 | ||
|
43153
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
38259
diff
changeset
|
29 | Code_t |
|
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
38259
diff
changeset
|
30 | ZUnsetLocation(void) |
| 2086 | 31 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
18220
diff
changeset
|
32 | return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH, |
| 2086 | 33 | "$sender logged out of $1 on $3 at $2")); |
| 34 | } | |
| 35 | ||
|
43153
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
38259
diff
changeset
|
36 | Code_t |
|
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
38259
diff
changeset
|
37 | ZFlushMyLocations(void) |
| 2086 | 38 | { |
| 39 | return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, "")); | |
| 40 | } | |
| 41 | ||
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
42 | static char host[MAXHOSTNAMELEN]; |
|
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
43 | static char *mytty = NULL; |
| 2086 | 44 | static int reenter = 0; |
| 45 | ||
|
43153
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
38259
diff
changeset
|
46 | Code_t |
|
2e4624a59df5
zephyr: Modernize K&R function prototypes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
38259
diff
changeset
|
47 | Z_SendLocation(char *class, char *opcode, Z_AuthProc auth, char *format) |
| 2086 | 48 | { |
| 49 | int retval; | |
| 50 | time_t ourtime; | |
| 51 | ZNotice_t notice, retnotice; | |
| 10867 | 52 | char *bptr[3]; |
| 2086 | 53 | #ifndef X_DISPLAY_MISSING |
| 54 | char *display; | |
| 55 | #endif | |
| 10867 | 56 | #ifndef WIN32 |
| 2086 | 57 | char *ttyp; |
| 10867 | 58 | char *p; |
| 59 | #endif | |
| 2086 | 60 | struct hostent *hent; |
| 61 | short wg_port = ZGetWGPort(); | |
| 62 | ||
| 63 | (void) memset((char *)¬ice, 0, sizeof(notice)); | |
| 64 | notice.z_kind = ACKED; | |
|
7475
987384816492
[gaim-migrate @ 8088]
Mark Doliner <markdoliner@pidgin.im>
parents:
2419
diff
changeset
|
65 | notice.z_port = (unsigned short) ((wg_port == -1) ? 0 : wg_port); |
| 2086 | 66 | notice.z_class = class; |
| 67 | notice.z_class_inst = ZGetSender(); | |
| 68 | notice.z_opcode = opcode; | |
| 69 | notice.z_sender = 0; | |
| 70 | notice.z_recipient = ""; | |
| 71 | notice.z_num_other_fields = 0; | |
| 72 | notice.z_default_format = format; | |
| 73 | ||
| 74 | /* | |
| 75 | keep track of what we said before so that we can be consistent | |
| 76 | when changing location information. | |
| 77 | This is done mainly for the sake of the WindowGram client. | |
| 78 | */ | |
| 79 | ||
| 80 | if (!reenter) { | |
| 81 | if (gethostname(host, MAXHOSTNAMELEN) < 0) | |
| 82 | return (errno); | |
| 83 | ||
| 84 | hent = gethostbyname(host); | |
| 85 | if (hent) { | |
| 86 | (void) strncpy(host, hent->h_name, sizeof(host)); | |
| 87 | host[sizeof(host) - 1] = '\0'; | |
| 88 | } | |
| 89 | #ifndef X_DISPLAY_MISSING | |
| 90 | if ((display = getenv("DISPLAY")) && *display) { | |
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
91 | mytty = g_strdup(display); |
| 2086 | 92 | } else { |
| 93 | #endif | |
| 10867 | 94 | #ifdef WIN32 |
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
95 | mytty = g_strdup("WinPurple"); |
| 10867 | 96 | #else |
| 2086 | 97 | ttyp = ttyname(0); |
| 2419 | 98 | if (ttyp && *ttyp) { |
| 99 | p = strchr(ttyp + 1, '/'); | |
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
100 | mytty = g_strdup((p) ? p + 1 : ttyp); |
| 2419 | 101 | } else { |
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
102 | mytty = g_strdup("unknown"); |
| 2086 | 103 | } |
| 10867 | 104 | #endif |
| 2086 | 105 | #ifndef X_DISPLAY_MISSING |
| 106 | } | |
| 107 | #endif | |
| 108 | reenter = 1; | |
| 109 | } | |
| 110 | ||
| 111 | ourtime = time((time_t *)0); | |
| 2419 | 112 | bptr[0] = host; |
| 2086 | 113 | bptr[1] = ctime(&ourtime); |
| 114 | bptr[1][strlen(bptr[1])-1] = '\0'; | |
| 2419 | 115 | bptr[2] = mytty; |
| 2086 | 116 | |
| 117 | if ((retval = ZSendList(¬ice, bptr, 3, auth)) != ZERR_NONE) | |
| 118 | return (retval); | |
| 119 | ||
| 120 | retval = Z_WaitForNotice (&retnotice, ZCompareUIDPred, ¬ice.z_uid, | |
| 121 | SRV_TIMEOUT); | |
| 122 | if (retval != ZERR_NONE) | |
| 123 | return retval; | |
| 124 | ||
| 125 | if (retnotice.z_kind == SERVNAK) { | |
| 126 | if (!retnotice.z_message_len) { | |
| 127 | ZFreeNotice(&retnotice); | |
| 128 | return (ZERR_SERVNAK); | |
| 129 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
31294
diff
changeset
|
130 | if (purple_strequal(retnotice.z_message, ZSRVACK_NOTSENT)) { |
| 2086 | 131 | ZFreeNotice(&retnotice); |
| 132 | return (ZERR_AUTHFAIL); | |
| 133 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
31294
diff
changeset
|
134 | if (purple_strequal(retnotice.z_message, ZSRVACK_FAIL)) { |
| 2086 | 135 | ZFreeNotice(&retnotice); |
| 136 | return (ZERR_LOGINFAIL); | |
| 137 | } | |
| 138 | ZFreeNotice(&retnotice); | |
| 139 | return (ZERR_SERVNAK); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
18220
diff
changeset
|
140 | } |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
18220
diff
changeset
|
141 | |
| 2086 | 142 | if (retnotice.z_kind != SERVACK) { |
| 143 | ZFreeNotice(&retnotice); | |
| 144 | return (ZERR_INTERNAL); | |
| 145 | } | |
| 146 | ||
| 147 | if (!retnotice.z_message_len) { | |
| 148 | ZFreeNotice(&retnotice); | |
| 149 | return (ZERR_INTERNAL); | |
| 150 | } | |
| 151 | ||
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
152 | if (!purple_strequal(retnotice.z_message, ZSRVACK_SENT) && |
|
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
153 | !purple_strequal(retnotice.z_message, ZSRVACK_NOTSENT)) { |
| 2086 | 154 | ZFreeNotice(&retnotice); |
| 155 | return (ZERR_INTERNAL); | |
| 156 | } | |
| 157 | ||
| 158 | ZFreeNotice(&retnotice); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
18220
diff
changeset
|
159 | |
| 2086 | 160 | return (ZERR_NONE); |
| 161 | } |