netsnmp_ds_get_boolean:
  242|  2.30k|{
  243|  2.30k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  4.60k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (243:9): [True: 0, False: 2.30k]
  |  Branch (243:24): [True: 0, False: 2.30k]
  ------------------
  244|  2.30k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  2.30k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (244:2): [True: 0, False: 2.30k]
  |  Branch (244:17): [True: 0, False: 2.30k]
  ------------------
  245|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  246|      0|    }
  247|       |
  248|  2.30k|    return (netsnmp_ds_booleans[storeid][which/8] & (1 << (which % 8))) ? 1:0;
  ------------------
  |  Branch (248:12): [True: 0, False: 2.30k]
  ------------------
  249|  2.30k|}
netsnmp_ds_get_int:
  268|     10|{
  269|     10|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|     20|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (269:9): [True: 0, False: 10]
  |  Branch (269:24): [True: 0, False: 10]
  ------------------
  270|     10|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|     10|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (270:2): [True: 0, False: 10]
  |  Branch (270:17): [True: 0, False: 10]
  ------------------
  271|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  272|      0|    }
  273|       |
  274|     10|    return netsnmp_ds_integers[storeid][which];
  275|     10|}
netsnmp_ds_set_string:
  279|      1|{
  280|      1|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|      2|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (280:9): [True: 0, False: 1]
  |  Branch (280:24): [True: 0, False: 1]
  ------------------
  281|      1|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|      1|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (281:2): [True: 0, False: 1]
  |  Branch (281:17): [True: 0, False: 1]
  ------------------
  282|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  283|      0|    }
  284|       |
  285|      1|    DEBUGMSGTL(("netsnmp_ds_set_string", "Setting %s:%d = \"%s\"\n",
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
  286|      1|                stores[storeid], which, (value ? value : "(null)")));
  287|       |
  288|       |    /*
  289|       |     * is some silly person is calling us with our own pointer?
  290|       |     */
  291|      1|    if (netsnmp_ds_strings[storeid][which] == value)
  ------------------
  |  Branch (291:9): [True: 0, False: 1]
  ------------------
  292|      0|        return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  293|       |
  294|      1|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|      1|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 1]
  |  |  ------------------
  ------------------
  295|      1|    if (netsnmp_ds_strings[storeid][which] != NULL) {
  ------------------
  |  Branch (295:9): [True: 0, False: 1]
  ------------------
  296|      0|        free(netsnmp_ds_strings[storeid][which]);
  297|      0|	netsnmp_ds_strings[storeid][which] = NULL;
  298|      0|    }
  299|      1|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|      1|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 1]
  |  |  ------------------
  ------------------
  300|       |
  301|      1|    if (value) {
  ------------------
  |  Branch (301:9): [True: 1, False: 0]
  ------------------
  302|      1|        netsnmp_ds_strings[storeid][which] = strdup(value);
  303|      1|    } else {
  304|      0|        netsnmp_ds_strings[storeid][which] = NULL;
  305|      0|    }
  306|       |
  307|      1|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  308|      1|}
netsnmp_ds_get_string:
  312|  1.17k|{
  313|  1.17k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  2.34k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (313:9): [True: 0, False: 1.17k]
  |  Branch (313:24): [True: 0, False: 1.17k]
  ------------------
  314|  1.17k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  1.17k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (314:2): [True: 0, False: 1.17k]
  |  Branch (314:17): [True: 0, False: 1.17k]
  ------------------
  315|      0|        return NULL;
  316|      0|    }
  317|       |
  318|  1.17k|    return netsnmp_ds_strings[storeid][which];
  319|  1.17k|}

get_tree_head:
 2129|     55|{
 2130|     55|    return (tree_head);
 2131|     55|}
netsnmp_set_mib_directory:
 2522|      1|{
 2523|      1|    const char *newdir;
 2524|      1|    char *olddir, *tmpdir = NULL;
 2525|       |
 2526|      1|    DEBUGTRACE;
  ------------------
  |  |   63|      1|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2527|      1|    if (NULL == dir) {
  ------------------
  |  Branch (2527:9): [True: 0, False: 1]
  ------------------
 2528|      0|        return;
 2529|      0|    }
 2530|       |    
 2531|      1|    olddir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 2532|      1|				   NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|      1|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2533|      1|    if (olddir) {
  ------------------
  |  Branch (2533:9): [True: 0, False: 1]
  ------------------
 2534|      0|        if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2534:13): [True: 0, False: 0]
  |  Branch (2534:30): [True: 0, False: 0]
  ------------------
 2535|       |            /** New dir starts with '+', thus we add it. */
 2536|      0|            tmpdir = (char *)malloc(strlen(dir) + strlen(olddir) + 2);
 2537|      0|            if (!tmpdir) {
  ------------------
  |  Branch (2537:17): [True: 0, False: 0]
  ------------------
 2538|      0|                DEBUGMSGTL(("read_config:initmib", "set mibdir malloc failed"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2539|      0|                return;
 2540|      0|            }
 2541|      0|            if (*dir++ == '+')
  ------------------
  |  Branch (2541:17): [True: 0, False: 0]
  ------------------
 2542|      0|                sprintf(tmpdir, "%s%c%s", olddir, ENV_SEPARATOR_CHAR, dir);
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2543|      0|            else
 2544|      0|                sprintf(tmpdir, "%s%c%s", dir, ENV_SEPARATOR_CHAR, olddir);
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2545|      0|            newdir = tmpdir;
 2546|      0|        } else {
 2547|      0|            newdir = dir;
 2548|      0|        }
 2549|      1|    } else {
 2550|       |        /** If dir starts with '+' skip '+' it. */
 2551|      1|        newdir = ((*dir == '+') ? ++dir : dir);
  ------------------
  |  Branch (2551:19): [True: 0, False: 1]
  ------------------
 2552|      1|    }
 2553|      1|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS,
  ------------------
  |  |  162|      1|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2554|      1|                          newdir);
 2555|       |
 2556|       |    /** set_string calls strdup, so if we allocated memory, free it */
 2557|      1|    if (tmpdir == newdir) {
  ------------------
  |  Branch (2557:9): [True: 0, False: 1]
  ------------------
 2558|       |        SNMP_FREE(tmpdir);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2559|      0|    }
 2560|      1|}
