annotate plugins/zephyr/ZFmtAuth.c @ 1730:2d7601acacdd

[gaim-migrate @ 1740] sean egan's perl patch committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 20 Apr 2001 07:50:47 +0000
parents 1e0fa7e130d0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1700
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* This file is part of the Project Athena Zephyr Notification System.
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * It contains source for the ZFormatAuthenticNotice function.
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Created by: Robert French
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * $Source$
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * $Author: warmenhoven $
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 *
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * For copying and distribution information, see the file
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * "mit-copyright.h".
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 /* $Header$ */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 #ifndef lint
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 static char rcsid_ZFormatAuthenticNotice_c[] = "$Header$";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 #endif
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 #include <internal.h>
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 #ifdef ZEPHYR_USES_KERBEROS
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 Code_t ZFormatAuthenticNotice(notice, buffer, buffer_len, len, session)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 ZNotice_t *notice;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 register char *buffer;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 register int buffer_len;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 int *len;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 C_Block session;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 ZNotice_t newnotice;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 char *ptr;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 int retval, hdrlen;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 newnotice = *notice;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 newnotice.z_auth = 1;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 newnotice.z_authent_len = 0;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 newnotice.z_ascii_authent = "";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len,
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 &hdrlen, &ptr, NULL)) != ZERR_NONE)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 return (retval);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 #ifdef NOENCRYPTION
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 newnotice.z_checksum = 0;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #else
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 newnotice.z_checksum =
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 (ZChecksum_t)des_quad_cksum(buffer, NULL, ptr - buffer, 0, session);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #endif
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len,
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 &hdrlen, NULL, NULL)) != ZERR_NONE)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 return (retval);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 ptr = buffer+hdrlen;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 if (newnotice.z_message_len+hdrlen > buffer_len)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 return (ZERR_PKTLEN);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 (void) memcpy(ptr, newnotice.z_message, newnotice.z_message_len);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 *len = hdrlen+newnotice.z_message_len;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 if (*len > Z_MAXPKTLEN)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 return (ZERR_PKTLEN);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 return (ZERR_NONE);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 #endif