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