MCPcopy Create free account
hub / github.com/OpenPrinting/cups / _cupsSNMPStringToOID

Function _cupsSNMPStringToOID

cups/snmp.c:478–538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

476 */
477
478int * /* O - Pointer to OID array or @code NULL@ on error */
479_cupsSNMPStringToOID(const char *src, /* I - OID string */
480 int *dst, /* I - OID array */
481 int dstsize)/* I - Number of integers in OID array */
482{
483 int *dstptr, /* Pointer into OID array */
484 *dstend; /* End of OID array */
485
486
487 DEBUG_printf(("4_cupsSNMPStringToOID(src=\"%s\", dst=%p, dstsize=%d)",
488 src, dst, dstsize));
489
490 /*
491 * Range check input...
492 */
493
494 if (!src || !dst || dstsize < 2)
495 return (NULL);
496
497 /*
498 * Skip leading "."...
499 */
500
501 if (*src == '.')
502 src ++;
503
504 /*
505 * Loop to the end of the string...
506 */
507
508 for (dstend = dst + dstsize - 1, dstptr = dst, *dstptr = 0;
509 *src && dstptr < dstend;
510 src ++)
511 {
512 if (*src == '.' && src[1])
513 {
514 dstptr ++;
515 *dstptr = 0;
516 }
517 else if (isdigit(*src & 255))
518 {
519 if ((*dstptr * 10 + *src - '0') > 0xffff)
520 break;
521
522 *dstptr = *dstptr * 10 + *src - '0';
523 }
524 else
525 break;
526 }
527
528 if (*src)
529 return (NULL);
530
531 /*
532 * Terminate the end of the OID array and return...
533 */
534
535 dstptr[1] = -1;

Callers 2

backendNetworkSideCBFunction · 0.85
show_oidFunction · 0.85

Calls

no outgoing calls

Tested by 1

show_oidFunction · 0.68