summaryrefslogtreecommitdiff
path: root/lib/ZParseNot.c
blob: 394e89a0eeca2a5f5cbddf6fe0b81ecc1fb3a1ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* This file is part of the Project Athena Zephyr Notification System.
 * It contains source for the ZParseNotice function.
 *
 *	Created by:	Robert French
 *
 *	$Source$
 *	$Author$
 *
 *	Copyright (c) 1987 by the Massachusetts Institute of Technology.
 *	For copying and distribution information, see the file
 *	"mit-copyright.h". 
 */
/* $Header$ */

#include <zephyr/mit-copyright.h>

#include <zephyr/zephyr_internal.h>

Code_t ZParseNotice(buffer,len,notice,auth)
	ZPacket_t	buffer;
	int		len;
	ZNotice_t	*notice;
	int		*auth;
{
	int hdrlen;
	char *ptr;

	hdrlen = *((short *)buffer);

	ptr = buffer+2;

	if (*ptr++ != ZVERSION)
		return (ZERR_VERS);

	notice->z_kind = (ZNotice_Kind_t)*ptr++;
	bcopy(ptr,notice->z_checksum,sizeof(ZChecksum_t));
	ptr += sizeof(ZChecksum_t);
	bcopy(ptr,&notice->z_uid,sizeof(ZUnique_Id_t));
	ptr += sizeof(ZUnique_Id_t);
	notice->z_port = *((short *)ptr);
	ptr += sizeof(short);
	notice->z_class = ptr;
	ptr += strlen(ptr)+1;
	notice->z_class_inst = ptr;
	ptr += strlen(ptr)+1;
	notice->z_opcode = ptr;
	ptr += strlen(ptr)+1;
	notice->z_sender = ptr;
	ptr += strlen(ptr)+1;
	notice->z_recipient = ptr;
	ptr += strlen(ptr)+1;

	if (ptr-buffer != hdrlen)
		return(ZERR_BADPKT);

	notice->z_message = (caddr_t) ptr;
	notice->z_message_len = len-hdrlen;

	*auth = 0;
}