| 476 | */ |
| 477 | |
| 478 | int * /* 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; |
no outgoing calls