Tue, 26 Oct 2004 01:00:35 +0000
[gaim-migrate @ 11218]
This fixes the crash / hang / strangeness when dragging a buddy to a
conversation entry thing. Also fixes a minor memory leak with old plugins.
| 2086 | 1 | /* This file is part of the Project Athena Zephyr Notification System. |
| 2 | * It contains source for the ZMakeAscii function. | |
| 3 | * | |
| 4 | * Created by: Robert French | |
| 5 | * | |
| 6 | * $Source$ | |
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2086
diff
changeset
|
7 | * $Author: chipx86 $ |
| 2086 | 8 | * |
| 9 | * Copyright (c) 1987 by the Massachusetts Institute of Technology. | |
| 10 | * For copying and distribution information, see the file | |
| 11 | * "mit-copyright.h". | |
| 12 | */ | |
| 13 | /* $Header$ */ | |
| 14 | ||
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2086
diff
changeset
|
15 | #include "internal.h" |
| 2086 | 16 | #include <assert.h> |
| 17 | ||
| 18 | #ifndef lint | |
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2086
diff
changeset
|
19 | static const char rcsid_ZMakeAscii_c[] = "$Id: ZMakeAscii.c 9554 2004-04-24 09:02:28Z chipx86 $"; |
| 2086 | 20 | #endif |
| 21 | ||
| 22 | static char *itox_chars = "0123456789ABCDEF"; | |
| 23 | ||
| 24 | Code_t ZMakeAscii(ptr, len, field, num) | |
| 25 | register char *ptr; | |
| 26 | int len; | |
| 27 | unsigned char *field; | |
| 28 | int num; | |
| 29 | { | |
| 30 | int i; | |
| 31 | ||
| 32 | for (i=0;i<num;i++) { | |
| 33 | /* we need to add "0x" if we are between 4 byte pieces */ | |
| 34 | if ((i & 3) == 0) { | |
| 35 | if (len < (i?4:3)) | |
| 36 | return ZERR_FIELDLEN; | |
| 37 | /* except at the beginning, put a space in before the "0x" */ | |
| 38 | if (i) { | |
| 39 | *ptr++ = ' '; | |
| 40 | len--; | |
| 41 | } | |
| 42 | *ptr++ = '0'; | |
| 43 | *ptr++ = 'x'; | |
| 44 | len -= 2; | |
| 45 | } | |
| 46 | if (len < 3) | |
| 47 | return ZERR_FIELDLEN; | |
| 48 | *ptr++ = itox_chars[(int) (field[i] >> 4)]; | |
| 49 | *ptr++ = itox_chars[(int) (field[i] & 0xf)]; | |
| 50 | len -= 2; | |
| 51 | } | |
| 52 | ||
| 53 | *ptr = '\0'; | |
| 54 | return ZERR_NONE; | |
| 55 | } | |
| 56 | ||
| 57 | Code_t ZMakeAscii32(ptr, len, value) | |
| 58 | register char *ptr; | |
| 59 | int len; | |
| 60 | unsigned long value; | |
| 61 | { | |
| 62 | if (len < 11) | |
| 63 | return ZERR_FIELDLEN; | |
| 64 | *ptr++ = '0'; | |
| 65 | *ptr++ = 'x'; | |
| 66 | *ptr++ = itox_chars[(value >> 28) & 0xf]; | |
| 67 | *ptr++ = itox_chars[(value >> 24) & 0xf]; | |
| 68 | *ptr++ = itox_chars[(value >> 20) & 0xf]; | |
| 69 | *ptr++ = itox_chars[(value >> 16) & 0xf]; | |
| 70 | *ptr++ = itox_chars[(value >> 12) & 0xf]; | |
| 71 | *ptr++ = itox_chars[(value >> 8) & 0xf]; | |
| 72 | *ptr++ = itox_chars[(value >> 4) & 0xf]; | |
| 73 | *ptr++ = itox_chars[(value >> 0) & 0xf]; | |
| 74 | *ptr = 0; | |
| 75 | return ZERR_NONE; | |
| 76 | } | |
| 77 | ||
| 78 | Code_t ZMakeAscii16(ptr, len, value) | |
| 79 | register char *ptr; | |
| 80 | int len; | |
| 81 | unsigned int value; | |
| 82 | { | |
| 83 | if (len < 7) | |
| 84 | return ZERR_FIELDLEN; | |
| 85 | *ptr++ = '0'; | |
| 86 | *ptr++ = 'x'; | |
| 87 | *ptr++ = itox_chars[(value >> 12) & 0xf]; | |
| 88 | *ptr++ = itox_chars[(value >> 8) & 0xf]; | |
| 89 | *ptr++ = itox_chars[(value >> 4) & 0xf]; | |
| 90 | *ptr++ = itox_chars[(value >> 0) & 0xf]; | |
| 91 | *ptr = 0; | |
| 92 | return ZERR_NONE; | |
| 93 | } | |
| 94 |