Thu, 18 Aug 2005 06:33:33 +0000
[gaim-migrate @ 13499]
Fix a C99ism.
| 2086 | 1 | /* This file is part of the Project Athena Zephyr Notification System. |
| 2 | * It contains source for the ZGetSender.c function. | |
| 3 | * | |
| 4 | * Created by: Robert French | |
| 5 | * | |
| 6 | * Copyright (c) 1987, 1991 by the Massachusetts Institute of Technology. | |
| 7 | * For copying and distribution information, see the file | |
| 8 | * "mit-copyright.h". | |
| 9 | */ | |
| 10 | ||
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2086
diff
changeset
|
11 | #include "internal.h" |
| 2086 | 12 | |
| 10867 | 13 | #ifndef WIN32 |
| 2086 | 14 | #include <pwd.h> |
| 10867 | 15 | #endif |
| 2086 | 16 | |
| 17 | char *ZGetSender() | |
| 18 | { | |
| 19 | struct passwd *pw; | |
| 20 | #ifdef ZEPHYR_USES_KERBEROS | |
| 21 | char pname[ANAME_SZ], pinst[INST_SZ], prealm[REALM_SZ]; | |
| 22 | static char sender[ANAME_SZ+INST_SZ+REALM_SZ+3] = ""; | |
| 10867 | 23 | long int kerror; |
| 2086 | 24 | #else |
| 25 | static char sender[128] = ""; | |
| 26 | #endif | |
| 27 | ||
| 10867 | 28 | #ifdef WIN32 |
| 29 | unsigned long sender_size = 127; | |
| 30 | #endif | |
| 31 | ||
| 2086 | 32 | /* Return it if already cached */ |
| 10038 | 33 | |
| 34 | /* if (*sender) | |
| 2086 | 35 | return (sender); |
| 10038 | 36 | */ |
| 2086 | 37 | |
| 38 | #ifdef ZEPHYR_USES_KERBEROS | |
| 10867 | 39 | if ((kerror = krb_get_tf_fullname((char *)TKT_FILE, pname, pinst, prealm)) == KSUCCESS) |
| 2086 | 40 | { |
| 41 | (void) sprintf(sender, "%s%s%s@%s", pname, (pinst[0]?".":""), | |
| 42 | pinst, prealm); | |
| 43 | return (sender); | |
| 10867 | 44 | } else { |
| 45 | sprintf(sender,"%s@%s",(username?username:"unknown"),__Zephyr_realm); | |
| 46 | return (sender); | |
| 2086 | 47 | } |
| 48 | #endif | |
| 49 | ||
| 50 | /* XXX a uid_t is a u_short (now), but getpwuid | |
| 51 | * wants an int. AARGH! */ | |
| 10867 | 52 | #ifdef WIN32 |
| 53 | GetUserName(sender, &sender_size); | |
| 54 | #else | |
| 2086 | 55 | pw = getpwuid((int) getuid()); |
| 56 | if (!pw) | |
| 57 | return ("unknown"); | |
| 58 | (void) sprintf(sender, "%s@%s", pw->pw_name, __Zephyr_realm); | |
| 10867 | 59 | #endif |
| 2086 | 60 | return (sender); |
| 61 | } |