ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-SNMP-XS/XS.xs
(Generate patch)

Comparing Net-SNMP-XS/XS.xs (file contents):
Revision 1.4 by root, Thu Apr 9 04:37:05 2009 UTC vs.
Revision 1.5 by root, Thu Apr 9 04:49:16 2009 UTC

197 return &PL_sv_undef; 197 return &PL_sv_undef;
198 } 198 }
199 199
200 return newSVpvn (data, length); 200 return newSVpvn (data, length);
201} 201}
202
203static char *
204write_uv (char *buf, U32 u)
205{
206 // the one-digit case is absolutely predominant
207 if (u < 10)
208 *buf++ = u + '0';
209 else
210 buf += sprintf (buf, "%u", (unsigned int)u);
211
212 return buf;
213}
214
202static SV * 215static SV *
203process_object_identifier_sv (void) 216process_object_identifier_sv (void)
204{ 217{
205 U32 length = process_length (); 218 U32 length = process_length ();
206 219
212 225
213 U8 *end = cur + length; 226 U8 *end = cur + length;
214 U32 w = getb (); 227 U32 w = getb ();
215 228
216 static char oid[MAX_OID_STRLEN]; 229 static char oid[MAX_OID_STRLEN];
217 char *buf = oid; 230 char *app = oid;
218 231
219 if (leading_dot) 232 *app = '.'; app += ! ! leading_dot;
233 app = write_uv (app, w / 40);
234 *app++ = '.';
235 app = write_uv (app, w % 40);
236
237 // we assume an oid component is never > 64 bytes
238 while (cur < end && oid + sizeof (oid) - app > 64)
239 {
240 w = getb ();
220 *buf++ = '.'; 241 *app++ = '.';
221 242 app = write_uv (app, w);
243 }
244#if 0
222 buf += snprintf (buf, oid + sizeof (oid) - buf, "%d.%d", (int)w / 40, (int)w % 40); 245 buf += snprintf (buf, oid + sizeof (oid) - buf, "%d.%d", (int)w / 40, (int)w % 40);
223 246
224 while (cur < end) 247 while (cur < end)
225 { 248 {
226 w = getb (); 249 w = getb ();
227 buf += snprintf (buf, oid + sizeof (oid) - buf, ".%u", (unsigned int)w); 250 buf += snprintf (buf, oid + sizeof (oid) - buf, ".%u", (unsigned int)w);
228 } 251 }
252#endif
229 253
230 return newSVpvn (oid, buf - oid); 254 return newSVpvn (oid, app - oid);
231} 255}
232 256
233static AV *av_type; 257static AV *av_type;
234 258
235MODULE = Net::SNMP::XS PACKAGE = Net::SNMP::XS 259MODULE = Net::SNMP::XS PACKAGE = Net::SNMP::XS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines