Mercurial > pidgin
annotate src/protocols/zephyr/ZFmtNotice.c @ 10261:d4e9ff2edc4e
[gaim-migrate @ 11405]
This should fix segfault bug 1072604. Oops.
committer: Tailor Script <tailor@pidgin.im>
| author | Tim Ringenbach <marv@pidgin.im> |
|---|---|
| date | Thu, 25 Nov 2004 18:35:26 +0000 |
| parents | 43d6c08d7e96 |
| children | 64895571248f |
| rev | line source |
|---|---|
| 2086 | 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 * $Source$ | |
|
8792
43d6c08d7e96
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2086
diff
changeset
|
7 * $Author: chipx86 $ |
| 2086 | 8 * |
| 9 * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology. | |
| 10 * For copying and distribution information, see the file | |
| 11 * "mit-copyright.h". | |
| 12 */ | |
| 13 /* $Header$ */ | |
| 14 | |
| 15 #ifndef lint | |
|
8792
43d6c08d7e96
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2086
diff
changeset
|
16 static char rcsid_ZFormatNotice_c[] = "$Id: ZFmtNotice.c 9554 2004-04-24 09:02:28Z chipx86 $"; |
| 2086 | 17 #endif |
| 18 | |
|
8792
43d6c08d7e96
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2086
diff
changeset
|
19 #include "internal.h" |
| 2086 | 20 |
| 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; | |
| 26 { | |
| 27 char header[Z_MAXHEADERLEN]; | |
| 28 int hdrlen; | |
| 29 Code_t retval; | |
| 30 | |
| 31 if ((retval = Z_FormatHeader(notice, header, sizeof(header), &hdrlen, | |
| 32 cert_routine)) != ZERR_NONE) | |
| 33 return (retval); | |
| 34 | |
| 35 *ret_len = hdrlen+notice->z_message_len; | |
| 36 | |
| 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); | |
| 40 | |
| 41 (void) memcpy(*buffer, header, hdrlen); | |
| 42 (void) memcpy(*buffer+hdrlen, notice->z_message, notice->z_message_len); | |
| 43 | |
| 44 return (ZERR_NONE); | |
| 45 } |
