libpurple/protocols/zephyr/ZParseNot.c

changeset 40624
6f7bbd42d36c
parent 40166
811f82db29dd
child 40643
1c9bdf8d3e85
equal deleted inserted replaced
40623:6260f39c7c65 40624:6f7bbd42d36c
7 * For copying and distribution information, see the file 7 * For copying and distribution information, see the file
8 * "mit-copyright.h". 8 * "mit-copyright.h".
9 */ 9 */
10 10
11 #include "internal.h" 11 #include "internal.h"
12
13 #include <purple.h>
12 14
13 /* Assume that strlen is efficient on this machine... */ 15 /* Assume that strlen is efficient on this machine... */
14 #define next_field(ptr) ptr += strlen (ptr) + 1 16 #define next_field(ptr) ptr += strlen (ptr) + 1
15 17
16 #if defined (__GNUC__) && defined (__vax__) 18 #if defined (__GNUC__) && defined (__vax__)
91 notice->z_version = ptr; 93 notice->z_version = ptr;
92 if (strncmp(ptr, ZVERSIONHDR, sizeof(ZVERSIONHDR) - 1)) 94 if (strncmp(ptr, ZVERSIONHDR, sizeof(ZVERSIONHDR) - 1))
93 return (ZERR_VERS); 95 return (ZERR_VERS);
94 ptr += sizeof(ZVERSIONHDR) - 1; 96 ptr += sizeof(ZVERSIONHDR) - 1;
95 if (!*ptr) { 97 if (!*ptr) {
96 #ifdef Z_DEBUG 98 purple_debug_error("zephyr", "ZParseNotice: null version string");
97 Z_debug ("ZParseNotice: null version string");
98 #endif
99 return ZERR_BADPKT; 99 return ZERR_BADPKT;
100 } 100 }
101 maj = atoi(ptr); 101 maj = atoi(ptr);
102 if (maj != ZVERSIONMAJOR) 102 if (maj != ZVERSIONMAJOR)
103 return (ZERR_VERS); 103 return (ZERR_VERS);
109 next_field (ptr); 109 next_field (ptr);
110 110
111 /*XXX 3 */ 111 /*XXX 3 */
112 numfields -= 2; /* numfields, version, and checksum */ 112 numfields -= 2; /* numfields, version, and checksum */
113 if (numfields < 0) { 113 if (numfields < 0) {
114 badpkt:
115 #if 0
114 #ifdef __LINE__ 116 #ifdef __LINE__
115 lineno = __LINE__; 117 lineno = __LINE__;
116 badpkt: 118 purple_debug_error("zephyr", "ZParseNotice: bad packet from %s/%d (line %d)", inet_ntoa (notice->z_uid.zuid_addr.s_addr), notice->z_port, lineno);
117 #ifdef Z_DEBUG
118 Z_debug ("ZParseNotice: bad packet from %s/%d (line %d)",
119 inet_ntoa (notice->z_uid.zuid_addr.s_addr),
120 notice->z_port, lineno);
121 #else 119 #else
122 /* We won't use lineno anywhere else, so let's silence a warning. */ 120 purple_debug_error("zephyr", "ZParseNotice: bad packet from %s/%d", inet_ntoa (notice->z_uid.zuid_addr.s_addr), notice->z_port);
123 (void)lineno;
124 #endif
125 #else
126 badpkt:
127 #ifdef Z_DEBUG
128 Z_debug ("ZParseNotice: bad packet from %s/%d",
129 inet_ntoa (notice->z_uid.zuid_addr.s_addr),
130 notice->z_port);
131 #endif 121 #endif
132 #endif 122 #endif
133 return ZERR_BADPKT; 123 return ZERR_BADPKT;
134 } 124 }
135 125

mercurial