]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/lib/ZFmtNotice.c
d7876d79dc93396d552d544c3f0abf844d57f3a1
[1ts-debian.git] / zephyr / lib / ZFmtNotice.c
1 /* This file is part of the Project Athena Zephyr Notification System.
2  * It contains source for the ZFormatNotice function.
3  *
4  *      Created by:     Robert French
5  *
6  *      $Id$
7  *
8  *      Copyright (c) 1987,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_ZFormatNotice_c[] = "$Id$";
15 #endif
16
17 #include <internal.h>
18
19 Code_t ZFormatNotice(notice, buffer, ret_len, cert_routine)
20     register ZNotice_t *notice;
21     char **buffer;
22     int *ret_len;
23     Z_AuthProc cert_routine;
24 {
25     char header[Z_MAXHEADERLEN];
26     int hdrlen;
27     Code_t retval;
28
29     if ((retval = Z_FormatHeader(notice, header, sizeof(header), &hdrlen, 
30                                  cert_routine)) != ZERR_NONE)
31         return (retval);
32
33     *ret_len = hdrlen+notice->z_message_len;
34
35     /* Length can never be zero, don't have to worry about malloc(0). */
36     if (!(*buffer = (char *) malloc((unsigned)*ret_len)))
37         return (ENOMEM);
38
39     (void) memcpy(*buffer, header, hdrlen);
40     (void) memcpy(*buffer+hdrlen, notice->z_message, notice->z_message_len);
41
42     return (ZERR_NONE);
43 }