netsnmp_get_mib_directory:
 2577|      1|{
 2578|      1|    char *dir;
 2579|       |
 2580|      1|    DEBUGTRACE;
  ------------------
  |  |   63|      1|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2581|      1|    dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|      1|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2582|      1|    if (dir == NULL) {
  ------------------
  |  Branch (2582:9): [True: 1, False: 0]
  ------------------
 2583|      1|        DEBUGMSGTL(("get_mib_directory", "no mib directories set\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2584|       |
 2585|       |        /** Check if the environment variable is set */
 2586|      1|        dir = netsnmp_getenv("MIBDIRS");
 2587|      1|        if (dir == NULL) {
  ------------------
  |  Branch (2587:13): [True: 1, False: 0]
  ------------------
 2588|      1|            DEBUGMSGTL(("get_mib_directory", "no mib directories set by environment\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2589|       |            /** Not set use hard coded path */
 2590|      1|            if (confmibdir == NULL) {
  ------------------
  |  Branch (2590:17): [True: 1, False: 0]
  ------------------
 2591|      1|                DEBUGMSGTL(("get_mib_directory", "no mib directories set by config\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2592|      1|                netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1641|      1|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2593|      1|            }
 2594|      0|            else if ((*confmibdir == '+') || (*confmibdir == '-')) {
  ------------------
  |  Branch (2594:22): [True: 0, False: 0]
  |  Branch (2594:46): [True: 0, False: 0]
  ------------------
 2595|      0|                DEBUGMSGTL(("get_mib_directory", "mib directories set by config (but added)\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2596|      0|                netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1641|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2597|      0|                netsnmp_set_mib_directory(confmibdir);
 2598|      0|            }
 2599|      0|            else {
 2600|      0|                DEBUGMSGTL(("get_mib_directory", "mib directories set by config\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2601|      0|                netsnmp_set_mib_directory(confmibdir);
 2602|      0|            }
 2603|      1|        } else if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2603:20): [True: 0, False: 0]
  |  Branch (2603:37): [True: 0, False: 0]
  ------------------
 2604|      0|            DEBUGMSGTL(("get_mib_directory", "mib directories set by environment (but added)\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2605|      0|            netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1641|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2606|      0|            netsnmp_set_mib_directory(dir);
 2607|      0|        } else {
 2608|      0|            DEBUGMSGTL(("get_mib_directory", "mib directories set by environment\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2609|      0|            netsnmp_set_mib_directory(dir);
 2610|      0|        }
 2611|      1|        dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                      dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|      1|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2612|      1|    }
 2613|      1|    DEBUGMSGTL(("get_mib_directory", "mib directories set '%s'\n", dir));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2614|      1|    return(dir);
 2615|      1|}
set_function:
 2910|      3|{
 2911|      3|    subtree->printer = NULL;
 2912|      3|    switch (subtree->type) {
 2913|      0|    case TYPE_OBJID:
  ------------------
  |  |  155|      0|#define TYPE_OBJID          1
  ------------------
  |  Branch (2913:5): [True: 0, False: 3]
  ------------------
 2914|      0|        subtree->printomat = sprint_realloc_object_identifier;
 2915|      0|        break;
 2916|      0|    case TYPE_OCTETSTR:
  ------------------
  |  |  156|      0|#define TYPE_OCTETSTR       2
  ------------------
  |  Branch (2916:5): [True: 0, False: 3]
  ------------------
 2917|      0|        subtree->printomat = sprint_realloc_octet_string;
 2918|      0|        break;
 2919|      0|    case TYPE_INTEGER:
  ------------------
  |  |  157|      0|#define TYPE_INTEGER        3
  ------------------
  |  Branch (2919:5): [True: 0, False: 3]
  ------------------
 2920|      0|        subtree->printomat = sprint_realloc_integer;
 2921|      0|        break;
 2922|      0|    case TYPE_INTEGER32:
  ------------------
  |  |  170|      0|#define TYPE_INTEGER32      16
  ------------------
  |  Branch (2922:5): [True: 0, False: 3]
  ------------------
 2923|      0|        subtree->printomat = sprint_realloc_integer;
 2924|      0|        break;
 2925|      0|    case TYPE_NETADDR:
  ------------------
  |  |  158|      0|#define TYPE_NETADDR        4
  ------------------
  |  Branch (2925:5): [True: 0, False: 3]
  ------------------
 2926|      0|        subtree->printomat = sprint_realloc_networkaddress;
 2927|      0|        break;
 2928|      0|    case TYPE_IPADDR:
  ------------------
  |  |  159|      0|#define TYPE_IPADDR         5
  ------------------
  |  Branch (2928:5): [True: 0, False: 3]
  ------------------
 2929|      0|        subtree->printomat = sprint_realloc_ipaddress;
 2930|      0|        break;
 2931|      0|    case TYPE_COUNTER:
  ------------------
  |  |  160|      0|#define TYPE_COUNTER        6
  ------------------
  |  Branch (2931:5): [True: 0, False: 3]
  ------------------
 2932|      0|        subtree->printomat = sprint_realloc_counter;
 2933|      0|        break;
 2934|      0|    case TYPE_GAUGE:
  ------------------
  |  |  161|      0|#define TYPE_GAUGE          7
  ------------------
  |  Branch (2934:5): [True: 0, False: 3]
  ------------------
 2935|      0|        subtree->printomat = sprint_realloc_gauge;
 2936|      0|        break;
 2937|      0|    case TYPE_TIMETICKS:
  ------------------
  |  |  162|      0|#define TYPE_TIMETICKS      8
  ------------------
  |  Branch (2937:5): [True: 0, False: 3]
  ------------------
 2938|      0|        subtree->printomat = sprint_realloc_timeticks;
 2939|      0|        break;
 2940|      0|    case TYPE_OPAQUE:
  ------------------
  |  |  163|      0|#define TYPE_OPAQUE         9
  ------------------
  |  Branch (2940:5): [True: 0, False: 3]
  ------------------
 2941|      0|        subtree->printomat = sprint_realloc_opaque;
 2942|      0|        break;
 2943|      0|    case TYPE_NULL:
  ------------------
  |  |  164|      0|#define TYPE_NULL           10
  ------------------
  |  Branch (2943:5): [True: 0, False: 3]
  ------------------
 2944|      0|        subtree->printomat = sprint_realloc_null;
 2945|      0|        break;
 2946|      0|    case TYPE_BITSTRING:
  ------------------
  |  |  166|      0|#define TYPE_BITSTRING      12
  ------------------
  |  Branch (2946:5): [True: 0, False: 3]
  ------------------
 2947|      0|        subtree->printomat = sprint_realloc_bitstring;
 2948|      0|        break;
 2949|      0|    case TYPE_NSAPADDRESS:
  ------------------
  |  |  167|      0|#define TYPE_NSAPADDRESS    13
  ------------------
  |  Branch (2949:5): [True: 0, False: 3]
  ------------------
 2950|      0|        subtree->printomat = sprint_realloc_nsapaddress;
 2951|      0|        break;
 2952|      0|    case TYPE_COUNTER64:
  ------------------
  |  |  165|      0|#define TYPE_COUNTER64      11
  ------------------
  |  Branch (2952:5): [True: 0, False: 3]
  ------------------
 2953|      0|        subtree->printomat = sprint_realloc_counter64;
 2954|      0|        break;
 2955|      0|    case TYPE_UINTEGER:
  ------------------
  |  |  168|      0|#define TYPE_UINTEGER       14
  ------------------
  |  Branch (2955:5): [True: 0, False: 3]
  ------------------
 2956|      0|        subtree->printomat = sprint_realloc_uinteger;
 2957|      0|        break;
 2958|      0|    case TYPE_UNSIGNED32:
  ------------------
  |  |  169|      0|#define TYPE_UNSIGNED32     15
  ------------------
  |  Branch (2958:5): [True: 0, False: 3]
  ------------------
 2959|      0|        subtree->printomat = sprint_realloc_gauge;
 2960|      0|        break;
 2961|      3|    case TYPE_OTHER:
  ------------------
  |  |  154|      3|#define TYPE_OTHER          0
  ------------------
  |  Branch (2961:5): [True: 3, False: 0]
  ------------------
 2962|      3|    default:
  ------------------
  |  Branch (2962:5): [True: 0, False: 3]
  ------------------
 2963|      3|        subtree->printomat = sprint_realloc_by_type;
 2964|      3|        break;
 2965|      3|    }
 2966|      3|}
read_objid:
 2987|    417|{
 2988|    417|#ifndef NETSNMP_DISABLE_MIB_LOADING
 2989|    417|    struct tree    *root = tree_top;
 2990|    417|    char            buf[SPRINT_MAX_LEN];
 2991|    417|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 2992|    417|    int             ret, max_out_len;
 2993|    417|    char           *name, ch;
 2994|    417|    const char     *cp;
 2995|       |
 2996|    417|    cp = input;
 2997|  2.98k|    while ((ch = *cp)) {
  ------------------
  |  Branch (2997:12): [True: 2.89k, False: 88]
  ------------------
 2998|  2.89k|        if (('0' <= ch && ch <= '9')
  ------------------
  |  Branch (2998:14): [True: 2.27k, False: 626]
  |  Branch (2998:27): [True: 376, False: 1.89k]
  ------------------
 2999|  2.52k|            || ('a' <= ch && ch <= 'z')
  ------------------
  |  Branch (2999:17): [True: 1.56k, False: 955]
  |  Branch (2999:30): [True: 1.55k, False: 10]
  ------------------
 3000|    965|            || ('A' <= ch && ch <= 'Z')
  ------------------
  |  Branch (3000:17): [True: 330, False: 635]
  |  Branch (3000:30): [True: 310, False: 20]
  ------------------
 3001|    655|            || ch == '-')
  ------------------
  |  Branch (3001:16): [True: 326, False: 329]
  ------------------
 3002|  2.56k|            cp++;
 3003|    329|        else
 3004|    329|            break;
 3005|  2.89k|    }
 3006|    417|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3007|    417|    if (ch == ':')
  ------------------
  |  Branch (3007:9): [True: 0, False: 417]
  ------------------
 3008|      0|        return get_node(input, output, out_len);
 3009|    417|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3010|       |
 3011|    417|    if (*input == '.')
  ------------------
  |  Branch (3011:9): [True: 3, False: 414]
  ------------------
 3012|      3|        input++;
 3013|    414|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3014|    414|    else if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_READ_UCD_STYLE_OID)) {
  ------------------
  |  |   48|    414|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  else if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_READ_UCD_STYLE_OID)) {
  ------------------
  |  |   85|    414|#define NETSNMP_DS_LIB_READ_UCD_STYLE_OID  25   /* require top-level OIDs to be prefixed with a dot */
  ------------------
  |  Branch (3014:14): [True: 0, False: 414]
  ------------------
 3015|       |        /*
 3016|       |         * get past leading '.', append '.' to Prefix. 
 3017|       |         */
 3018|      0|        if (*Prefix == '.')
  ------------------
  |  Branch (3018:13): [True: 0, False: 0]
  ------------------
 3019|      0|            strlcpy(buf, Prefix + 1, sizeof(buf));
 3020|      0|        else
 3021|      0|            strlcpy(buf, Prefix, sizeof(buf));
 3022|      0|        strlcat(buf, ".", sizeof(buf));
 3023|      0|        strlcat(buf, input, sizeof(buf));
 3024|      0|        input = buf;
 3025|      0|    }
 3026|    417|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3027|       |
 3028|    417|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3029|    417|    if ((root == NULL) && (tree_head != NULL)) {
  ------------------
  |  Branch (3029:9): [True: 417, False: 0]
  |  Branch (3029:27): [True: 361, False: 56]
  ------------------
 3030|    361|        root = tree_head;
 3031|    361|    }
 3032|     56|    else if (root == NULL) {
  ------------------
  |  Branch (3032:14): [True: 56, False: 0]
  ------------------
 3033|     56|        SET_SNMP_ERROR(SNMPERR_NOMIB);
  ------------------
  |  |   56|     56|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 3034|     56|        *out_len = 0;
 3035|     56|        return 0;
 3036|     56|    }
 3037|    361|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3038|    361|    name = strdup(input);
 3039|    361|    max_out_len = *out_len;
 3040|    361|    *out_len = 0;
 3041|    361|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3042|    361|    if ((ret =
  ------------------
  |  Branch (3042:9): [True: 279, False: 82]
  ------------------
 3043|    361|         _add_strings_to_oid(root, name, output, out_len,
 3044|    361|                             max_out_len)) <= 0)
 3045|       |#else
 3046|       |    if ((ret =
 3047|       |         _add_strings_to_oid(NULL, name, output, out_len,
 3048|       |                             max_out_len)) <= 0)
 3049|       |#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3050|    279|    {
 3051|    279|        if (ret == 0)
  ------------------
  |  Branch (3051:13): [True: 279, False: 0]
  ------------------
 3052|    279|            ret = SNMPERR_UNKNOWN_OBJID;
  ------------------
  |  |  275|    279|#define SNMPERR_UNKNOWN_OBJID		(-58)
  ------------------
 3053|    279|        SET_SNMP_ERROR(ret);
  ------------------
  |  |   56|    279|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 3054|    279|        SNMP_FREE(name);
  ------------------
  |  |   62|    279|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 279, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 279]
  |  |  ------------------
  ------------------
 3055|    279|        return 0;
 3056|    279|    }
 3057|     82|    SNMP_FREE(name);
  ------------------
  |  |   62|     82|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 82, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 82]
  |  |  ------------------
  ------------------
 3058|       |
 3059|     82|    return 1;
 3060|    361|}
get_module_node:
 5156|    524|{
 5157|    524|    int             modid, rc = 0;
 5158|    524|    struct tree    *tp;
 5159|    524|    char           *name, *cp;
 5160|       |
 5161|    524|    if (!strcmp(module, "ANY"))
  ------------------
  |  Branch (5161:9): [True: 359, False: 165]
  ------------------
 5162|    359|        modid = -1;
 5163|    165|    else {
 5164|    165|        netsnmp_read_module(module);
 5165|    165|        modid = which_module(module);
 5166|    165|        if (modid == -1)
  ------------------
  |  Branch (5166:13): [True: 165, False: 0]
  ------------------
 5167|    165|            return 0;
 5168|    165|    }
 5169|       |
 5170|       |    /*
 5171|       |     * Isolate the first component of the name ... 
 5172|       |     */
 5173|    359|    name = strdup(fname);
 5174|    359|    if (name == NULL)
  ------------------
  |  Branch (5174:9): [True: 0, False: 359]
  ------------------
 5175|      0|        return -1;
 5176|    359|    cp = strchr(name, '.');
 5177|    359|    if (cp != NULL) {
  ------------------
  |  Branch (5177:9): [True: 63, False: 296]
  ------------------
 5178|     63|        *cp = '\0';
 5179|     63|        cp++;
 5180|     63|    }
 5181|       |    /*
 5182|       |     * ... and locate it in the tree. 
 5183|       |     */
 5184|    359|    tp = find_tree_node(name, modid);
 5185|    359|    if (tp) {
  ------------------
  |  Branch (5185:9): [True: 28, False: 331]
  ------------------
 5186|     28|        size_t          maxlen = *objidlen;
 5187|       |
 5188|       |        /*
 5189|       |         * Set the first element of the object ID 
 5190|       |         */
 5191|     28|        if (node_to_oid(tp, objid, objidlen)) {
  ------------------
  |  Branch (5191:13): [True: 28, False: 0]
  ------------------
 5192|     28|            rc = 1;
 5193|       |
 5194|       |            /*
 5195|       |             * If the name requested was more than one element,
 5196|       |             * tag on the rest of the components 
 5197|       |             */
 5198|     28|            if (cp != NULL)
  ------------------
  |  Branch (5198:17): [True: 5, False: 23]
  ------------------
 5199|      5|                rc = _add_strings_to_oid(tp, cp, objid, objidlen, maxlen);
 5200|     28|        }
 5201|     28|    }
 5202|       |
 5203|       |    SNMP_FREE(name);
  ------------------
  |  |   62|    359|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 359, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 359]
  |  |  ------------------
  ------------------
 5204|    359|    return (rc);
 5205|    359|}
get_wild_node:
 5698|    333|{
 5699|    333|    struct tree    *tp = find_best_tree_node(name, tree_head, NULL);
 5700|    333|    if (!tp)
  ------------------
  |  Branch (5700:9): [True: 312, False: 21]
  ------------------
 5701|    312|        return 0;
 5702|     21|    return get_node(tp->label, objid, objidlen);
 5703|    333|}
get_node:
 5707|    524|{
 5708|    524|    const char     *cp;
 5709|    524|    char            ch;
 5710|    524|    int             res;
 5711|       |
 5712|    524|    cp = name;
 5713|  8.99k|    while ((ch = *cp))
  ------------------
  |  Branch (5713:12): [True: 8.88k, False: 107]
  ------------------
 5714|  8.88k|        if (('0' <= ch && ch <= '9')
  ------------------
  |  Branch (5714:14): [True: 8.18k, False: 707]
  |  Branch (5714:27): [True: 3.07k, False: 5.10k]
  ------------------
 5715|  5.81k|            || ('a' <= ch && ch <= 'z')
  ------------------
  |  Branch (5715:17): [True: 2.03k, False: 3.77k]
  |  Branch (5715:30): [True: 2.02k, False: 10]
  ------------------
 5716|  3.78k|            || ('A' <= ch && ch <= 'Z')
  ------------------
  |  Branch (5716:17): [True: 2.90k, False: 882]
  |  Branch (5716:30): [True: 2.88k, False: 20]
  ------------------
 5717|    902|            || ch == '-')
  ------------------
  |  Branch (5717:16): [True: 485, False: 417]
  ------------------
 5718|  8.47k|            cp++;
 5719|    417|        else
 5720|    417|            break;
 5721|    524|    if (ch != ':')
  ------------------
  |  Branch (5721:9): [True: 358, False: 166]
  ------------------
 5722|    358|        if (*name == '.')
  ------------------
  |  Branch (5722:13): [True: 2, False: 356]
  ------------------
 5723|      2|            res = get_module_node(name + 1, "ANY", objid, objidlen);
 5724|    356|        else
 5725|    356|            res = get_module_node(name, "ANY", objid, objidlen);
 5726|    166|    else {
 5727|    166|        char           *module;
 5728|       |        /*
 5729|       |         *  requested name is of the form
 5730|       |         *      "module:subidentifier"
 5731|       |         */
 5732|    166|        module = (char *) malloc((size_t) (cp - name + 1));
 5733|    166|        if (!module)
  ------------------
  |  Branch (5733:13): [True: 0, False: 166]
  ------------------
 5734|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 5735|    166|        sprintf(module, "%.*s", (int) (cp - name), name);
 5736|    166|        cp++;                   /* cp now point to the subidentifier */
 5737|    166|        if (*cp == ':')
  ------------------
  |  Branch (5737:13): [True: 3, False: 163]
  ------------------
 5738|      3|            cp++;
 5739|       |
 5740|       |        /*
 5741|       |         * 'cp' and 'name' *do* go that way round! 
 5742|       |         */
 5743|    166|        res = get_module_node(cp, module, objid, objidlen);
 5744|    166|        SNMP_FREE(module);
  ------------------
  |  |   62|    166|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 166, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 166]
  |  |  ------------------
  ------------------
 5745|    166|    }
 5746|    524|    if (res == 0) {
  ------------------
  |  Branch (5746:9): [True: 500, False: 24]
  ------------------
 5747|    500|        SET_SNMP_ERROR(SNMPERR_UNKNOWN_OBJID);
  ------------------
  |  |   56|    500|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 5748|    500|    }
 5749|       |
 5750|    524|    return res;
 5751|    524|}
clear_tree_flags:
 5788|    333|{
 5789|  1.16k|    for (; tp; tp = tp->next_peer) {
  ------------------
  |  Branch (5789:12): [True: 831, False: 333]
  ------------------
 5790|    831|        tp->reported = 0;
 5791|    831|        if (tp->child_list)
  ------------------
  |  Branch (5791:13): [True: 0, False: 831]
  ------------------
 5792|      0|            clear_tree_flags(tp->child_list);
 5793|    831|     /*RECURSE*/}
 5794|    333|}
snmp_parse_oid:
 6047|    585|{
 6048|    585|#ifndef NETSNMP_DISABLE_MIB_LOADING
 6049|    585|    size_t          savlen = *rootlen;
 6050|    585|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 6051|    585|    char           *tmpbuf = NULL;
 6052|    585|    const char     *suffix, *prefix;
 6053|       |
 6054|    585|    suffix = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    585|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 6055|    585|                                   NETSNMP_DS_LIB_OIDSUFFIX);
  ------------------
  |  |  163|    585|#define NETSNMP_DS_LIB_OIDSUFFIX         12
  ------------------
 6056|    585|    prefix = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    585|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 6057|    585|                                   NETSNMP_DS_LIB_OIDPREFIX);
  ------------------
  |  |  164|    585|#define NETSNMP_DS_LIB_OIDPREFIX         13
  ------------------
 6058|    585|    if ((suffix && suffix[0]) || (prefix && prefix[0])) {
  ------------------
  |  Branch (6058:10): [True: 0, False: 585]
  |  Branch (6058:20): [True: 0, False: 0]
  |  Branch (6058:35): [True: 0, False: 585]
  |  Branch (6058:45): [True: 0, False: 0]
  ------------------
 6059|      0|        if (!suffix)
  ------------------
  |  Branch (6059:13): [True: 0, False: 0]
  ------------------
 6060|      0|            suffix = "";
 6061|      0|        if (!prefix)
  ------------------
  |  Branch (6061:13): [True: 0, False: 0]
  ------------------
 6062|      0|            prefix = "";
 6063|      0|        if (asprintf(&tmpbuf, "%s%s%s%s", prefix, argv,
  ------------------
  |  Branch (6063:13): [True: 0, False: 0]
  ------------------
 6064|      0|                     suffix[0] == '.' || suffix[0] == '\0' ? "" : ".",
  ------------------
  |  Branch (6064:22): [True: 0, False: 0]
  |  Branch (6064:42): [True: 0, False: 0]
  ------------------
 6065|      0|                     suffix) < 0) {
 6066|      0|            DEBUGMSGTL(("snmp_parse_oid", "Out of memory\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6067|      0|            return NULL;
 6068|      0|        }
 6069|      0|        argv = tmpbuf;
 6070|      0|        DEBUGMSGTL(("snmp_parse_oid","Parsing: %s\n",argv));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6071|      0|    }
 6072|       |
 6073|    585|#ifndef NETSNMP_DISABLE_MIB_LOADING
 6074|    585|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    585|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (6074:9): [True: 0, False: 585]
  ------------------
 6075|    585|                               NETSNMP_DS_LIB_RANDOM_ACCESS)
  ------------------
  |  |   74|    585|#define NETSNMP_DS_LIB_RANDOM_ACCESS	   14   /* random access to oid labels */
  ------------------
 6076|    585|        || strchr(argv, ':')) {
  ------------------
  |  Branch (6076:12): [True: 168, False: 417]
  ------------------
 6077|    168|        if (get_node(argv, root, rootlen))
  ------------------
  |  Branch (6077:13): [True: 1, False: 167]
  ------------------
 6078|      1|            goto out;
 6079|    417|    } else if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    417|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (6079:16): [True: 0, False: 417]
  ------------------
 6080|    417|                                      NETSNMP_DS_LIB_REGEX_ACCESS)) {
  ------------------
  |  |   75|    417|#define NETSNMP_DS_LIB_REGEX_ACCESS	   15   /* regex matching to oid labels */
  ------------------
 6081|      0|	clear_tree_flags(tree_head);
 6082|      0|        if (get_wild_node(argv, root, rootlen))
  ------------------
  |  Branch (6082:13): [True: 0, False: 0]
  ------------------
 6083|      0|            goto out;
 6084|    417|    } else {
 6085|    417|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 6086|    417|        if (read_objid(argv, root, rootlen))
  ------------------
  |  Branch (6086:13): [True: 82, False: 335]
  ------------------
 6087|     82|            goto out;
 6088|    335|#ifndef NETSNMP_DISABLE_MIB_LOADING
 6089|    335|        *rootlen = savlen;
 6090|    335|        if (get_node(argv, root, rootlen))
  ------------------
  |  Branch (6090:13): [True: 2, False: 333]
  ------------------
 6091|      2|            goto out;
 6092|    333|        *rootlen = savlen;
 6093|    333|        DEBUGMSGTL(("parse_oid", "wildly parsing\n"));
  ------------------
  |  |   66|    333|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    333|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 333]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 333]
  |  |  ------------------
  ------------------
 6094|    333|	clear_tree_flags(tree_head);
 6095|    333|        if (get_wild_node(argv, root, rootlen))
  ------------------
  |  Branch (6095:13): [True: 21, False: 312]
  ------------------
 6096|     21|            goto out;
 6097|    333|    }
 6098|    479|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 6099|       |
 6100|    479|    root = NULL;
 6101|       |
 6102|    585|out:
 6103|    585|    free(tmpbuf);
 6104|    585|    return root;
 6105|    479|}
