[gaim-migrate @ 3063]
[pidgin-git.git] / src / protocols / zephyr / ZFmtNotice.c
blob18f4cff78c03924cc59a31b41e2d6b51078d12a8
1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains source for the ZFormatNotice function.
4 * Created by: Robert French
6 * $Source$
7 * $Author: warmenhoven $
9 * Copyright (c) 1987,1988 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_ZFormatNotice_c[] = "$Id: ZFmtNotice.c 2096 2001-07-31 01:00:39Z warmenhoven $";
17 #endif
19 #include <internal.h>
21 Code_t ZFormatNotice(notice, buffer, ret_len, cert_routine)
22 register ZNotice_t *notice;
23 char **buffer;
24 int *ret_len;
25 Z_AuthProc cert_routine;
27 char header[Z_MAXHEADERLEN];
28 int hdrlen;
29 Code_t retval;
31 if ((retval = Z_FormatHeader(notice, header, sizeof(header), &hdrlen,
32 cert_routine)) != ZERR_NONE)
33 return (retval);
35 *ret_len = hdrlen+notice->z_message_len;
37 /* Length can never be zero, don't have to worry about malloc(0). */
38 if (!(*buffer = (char *) malloc((unsigned)*ret_len)))
39 return (ENOMEM);
41 (void) memcpy(*buffer, header, hdrlen);
42 (void) memcpy(*buffer+hdrlen, notice->z_message, notice->z_message_len);
44 return (ZERR_NONE);