Mercurial > pidgin
annotate src/protocols/zephyr/ZGetSender.c @ 14181:fc92a5a7dd95
[gaim-migrate @ 16833]
Split the DNS query code out into its own file without actually
changing anything.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 18 Aug 2006 07:20:31 +0000 |
parents | 1b0c83666f98 |
children |
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 * 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
43d6c08d7e96
[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 { | |
11933
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
19 struct passwd *pw; |
2086 | 20 #ifdef ZEPHYR_USES_KERBEROS |
11933
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
21 char pname[ANAME_SZ]; |
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
22 char pinst[INST_SZ]; |
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
23 char prealm[REALM_SZ]; |
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
24 static char sender[ANAME_SZ+INST_SZ+REALM_SZ+3] = ""; |
10867 | 25 long int kerror; |
2086 | 26 #else |
11933
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
27 static char sender[128] = ""; |
2086 | 28 #endif |
29 | |
10867 | 30 #ifdef WIN32 |
11933
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
31 unsigned long sender_size = sizeof(sender) - 1; |
10867 | 32 #endif |
33 | |
2086 | 34 #ifdef ZEPHYR_USES_KERBEROS |
10867 | 35 if ((kerror = krb_get_tf_fullname((char *)TKT_FILE, pname, pinst, prealm)) == KSUCCESS) |
11933
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
36 { |
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
37 sprintf(sender, "%s%s%s@%s", pname, (pinst[0] ? "." : ""), pinst, prealm); |
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
38 return sender; |
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
39 } |
2086 | 40 #endif |
41 | |
10867 | 42 #ifdef WIN32 |
11933
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
43 GetUserName(sender, &sender_size); |
10867 | 44 #else |
11933
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
45 /* XXX a uid_t is a u_short (now), but getpwuid |
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
46 * wants an int. AARGH! */ |
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
47 pw = getpwuid((int) getuid()); |
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
48 if (!pw) |
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
49 return ("unknown"); |
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
50 sprintf(sender, "%s@%s", pw->pw_name, __Zephyr_realm); |
10867 | 51 #endif |
11933
1b0c83666f98
[gaim-migrate @ 14224]
Richard Laager <rlaager@wiktel.com>
parents:
11932
diff
changeset
|
52 return sender; |
2086 | 53 } |