mib.c:node_to_oid:
 5227|     28|{
 5228|     28|    size_t          numids, lenids;
 5229|     28|    oid            *op;
 5230|       |
 5231|     28|    if (!tp || !objid || !objidlen)
  ------------------
  |  Branch (5231:9): [True: 0, False: 28]
  |  Branch (5231:16): [True: 0, False: 28]
  |  Branch (5231:26): [True: 0, False: 28]
  ------------------
 5232|      0|        return 0;
 5233|       |
 5234|     28|    lenids = *objidlen;
 5235|     28|    op = objid + lenids;        /* points after the last element */
 5236|       |
 5237|     56|    for (numids = 0; tp; tp = tp->parent, numids++) {
  ------------------
  |  Branch (5237:22): [True: 28, False: 28]
  ------------------
 5238|     28|        if (numids >= lenids)
  ------------------
  |  Branch (5238:13): [True: 0, False: 28]
  ------------------
 5239|      0|            continue;
 5240|     28|        --op;
 5241|     28|        *op = tp->subid;
 5242|     28|    }
 5243|       |
 5244|     28|    *objidlen = numids;
 5245|     28|    if (numids > lenids) {
  ------------------
  |  Branch (5245:9): [True: 0, False: 28]
  ------------------
 5246|      0|        return 0;
 5247|      0|    }
 5248|       |
 5249|     28|    if (numids < lenids)
  ------------------
  |  Branch (5249:9): [True: 28, False: 0]
  ------------------
 5250|     28|        memmove(objid, op, numids * sizeof(oid));
 5251|       |
 5252|     28|    return numids;
 5253|     28|}
