Sat, 25 Jun 2005 17:58:42 +0000
[gaim-migrate @ 12905]
I use
CFLAGS="-g3 -D_FORTIFY_SOURCE=2 -Werror-implicit-function-declaration -Wno-pointer-sign -Wdeclaration-after-statement"
... shouldn't I be using Gentoo ?
| 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 | * $Source$ | |
|
10328
b097a5cc92f3
[gaim-migrate @ 11535]
Mark Doliner <markdoliner@pidgin.im>
parents:
10326
diff
changeset
|
8 | * $Author: thekingant $ |
| 2086 | 9 | * |
| 10 | * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of Technology. | |
| 11 | * For copying and distribution information, see the file | |
| 12 | * "mit-copyright.h". | |
| 13 | */ | |
| 14 | /* $Header$ */ | |
| 15 | ||
| 16 | #ifndef lint | |
| 17 | static char rcsid_ZLocations_c[] = | |
| 18 | "$Zephyr: /afs/athena.mit.edu/astaff/project/zephyr/src/lib/RCS/ZLocations.c,v 1.30 90/12/20 03:04:39 raeburn Exp $"; | |
| 19 | #endif | |
| 20 | ||
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
7475
diff
changeset
|
21 | #include "internal.h" |
| 2086 | 22 | |
| 10867 | 23 | #ifndef WIN32 |
| 2086 | 24 | #include <pwd.h> |
| 10867 | 25 | #endif |
| 2086 | 26 | |
| 27 | extern char *getenv(); | |
| 28 | extern int errno; | |
| 29 | ||
| 30 | Code_t ZSetLocation(exposure) | |
| 31 | char *exposure; | |
| 32 | { | |
| 33 | return (Z_SendLocation(LOGIN_CLASS, exposure, ZAUTH, | |
| 34 | "$sender logged in to $1 on $3 at $2")); | |
| 35 | } | |
| 36 | ||
| 37 | Code_t ZUnsetLocation() | |
| 38 | { | |
| 39 | return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH, | |
| 40 | "$sender logged out of $1 on $3 at $2")); | |
| 41 | } | |
| 42 | ||
| 43 | Code_t ZFlushMyLocations() | |
| 44 | { | |
| 45 | return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, "")); | |
| 46 | } | |
| 47 | ||
| 48 | static char host[MAXHOSTNAMELEN], mytty[MAXPATHLEN]; | |
| 49 | static int reenter = 0; | |
| 50 | ||
| 51 | Code_t Z_SendLocation(class, opcode, auth, format) | |
| 52 | char *class; | |
| 53 | char *opcode; | |
| 54 | Z_AuthProc auth; | |
| 55 | char *format; | |
| 56 | { | |
| 57 | int retval; | |
| 58 | time_t ourtime; | |
| 59 | ZNotice_t notice, retnotice; | |
| 10867 | 60 | char *bptr[3]; |
| 2086 | 61 | #ifndef X_DISPLAY_MISSING |
| 62 | char *display; | |
| 63 | #endif | |
| 10867 | 64 | #ifndef WIN32 |
| 2086 | 65 | char *ttyp; |
| 10867 | 66 | char *p; |
| 67 | #endif | |
| 2086 | 68 | struct hostent *hent; |
| 69 | short wg_port = ZGetWGPort(); | |
| 70 | ||
| 71 | (void) memset((char *)¬ice, 0, sizeof(notice)); | |
| 72 | notice.z_kind = ACKED; | |
|
7475
987384816492
[gaim-migrate @ 8088]
Mark Doliner <markdoliner@pidgin.im>
parents:
2419
diff
changeset
|
73 | notice.z_port = (unsigned short) ((wg_port == -1) ? 0 : wg_port); |
| 2086 | 74 | notice.z_class = class; |
| 75 | notice.z_class_inst = ZGetSender(); | |
| 76 | notice.z_opcode = opcode; | |
| 77 | notice.z_sender = 0; | |
| 78 | notice.z_recipient = ""; | |
| 79 | notice.z_num_other_fields = 0; | |
| 80 | notice.z_default_format = format; | |
| 81 | ||
| 82 | /* | |
| 83 | keep track of what we said before so that we can be consistent | |
| 84 | when changing location information. | |
| 85 | This is done mainly for the sake of the WindowGram client. | |
| 86 | */ | |
| 87 | ||
| 88 | if (!reenter) { | |
| 89 | if (gethostname(host, MAXHOSTNAMELEN) < 0) | |
| 90 | return (errno); | |
| 91 | ||
| 92 | hent = gethostbyname(host); | |
| 93 | if (hent) { | |
| 94 | (void) strncpy(host, hent->h_name, sizeof(host)); | |
| 95 | host[sizeof(host) - 1] = '\0'; | |
| 96 | } | |
| 97 | #ifndef X_DISPLAY_MISSING | |
| 98 | if ((display = getenv("DISPLAY")) && *display) { | |
|
10328
b097a5cc92f3
[gaim-migrate @ 11535]
Mark Doliner <markdoliner@pidgin.im>
parents:
10326
diff
changeset
|
99 | (void) strncpy(mytty, display, sizeof(mytty)); |
| 2086 | 100 | } else { |
| 101 | #endif | |
| 10867 | 102 | #ifdef WIN32 |
|
10897
98867eee9779
[gaim-migrate @ 12612]
Mark Doliner <markdoliner@pidgin.im>
parents:
10867
diff
changeset
|
103 | strncpy(mytty, "WinGaim", sizeof(mytty)); |
| 10867 | 104 | #else |
| 2086 | 105 | ttyp = ttyname(0); |
| 2419 | 106 | if (ttyp && *ttyp) { |
| 107 | p = strchr(ttyp + 1, '/'); | |
| 108 | strcpy(mytty, (p) ? p + 1 : ttyp); | |
| 109 | } else { | |
|
10897
98867eee9779
[gaim-migrate @ 12612]
Mark Doliner <markdoliner@pidgin.im>
parents:
10867
diff
changeset
|
110 | strncpy(mytty, "unknown", sizeof(mytty)); |
| 2086 | 111 | } |
| 10867 | 112 | #endif |
|
10897
98867eee9779
[gaim-migrate @ 12612]
Mark Doliner <markdoliner@pidgin.im>
parents:
10867
diff
changeset
|
113 | mytty[sizeof(mytty)-1] = '\0'; |
| 2086 | 114 | #ifndef X_DISPLAY_MISSING |
| 115 | } | |
| 116 | #endif | |
| 117 | reenter = 1; | |
| 118 | } | |
| 119 | ||
| 120 | ourtime = time((time_t *)0); | |
| 2419 | 121 | bptr[0] = host; |
| 2086 | 122 | bptr[1] = ctime(&ourtime); |
| 123 | bptr[1][strlen(bptr[1])-1] = '\0'; | |
| 2419 | 124 | bptr[2] = mytty; |
| 2086 | 125 | |
| 126 | ||
| 127 | if ((retval = ZSendList(¬ice, bptr, 3, auth)) != ZERR_NONE) | |
| 128 | return (retval); | |
| 129 | ||
| 130 | retval = Z_WaitForNotice (&retnotice, ZCompareUIDPred, ¬ice.z_uid, | |
| 131 | SRV_TIMEOUT); | |
| 132 | if (retval != ZERR_NONE) | |
| 133 | return retval; | |
| 134 | ||
| 135 | if (retnotice.z_kind == SERVNAK) { | |
| 136 | if (!retnotice.z_message_len) { | |
| 137 | ZFreeNotice(&retnotice); | |
| 138 | return (ZERR_SERVNAK); | |
| 139 | } | |
| 140 | if (!strcmp(retnotice.z_message, ZSRVACK_NOTSENT)) { | |
| 141 | ZFreeNotice(&retnotice); | |
| 142 | return (ZERR_AUTHFAIL); | |
| 143 | } | |
| 144 | if (!strcmp(retnotice.z_message, ZSRVACK_FAIL)) { | |
| 145 | ZFreeNotice(&retnotice); | |
| 146 | return (ZERR_LOGINFAIL); | |
| 147 | } | |
| 148 | ZFreeNotice(&retnotice); | |
| 149 | return (ZERR_SERVNAK); | |
| 150 | } | |
| 151 | ||
| 152 | if (retnotice.z_kind != SERVACK) { | |
| 153 | ZFreeNotice(&retnotice); | |
| 154 | return (ZERR_INTERNAL); | |
| 155 | } | |
| 156 | ||
| 157 | if (!retnotice.z_message_len) { | |
| 158 | ZFreeNotice(&retnotice); | |
| 159 | return (ZERR_INTERNAL); | |
| 160 | } | |
| 161 | ||
| 162 | if (strcmp(retnotice.z_message, ZSRVACK_SENT) && | |
| 163 | strcmp(retnotice.z_message, ZSRVACK_NOTSENT)) { | |
| 164 | ZFreeNotice(&retnotice); | |
| 165 | return (ZERR_INTERNAL); | |
| 166 | } | |
| 167 | ||
| 168 | ZFreeNotice(&retnotice); | |
| 169 | ||
| 170 | return (ZERR_NONE); | |
| 171 | } |