]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - lib/ZFmtRaw.c
2940f98f30647668db9d65969dc01a5e0c948828
[1ts-debian.git] / 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 ZFormatRawNotice(notice, buffer, ret_len)
20     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 }