mib.c:_add_strings_to_oid:
 5297|    366|{
 5298|    366|    oid             subid;
 5299|    366|    char           *fcp, *ecp, *cp2 = NULL;
 5300|    366|    char            doingquote;
 5301|    366|    int             len = -1;
 5302|    366|#ifndef NETSNMP_DISABLE_MIB_LOADING
 5303|    366|    struct tree    *tp2 = NULL;
 5304|    366|    struct index_list *in_dices = NULL;
 5305|    366|    int             pos = -1;
 5306|    366|    int             check =
 5307|    366|        !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   48|    366|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                      !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   76|    366|#define NETSNMP_DS_LIB_DONT_CHECK_RANGE    16   /* don't check values for ranges on send */
  ------------------
 5308|    366|    int             do_hint = !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   48|    366|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  int             do_hint = !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   90|    366|#define NETSNMP_DS_LIB_NO_DISPLAY_HINT     30 /* don't apply DISPLAY-HINTs */
  ------------------
 5309|    366|    int             len_index = 1000000;
 5310|       |
 5311|    366|    while (cp && tp && tp->child_list) {
  ------------------
  |  Branch (5311:12): [True: 366, False: 0]
  |  Branch (5311:18): [True: 366, False: 0]
  |  Branch (5311:24): [True: 0, False: 366]
  ------------------
 5312|      0|        fcp = cp;
 5313|      0|        tp2 = tp->child_list;
 5314|       |        /*
 5315|       |         * Isolate the next entry 
 5316|       |         */
 5317|      0|        cp2 = strchr(cp, '.');
 5318|      0|        if (cp2)
  ------------------
  |  Branch (5318:13): [True: 0, False: 0]
  ------------------
 5319|      0|            *cp2++ = '\0';
 5320|       |
 5321|       |        /*
 5322|       |         * Search for the appropriate child 
 5323|       |         */
 5324|      0|        if (isdigit((unsigned char)(*cp))) {
  ------------------
  |  Branch (5324:13): [True: 0, False: 0]
  ------------------
 5325|      0|            subid = strtoul(cp, &ecp, 0);
 5326|      0|            if (*ecp)
  ------------------
  |  Branch (5326:17): [True: 0, False: 0]
  ------------------
 5327|      0|                goto bad_id;
 5328|      0|            while (tp2 && tp2->subid != subid)
  ------------------
  |  Branch (5328:20): [True: 0, False: 0]
  |  Branch (5328:27): [True: 0, False: 0]
  ------------------
 5329|      0|                tp2 = tp2->next_peer;
 5330|      0|        } else {
 5331|      0|            while (tp2 && strcmp(tp2->label, fcp))
  ------------------
  |  Branch (5331:20): [True: 0, False: 0]
  |  Branch (5331:27): [True: 0, False: 0]
  ------------------
 5332|      0|                tp2 = tp2->next_peer;
 5333|      0|            if (!tp2)
  ------------------
  |  Branch (5333:17): [True: 0, False: 0]
  ------------------
 5334|      0|                goto bad_id;
 5335|      0|            subid = tp2->subid;
 5336|      0|        }
 5337|      0|        if (*objidlen >= maxlen)
  ------------------
  |  Branch (5337:13): [True: 0, False: 0]
  ------------------
 5338|      0|            goto bad_id;
 5339|      0|	while (tp2 && tp2->next_peer && tp2->next_peer->subid == subid)
  ------------------
  |  Branch (5339:9): [True: 0, False: 0]
  |  Branch (5339:16): [True: 0, False: 0]
  |  Branch (5339:34): [True: 0, False: 0]
  ------------------
 5340|      0|	    tp2 = tp2->next_peer;
 5341|      0|        objid[*objidlen] = subid;
 5342|      0|        (*objidlen)++;
 5343|       |
 5344|      0|        cp = cp2;
 5345|      0|        if (!tp2)
  ------------------
  |  Branch (5345:13): [True: 0, False: 0]
  ------------------
 5346|      0|            break;
 5347|      0|        tp = tp2;
 5348|      0|    }
 5349|       |
 5350|    366|    if (tp && !tp->child_list) {
  ------------------
  |  Branch (5350:9): [True: 366, False: 0]
  |  Branch (5350:15): [True: 366, False: 0]
  ------------------
 5351|    366|        if ((tp2 = tp->parent)) {
  ------------------
  |  Branch (5351:13): [True: 0, False: 366]
  ------------------
 5352|      0|            if (tp2->indexes)
  ------------------
  |  Branch (5352:17): [True: 0, False: 0]
  ------------------
 5353|      0|                in_dices = tp2->indexes;
 5354|      0|            else if (tp2->augments) {
  ------------------
  |  Branch (5354:22): [True: 0, False: 0]
  ------------------
 5355|      0|                tp2 = find_tree_node(tp2->augments, -1);
 5356|      0|                if (tp2)
  ------------------
  |  Branch (5356:21): [True: 0, False: 0]
  ------------------
 5357|      0|                    in_dices = tp2->indexes;
 5358|      0|            }
 5359|      0|        }
 5360|    366|        tp = NULL;
 5361|    366|    }
 5362|       |
 5363|    366|    while (cp && in_dices) {
  ------------------
  |  Branch (5363:12): [True: 366, False: 0]
  |  Branch (5363:18): [True: 0, False: 366]
  ------------------
 5364|      0|        fcp = cp;
 5365|       |
 5366|      0|        tp = find_tree_node(in_dices->ilabel, -1);
 5367|      0|        if (!tp)
  ------------------
  |  Branch (5367:13): [True: 0, False: 0]
  ------------------
 5368|      0|            break;
 5369|      0|        switch (tp->type) {
 5370|      0|        case TYPE_INTEGER:
  ------------------
  |  |  157|      0|#define TYPE_INTEGER        3
  ------------------
  |  Branch (5370:9): [True: 0, False: 0]
  ------------------
 5371|      0|        case TYPE_INTEGER32:
  ------------------
  |  |  170|      0|#define TYPE_INTEGER32      16
  ------------------
  |  Branch (5371:9): [True: 0, False: 0]
  ------------------
 5372|      0|        case TYPE_UINTEGER:
  ------------------
  |  |  168|      0|#define TYPE_UINTEGER       14
  ------------------
  |  Branch (5372:9): [True: 0, False: 0]
  ------------------
 5373|      0|        case TYPE_UNSIGNED32:
  ------------------
  |  |  169|      0|#define TYPE_UNSIGNED32     15
  ------------------
  |  Branch (5373:9): [True: 0, False: 0]
  ------------------
 5374|      0|        case TYPE_TIMETICKS:
  ------------------
  |  |  162|      0|#define TYPE_TIMETICKS      8
  ------------------
  |  Branch (5374:9): [True: 0, False: 0]
  ------------------
 5375|       |            /*
 5376|       |             * Isolate the next entry 
 5377|       |             */
 5378|      0|            cp2 = strchr(cp, '.');
 5379|      0|            if (cp2)
  ------------------
  |  Branch (5379:17): [True: 0, False: 0]
  ------------------
 5380|      0|                *cp2++ = '\0';
 5381|      0|            if (isdigit((unsigned char)(*cp))) {
  ------------------
  |  Branch (5381:17): [True: 0, False: 0]
  ------------------
 5382|      0|                subid = strtoul(cp, &ecp, 0);
 5383|      0|                if (*ecp)
  ------------------
  |  Branch (5383:21): [True: 0, False: 0]
  ------------------
 5384|      0|                    goto bad_id;
 5385|      0|            } else {
 5386|      0|                if (tp->enums) {
  ------------------
  |  Branch (5386:21): [True: 0, False: 0]
  ------------------
 5387|      0|                    struct enum_list *ep = tp->enums;
 5388|      0|                    while (ep && strcmp(ep->label, cp))
  ------------------
  |  Branch (5388:28): [True: 0, False: 0]
  |  Branch (5388:34): [True: 0, False: 0]
  ------------------
 5389|      0|                        ep = ep->next;
 5390|      0|                    if (!ep)
  ------------------
  |  Branch (5390:25): [True: 0, False: 0]
  ------------------
 5391|      0|                        goto bad_id;
 5392|      0|                    subid = ep->value;
 5393|      0|                } else
 5394|      0|                    goto bad_id;
 5395|      0|            }
 5396|      0|            if (check && tp->ranges) {
  ------------------
  |  Branch (5396:17): [True: 0, False: 0]
  |  Branch (5396:26): [True: 0, False: 0]
  ------------------
 5397|      0|                struct range_list *rp = tp->ranges;
 5398|      0|                int             ok = 0;
 5399|      0|                if (tp->type == TYPE_INTEGER ||
  ------------------
  |  |  157|      0|#define TYPE_INTEGER        3
  ------------------
  |  Branch (5399:21): [True: 0, False: 0]
  ------------------
 5400|      0|                    tp->type == TYPE_INTEGER32) {
  ------------------
  |  |  170|      0|#define TYPE_INTEGER32      16
  ------------------
  |  Branch (5400:21): [True: 0, False: 0]
  ------------------
 5401|      0|                  while (!ok && rp) {
  ------------------
  |  Branch (5401:26): [True: 0, False: 0]
  |  Branch (5401:33): [True: 0, False: 0]
  ------------------
 5402|      0|                    if ((rp->low <= (int) subid)
  ------------------
  |  Branch (5402:25): [True: 0, False: 0]
  ------------------
 5403|      0|                        && ((int) subid <= rp->high))
  ------------------
  |  Branch (5403:28): [True: 0, False: 0]
  ------------------
 5404|      0|                        ok = 1;
 5405|      0|                    else
 5406|      0|                        rp = rp->next;
 5407|      0|                  }
 5408|      0|                } else { /* check unsigned range */
 5409|      0|                  while (!ok && rp) {
  ------------------
  |  Branch (5409:26): [True: 0, False: 0]
  |  Branch (5409:33): [True: 0, False: 0]
  ------------------
 5410|      0|                    if (((unsigned int)rp->low <= subid)
  ------------------
  |  Branch (5410:25): [True: 0, False: 0]
  ------------------
 5411|      0|                        && (subid <= (unsigned int)rp->high))
  ------------------
  |  Branch (5411:28): [True: 0, False: 0]
  ------------------
 5412|      0|                        ok = 1;
 5413|      0|                    else
 5414|      0|                        rp = rp->next;
 5415|      0|                  }
 5416|      0|                }
 5417|      0|                if (!ok)
  ------------------
  |  Branch (5417:21): [True: 0, False: 0]
  ------------------
 5418|      0|                    goto bad_id;
 5419|      0|            }
 5420|      0|            if (*objidlen >= maxlen)
  ------------------
  |  Branch (5420:17): [True: 0, False: 0]
  ------------------
 5421|      0|                goto bad_id;
 5422|      0|            objid[*objidlen] = subid;
 5423|      0|            (*objidlen)++;
 5424|      0|            break;
 5425|      0|        case TYPE_IPADDR:
  ------------------
  |  |  159|      0|#define TYPE_IPADDR         5
  ------------------
  |  Branch (5425:9): [True: 0, False: 0]
  ------------------
 5426|      0|            if (*objidlen + 4 > maxlen)
  ------------------
  |  Branch (5426:17): [True: 0, False: 0]
  ------------------
 5427|      0|                goto bad_id;
 5428|      0|            for (subid = 0; cp && subid < 4; subid++) {
  ------------------
  |  Branch (5428:29): [True: 0, False: 0]
  |  Branch (5428:35): [True: 0, False: 0]
  ------------------
 5429|      0|                fcp = cp;
 5430|      0|                cp2 = strchr(cp, '.');
 5431|      0|                if (cp2)
  ------------------
  |  Branch (5431:21): [True: 0, False: 0]
  ------------------
 5432|      0|                    *cp2++ = 0;
 5433|      0|                objid[*objidlen] = strtoul(cp, &ecp, 0);
 5434|      0|                if (*ecp)
  ------------------
  |  Branch (5434:21): [True: 0, False: 0]
  ------------------
 5435|      0|                    goto bad_id;
 5436|      0|                if (check && objid[*objidlen] > 255)
  ------------------
  |  Branch (5436:21): [True: 0, False: 0]
  |  Branch (5436:30): [True: 0, False: 0]
  ------------------
 5437|      0|                    goto bad_id;
 5438|      0|                (*objidlen)++;
 5439|      0|                cp = cp2;
 5440|      0|            }
 5441|      0|            break;
 5442|      0|        case TYPE_OCTETSTR:
  ------------------
  |  |  156|      0|#define TYPE_OCTETSTR       2
  ------------------
  |  Branch (5442:9): [True: 0, False: 0]
  ------------------
 5443|      0|            if (tp->ranges && !tp->ranges->next
  ------------------
  |  Branch (5443:17): [True: 0, False: 0]
  |  Branch (5443:31): [True: 0, False: 0]
  ------------------
 5444|      0|                && tp->ranges->low == tp->ranges->high)
  ------------------
  |  Branch (5444:20): [True: 0, False: 0]
  ------------------
 5445|      0|                len = tp->ranges->low;
 5446|      0|            else
 5447|      0|                len = -1;
 5448|      0|            pos = 0;
 5449|      0|            if (*cp == '"' || *cp == '\'') {
  ------------------
  |  Branch (5449:17): [True: 0, False: 0]
  |  Branch (5449:31): [True: 0, False: 0]
  ------------------
 5450|      0|                doingquote = *cp++;
 5451|       |                /*
 5452|       |                 * insert length if requested 
 5453|       |                 */
 5454|      0|                if (!in_dices->isimplied && len == -1) {
  ------------------
  |  Branch (5454:21): [True: 0, False: 0]
  |  Branch (5454:45): [True: 0, False: 0]
  ------------------
 5455|      0|                    if (doingquote == '\'') {
  ------------------
  |  Branch (5455:25): [True: 0, False: 0]
  ------------------
 5456|      0|                        snmp_set_detail
 5457|      0|                            ("'-quote is for fixed length strings");
 5458|      0|                        return 0;
 5459|      0|                    }
 5460|      0|                    if (*objidlen >= maxlen)
  ------------------
  |  Branch (5460:25): [True: 0, False: 0]
  ------------------
 5461|      0|                        goto bad_id;
 5462|      0|                    len_index = *objidlen;
 5463|      0|                    (*objidlen)++;
 5464|      0|                } else if (doingquote == '"') {
  ------------------
  |  Branch (5464:28): [True: 0, False: 0]
  ------------------
 5465|      0|                    snmp_set_detail
 5466|      0|                        ("\"-quote is for variable length strings");
 5467|      0|                    return 0;
 5468|      0|                }
 5469|       |
 5470|      0|		cp2 = _apply_escapes(cp, doingquote);
 5471|      0|		if (!cp2) goto bad_id;
  ------------------
  |  Branch (5471:7): [True: 0, False: 0]
  ------------------
 5472|      0|		else {
 5473|      0|		    unsigned char *new_val;
 5474|      0|		    int new_val_len;
 5475|      0|		    int parsed_hint = 0;
 5476|      0|		    const char *parsed_value;
 5477|       |
 5478|      0|		    if (do_hint && tp->hint) {
  ------------------
  |  Branch (5478:11): [True: 0, False: 0]
  |  Branch (5478:22): [True: 0, False: 0]
  ------------------
 5479|      0|			parsed_value = parse_octet_hint(tp->hint, cp,
 5480|      0|			                                &new_val, &new_val_len);
 5481|      0|			parsed_hint = parsed_value == NULL;
 5482|      0|		    }
 5483|      0|		    if (parsed_hint) {
  ------------------
  |  Branch (5483:11): [True: 0, False: 0]
  ------------------
 5484|      0|			int i;
 5485|      0|			for (i = 0; i < new_val_len; i++) {
  ------------------
  |  Branch (5485:16): [True: 0, False: 0]
  ------------------
 5486|      0|			    if (*objidlen >= maxlen) goto bad_id;
  ------------------
  |  Branch (5486:12): [True: 0, False: 0]
  ------------------
 5487|      0|			    objid[ *objidlen ] = new_val[i];
 5488|      0|			    (*objidlen)++;
 5489|      0|			    pos++;
 5490|      0|			}
 5491|      0|			SNMP_FREE(new_val);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5492|      0|		    } else {
 5493|      0|			while(*cp) {
  ------------------
  |  Branch (5493:10): [True: 0, False: 0]
  ------------------
 5494|      0|			    if (*objidlen >= maxlen) goto bad_id;
  ------------------
  |  Branch (5494:12): [True: 0, False: 0]
  ------------------
 5495|      0|			    objid[ *objidlen ] = *cp++;
 5496|      0|			    (*objidlen)++;
 5497|      0|			    pos++;
 5498|      0|			}
 5499|      0|		    }
 5500|      0|		}
 5501|       |		
 5502|      0|		cp2++;
 5503|      0|                if (!*cp2)
  ------------------
  |  Branch (5503:21): [True: 0, False: 0]
  ------------------
 5504|      0|                    cp2 = NULL;
 5505|      0|                else if (*cp2 != '.')
  ------------------
  |  Branch (5505:26): [True: 0, False: 0]
  ------------------
 5506|      0|                    goto bad_id;
 5507|      0|                else
 5508|      0|                    cp2++;
 5509|      0|		if (check) {
  ------------------
  |  Branch (5509:7): [True: 0, False: 0]
  ------------------
 5510|      0|                    if (len == -1) {
  ------------------
  |  Branch (5510:25): [True: 0, False: 0]
  ------------------
 5511|      0|                        struct range_list *rp = tp->ranges;
 5512|      0|                        int             ok = 0;
 5513|      0|                        while (rp && !ok)
  ------------------
  |  Branch (5513:32): [True: 0, False: 0]
  |  Branch (5513:38): [True: 0, False: 0]
  ------------------
 5514|      0|                            if (rp->low <= pos && pos <= rp->high)
  ------------------
  |  Branch (5514:33): [True: 0, False: 0]
  |  Branch (5514:51): [True: 0, False: 0]
  ------------------
 5515|      0|                                ok = 1;
 5516|      0|                            else
 5517|      0|                                rp = rp->next;
 5518|      0|                        if (!ok)
  ------------------
  |  Branch (5518:29): [True: 0, False: 0]
  ------------------
 5519|      0|                            goto bad_id;
 5520|      0|                        if (!in_dices->isimplied)
  ------------------
  |  Branch (5520:29): [True: 0, False: 0]
  ------------------
 5521|      0|                            objid[len_index] = pos;
 5522|      0|                    } else if (pos != len)
  ------------------
  |  Branch (5522:32): [True: 0, False: 0]
  ------------------
 5523|      0|                        goto bad_id;
 5524|      0|		}
 5525|      0|		else if (len == -1 && !in_dices->isimplied)
  ------------------
  |  Branch (5525:12): [True: 0, False: 0]
  |  Branch (5525:25): [True: 0, False: 0]
  ------------------
 5526|      0|		    objid[len_index] = pos;
 5527|      0|            } else {
 5528|      0|                if (!in_dices->isimplied && len == -1) {
  ------------------
  |  Branch (5528:21): [True: 0, False: 0]
  |  Branch (5528:45): [True: 0, False: 0]
  ------------------
 5529|      0|                    fcp = cp;
 5530|      0|                    cp2 = strchr(cp, '.');
 5531|      0|                    if (cp2)
  ------------------
  |  Branch (5531:25): [True: 0, False: 0]
  ------------------
 5532|      0|                        *cp2++ = 0;
 5533|      0|                    len = strtoul(cp, &ecp, 0);
 5534|      0|                    if (*ecp)
  ------------------
  |  Branch (5534:25): [True: 0, False: 0]
  ------------------
 5535|      0|                        goto bad_id;
 5536|      0|                    if (*objidlen + len + 1 >= maxlen)
  ------------------
  |  Branch (5536:25): [True: 0, False: 0]
  ------------------
 5537|      0|                        goto bad_id;
 5538|      0|                    objid[*objidlen] = len;
 5539|      0|                    (*objidlen)++;
 5540|      0|                    cp = cp2;
 5541|      0|                }
 5542|      0|                while (len && cp) {
  ------------------
  |  Branch (5542:24): [True: 0, False: 0]
  |  Branch (5542:31): [True: 0, False: 0]
  ------------------
 5543|      0|                    fcp = cp;
 5544|      0|                    cp2 = strchr(cp, '.');
 5545|      0|                    if (cp2)
  ------------------
  |  Branch (5545:25): [True: 0, False: 0]
  ------------------
 5546|      0|                        *cp2++ = 0;
 5547|      0|                    objid[*objidlen] = strtoul(cp, &ecp, 0);
 5548|      0|                    if (*ecp)
  ------------------
  |  Branch (5548:25): [True: 0, False: 0]
  ------------------
 5549|      0|                        goto bad_id;
 5550|      0|                    if (check && objid[*objidlen] > 255)
  ------------------
  |  Branch (5550:25): [True: 0, False: 0]
  |  Branch (5550:34): [True: 0, False: 0]
  ------------------
 5551|      0|                        goto bad_id;
 5552|      0|                    (*objidlen)++;
 5553|      0|                    len--;
 5554|      0|                    cp = cp2;
 5555|      0|                }
 5556|      0|            }
 5557|      0|            break;
 5558|      0|        case TYPE_OBJID:
  ------------------
  |  |  155|      0|#define TYPE_OBJID          1
  ------------------
  |  Branch (5558:9): [True: 0, False: 0]
  ------------------
 5559|      0|            in_dices = NULL;
 5560|      0|            cp2 = cp;
 5561|      0|            break;
 5562|      0|	case TYPE_NETADDR:
  ------------------
  |  |  158|      0|#define TYPE_NETADDR        4
  ------------------
  |  Branch (5562:2): [True: 0, False: 0]
  ------------------
 5563|      0|	    fcp = cp;
 5564|      0|	    cp2 = strchr(cp, '.');
 5565|      0|	    if (cp2)
  ------------------
  |  Branch (5565:10): [True: 0, False: 0]
  ------------------
 5566|      0|		*cp2++ = 0;
 5567|      0|	    subid = strtoul(cp, &ecp, 0);
 5568|      0|	    if (*ecp)
  ------------------
  |  Branch (5568:10): [True: 0, False: 0]
  ------------------
 5569|      0|		goto bad_id;
 5570|      0|	    if (*objidlen + 1 >= maxlen)
  ------------------
  |  Branch (5570:10): [True: 0, False: 0]
  ------------------
 5571|      0|		goto bad_id;
 5572|      0|	    objid[*objidlen] = subid;
 5573|      0|	    (*objidlen)++;
 5574|      0|	    cp = cp2;
 5575|      0|	    if (subid == 1) {
  ------------------
  |  Branch (5575:10): [True: 0, False: 0]
  ------------------
 5576|      0|		for (len = 0; cp && len < 4; len++) {
  ------------------
  |  Branch (5576:17): [True: 0, False: 0]
  |  Branch (5576:23): [True: 0, False: 0]
  ------------------
 5577|      0|		    fcp = cp;
 5578|      0|		    cp2 = strchr(cp, '.');
 5579|      0|		    if (cp2)
  ------------------
  |  Branch (5579:11): [True: 0, False: 0]
  ------------------
 5580|      0|			*cp2++ = 0;
 5581|      0|		    subid = strtoul(cp, &ecp, 0);
 5582|      0|		    if (*ecp)
  ------------------
  |  Branch (5582:11): [True: 0, False: 0]
  ------------------
 5583|      0|			goto bad_id;
 5584|      0|		    if (*objidlen + 1 >= maxlen)
  ------------------
  |  Branch (5584:11): [True: 0, False: 0]
  ------------------
 5585|      0|			goto bad_id;
 5586|      0|		    if (check && subid > 255)
  ------------------
  |  Branch (5586:11): [True: 0, False: 0]
  |  Branch (5586:20): [True: 0, False: 0]
  ------------------
 5587|      0|			goto bad_id;
 5588|      0|		    objid[*objidlen] = subid;
 5589|      0|		    (*objidlen)++;
 5590|      0|		    cp = cp2;
 5591|      0|		}
 5592|      0|	    }
 5593|      0|	    else {
 5594|      0|		in_dices = NULL;
 5595|      0|	    }
 5596|      0|	    break;
 5597|      0|        default:
  ------------------
  |  Branch (5597:9): [True: 0, False: 0]
  ------------------
 5598|      0|            snmp_log(LOG_ERR, "Unexpected index type: %d %s %s\n",
 5599|      0|                     tp->type, in_dices->ilabel, cp);
 5600|      0|            in_dices = NULL;
 5601|      0|            cp2 = cp;
 5602|      0|            break;
 5603|      0|        }
 5604|      0|        cp = cp2;
 5605|      0|        if (in_dices)
  ------------------
  |  Branch (5605:13): [True: 0, False: 0]
  ------------------
 5606|      0|            in_dices = in_dices->next;
 5607|      0|    }
 5608|       |
 5609|    366|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 5610|  3.42k|    while (cp) {
  ------------------
  |  Branch (5610:12): [True: 3.34k, False: 83]
  ------------------
 5611|  3.34k|        fcp = cp;
 5612|  3.34k|        switch (*cp) {
 5613|    212|        case '0':
  ------------------
  |  Branch (5613:9): [True: 212, False: 3.13k]
  ------------------
 5614|    411|        case '1':
  ------------------
  |  Branch (5614:9): [True: 199, False: 3.14k]
  ------------------
 5615|    608|        case '2':
  ------------------
  |  Branch (5615:9): [True: 197, False: 3.14k]
  ------------------
 5616|    804|        case '3':
  ------------------
  |  Branch (5616:9): [True: 196, False: 3.14k]
  ------------------
 5617|  1.12k|        case '4':
  ------------------
  |  Branch (5617:9): [True: 322, False: 3.02k]
  ------------------
 5618|  1.32k|        case '5':
  ------------------
  |  Branch (5618:9): [True: 197, False: 3.14k]
  ------------------
 5619|  1.51k|        case '6':
  ------------------
  |  Branch (5619:9): [True: 193, False: 3.15k]
  ------------------
 5620|  1.73k|        case '7':
  ------------------
  |  Branch (5620:9): [True: 219, False: 3.12k]
  ------------------
 5621|  1.93k|        case '8':
  ------------------
  |  Branch (5621:9): [True: 196, False: 3.14k]
  ------------------
 5622|  2.12k|        case '9':
  ------------------
  |  Branch (5622:9): [True: 195, False: 3.14k]
  ------------------
 5623|  2.12k|            cp2 = strchr(cp, '.');
 5624|  2.12k|            if (cp2)
  ------------------
  |  Branch (5624:17): [True: 2.03k, False: 94]
  ------------------
 5625|  2.03k|                *cp2++ = 0;
 5626|  2.12k|            subid = strtoul(cp, &ecp, 0);
 5627|  2.12k|            if (*ecp)
  ------------------
  |  Branch (5627:17): [True: 18, False: 2.10k]
  ------------------
 5628|     18|                goto bad_id;
 5629|  2.10k|            if (*objidlen >= maxlen)
  ------------------
  |  Branch (5629:17): [True: 1, False: 2.10k]
  ------------------
 5630|      1|                goto bad_id;
 5631|  2.10k|            objid[*objidlen] = subid;
 5632|  2.10k|            (*objidlen)++;
 5633|  2.10k|            break;
 5634|    610|        case '"':
  ------------------
  |  Branch (5634:9): [True: 610, False: 2.73k]
  ------------------
 5635|  1.02k|        case '\'':
  ------------------
  |  Branch (5635:9): [True: 419, False: 2.92k]
  ------------------
 5636|  1.02k|            doingquote = *cp++;
 5637|  1.02k|            if (*cp == '\0')
  ------------------
  |  Branch (5637:17): [True: 15, False: 1.01k]
  ------------------
 5638|     15|                goto bad_id;
 5639|       |            /*
 5640|       |             * insert length if requested 
 5641|       |             */
 5642|  1.01k|            if (doingquote == '"') {
  ------------------
  |  Branch (5642:17): [True: 603, False: 411]
  ------------------
 5643|    603|                if (*objidlen >= maxlen)
  ------------------
  |  Branch (5643:21): [True: 2, False: 601]
  ------------------
 5644|      2|                    goto bad_id;
 5645|    601|                objid[*objidlen] = len = strchr(cp, doingquote) - cp;
 5646|    601|                (*objidlen)++;
 5647|    601|            }
 5648|       |
 5649|  3.04k|            while (*cp && *cp != doingquote) {
  ------------------
  |  Branch (5649:20): [True: 3.01k, False: 38]
  |  Branch (5649:27): [True: 2.04k, False: 967]
  ------------------
 5650|  2.04k|                if (*objidlen >= maxlen)
  ------------------
  |  Branch (5650:21): [True: 7, False: 2.03k]
  ------------------
 5651|      7|                    goto bad_id;
 5652|  2.03k|                objid[*objidlen] = *cp++;
 5653|  2.03k|                (*objidlen)++;
 5654|  2.03k|            }
 5655|  1.00k|            if (!*cp)
  ------------------
  |  Branch (5655:17): [True: 38, False: 967]
  ------------------
 5656|     38|                goto bad_id;
 5657|    967|            cp2 = cp + 1;
 5658|    967|            if (!*cp2)
  ------------------
  |  Branch (5658:17): [True: 8, False: 959]
  ------------------
 5659|      8|                cp2 = NULL;
 5660|    959|            else if (*cp2 == '.')
  ------------------
  |  Branch (5660:22): [True: 945, False: 14]
  ------------------
 5661|    945|                cp2++;
 5662|     14|            else
 5663|     14|                goto bad_id;
 5664|    953|            break;
 5665|    953|        default:
  ------------------
  |  Branch (5665:9): [True: 188, False: 3.15k]
  ------------------
 5666|    188|            goto bad_id;
 5667|  3.34k|        }
 5668|  3.06k|        cp = cp2;
 5669|  3.06k|    }
 5670|     83|    return 1;
 5671|       |
 5672|    283|  bad_id:
 5673|    283|    {
 5674|    283|        char            buf[256];
 5675|    283|#ifndef NETSNMP_DISABLE_MIB_LOADING
 5676|    283|        if (in_dices)
  ------------------
  |  Branch (5676:13): [True: 0, False: 283]
  ------------------
 5677|      0|            snprintf(buf, sizeof(buf), "Index out of range: %s (%s)",
 5678|      0|                    fcp, in_dices->ilabel);
 5679|    283|        else if (tp)
  ------------------
  |  Branch (5679:18): [True: 0, False: 283]
  ------------------
 5680|      0|            snprintf(buf, sizeof(buf), "Sub-id not found: %s -> %s", tp->label, fcp);
 5681|    283|        else
 5682|    283|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 5683|    283|            snprintf(buf, sizeof(buf), "%s", fcp);
 5684|    283|        buf[ sizeof(buf)-1 ] = 0;
 5685|       |
 5686|    283|        snmp_set_detail(buf);
 5687|    283|    }
 5688|    283|    return 0;
 5689|    366|}

