]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/lib/ZFmtSmRLst.c
6e412853129450f35f3a77f1375c99f505d812e2
[1ts-debian.git] / zephyr / lib / ZFmtSmRLst.c
1 /* This file is part of the Project Athena Zephyr Notification System.
2  * It contains source for the ZFormatSmallRawNoticeList function.
3  *
4  *      Created by:     John T. Kohl
5  *
6  *      $Id$
7  *
8  *      Copyright (c) 1988 by the Massachusetts Institute of Technology.
9  *      For copying and distribution information, see the file
10  *      "mit-copyright.h". 
11  */
12
13 #ifndef lint
14 static char rcsid_ZFormatRawNoticeList_c[] = "$Id$";
15 #endif
16
17 #include <internal.h>
18
19 Code_t ZFormatSmallRawNoticeList(notice, list, nitems, buffer, ret_len)
20     ZNotice_t *notice;
21     char *list[];
22     int nitems;
23     ZPacket_t buffer;
24     int *ret_len;
25 {
26     Code_t retval;
27     int hdrlen, i, size;
28     char *ptr;
29
30     if ((retval = Z_FormatRawHeader(notice, buffer, Z_MAXHEADERLEN,
31                                     &hdrlen, NULL, NULL)) != ZERR_NONE)
32         return (retval);
33
34     size = 0;
35     for (i=0;i<nitems;i++)
36         size += strlen(list[i])+1;
37
38     *ret_len = hdrlen+size;
39
40     if (*ret_len > Z_MAXPKTLEN)
41         return (ZERR_PKTLEN);
42
43     ptr = buffer+hdrlen;
44
45     for (;nitems;nitems--, list++) {
46         i = strlen(*list)+1;
47         (void) memcpy(ptr, *list, i);
48         ptr += i;
49     }
50
51     return (ZERR_NONE);
52 }