[gaim-migrate @ 5229]
[pidgin-git.git] / src / protocols / zephyr / ZFmtRawLst.c
blobc4b798923d17b0f7b5070058257d19ab392c0044
1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains source for the ZFormatRawNoticeList function.
4 * Created by: Robert French
6 * $Source$
7 * $Author: warmenhoven $
9 * Copyright (c) 1987 by the Massachusetts Institute of Technology.
10 * For copying and distribution information, see the file
11 * "mit-copyright.h".
13 /* $Header$ */
15 #ifndef lint
16 static char rcsid_ZFormatRawNoticeList_c[] = "$Header$";
17 #endif
19 #include <internal.h>
21 Code_t ZFormatRawNoticeList(notice, list, nitems, buffer, ret_len)
22 ZNotice_t *notice;
23 char *list[];
24 int nitems;
25 char **buffer;
26 int *ret_len;
28 char header[Z_MAXHEADERLEN];
29 int hdrlen, i, size;
30 char *ptr;
31 Code_t retval;
33 if ((retval = Z_FormatRawHeader(notice, header, sizeof(header),
34 &hdrlen, NULL, NULL)) != ZERR_NONE)
35 return (retval);
37 size = 0;
38 for (i=0;i<nitems;i++)
39 size += strlen(list[i])+1;
41 *ret_len = hdrlen+size;
43 if (!(*buffer = (char *) malloc((unsigned) *ret_len)))
44 return (ENOMEM);
46 (void) memcpy(*buffer, header, hdrlen);
48 ptr = *buffer+hdrlen;
50 for (;nitems;nitems--, list++) {
51 i = strlen(*list)+1;
52 (void) memcpy(ptr, *list, i);
53 ptr += i;
56 return (ZERR_NONE);