netsnmp_init_mib_internals:
  700|    175|{
  701|    175|    register struct tok *tp;
  702|    175|    register int    b, i;
  703|    175|    int             max_modc;
  704|       |
  705|    175|    if (tree_head)
  ------------------
  |  Branch (705:9): [True: 174, False: 1]
  ------------------
  706|    174|        return;
  707|       |
  708|       |    /*
  709|       |     * Set up hash list of pre-defined tokens
  710|       |     */
  711|      1|    memset(buckets, 0, sizeof(buckets));
  712|     93|    for (tp = tokens; tp->name; tp++) {
  ------------------
  |  Branch (712:23): [True: 92, False: 1]
  ------------------
  713|     92|        tp->hash = name_hash(tp->name);
  714|     92|        b = BUCKET(tp->hash);
  ------------------
  |  |  527|     92|#define BUCKET(x)       (x & (HASHSIZE-1))
  |  |  ------------------
  |  |  |  |  526|     92|#define HASHSIZE        32
  |  |  ------------------
  ------------------
  715|     92|        if (buckets[b])
  ------------------
  |  Branch (715:13): [True: 60, False: 32]
  ------------------
  716|     60|            tp->next = buckets[b];      /* BUG ??? */
  717|     92|        buckets[b] = tp;
  718|     92|    }
  719|       |
  720|       |    /*
  721|       |     * Initialise other internal structures
  722|       |     */
  723|       |
  724|      1|    max_modc = sizeof(module_map) / sizeof(module_map[0]) - 1;
  725|     22|    for (i = 0; i < max_modc; ++i)
  ------------------
  |  Branch (725:17): [True: 21, False: 1]
  ------------------
  726|     21|        module_map[i].next = &(module_map[i + 1]);
  727|      1|    module_map[max_modc].next = NULL;
  728|      1|    module_map_head = module_map;
  729|       |
  730|      1|    memset(nbuckets, 0, sizeof(nbuckets));
  731|      1|    memset(tbuckets, 0, sizeof(tbuckets));
  732|      1|    free(tclist);
  733|      1|    tc_alloc = TC_INCR;
  ------------------
  |  |  134|      1|#define TC_INCR 100
  ------------------
  734|      1|    tclist = calloc(tc_alloc, sizeof(struct tc));
  735|      1|    build_translation_table();
  736|      1|    init_tree_roots();          /* Set up initial roots */
  737|       |    /*
  738|       |     * Relies on 'add_mibdir' having set up the modules 
  739|       |     */
  740|      1|}
find_tree_node:
 1242|    359|{
 1243|    359|    struct tree    *tp, *headtp;
 1244|    359|    int             count, *int_p;
 1245|       |
 1246|    359|    if (!name || !*name)
  ------------------
  |  Branch (1246:9): [True: 0, False: 359]
  |  Branch (1246:18): [True: 2, False: 357]
  ------------------
 1247|      2|        return (NULL);
 1248|       |
 1249|    357|    headtp = tbuckets[NBUCKET(name_hash(name))];
  ------------------
  |  |  530|    357|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|    357|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1250|    475|    for (tp = headtp; tp; tp = tp->next) {
  ------------------
  |  Branch (1250:23): [True: 146, False: 329]
  ------------------
 1251|    146|        if (tp->label && !label_compare(tp->label, name)) {
  ------------------
  |  | 1236|    146|#define	label_compare	strcmp
  ------------------
  |  Branch (1251:13): [True: 146, False: 0]
  |  Branch (1251:26): [True: 28, False: 118]
  ------------------
 1252|       |
 1253|     28|            if (modid == -1)    /* Any module */
  ------------------
  |  Branch (1253:17): [True: 28, False: 0]
  ------------------
 1254|     28|                return (tp);
 1255|       |
 1256|      0|            for (int_p = tp->module_list, count = 0;
 1257|      0|                 count < tp->number_modules; ++count, ++int_p)
  ------------------
  |  Branch (1257:18): [True: 0, False: 0]
  ------------------
 1258|      0|                if (*int_p == modid)
  ------------------
  |  Branch (1258:21): [True: 0, False: 0]
  ------------------
 1259|      0|                    return (tp);
 1260|      0|        }
 1261|    146|    }
 1262|       |
 1263|    329|    return (NULL);
 1264|    357|}
