summaryrefslogtreecommitdiff
path: root/lib/ZParseNot.c
diff options
context:
space:
mode:
authorGravatar Robert S. French <rfrench@mit.edu>1988-05-13 13:53:14 +0000
committerGravatar Robert S. French <rfrench@mit.edu>1988-05-13 13:53:14 +0000
commit6cc2f240adefe2956a056bcc55d7de63e13f2bb2 (patch)
tree98375a4388f6616d887099b7776e429e5cd9fb48 /lib/ZParseNot.c
parentf04d955292771dd504a7a5e94b20a944f9fb7d99 (diff)
Inlined instead of call to Zinternal...changed to handle other fields in
ZNotice_t
Diffstat (limited to 'lib/ZParseNot.c')
-rw-r--r--lib/ZParseNot.c186
1 files changed, 180 insertions, 6 deletions
diff --git a/lib/ZParseNot.c b/lib/ZParseNot.c
index 25610b4..96cb4e0 100644
--- a/lib/ZParseNot.c
+++ b/lib/ZParseNot.c
@@ -20,12 +20,186 @@ static char rcsid_ZParseNotice_c[] = "$Header$";
#include <zephyr/zephyr_internal.h>
-Code_t ZParseNotice(buffer,len,notice)
- ZPacket_t buffer;
- int len;
- ZNotice_t *notice;
+Code_t ZParseNotice(buffer, len, notice)
+ char *buffer;
+ int len;
+ ZNotice_t *notice;
{
- extern int ZCheckAuthentication();
+ char *ptr, *end;
+ int maj, numfields, i;
+ unsigned int temp[3];
- return (Z_InternalParseNotice(buffer,len,notice));
+ bzero(notice, sizeof(ZNotice_t));
+
+ ptr = buffer;
+ end = buffer+len;
+
+ notice->z_packet = buffer;
+
+ notice->z_version = ptr;
+ if (strncmp(ptr, ZVERSIONHDR, strlen(ZVERSIONHDR)))
+ return (ZERR_VERS);
+ ptr += strlen(ZVERSIONHDR);
+ maj = atoi(ptr);
+ if (maj != ZVERSIONMAJOR)
+ return (ZERR_VERS);
+ ptr += strlen(ptr)+1;
+
+ if (ZReadAscii(ptr, end-ptr, (unsigned char *)temp,
+ sizeof(int)) == ZERR_BADFIELD)
+ return (ZERR_BADPKT);
+ numfields = ntohl(*temp);
+ ptr += strlen(ptr)+1;
+
+ numfields -= 2;
+ if (numfields < 0)
+ numfields = 0;
+
+ if (numfields) {
+ if (ZReadAscii(ptr, end-ptr, (unsigned char *)temp,
+ sizeof(int)) == ZERR_BADFIELD)
+ return (ZERR_BADPKT);
+ notice->z_kind = (ZNotice_Kind_t)ntohl((ZNotice_Kind_t)*temp);
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ return (ZERR_BADPKT);
+
+ if (numfields) {
+ if (ZReadAscii(ptr, end-ptr, (unsigned char *)temp,
+ sizeof(ZUnique_Id_t)) == ZERR_BADFIELD)
+ return (ZERR_BADPKT);
+ bcopy((char *)temp, (char *)&notice->z_uid, sizeof(ZUnique_Id_t));
+ notice->z_time.tv_sec = ntohl(notice->z_uid.tv.tv_sec);
+ notice->z_time.tv_usec = ntohl(notice->z_uid.tv.tv_usec);
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ return (ZERR_BADPKT);
+
+ if (numfields) {
+ if (ZReadAscii(ptr, end-ptr, (unsigned char *)temp,
+ sizeof(u_short)) ==
+ ZERR_BADFIELD)
+ return (ZERR_BADPKT);
+ notice->z_port = *((u_short *)temp);
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ return (ZERR_BADPKT);
+
+ if (numfields) {
+ if (ZReadAscii(ptr, end-ptr, (unsigned char *)temp,
+ sizeof(int)) == ZERR_BADFIELD)
+ return (ZERR_BADPKT);
+ notice->z_auth = *temp;
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ return (ZERR_BADPKT);
+
+ if (numfields) {
+ if (ZReadAscii(ptr, end-ptr, (unsigned char *)temp,
+ sizeof(int)) == ZERR_BADFIELD)
+ return (ZERR_BADPKT);
+ notice->z_authent_len = ntohl(*temp);
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ return (ZERR_BADPKT);
+
+ if (numfields) {
+ notice->z_ascii_authent = ptr;
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ return (ZERR_BADPKT);
+
+ if (numfields) {
+ notice->z_class = ptr;
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ notice->z_class = "";
+
+ if (numfields) {
+ notice->z_class_inst = ptr;
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ notice->z_class_inst = "";
+
+ if (numfields) {
+ notice->z_opcode = ptr;
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ notice->z_opcode = "";
+
+ if (numfields) {
+ notice->z_sender = ptr;
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ notice->z_sender = "";
+
+ if (numfields) {
+ notice->z_recipient = ptr;
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ notice->z_recipient = "";
+
+ if (numfields) {
+ notice->z_default_format = ptr;
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ notice->z_default_format = "";
+
+ if (numfields) {
+ if (ZReadAscii(ptr, end-ptr, (unsigned char *)temp,
+ sizeof(ZChecksum_t))
+ == ZERR_BADFIELD)
+ return (ZERR_BADPKT);
+ notice->z_checksum = ntohl(*temp);
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ notice->z_checksum = 0;
+
+ if (numfields) {
+ notice->z_multinotice = ptr;
+ numfields--;
+ ptr += strlen(ptr)+1;
+ }
+ else
+ notice->z_multinotice = "";
+
+ for (i=0;i<Z_MAXOTHERFIELDS && numfields;i++,numfields--) {
+ notice->z_other_fields[i] = ptr;
+ ptr += strlen(ptr)+1;
+ }
+ notice->z_num_other_fields = i;
+
+ for (i=0;i<numfields;i++)
+ ptr += strlen(ptr)+1;
+
+ notice->z_message = (caddr_t) ptr;
+ notice->z_message_len = len-(ptr-buffer);
+
+ return (ZERR_NONE);
}