Mercurial > pidgin
annotate src/protocols/zephyr/ZGetSender.c @ 10897:04cb7363260d
[gaim-migrate @ 12612]
This might be a tiny bit clearer. It might also be uglier.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 03 May 2005 02:52:39 +0000 |
parents | 5727afad0fb8 |
children | 64895571248f |
rev | line source |
---|---|
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 * $Source$ | |
10867 | 7 * $Author: thekingant $ |
2086 | 8 * |
9 * Copyright (c) 1987, 1991 by the Massachusetts Institute of Technology. | |
10 * For copying and distribution information, see the file | |
11 * "mit-copyright.h". | |
12 */ | |
13 /* $Header$ */ | |
14 | |
8792
43d6c08d7e96
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2086
diff
changeset
|
15 #include "internal.h" |
2086 | 16 |
17 #ifndef lint | |
18 static const char rcsid_ZGetSender_c[] = | |
10867 | 19 "$Id: ZGetSender.c 12553 2005-04-25 01:53:01Z thekingant $"; |
2086 | 20 #endif |
21 | |
10867 | 22 #ifndef WIN32 |
2086 | 23 #include <pwd.h> |
10867 | 24 #endif |
2086 | 25 |
26 char *ZGetSender() | |
27 { | |
28 struct passwd *pw; | |
29 #ifdef ZEPHYR_USES_KERBEROS | |
30 char pname[ANAME_SZ], pinst[INST_SZ], prealm[REALM_SZ]; | |
31 static char sender[ANAME_SZ+INST_SZ+REALM_SZ+3] = ""; | |
10867 | 32 long int kerror; |
2086 | 33 #else |
34 static char sender[128] = ""; | |
35 #endif | |
36 | |
10867 | 37 #ifdef WIN32 |
38 unsigned long sender_size = 127; | |
39 #endif | |
40 | |
2086 | 41 /* Return it if already cached */ |
10038 | 42 |
43 /* if (*sender) | |
2086 | 44 return (sender); |
10038 | 45 */ |
2086 | 46 |
47 #ifdef ZEPHYR_USES_KERBEROS | |
10867 | 48 if ((kerror = krb_get_tf_fullname((char *)TKT_FILE, pname, pinst, prealm)) == KSUCCESS) |
2086 | 49 { |
50 (void) sprintf(sender, "%s%s%s@%s", pname, (pinst[0]?".":""), | |
51 pinst, prealm); | |
52 return (sender); | |
10867 | 53 } else { |
54 sprintf(sender,"%s@%s",(username?username:"unknown"),__Zephyr_realm); | |
55 return (sender); | |
2086 | 56 } |
57 #endif | |
58 | |
59 /* XXX a uid_t is a u_short (now), but getpwuid | |
60 * wants an int. AARGH! */ | |
10867 | 61 #ifdef WIN32 |
62 GetUserName(sender, &sender_size); | |
63 #else | |
2086 | 64 pw = getpwuid((int) getuid()); |
65 if (!pw) | |
66 return ("unknown"); | |
67 (void) sprintf(sender, "%s@%s", pw->pw_name, __Zephyr_realm); | |
10867 | 68 #endif |
2086 | 69 return (sender); |
70 } |