find_best_tree_node:
 1342|    333|{
 1343|    333|    struct tree    *tp, *best_so_far = NULL, *retptr;
 1344|    333|    u_int           old_match = MAX_BAD, new_match = MAX_BAD;
  ------------------
  |  | 1271|    333|#define MAX_BAD 0xffffff
  ------------------
                  u_int           old_match = MAX_BAD, new_match = MAX_BAD;
  ------------------
  |  | 1271|    333|#define MAX_BAD 0xffffff
  ------------------
 1345|       |
 1346|    333|    if (!pattrn || !*pattrn)
  ------------------
  |  Branch (1346:9): [True: 0, False: 333]
  |  Branch (1346:20): [True: 1, False: 332]
  ------------------
 1347|      1|        return (NULL);
 1348|       |
 1349|    332|    if (!tree_top)
  ------------------
  |  Branch (1349:9): [True: 55, False: 277]
  ------------------
 1350|     55|        tree_top = get_tree_head();
 1351|       |
 1352|  1.15k|    for (tp = tree_top; tp; tp = tp->next_peer) {
  ------------------
  |  Branch (1352:25): [True: 827, False: 327]
  ------------------
 1353|    827|        if (!tp->reported && tp->label)
  ------------------
  |  Branch (1353:13): [True: 827, False: 0]
  |  Branch (1353:30): [True: 827, False: 0]
  ------------------
 1354|    827|            new_match = compute_match(tp->label, pattrn);
 1355|    827|        tp->reported = 1;
 1356|       |
 1357|    827|        if (new_match < old_match) {
  ------------------
  |  Branch (1357:13): [True: 29, False: 798]
  ------------------
 1358|     29|            best_so_far = tp;
 1359|     29|            old_match = new_match;
 1360|     29|        }
 1361|    827|        if (new_match == 0)
  ------------------
  |  Branch (1361:13): [True: 5, False: 822]
  ------------------
 1362|      5|            break;              /* this is the best result we can get */
 1363|    822|        if (tp->child_list) {
  ------------------
  |  Branch (1363:13): [True: 0, False: 822]
  ------------------
 1364|      0|            retptr =
 1365|      0|                find_best_tree_node(pattrn, tp->child_list, &new_match);
 1366|      0|            if (new_match < old_match) {
  ------------------
  |  Branch (1366:17): [True: 0, False: 0]
  ------------------
 1367|      0|                best_so_far = retptr;
 1368|      0|                old_match = new_match;
 1369|      0|            }
 1370|      0|            if (new_match == 0)
  ------------------
  |  Branch (1370:17): [True: 0, False: 0]
  ------------------
 1371|      0|                break;          /* this is the best result we can get */
 1372|      0|        }
 1373|    822|    }
 1374|    332|    if (match)
  ------------------
  |  Branch (1374:9): [True: 0, False: 332]
  ------------------
 1375|      0|        *match = old_match;
 1376|    332|    return (best_so_far);
 1377|    333|}
which_module:
 3801|    168|{
 3802|    168|    struct module  *mp;
 3803|       |
 3804|    168|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3804:28): [True: 0, False: 168]
  ------------------
 3805|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1236|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (3805:13): [True: 0, False: 0]
  ------------------
 3806|      0|            return (mp->modid);
 3807|       |
 3808|    168|    DEBUGMSGTL(("parse-mibs", "Module %s not found\n", name));
  ------------------
  |  |   66|    168|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    168|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 168]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 168]
  |  |  ------------------
  ------------------
 3809|    168|    return (-1);
 3810|    168|}
netsnmp_read_module:
 4077|    175|{
 4078|    175|    int status = 0;
 4079|    175|    status = read_module_internal(name);
 4080|       |
 4081|    175|    if (status == MODULE_NOT_FOUND) {
  ------------------
  |  |  513|    175|#define MODULE_NOT_FOUND	0
  ------------------
  |  Branch (4081:9): [True: 175, False: 0]
  ------------------
 4082|    175|        if (!read_module_replacements(name))
  ------------------
  |  Branch (4082:13): [True: 165, False: 10]
  ------------------
 4083|    165|            print_module_not_found(name);
 4084|    175|    } else if (status == MODULE_SYNTAX_ERROR) {
  ------------------
  |  |  520|      0|#define MODULE_SYNTAX_ERROR     4
  ------------------
  |  Branch (4084:16): [True: 0, False: 0]
  ------------------
 4085|      0|        gMibError = 0;
 4086|      0|        gLoop = 1;
 4087|       |
 4088|      0|        strncat(gMibNames, " ", sizeof(gMibNames) - strlen(gMibNames) - 1);
 4089|      0|        strncat(gMibNames, name, sizeof(gMibNames) - strlen(gMibNames) - 1);
 4090|      0|    }
 4091|       |
 4092|    175|    return tree_head;
 4093|    175|}
parse.c:name_hash:
  687|    452|{
  688|    452|    int             hash = 0;
  689|    452|    const char     *cp;
  690|       |
  691|    452|    if (!name)
  ------------------
  |  Branch (691:9): [True: 0, False: 452]
  ------------------
  692|      0|        return 0;
  693|  6.27k|    for (cp = name; *cp; cp++)
  ------------------
  |  Branch (693:21): [True: 5.82k, False: 452]
  ------------------
  694|  5.82k|        hash += tolower((unsigned char)(*cp));
  ------------------
  |  Branch (694:17): [True: 0, False: 0]
  |  Branch (694:17): [True: 0, False: 0]
  |  Branch (694:17): [Folded, False: 5.82k]
  ------------------
  695|    452|    return (hash);
  696|    452|}
parse.c:build_translation_table:
 1071|      1|{
 1072|      1|    int             count;
 1073|       |
 1074|    257|    for (count = 0; count < 256; count++) {
  ------------------
  |  Branch (1074:21): [True: 256, False: 1]
  ------------------
 1075|    256|        switch (count) {
 1076|      1|        case OBJID:
  ------------------
  |  |  167|      1|#define OBJID       (4 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1076:9): [True: 1, False: 255]
  ------------------
 1077|      1|            translation_table[count] = TYPE_OBJID;
  ------------------
  |  |  155|      1|#define TYPE_OBJID          1
  ------------------
 1078|      1|            break;
 1079|      1|        case OCTETSTR:
  ------------------
  |  |  168|      1|#define OCTETSTR    (5 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1079:9): [True: 1, False: 255]
  ------------------
 1080|      1|            translation_table[count] = TYPE_OCTETSTR;
  ------------------
  |  |  156|      1|#define TYPE_OCTETSTR       2
  ------------------
 1081|      1|            break;
 1082|      1|        case INTEGER:
  ------------------
  |  |  169|      1|#define INTEGER     (6 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1082:9): [True: 1, False: 255]
  ------------------
 1083|      1|            translation_table[count] = TYPE_INTEGER;
  ------------------
  |  |  157|      1|#define TYPE_INTEGER        3
  ------------------
 1084|      1|            break;
 1085|      1|        case NETADDR:
  ------------------
  |  |  170|      1|#define NETADDR     (7 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1085:9): [True: 1, False: 255]
  ------------------
 1086|      1|            translation_table[count] = TYPE_NETADDR;
  ------------------
  |  |  158|      1|#define TYPE_NETADDR        4
  ------------------
 1087|      1|            break;
 1088|      1|        case IPADDR:
  ------------------
  |  |  171|      1|#define IPADDR      (8 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1088:9): [True: 1, False: 255]
  ------------------
 1089|      1|            translation_table[count] = TYPE_IPADDR;
  ------------------
  |  |  159|      1|#define TYPE_IPADDR         5
  ------------------
 1090|      1|            break;
 1091|      1|        case COUNTER:
  ------------------
  |  |  172|      1|#define COUNTER     (9 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1091:9): [True: 1, False: 255]
  ------------------
 1092|      1|            translation_table[count] = TYPE_COUNTER;
  ------------------
  |  |  160|      1|#define TYPE_COUNTER        6
  ------------------
 1093|      1|            break;
 1094|      1|        case GAUGE:
  ------------------
  |  |  173|      1|#define GAUGE       (10 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1094:9): [True: 1, False: 255]
  ------------------
 1095|      1|            translation_table[count] = TYPE_GAUGE;
  ------------------
  |  |  161|      1|#define TYPE_GAUGE          7
  ------------------
 1096|      1|            break;
 1097|      1|        case TIMETICKS:
  ------------------
  |  |  174|      1|#define TIMETICKS   (11 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1097:9): [True: 1, False: 255]
  ------------------
 1098|      1|            translation_table[count] = TYPE_TIMETICKS;
  ------------------
  |  |  162|      1|#define TYPE_TIMETICKS      8
  ------------------
 1099|      1|            break;
 1100|      1|        case KW_OPAQUE:
  ------------------
  |  |  175|      1|#define KW_OPAQUE   (12 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1100:9): [True: 1, False: 255]
  ------------------
 1101|      1|            translation_table[count] = TYPE_OPAQUE;
  ------------------
  |  |  163|      1|#define TYPE_OPAQUE         9
  ------------------
 1102|      1|            break;
 1103|      1|        case NUL:
  ------------------
  |  |  176|      1|#define NUL         (13 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1103:9): [True: 1, False: 255]
  ------------------
 1104|      1|            translation_table[count] = TYPE_NULL;
  ------------------
  |  |  164|      1|#define TYPE_NULL           10
  ------------------
 1105|      1|            break;
 1106|      1|        case COUNTER64:
  ------------------
  |  |  211|      1|#define COUNTER64   (43 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1106:9): [True: 1, False: 255]
  ------------------
 1107|      1|            translation_table[count] = TYPE_COUNTER64;
  ------------------
  |  |  165|      1|#define TYPE_COUNTER64      11
  ------------------
 1108|      1|            break;
 1109|      1|        case BITSTRING:
  ------------------
  |  |  209|      1|#define BITSTRING   (41 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1109:9): [True: 1, False: 255]
  ------------------
 1110|      1|            translation_table[count] = TYPE_BITSTRING;
  ------------------
  |  |  166|      1|#define TYPE_BITSTRING      12
  ------------------
 1111|      1|            break;
 1112|      1|        case NSAPADDRESS:
  ------------------
  |  |  210|      1|#define NSAPADDRESS (42 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1112:9): [True: 1, False: 255]
  ------------------
 1113|      1|            translation_table[count] = TYPE_NSAPADDRESS;
  ------------------
  |  |  167|      1|#define TYPE_NSAPADDRESS    13
  ------------------
 1114|      1|            break;
 1115|      1|        case INTEGER32:
  ------------------
  |  |  274|      1|#define INTEGER32	(105 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1115:9): [True: 1, False: 255]
  ------------------
 1116|      1|            translation_table[count] = TYPE_INTEGER32;
  ------------------
  |  |  170|      1|#define TYPE_INTEGER32      16
  ------------------
 1117|      1|            break;
 1118|      1|        case UINTEGER32:
  ------------------
  |  |  224|      1|#define UINTEGER32 (56 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1118:9): [True: 1, False: 255]
  ------------------
 1119|      1|            translation_table[count] = TYPE_UINTEGER;
  ------------------
  |  |  168|      1|#define TYPE_UINTEGER       14
  ------------------
 1120|      1|            break;
 1121|      1|        case UNSIGNED32:
  ------------------
  |  |  273|      1|#define UNSIGNED32	(104 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1121:9): [True: 1, False: 255]
  ------------------
 1122|      1|            translation_table[count] = TYPE_UNSIGNED32;
  ------------------
  |  |  169|      1|#define TYPE_UNSIGNED32     15
  ------------------
 1123|      1|            break;
 1124|      1|        case TRAPTYPE:
  ------------------
  |  |  229|      1|#define TRAPTYPE    61
  ------------------
  |  Branch (1124:9): [True: 1, False: 255]
  ------------------
 1125|      1|            translation_table[count] = TYPE_TRAPTYPE;
  ------------------
  |  |  174|      1|#define TYPE_TRAPTYPE	    20
  ------------------
 1126|      1|            break;
 1127|      1|        case NOTIFTYPE:
  ------------------
  |  |  213|      1|#define NOTIFTYPE   45
  ------------------
  |  Branch (1127:9): [True: 1, False: 255]
  ------------------
 1128|      1|            translation_table[count] = TYPE_NOTIFTYPE;
  ------------------
  |  |  175|      1|#define TYPE_NOTIFTYPE      21
  ------------------
 1129|      1|            break;
 1130|      1|        case NOTIFGROUP:
  ------------------
  |  |  258|      1|#define NOTIFGROUP  88
  ------------------
  |  Branch (1130:9): [True: 1, False: 255]
  ------------------
 1131|      1|            translation_table[count] = TYPE_NOTIFGROUP;
  ------------------
  |  |  177|      1|#define TYPE_NOTIFGROUP	    23
  ------------------
 1132|      1|            break;
 1133|      1|        case OBJGROUP:
  ------------------
  |  |  212|      1|#define OBJGROUP    44
  ------------------
  |  Branch (1133:9): [True: 1, False: 255]
  ------------------
 1134|      1|            translation_table[count] = TYPE_OBJGROUP;
  ------------------
  |  |  176|      1|#define TYPE_OBJGROUP	    22
  ------------------
 1135|      1|            break;
 1136|      1|        case MODULEIDENTITY:
  ------------------
  |  |  220|      1|#define MODULEIDENTITY 52
  ------------------
  |  Branch (1136:9): [True: 1, False: 255]
  ------------------
 1137|      1|            translation_table[count] = TYPE_MODID;
  ------------------
  |  |  178|      1|#define TYPE_MODID	    24
  ------------------
 1138|      1|            break;
 1139|      1|        case OBJIDENTITY:
  ------------------
  |  |  275|      1|#define OBJIDENTITY	106
  ------------------
  |  Branch (1139:9): [True: 1, False: 255]
  ------------------
 1140|      1|            translation_table[count] = TYPE_OBJIDENTITY;
  ------------------
  |  |  181|      1|#define TYPE_OBJIDENTITY    27
  ------------------
 1141|      1|            break;
 1142|      1|        case AGENTCAP:
  ------------------
  |  |  243|      1|#define AGENTCAP    73
  ------------------
  |  Branch (1142:9): [True: 1, False: 255]
  ------------------
 1143|      1|            translation_table[count] = TYPE_AGENTCAP;
  ------------------
  |  |  179|      1|#define TYPE_AGENTCAP       25
  ------------------
 1144|      1|            break;
 1145|      1|        case COMPLIANCE:
  ------------------
  |  |  215|      1|#define COMPLIANCE  47
  ------------------
  |  Branch (1145:9): [True: 1, False: 255]
  ------------------
 1146|      1|            translation_table[count] = TYPE_MODCOMP;
  ------------------
  |  |  180|      1|#define TYPE_MODCOMP        26
  ------------------
 1147|      1|            break;
 1148|    232|        default:
  ------------------
  |  Branch (1148:9): [True: 232, False: 24]
  ------------------
 1149|    232|            translation_table[count] = TYPE_OTHER;
  ------------------
  |  |  154|    232|#define TYPE_OTHER          0
  ------------------
 1150|    232|            break;
 1151|    256|        }
 1152|    256|    }
 1153|      1|}
