summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Robert S. French <rfrench@mit.edu>1987-06-12 13:01:26 +0000
committerGravatar Robert S. French <rfrench@mit.edu>1987-06-12 13:01:26 +0000
commit140725197bc779a27b98fae5d992a3512097adf0 (patch)
treecbbbd9e2ba4469173257c3dee49cd56eadc361c2
parent2a79930d731c6d85df0fc46e869a4466dbf1d1fd (diff)
Initial revision
-rw-r--r--lib/ZFmtList.c49
-rw-r--r--lib/ZFmtNotice.c45
2 files changed, 94 insertions, 0 deletions
diff --git a/lib/ZFmtList.c b/lib/ZFmtList.c
new file mode 100644
index 0000000..9a0aaa8
--- /dev/null
+++ b/lib/ZFmtList.c
@@ -0,0 +1,49 @@
+/* This file is part of the Project Athena Zephyr Notification System.
+ * It contains source for the ZFormatNoticeList 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 ZFormatNoticeList(notice,list,nitems,buffer,buffer_len,ret_len)
+ ZNotice_t *notice;
+ char *list[];
+ int nitems;
+ ZPacket_t buffer;
+ int buffer_len;
+ int *ret_len;
+{
+ char *ptr,*end;
+ Code_t retval;
+
+ end = buffer+buffer_len;
+
+ if ((retval = Z_FormatHeader(notice,buffer,buffer_len,ret_len)) > 0)
+ return (retval);
+
+ ptr = buffer+*ret_len;
+
+ for (;nitems;nitems--,list++) {
+ if (ptr+strlen(*list)+1 > end)
+ return (ZERR_PKTLEN);
+ bcopy(*list,ptr,strlen(*list)+1);
+ *ret_len += strlen(*list)+1;
+ ptr += strlen(*list)+1;
+ }
+
+ if (*ret_len > Z_MAXPKTLEN)
+ return (ZERR_PKTLEN);
+
+ return (ZERR_NONE);
+}
diff --git a/lib/ZFmtNotice.c b/lib/ZFmtNotice.c
new file mode 100644
index 0000000..e1d3e7b
--- /dev/null
+++ b/lib/ZFmtNotice.c
@@ -0,0 +1,45 @@
+/* This file is part of the Project Athena Zephyr Notification System.
+ * It contains source for the ZFormatNotice 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.h>
+
+Code_t ZFormatNotice(notice,buffer,buffer_len,len)
+ ZNotice_t *notice;
+ ZPacket_t buffer;
+ int buffer_len;
+ int *len;
+{
+ char *ptr;
+ int hdrlen;
+ Code_t retval;
+
+ if ((retval = Z_FormatHeader(notice,buffer,buffer_len,&hdrlen)) > 0)
+ return (retval);
+
+ ptr = buffer+hdrlen;
+
+ if (notice->z_message_len+hdrlen > buffer_len)
+ return (ZERR_PKTLEN);
+
+ bcopy(notice->z_message,ptr,notice->z_message_len);
+
+ *len = hdrlen+notice->z_message_len;
+
+ if (*len > Z_MAXPKTLEN)
+ return (ZERR_PKTLEN);
+
+ return (ZERR_NONE);
+}