parse.c:init_tree_roots:
 1157|      1|{
 1158|      1|    struct tree    *tp, *lasttp;
 1159|      1|    int             base_modid;
 1160|      1|    int             hash;
 1161|       |
 1162|      1|    base_modid = which_module("SNMPv2-SMI");
 1163|      1|    if (base_modid == -1)
  ------------------
  |  Branch (1163:9): [True: 1, False: 0]
  ------------------
 1164|      1|        base_modid = which_module("RFC1155-SMI");
 1165|      1|    if (base_modid == -1)
  ------------------
  |  Branch (1165:9): [True: 1, False: 0]
  ------------------
 1166|      1|        base_modid = which_module("RFC1213-MIB");
 1167|       |
 1168|       |    /*
 1169|       |     * build root node 
 1170|       |     */
 1171|      1|    tp = calloc(1, sizeof(struct tree));
 1172|      1|    if (tp == NULL)
  ------------------
  |  Branch (1172:9): [True: 0, False: 1]
  ------------------
 1173|      0|        return;
 1174|      1|    tp->label = strdup("joint-iso-ccitt");
 1175|      1|    tp->modid = base_modid;
 1176|      1|    tp->number_modules = 1;
 1177|      1|    tp->module_list = &(tp->modid);
 1178|      1|    tp->subid = 2;
 1179|      1|    tp->tc_index = -1;
 1180|      1|    set_function(tp);           /* from mib.c */
 1181|      1|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|      1|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|      1|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1182|      1|    tp->next = tbuckets[hash];
 1183|      1|    tbuckets[hash] = tp;
 1184|      1|    lasttp = tp;
 1185|      1|    root_imports[0].label = strdup(tp->label);
 1186|      1|    root_imports[0].modid = base_modid;
 1187|       |
 1188|       |    /*
 1189|       |     * build root node 
 1190|       |     */
 1191|      1|    tp = calloc(1, sizeof(struct tree));
 1192|      1|    if (tp == NULL)
  ------------------
  |  Branch (1192:9): [True: 0, False: 1]
  ------------------
 1193|      0|        return;
 1194|      1|    tp->next_peer = lasttp;
 1195|      1|    tp->label = strdup("ccitt");
 1196|      1|    tp->modid = base_modid;
 1197|      1|    tp->number_modules = 1;
 1198|      1|    tp->module_list = &(tp->modid);
 1199|      1|    tp->subid = 0;
 1200|      1|    tp->tc_index = -1;
 1201|      1|    set_function(tp);           /* from mib.c */
 1202|      1|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|      1|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|      1|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1203|      1|    tp->next = tbuckets[hash];
 1204|      1|    tbuckets[hash] = tp;
 1205|      1|    lasttp = tp;
 1206|      1|    root_imports[1].label = strdup(tp->label);
 1207|      1|    root_imports[1].modid = base_modid;
 1208|       |
 1209|       |    /*
 1210|       |     * build root node 
 1211|       |     */
 1212|      1|    tp = calloc(1, sizeof(struct tree));
 1213|      1|    if (tp == NULL)
  ------------------
  |  Branch (1213:9): [True: 0, False: 1]
  ------------------
 1214|      0|        return;
 1215|      1|    tp->next_peer = lasttp;
 1216|      1|    tp->label = strdup("iso");
 1217|      1|    tp->modid = base_modid;
 1218|      1|    tp->number_modules = 1;
 1219|      1|    tp->module_list = &(tp->modid);
 1220|      1|    tp->subid = 1;
 1221|      1|    tp->tc_index = -1;
 1222|      1|    set_function(tp);           /* from mib.c */
 1223|      1|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|      1|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|      1|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1224|      1|    tp->next = tbuckets[hash];
 1225|      1|    tbuckets[hash] = tp;
 1226|      1|    lasttp = tp;
 1227|      1|    root_imports[2].label = strdup(tp->label);
 1228|      1|    root_imports[2].modid = base_modid;
 1229|       |
 1230|      1|    tree_head = tp;
 1231|      1|}
parse.c:compute_match:
 1275|    827|{
 1276|    827|#if defined(HAVE_REGEX_H) && defined(HAVE_REGCOMP)
 1277|    827|    int             rc;
 1278|    827|    regex_t         parsetree;
 1279|    827|    regmatch_t      pmatch;
 1280|    827|    rc = regcomp(&parsetree, key, REG_ICASE | REG_EXTENDED);
 1281|    827|    if (rc == 0)
  ------------------
  |  Branch (1281:9): [True: 788, False: 39]
  ------------------
 1282|    788|        rc = regexec(&parsetree, search_base, 1, &pmatch, 0);
 1283|    827|    regfree(&parsetree);
 1284|    827|    if (rc == 0) {
  ------------------
  |  Branch (1284:9): [True: 33, False: 794]
  ------------------
 1285|       |        /*
 1286|       |         * found 
 1287|       |         */
 1288|     33|        return pmatch.rm_so;
 1289|     33|    }
 1290|       |#else                           /* use our own wildcard matcher */
 1291|       |    /*
 1292|       |     * first find the longest matching substring (ick) 
 1293|       |     */
 1294|       |    char           *first = NULL, *result = NULL, *entry;
 1295|       |    const char     *position;
 1296|       |    char           *newkey = strdup(key);
 1297|       |    char           *st;
 1298|       |
 1299|       |
 1300|       |    entry = strtok_r(newkey, "*", &st);
 1301|       |    position = search_base;
 1302|       |    while (entry) {
 1303|       |        result = strcasestr(position, entry);
 1304|       |
 1305|       |        if (result == NULL) {
 1306|       |            free(newkey);
 1307|       |            return MAX_BAD;
 1308|       |        }
 1309|       |
 1310|       |        if (first == NULL)
 1311|       |            first = result;
 1312|       |
 1313|       |        position = result + strlen(entry);
 1314|       |        entry = strtok_r(NULL, "*", &st);
 1315|       |    }
 1316|       |    free(newkey);
 1317|       |    if (result)
 1318|       |        return (first - search_base);
 1319|       |#endif
 1320|       |
 1321|       |    /*
 1322|       |     * not found 
 1323|       |     */
 1324|    794|    return MAX_BAD;
  ------------------
  |  | 1271|    794|#define MAX_BAD 0xffffff
  ------------------
 1325|    827|}
parse.c:read_module_internal:
 3985|    175|{
 3986|    175|    struct module  *mp;
 3987|       |
 3988|    175|    netsnmp_init_mib_internals();
 3989|       |
 3990|    175|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3990:28): [True: 0, False: 175]
  ------------------
 3991|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1236|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (3991:13): [True: 0, False: 0]
  ------------------
 3992|      0|            return read_from_file(mp, name);
 3993|       |
 3994|    175|    return MODULE_NOT_FOUND;
  ------------------
  |  |  513|    175|#define MODULE_NOT_FOUND	0
  ------------------
 3995|    175|}
parse.c:print_error:
  780|    155|{
  781|    155|    erroneousMibs++;
  782|    155|    if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    155|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (782:9): [True: 155, False: 0]
  ------------------
  783|    155|                                NETSNMP_DS_LIB_MIB_ERRORS))
  ------------------
  |  |   59|    155|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  784|    155|	return;
  785|      0|    DEBUGMSGTL(("parse-mibs", "\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  786|      0|    if (type == ENDOFFILE)
  ------------------
  |  |  163|      0|#define ENDOFFILE   0
  ------------------
  |  Branch (786:9): [True: 0, False: 0]
  ------------------
  787|      0|        snmp_log(LOG_ERR, "%s (EOF): At line %d in %s\n", str, mibLine,
  788|      0|                 File);
  789|      0|    else if (token && *token)
  ------------------
  |  Branch (789:14): [True: 0, False: 0]
  |  Branch (789:23): [True: 0, False: 0]
  ------------------
  790|      0|        snmp_log(LOG_ERR, "%s (%s): At line %d in %s\n", str, token,
  791|      0|                 mibLine, File);
  792|      0|    else
  793|      0|        snmp_log(LOG_ERR, "%s: At line %d in %s\n", str, mibLine, File);
  794|      0|}
parse.c:read_module_replacements:
 3865|    175|{
 3866|    175|    struct module_compatability *mcp;
 3867|       |
 3868|  3.87k|    for (mcp = module_map_head; mcp; mcp = mcp->next) {
  ------------------
  |  Branch (3868:33): [True: 3.70k, False: 165]
  ------------------
 3869|  3.70k|        if (!label_compare(mcp->old_module, name)) {
  ------------------
  |  | 1236|  3.70k|#define	label_compare	strcmp
  ------------------
  |  Branch (3869:13): [True: 10, False: 3.69k]
  ------------------
 3870|     10|            if (netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     10|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3870:17): [True: 0, False: 10]
  ------------------
 3871|     10|				   NETSNMP_DS_LIB_MIB_WARNINGS)) {
  ------------------
  |  |  114|     10|#define NETSNMP_DS_LIB_MIB_WARNINGS         0
  ------------------
 3872|      0|                snmp_log(LOG_WARNING,
 3873|      0|                         "Loading replacement module %s for %s (%s)\n",
 3874|      0|                         mcp->new_module, name, File);
 3875|      0|	    }
 3876|     10|            (void) netsnmp_read_module(mcp->new_module);
 3877|     10|            return 1;
 3878|     10|        }
 3879|  3.70k|    }
 3880|    165|    return 0;
 3881|    175|}
parse.c:print_module_not_found:
  798|    165|{
  799|    165|    if (first_err_module) {
  ------------------
  |  Branch (799:9): [True: 1, False: 164]
  ------------------
  800|      1|        snmp_log(LOG_ERR, "MIB search path: %s\n",
  801|      1|                           netsnmp_get_mib_directory());
  802|      1|        first_err_module = 0;
  803|      1|    }
  804|    165|    if (!last_err_module || strcmp(cp, last_err_module))
  ------------------
  |  Branch (804:9): [True: 1, False: 164]
  |  Branch (804:29): [True: 154, False: 10]
  ------------------
  805|    155|        print_error("Cannot find module", cp, CONTINUE);
  ------------------
  |  |  162|    155|#define CONTINUE    -1
  ------------------
  806|    165|    if (last_err_module)
  ------------------
  |  Branch (806:9): [True: 164, False: 1]
  ------------------
  807|    164|        free(last_err_module);
  808|    165|    last_err_module = strdup(cp);
  809|    165|}

snmp_set_detail:
  516|    283|{
  517|    283|    if (detail_string != NULL) {
  ------------------
  |  Branch (517:9): [True: 283, False: 0]
  ------------------
  518|    283|        strlcpy(snmp_detail, detail_string, sizeof(snmp_detail));
  519|    283|        snmp_detail_f = 1;
  520|    283|    }
  521|    283|}

snmp_get_do_debugging:
  551|    508|{
  552|    508|    return dodebug;
  553|    508|}

netsnmp_set_line_buffering:
  187|      1|{
  188|       |#if defined(WIN32)
  189|       |    /*
  190|       |     * According to MSDN, the Microsoft Visual Studio C runtime library does
  191|       |     * not support line buffering, so turn off buffering completely.
  192|       |     * See also http://msdn.microsoft.com/en-us/library/86cebhfs(VS.71).aspx.
  193|       |     */
  194|       |    setvbuf(stream, NULL, _IONBF, BUFSIZ);
  195|       |#elif defined(HAVE_SETLINEBUF)
  196|       |    /* setlinefunction() is a function from the BSD Unix API. */
  197|       |    setlinebuf(stream);
  198|       |#else
  199|       |    /* See also the C89 or C99 standard for more information about setvbuf(). */
  200|      1|    setvbuf(stream, NULL, _IOLBF, BUFSIZ);
  201|      1|#endif
  202|      1|}
log_handler_stdouterr:
 1101|      1|{
 1102|      1|    static int      newline = 1;	 /* MTCRITICAL_RESOURCE */
 1103|      1|    const char     *newline_ptr;
 1104|      1|    char            sbuf[40];
 1105|       |
 1106|      1|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1106:9): [True: 0, False: 1]
  ------------------
 1107|      1|                               NETSNMP_DS_LIB_LOG_TIMESTAMP) && newline) {
  ------------------
  |  |   64|      1|#define NETSNMP_DS_LIB_LOG_TIMESTAMP       5
  ------------------
  |  Branch (1107:65): [True: 0, False: 0]
  ------------------
 1108|      0|        sprintf_stamp(NULL, sbuf);
 1109|      1|    } else {
 1110|      1|        strcpy(sbuf, "");
 1111|      1|    }
 1112|       |    /*
 1113|       |     * Remember whether or not the current line ends with a newline for the
 1114|       |     * next call of log_handler_stdouterr().
 1115|       |     */
 1116|      1|    newline_ptr = strrchr(str, '\n');
 1117|      1|    newline = newline_ptr && newline_ptr[1] == 0;
  ------------------
  |  Branch (1117:15): [True: 1, False: 0]
  |  Branch (1117:30): [True: 1, False: 0]
  ------------------
 1118|       |
 1119|      1|    if (logh->imagic)
  ------------------
  |  Branch (1119:9): [True: 0, False: 1]
  ------------------
 1120|      0|       printf(         "%s%s", sbuf, str);
 1121|      1|    else
 1122|      1|       fprintf(stderr, "%s%s", sbuf, str);
 1123|       |
 1124|      1|    return 1;
 1125|      1|}
snmp_log_string:
 1292|      1|{
 1293|      1|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1294|      1|    static int stderr_enabled = 0;
 1295|      1|    static netsnmp_log_handler lh = { 1, 0, 0, 0, "stderr",
 1296|      1|                                      log_handler_stdouterr, 0, NULL,  NULL,
 1297|      1|                                      NULL };
 1298|      1|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1299|      1|    netsnmp_log_handler *logh;
 1300|       |
 1301|       |    /*
 1302|       |     * We've got to be able to log messages *somewhere*!
 1303|       |     * If you don't want stderr logging, then enable something else.
 1304|       |     */
 1305|      1|    if (0 == logh_enabled) {
  ------------------
  |  Branch (1305:9): [True: 1, False: 0]
  ------------------
 1306|      1|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1307|      1|        if (!stderr_enabled) {
  ------------------
  |  Branch (1307:13): [True: 1, False: 0]
  ------------------
 1308|      1|            ++stderr_enabled;
 1309|      1|            netsnmp_set_line_buffering(stderr);
 1310|      1|        }
 1311|      1|        log_handler_stdouterr( &lh, priority, str );
 1312|      1|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1313|       |
 1314|      1|        return;
 1315|      1|    }
 1316|      0|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1317|      0|    else if (stderr_enabled) {
  ------------------
  |  Branch (1317:14): [True: 0, False: 0]
  ------------------
 1318|      0|        stderr_enabled = 0;
 1319|      0|        log_handler_stdouterr( &lh, LOG_INFO,
 1320|      0|                               "Log handling defined - disabling stderr\n" );
 1321|      0|    }
 1322|      0|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1323|       |        
 1324|       |
 1325|       |    /*
 1326|       |     * Start at the given priority, and work "upwards"....
 1327|       |     */
 1328|      0|    if (priority > LOG_DEBUG)
  ------------------
  |  Branch (1328:9): [True: 0, False: 0]
  ------------------
 1329|      0|        priority = LOG_DEBUG;
 1330|      0|    logh = logh_priorities[priority];
 1331|      0|    for ( ; logh; logh = logh->next ) {
  ------------------
  |  Branch (1331:13): [True: 0, False: 0]
  ------------------
 1332|       |        /*
 1333|       |         * ... but skipping any handlers with a "maximum priority"
 1334|       |         *     that we have already exceeded. And don't forget to
 1335|       |         *     ensure this logging is turned on (see snmp_disable_stderrlog
 1336|       |         *     and its cohorts).
 1337|       |         */
 1338|      0|        if (logh->enabled && priority <= logh->pri_max)
  ------------------
  |  Branch (1338:13): [True: 0, False: 0]
  |  Branch (1338:30): [True: 0, False: 0]
  ------------------
 1339|      0|            logh->handler( logh, priority, str );
 1340|      0|    }
 1341|      0|}
snmp_vlog:
 1379|      1|{
 1380|      1|    char           *buffer = NULL;
 1381|      1|    int             length;
 1382|       |
 1383|      1|    length = vasprintf(&buffer, format, ap);
 1384|      1|    if (length < 0) {
  ------------------
  |  Branch (1384:9): [True: 0, False: 1]
  ------------------
 1385|      0|        snmp_log_string(LOG_ERR, "Could not format log-string\n");
 1386|      0|        return -1;
 1387|      0|    }
 1388|       |
 1389|      1|    snmp_log_string(priority, buffer);
 1390|      1|    free(buffer);
 1391|      1|    return 0;
 1392|      1|}
snmp_log:
 1403|      1|{
 1404|      1|    va_list         ap;
 1405|      1|    int             ret;
 1406|      1|    va_start(ap, format);
 1407|      1|    ret = snmp_vlog(priority, format, ap);
 1408|       |    va_end(ap);
 1409|      1|    return (ret);
 1410|      1|}

strlcpy:
   26|    283|{ 
   27|    283|	size_t src_len = strlen(src); 
   28|    283|	size_t new_len; 
   29|       |
   30|    283|	if (len == 0) {
  ------------------
  |  Branch (30:6): [True: 0, False: 283]
  ------------------
   31|      0|		return (src_len);
   32|      0|	}
   33|       |
   34|    283|        if (src_len >= len) {
  ------------------
  |  Branch (34:13): [True: 8, False: 275]
  ------------------
   35|      8|		new_len = len - 1;
   36|    275|	} else {
   37|    275|                new_len = src_len;
   38|    275|	}
   39|       |
   40|    283|        memcpy(dest, src, new_len); 
   41|    283|	dest[new_len] = '\0'; 
   42|    283|	return (src_len); 
   43|    283|}

netsnmp_getenv:
 1187|      1|{
 1188|      1|#if !defined (WIN32) && !defined (cygwin)
 1189|      1|  return (getenv(name));
 1190|       |#else
 1191|       |  char *temp = NULL;  
 1192|       |  HKEY hKey;
 1193|       |  unsigned char * key_value = NULL;
 1194|       |  DWORD key_value_size = 0;
 1195|       |  DWORD key_value_type = 0;
 1196|       |  DWORD getenv_worked = 0;
 1197|       |
 1198|       |  DEBUGMSGTL(("read_config", "netsnmp_getenv called with name: %s\n",name));
 1199|       |
 1200|       |  if (!(name))
 1201|       |    return NULL;
 1202|       |  
 1203|       |  /* Try environment variable first */ 
 1204|       |  temp = getenv(name);
 1205|       |  if (temp) {
 1206|       |    getenv_worked = 1;
 1207|       |    DEBUGMSGTL(("read_config", "netsnmp_getenv will return from ENV: %s\n",temp));
 1208|       |  }
 1209|       |  
 1210|       |  /* Next try HKCU */
 1211|       |  if (temp == NULL)
 1212|       |  {
 1213|       |    if (getenv("SNMP_IGNORE_WINDOWS_REGISTRY"))
 1214|       |      return NULL;
 1215|       |
 1216|       |    if (RegOpenKeyExA(
 1217|       |          HKEY_CURRENT_USER, 
 1218|       |          "SOFTWARE\\Net-SNMP", 
 1219|       |          0, 
 1220|       |          KEY_QUERY_VALUE, 
 1221|       |          &hKey) == ERROR_SUCCESS) {   
 1222|       |      
 1223|       |      if (RegQueryValueExA(
 1224|       |            hKey, 
 1225|       |            name, 
 1226|       |            NULL, 
 1227|       |            &key_value_type, 
 1228|       |            NULL,               /* Just get the size */
 1229|       |            &key_value_size) == ERROR_SUCCESS) {
 1230|       |
 1231|       |        SNMP_FREE(key_value);
 1232|       |
 1233|       |        /* Allocate memory needed +1 to allow RegQueryValueExA to NULL terminate the
 1234|       |         * string data in registry is missing one (which is unlikely).
 1235|       |         */
 1236|       |        key_value = malloc((sizeof(char) * key_value_size)+sizeof(char));
 1237|       |        
 1238|       |        if (RegQueryValueExA(
 1239|       |              hKey, 
 1240|       |              name, 
 1241|       |              NULL, 
 1242|       |              &key_value_type, 
 1243|       |              key_value, 
 1244|       |              &key_value_size) == ERROR_SUCCESS) {
 1245|       |        }
 1246|       |        temp = (char *) key_value;
 1247|       |      }
 1248|       |      RegCloseKey(hKey);
 1249|       |      if (temp)
 1250|       |        DEBUGMSGTL(("read_config", "netsnmp_getenv will return from HKCU: %s\n",temp));
 1251|       |    }
 1252|       |  }
 1253|       |
 1254|       |  /* Next try HKLM */
 1255|       |  if (temp == NULL)
 1256|       |  {
 1257|       |    if (RegOpenKeyExA(
 1258|       |          HKEY_LOCAL_MACHINE, 
 1259|       |          "SOFTWARE\\Net-SNMP", 
 1260|       |          0, 
 1261|       |          KEY_QUERY_VALUE, 
 1262|       |          &hKey) == ERROR_SUCCESS) {   
 1263|       |      
 1264|       |      if (RegQueryValueExA(
 1265|       |            hKey, 
 1266|       |            name, 
 1267|       |            NULL, 
 1268|       |            &key_value_type, 
 1269|       |            NULL,               /* Just get the size */
 1270|       |            &key_value_size) == ERROR_SUCCESS) {
 1271|       |
 1272|       |        SNMP_FREE(key_value);
 1273|       |
 1274|       |        /* Allocate memory needed +1 to allow RegQueryValueExA to NULL terminate the
 1275|       |         * string data in registry is missing one (which is unlikely).
 1276|       |         */
 1277|       |        key_value = malloc((sizeof(char) * key_value_size)+sizeof(char));
 1278|       |        
 1279|       |        if (RegQueryValueExA(
 1280|       |              hKey, 
 1281|       |              name, 
 1282|       |              NULL, 
 1283|       |              &key_value_type, 
 1284|       |              key_value, 
 1285|       |              &key_value_size) == ERROR_SUCCESS) {
 1286|       |        }
 1287|       |        temp = (char *) key_value;
 1288|       |
 1289|       |      }
 1290|       |      RegCloseKey(hKey);
 1291|       |      if (temp)
 1292|       |        DEBUGMSGTL(("read_config", "netsnmp_getenv will return from HKLM: %s\n",temp));
 1293|       |    }
 1294|       |  }
 1295|       |  
 1296|       |  if (temp && !getenv_worked) {
 1297|       |    setenv(name, temp, 1);
 1298|       |    SNMP_FREE(temp);
 1299|       |  }
 1300|       |
 1301|       |  DEBUGMSGTL(("read_config", "netsnmp_getenv returning: %s\n",getenv(name)));
 1302|       |
 1303|       |  return(getenv(name));
 1304|       |#endif
 1305|      1|}

LLVMFuzzerInitialize:
   36|      2|int LLVMFuzzerInitialize(int *argc, char ***argv) {
   37|      2|    if (getenv("NETSNMP_DEBUGGING") != NULL) {
  ------------------
  |  Branch (37:9): [True: 0, False: 2]
  ------------------
   38|       |        /*
   39|       |         * Turn on all debugging, to help understand what
   40|       |         * bits of the parser are running.
   41|       |         */
   42|      0|        snmp_enable_stderrlog();
   43|      0|        snmp_set_do_debugging(1);
   44|      0|        debug_register_tokens("");
   45|      0|    }
   46|      2|    return 0;
   47|      2|}
LLVMFuzzerTestOneInput:
   53|    585|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   54|    585|    oid *root = malloc(MAX_OID_LEN * sizeof(oid));
  ------------------
  |  |  106|    585|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
   55|    585|    size_t rootlen = MAX_OID_LEN;
  ------------------
  |  |  106|    585|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
   56|    585|    char *input;
   57|       |
   58|    585|    input = strndup((const char *)data, size);
   59|    585|    if (root && input)
  ------------------
  |  Branch (59:9): [True: 585, False: 0]
  |  Branch (59:17): [True: 585, False: 0]
  ------------------
   60|    585|        snmp_parse_oid((const char *)input, root, &rootlen);
   61|    585|    free(root);
   62|    585|    free(input);
   63|    585|    return 0; 
   64|    585|}

