netsnmp_ds_get_boolean:
  242|  2.27k|{
  243|  2.27k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  4.55k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (243:9): [True: 0, False: 2.27k]
  |  Branch (243:24): [True: 0, False: 2.27k]
  ------------------
  244|  2.27k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  2.27k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (244:2): [True: 0, False: 2.27k]
  |  Branch (244:17): [True: 0, False: 2.27k]
  ------------------
  245|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  246|      0|    }
  247|       |
  248|  2.27k|    return (netsnmp_ds_booleans[storeid][which/8] & (1 << (which % 8))) ? 1:0;
  ------------------
  |  Branch (248:12): [True: 0, False: 2.27k]
  ------------------
  249|  2.27k|}
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;
  ------------------
  |  |  185|      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;
  ------------------
  |  |  185|      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;
  ------------------
  |  |  184|      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;
  ------------------
  |  |  184|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  308|      1|}
netsnmp_ds_get_string:
  312|  1.09k|{
  313|  1.09k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  2.18k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (313:9): [True: 0, False: 1.09k]
  |  Branch (313:24): [True: 0, False: 1.09k]
  ------------------
  314|  1.09k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  1.09k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (314:2): [True: 0, False: 1.09k]
  |  Branch (314:17): [True: 0, False: 1.09k]
  ------------------
  315|      0|        return NULL;
  316|      0|    }
  317|       |
  318|  1.09k|    return netsnmp_ds_strings[storeid][which];
  319|  1.09k|}

netsnmp_set_mib_directory:
 2550|      1|{
 2551|      1|    const char *newdir;
 2552|      1|    char *olddir, *tmpdir = NULL;
 2553|       |
 2554|      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]
  |  |  ------------------
  ------------------
 2555|      1|    if (NULL == dir) {
  ------------------
  |  Branch (2555:9): [True: 0, False: 1]
  ------------------
 2556|      0|        return;
 2557|      0|    }
 2558|       |    
 2559|      1|    olddir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 2560|      1|				   NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|      1|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2561|      1|    if (olddir) {
  ------------------
  |  Branch (2561:9): [True: 0, False: 1]
  ------------------
 2562|      0|        if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2562:13): [True: 0, False: 0]
  |  Branch (2562:30): [True: 0, False: 0]
  ------------------
 2563|       |            /** New dir starts with '+', thus we add it. */
 2564|      0|            if (*dir++ == '+') {
  ------------------
  |  Branch (2564:17): [True: 0, False: 0]
  ------------------
 2565|      0|                if (asprintf(&tmpdir, "%s%c%s", olddir, ENV_SEPARATOR_CHAR, dir) < 0)
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
  |  Branch (2565:21): [True: 0, False: 0]
  ------------------
 2566|      0|                    tmpdir = NULL;
 2567|      0|            } else {
 2568|      0|                if (asprintf(&tmpdir, "%s%c%s", dir, ENV_SEPARATOR_CHAR, olddir) < 0)
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
  |  Branch (2568:21): [True: 0, False: 0]
  ------------------
 2569|      0|                    tmpdir = NULL;
 2570|      0|            }
 2571|      0|            if (!tmpdir) {
  ------------------
  |  Branch (2571:17): [True: 0, False: 0]
  ------------------
 2572|      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]
  |  |  ------------------
  ------------------
 2573|      0|                return;
 2574|      0|            }
 2575|      0|            newdir = tmpdir;
 2576|      0|        } else {
 2577|      0|            newdir = dir;
 2578|      0|        }
 2579|      1|    } else {
 2580|       |        /** If dir starts with '+' skip '+' it. */
 2581|      1|        newdir = ((*dir == '+') ? ++dir : dir);
  ------------------
  |  Branch (2581:19): [True: 0, False: 1]
  ------------------
 2582|      1|    }
 2583|      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
  ------------------
 2584|      1|                          newdir);
 2585|       |
 2586|       |    /** set_string calls strdup, so if we allocated memory, free it */
 2587|      1|    if (tmpdir == newdir) {
  ------------------
  |  Branch (2587:9): [True: 0, False: 1]
  ------------------
 2588|       |        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]
  |  |  ------------------
  ------------------
 2589|      0|    }
 2590|      1|}
netsnmp_get_mib_directory:
 2607|      1|{
 2608|      1|    char *dir;
 2609|       |
 2610|      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]
  |  |  ------------------
  ------------------
 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|    if (dir == NULL) {
  ------------------
  |  Branch (2612:9): [True: 1, False: 0]
  ------------------
 2613|      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]
  |  |  ------------------
  ------------------
 2614|       |
 2615|       |        /** Check if the environment variable is set */
 2616|      1|        dir = netsnmp_getenv("MIBDIRS");
 2617|      1|        if (dir == NULL) {
  ------------------
  |  Branch (2617:13): [True: 1, False: 0]
  ------------------
 2618|      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]
  |  |  ------------------
  ------------------
 2619|       |            /** Not set use hard coded path */
 2620|      1|            if (confmibdir == NULL) {
  ------------------
  |  Branch (2620:17): [True: 1, False: 0]
  ------------------
 2621|      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]
  |  |  ------------------
  ------------------
 2622|      1|                netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1666|      1|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2623|      1|            }
 2624|      0|            else if ((*confmibdir == '+') || (*confmibdir == '-')) {
  ------------------
  |  Branch (2624:22): [True: 0, False: 0]
  |  Branch (2624:46): [True: 0, False: 0]
  ------------------
 2625|      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]
  |  |  ------------------
  ------------------
 2626|      0|                netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1666|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2627|      0|                netsnmp_set_mib_directory(confmibdir);
 2628|      0|            }
 2629|      0|            else {
 2630|      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]
  |  |  ------------------
  ------------------
 2631|      0|                netsnmp_set_mib_directory(confmibdir);
 2632|      0|            }
 2633|      1|        } else if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2633:20): [True: 0, False: 0]
  |  Branch (2633:37): [True: 0, False: 0]
  ------------------
 2634|      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]
  |  |  ------------------
  ------------------
 2635|      0|            netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1666|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2636|      0|            netsnmp_set_mib_directory(dir);
 2637|      0|        } else {
 2638|      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]
  |  |  ------------------
  ------------------
 2639|      0|            netsnmp_set_mib_directory(dir);
 2640|      0|        }
 2641|      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
  ------------------
 2642|      1|    }
 2643|      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]
  |  |  ------------------
  ------------------
 2644|      1|    return(dir);
 2645|      1|}
set_function:
 2940|      3|{
 2941|      3|    subtree->printer = NULL;
 2942|      3|    switch (subtree->type) {
 2943|      0|    case TYPE_OBJID:
  ------------------
  |  |  155|      0|#define TYPE_OBJID          1
  ------------------
  |  Branch (2943:5): [True: 0, False: 3]
  ------------------
 2944|      0|        subtree->printomat = sprint_realloc_object_identifier;
 2945|      0|        break;
 2946|      0|    case TYPE_OCTETSTR:
  ------------------
  |  |  156|      0|#define TYPE_OCTETSTR       2
  ------------------
  |  Branch (2946:5): [True: 0, False: 3]
  ------------------
 2947|      0|        subtree->printomat = sprint_realloc_octet_string;
 2948|      0|        break;
 2949|      0|    case TYPE_INTEGER:
  ------------------
  |  |  157|      0|#define TYPE_INTEGER        3
  ------------------
  |  Branch (2949:5): [True: 0, False: 3]
  ------------------
 2950|      0|        subtree->printomat = sprint_realloc_integer;
 2951|      0|        break;
 2952|      0|    case TYPE_INTEGER32:
  ------------------
  |  |  170|      0|#define TYPE_INTEGER32      16
  ------------------
  |  Branch (2952:5): [True: 0, False: 3]
  ------------------
 2953|      0|        subtree->printomat = sprint_realloc_integer;
 2954|      0|        break;
 2955|      0|    case TYPE_NETADDR:
  ------------------
  |  |  158|      0|#define TYPE_NETADDR        4
  ------------------
  |  Branch (2955:5): [True: 0, False: 3]
  ------------------
 2956|      0|        subtree->printomat = sprint_realloc_networkaddress;
 2957|      0|        break;
 2958|      0|    case TYPE_IPADDR:
  ------------------
  |  |  159|      0|#define TYPE_IPADDR         5
  ------------------
  |  Branch (2958:5): [True: 0, False: 3]
  ------------------
 2959|      0|        subtree->printomat = sprint_realloc_ipaddress;
 2960|      0|        break;
 2961|      0|    case TYPE_COUNTER:
  ------------------
  |  |  160|      0|#define TYPE_COUNTER        6
  ------------------
  |  Branch (2961:5): [True: 0, False: 3]
  ------------------
 2962|      0|        subtree->printomat = sprint_realloc_counter;
 2963|      0|        break;
 2964|      0|    case TYPE_GAUGE:
  ------------------
  |  |  161|      0|#define TYPE_GAUGE          7
  ------------------
  |  Branch (2964:5): [True: 0, False: 3]
  ------------------
 2965|      0|        subtree->printomat = sprint_realloc_gauge;
 2966|      0|        break;
 2967|      0|    case TYPE_TIMETICKS:
  ------------------
  |  |  162|      0|#define TYPE_TIMETICKS      8
  ------------------
  |  Branch (2967:5): [True: 0, False: 3]
  ------------------
 2968|      0|        subtree->printomat = sprint_realloc_timeticks;
 2969|      0|        break;
 2970|      0|    case TYPE_OPAQUE:
  ------------------
  |  |  163|      0|#define TYPE_OPAQUE         9
  ------------------
  |  Branch (2970:5): [True: 0, False: 3]
  ------------------
 2971|      0|        subtree->printomat = sprint_realloc_opaque;
 2972|      0|        break;
 2973|      0|    case TYPE_NULL:
  ------------------
  |  |  164|      0|#define TYPE_NULL           10
  ------------------
  |  Branch (2973:5): [True: 0, False: 3]
  ------------------
 2974|      0|        subtree->printomat = sprint_realloc_null;
 2975|      0|        break;
 2976|      0|    case TYPE_BITSTRING:
  ------------------
  |  |  166|      0|#define TYPE_BITSTRING      12
  ------------------
  |  Branch (2976:5): [True: 0, False: 3]
  ------------------
 2977|      0|        subtree->printomat = sprint_realloc_bitstring;
 2978|      0|        break;
 2979|      0|    case TYPE_NSAPADDRESS:
  ------------------
  |  |  167|      0|#define TYPE_NSAPADDRESS    13
  ------------------
  |  Branch (2979:5): [True: 0, False: 3]
  ------------------
 2980|      0|        subtree->printomat = sprint_realloc_nsapaddress;
 2981|      0|        break;
 2982|      0|    case TYPE_COUNTER64:
  ------------------
  |  |  165|      0|#define TYPE_COUNTER64      11
  ------------------
  |  Branch (2982:5): [True: 0, False: 3]
  ------------------
 2983|      0|        subtree->printomat = sprint_realloc_counter64;
 2984|      0|        break;
 2985|      0|    case TYPE_UINTEGER:
  ------------------
  |  |  168|      0|#define TYPE_UINTEGER       14
  ------------------
  |  Branch (2985:5): [True: 0, False: 3]
  ------------------
 2986|      0|        subtree->printomat = sprint_realloc_uinteger;
 2987|      0|        break;
 2988|      0|    case TYPE_UNSIGNED32:
  ------------------
  |  |  169|      0|#define TYPE_UNSIGNED32     15
  ------------------
  |  Branch (2988:5): [True: 0, False: 3]
  ------------------
 2989|      0|        subtree->printomat = sprint_realloc_gauge;
 2990|      0|        break;
 2991|      3|    case TYPE_OTHER:
  ------------------
  |  |  154|      3|#define TYPE_OTHER          0
  ------------------
  |  Branch (2991:5): [True: 3, False: 0]
  ------------------
 2992|      3|    default:
  ------------------
  |  Branch (2992:5): [True: 0, False: 3]
  ------------------
 2993|      3|        subtree->printomat = sprint_realloc_by_type;
 2994|      3|        break;
 2995|      3|    }
 2996|      3|}
read_objid:
 3017|    398|{
 3018|    398|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3019|    398|    struct tree    *root = tree_top;
 3020|    398|    char            buf[SPRINT_MAX_LEN];
 3021|    398|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3022|    398|    int             ret, max_out_len;
 3023|    398|    char           *name, ch;
 3024|    398|    const char     *cp;
 3025|       |
 3026|    398|    cp = input;
 3027|  2.61k|    while ((ch = *cp)) {
  ------------------
  |  Branch (3027:12): [True: 2.52k, False: 89]
  ------------------
 3028|  2.52k|        if (('0' <= ch && ch <= '9')
  ------------------
  |  Branch (3028:14): [True: 1.95k, False: 570]
  |  Branch (3028:27): [True: 387, False: 1.57k]
  ------------------
 3029|  2.14k|            || ('a' <= ch && ch <= 'z')
  ------------------
  |  Branch (3029:17): [True: 1.25k, False: 884]
  |  Branch (3029:30): [True: 1.24k, False: 9]
  ------------------
 3030|    893|            || ('A' <= ch && ch <= 'Z')
  ------------------
  |  Branch (3030:17): [True: 314, False: 579]
  |  Branch (3030:30): [True: 295, False: 19]
  ------------------
 3031|    598|            || ch == '-')
  ------------------
  |  Branch (3031:16): [True: 289, False: 309]
  ------------------
 3032|  2.21k|            cp++;
 3033|    309|        else
 3034|    309|            break;
 3035|  2.52k|    }
 3036|    398|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3037|    398|    if (ch == ':')
  ------------------
  |  Branch (3037:9): [True: 0, False: 398]
  ------------------
 3038|      0|        return get_node(input, output, out_len);
 3039|    398|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3040|       |
 3041|    398|    if (*input == '.')
  ------------------
  |  Branch (3041:9): [True: 5, False: 393]
  ------------------
 3042|      5|        input++;
 3043|    393|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3044|    393|    else if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_READ_UCD_STYLE_OID)) {
  ------------------
  |  |   48|    393|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  else if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_READ_UCD_STYLE_OID)) {
  ------------------
  |  |   85|    393|#define NETSNMP_DS_LIB_READ_UCD_STYLE_OID  25   /* require top-level OIDs to be prefixed with a dot */
  ------------------
  |  Branch (3044:14): [True: 0, False: 393]
  ------------------
 3045|       |        /*
 3046|       |         * get past leading '.', append '.' to Prefix. 
 3047|       |         */
 3048|      0|        if (*Prefix == '.')
  ------------------
  |  Branch (3048:13): [True: 0, False: 0]
  ------------------
 3049|      0|            strlcpy(buf, Prefix + 1, sizeof(buf));
 3050|      0|        else
 3051|      0|            strlcpy(buf, Prefix, sizeof(buf));
 3052|      0|        strlcat(buf, ".", sizeof(buf));
 3053|      0|        strlcat(buf, input, sizeof(buf));
 3054|      0|        input = buf;
 3055|      0|    }
 3056|    398|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3057|       |
 3058|    398|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3059|    398|    if ((root == NULL) && (tree_head != NULL)) {
  ------------------
  |  Branch (3059:9): [True: 398, False: 0]
  |  Branch (3059:27): [True: 398, False: 0]
  ------------------
 3060|    398|        root = tree_head;
 3061|    398|    }
 3062|      0|    else if (root == NULL) {
  ------------------
  |  Branch (3062:14): [True: 0, False: 0]
  ------------------
 3063|      0|        SET_SNMP_ERROR(SNMPERR_NOMIB);
  ------------------
  |  |   43|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 3064|      0|        *out_len = 0;
 3065|      0|        return 0;
 3066|      0|    }
 3067|    398|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3068|    398|    name = strdup(input);
 3069|    398|    max_out_len = *out_len;
 3070|    398|    *out_len = 0;
 3071|    398|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3072|    398|    if ((ret =
  ------------------
  |  Branch (3072:9): [True: 309, False: 89]
  ------------------
 3073|    398|         _add_strings_to_oid(root, name, output, out_len,
 3074|    398|                             max_out_len)) <= 0)
 3075|       |#else
 3076|       |    if ((ret =
 3077|       |         _add_strings_to_oid(NULL, name, output, out_len,
 3078|       |                             max_out_len)) <= 0)
 3079|       |#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3080|    309|    {
 3081|    309|        if (ret == 0)
  ------------------
  |  Branch (3081:13): [True: 309, False: 0]
  ------------------
 3082|    309|            ret = SNMPERR_UNKNOWN_OBJID;
  ------------------
  |  |  242|    309|#define SNMPERR_UNKNOWN_OBJID		(-58)
  ------------------
 3083|    309|        SET_SNMP_ERROR(ret);
  ------------------
  |  |   43|    309|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 3084|    309|        SNMP_FREE(name);
  ------------------
  |  |   62|    309|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 309, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 309]
  |  |  ------------------
  ------------------
 3085|    309|        return 0;
 3086|    309|    }
 3087|     89|    SNMP_FREE(name);
  ------------------
  |  |   62|     89|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 89, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 89]
  |  |  ------------------
  ------------------
 3088|       |
 3089|     89|    return 1;
 3090|    398|}
get_module_node:
 5183|    492|{
 5184|    492|    int             modid, rc = 0;
 5185|    492|    struct tree    *tp;
 5186|    492|    char           *name, *cp;
 5187|       |
 5188|    492|    if (!strcmp(module, "ANY"))
  ------------------
  |  Branch (5188:9): [True: 350, False: 142]
  ------------------
 5189|    350|        modid = -1;
 5190|    142|    else {
 5191|    142|        netsnmp_read_module(module);
 5192|    142|        modid = which_module(module);
 5193|    142|        if (modid == -1)
  ------------------
  |  Branch (5193:13): [True: 142, False: 0]
  ------------------
 5194|    142|            return 0;
 5195|    142|    }
 5196|       |
 5197|       |    /*
 5198|       |     * Isolate the first component of the name ... 
 5199|       |     */
 5200|    350|    name = strdup(fname);
 5201|    350|    if (name == NULL)
  ------------------
  |  Branch (5201:9): [True: 0, False: 350]
  ------------------
 5202|      0|        return -1;
 5203|    350|    cp = strchr(name, '.');
 5204|    350|    if (cp != NULL) {
  ------------------
  |  Branch (5204:9): [True: 57, False: 293]
  ------------------
 5205|     57|        *cp = '\0';
 5206|     57|        cp++;
 5207|     57|    }
 5208|       |    /*
 5209|       |     * ... and locate it in the tree. 
 5210|       |     */
 5211|    350|    tp = find_tree_node(name, modid);
 5212|    350|    if (tp) {
  ------------------
  |  Branch (5212:9): [True: 44, False: 306]
  ------------------
 5213|     44|        size_t          maxlen = *objidlen;
 5214|       |
 5215|       |        /*
 5216|       |         * Set the first element of the object ID 
 5217|       |         */
 5218|     44|        if (node_to_oid(tp, objid, objidlen)) {
  ------------------
  |  Branch (5218:13): [True: 44, False: 0]
  ------------------
 5219|     44|            rc = 1;
 5220|       |
 5221|       |            /*
 5222|       |             * If the name requested was more than one element,
 5223|       |             * tag on the rest of the components 
 5224|       |             */
 5225|     44|            if (cp != NULL)
  ------------------
  |  Branch (5225:17): [True: 6, False: 38]
  ------------------
 5226|      6|                rc = _add_strings_to_oid(tp, cp, objid, objidlen, maxlen);
 5227|     44|        }
 5228|     44|    }
 5229|       |
 5230|       |    SNMP_FREE(name);
  ------------------
  |  |   62|    350|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 350, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 350]
  |  |  ------------------
  ------------------
 5231|    350|    return (rc);
 5232|    350|}
get_wild_node:
 5724|    307|{
 5725|    307|    struct tree    *tp = find_best_tree_node(name, tree_head, NULL);
 5726|    307|    if (!tp)
  ------------------
  |  Branch (5726:9): [True: 271, False: 36]
  ------------------
 5727|    271|        return 0;
 5728|     36|    return get_node(tp->label, objid, objidlen);
 5729|    307|}
get_node:
 5733|    492|{
 5734|    492|    const char     *cp;
 5735|    492|    char            ch;
 5736|    492|    int             res;
 5737|       |
 5738|    492|    cp = name;
 5739|  5.98k|    while ((ch = *cp))
  ------------------
  |  Branch (5739:12): [True: 5.86k, False: 117]
  ------------------
 5740|  5.86k|        if (('0' <= ch && ch <= '9')
  ------------------
  |  Branch (5740:14): [True: 5.25k, False: 618]
  |  Branch (5740:27): [True: 1.79k, False: 3.45k]
  ------------------
 5741|  4.07k|            || ('a' <= ch && ch <= 'z')
  ------------------
  |  Branch (5741:17): [True: 1.63k, False: 2.43k]
  |  Branch (5741:30): [True: 1.62k, False: 9]
  ------------------
 5742|  2.44k|            || ('A' <= ch && ch <= 'Z')
  ------------------
  |  Branch (5742:17): [True: 1.67k, False: 770]
  |  Branch (5742:30): [True: 1.65k, False: 20]
  ------------------
 5743|    790|            || ch == '-')
  ------------------
  |  Branch (5743:16): [True: 415, False: 375]
  ------------------
 5744|  5.49k|            cp++;
 5745|    375|        else
 5746|    375|            break;
 5747|    492|    if (ch != ':')
  ------------------
  |  Branch (5747:9): [True: 349, False: 143]
  ------------------
 5748|    349|        if (*name == '.')
  ------------------
  |  Branch (5748:13): [True: 4, False: 345]
  ------------------
 5749|      4|            res = get_module_node(name + 1, "ANY", objid, objidlen);
 5750|    345|        else
 5751|    345|            res = get_module_node(name, "ANY", objid, objidlen);
 5752|    143|    else {
 5753|    143|        char           *module;
 5754|       |        /*
 5755|       |         *  requested name is of the form
 5756|       |         *      "module:subidentifier"
 5757|       |         */
 5758|    143|        module = (char *) malloc((size_t) (cp - name + 1));
 5759|    143|        if (!module)
  ------------------
  |  Branch (5759:13): [True: 0, False: 143]
  ------------------
 5760|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 5761|    143|        sprintf(module, "%.*s", (int) (cp - name), name);
 5762|    143|        cp++;                   /* cp now point to the subidentifier */
 5763|    143|        if (*cp == ':')
  ------------------
  |  Branch (5763:13): [True: 4, False: 139]
  ------------------
 5764|      4|            cp++;
 5765|       |
 5766|       |        /*
 5767|       |         * 'cp' and 'name' *do* go that way round! 
 5768|       |         */
 5769|    143|        res = get_module_node(cp, module, objid, objidlen);
 5770|    143|        SNMP_FREE(module);
  ------------------
  |  |   62|    143|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 143, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 143]
  |  |  ------------------
  ------------------
 5771|    143|    }
 5772|    492|    if (res == 0) {
  ------------------
  |  Branch (5772:9): [True: 453, False: 39]
  ------------------
 5773|    453|        SET_SNMP_ERROR(SNMPERR_UNKNOWN_OBJID);
  ------------------
  |  |   43|    453|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 5774|    453|    }
 5775|       |
 5776|    492|    return res;
 5777|    492|}
clear_tree_flags:
 5814|    307|{
 5815|  1.22k|    for (; tp; tp = tp->next_peer) {
  ------------------
  |  Branch (5815:12): [True: 921, False: 307]
  ------------------
 5816|    921|        tp->reported = 0;
 5817|    921|        if (tp->child_list)
  ------------------
  |  Branch (5817:13): [True: 0, False: 921]
  ------------------
 5818|      0|            clear_tree_flags(tp->child_list);
 5819|    921|     /*RECURSE*/}
 5820|    307|}
snmp_parse_oid:
 6073|    545|{
 6074|    545|#ifndef NETSNMP_DISABLE_MIB_LOADING
 6075|    545|    size_t          savlen = *rootlen;
 6076|    545|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 6077|    545|    char           *tmpbuf = NULL;
 6078|    545|    const char     *suffix, *prefix;
 6079|       |
 6080|    545|    suffix = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    545|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 6081|    545|                                   NETSNMP_DS_LIB_OIDSUFFIX);
  ------------------
  |  |  163|    545|#define NETSNMP_DS_LIB_OIDSUFFIX         12
  ------------------
 6082|    545|    prefix = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    545|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 6083|    545|                                   NETSNMP_DS_LIB_OIDPREFIX);
  ------------------
  |  |  164|    545|#define NETSNMP_DS_LIB_OIDPREFIX         13
  ------------------
 6084|    545|    if ((suffix && suffix[0]) || (prefix && prefix[0])) {
  ------------------
  |  Branch (6084:10): [True: 0, False: 545]
  |  Branch (6084:20): [True: 0, False: 0]
  |  Branch (6084:35): [True: 0, False: 545]
  |  Branch (6084:45): [True: 0, False: 0]
  ------------------
 6085|      0|        if (!suffix)
  ------------------
  |  Branch (6085:13): [True: 0, False: 0]
  ------------------
 6086|      0|            suffix = "";
 6087|      0|        if (!prefix)
  ------------------
  |  Branch (6087:13): [True: 0, False: 0]
  ------------------
 6088|      0|            prefix = "";
 6089|      0|        if (asprintf(&tmpbuf, "%s%s%s%s", prefix, argv,
  ------------------
  |  Branch (6089:13): [True: 0, False: 0]
  ------------------
 6090|      0|                     suffix[0] == '.' || suffix[0] == '\0' ? "" : ".",
  ------------------
  |  Branch (6090:22): [True: 0, False: 0]
  |  Branch (6090:42): [True: 0, False: 0]
  ------------------
 6091|      0|                     suffix) < 0) {
 6092|      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]
  |  |  ------------------
  ------------------
 6093|      0|            return NULL;
 6094|      0|        }
 6095|      0|        argv = tmpbuf;
 6096|      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]
  |  |  ------------------
  ------------------
 6097|      0|    }
 6098|       |
 6099|    545|#ifndef NETSNMP_DISABLE_MIB_LOADING
 6100|    545|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    545|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (6100:9): [True: 0, False: 545]
  ------------------
 6101|    545|                               NETSNMP_DS_LIB_RANDOM_ACCESS)
  ------------------
  |  |   74|    545|#define NETSNMP_DS_LIB_RANDOM_ACCESS	   14   /* random access to oid labels */
  ------------------
 6102|    545|        || strchr(argv, ':')) {
  ------------------
  |  Branch (6102:12): [True: 147, False: 398]
  ------------------
 6103|    147|        if (get_node(argv, root, rootlen))
  ------------------
  |  Branch (6103:13): [True: 1, False: 146]
  ------------------
 6104|      1|            goto out;
 6105|    398|    } else if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    398|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (6105:16): [True: 0, False: 398]
  ------------------
 6106|    398|                                      NETSNMP_DS_LIB_REGEX_ACCESS)) {
  ------------------
  |  |   75|    398|#define NETSNMP_DS_LIB_REGEX_ACCESS	   15   /* regex matching to oid labels */
  ------------------
 6107|      0|	clear_tree_flags(tree_head);
 6108|      0|        if (get_wild_node(argv, root, rootlen))
  ------------------
  |  Branch (6108:13): [True: 0, False: 0]
  ------------------
 6109|      0|            goto out;
 6110|    398|    } else {
 6111|    398|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 6112|    398|        if (read_objid(argv, root, rootlen))
  ------------------
  |  Branch (6112:13): [True: 89, False: 309]
  ------------------
 6113|     89|            goto out;
 6114|    309|#ifndef NETSNMP_DISABLE_MIB_LOADING
 6115|    309|        *rootlen = savlen;
 6116|    309|        if (get_node(argv, root, rootlen))
  ------------------
  |  Branch (6116:13): [True: 2, False: 307]
  ------------------
 6117|      2|            goto out;
 6118|    307|        *rootlen = savlen;
 6119|    307|        DEBUGMSGTL(("parse_oid", "wildly parsing\n"));
  ------------------
  |  |   66|    307|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    307|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 307]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 307]
  |  |  ------------------
  ------------------
 6120|    307|	clear_tree_flags(tree_head);
 6121|    307|        if (get_wild_node(argv, root, rootlen))
  ------------------
  |  Branch (6121:13): [True: 36, False: 271]
  ------------------
 6122|     36|            goto out;
 6123|    307|    }
 6124|    417|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 6125|       |
 6126|    417|    root = NULL;
 6127|       |
 6128|    545|out:
 6129|    545|    free(tmpbuf);
 6130|    545|    return root;
 6131|    417|}
mib.c:node_to_oid:
 5254|     44|{
 5255|     44|    size_t          numids, lenids;
 5256|     44|    oid            *op;
 5257|       |
 5258|     44|    if (!tp || !objid || !objidlen)
  ------------------
  |  Branch (5258:9): [True: 0, False: 44]
  |  Branch (5258:16): [True: 0, False: 44]
  |  Branch (5258:26): [True: 0, False: 44]
  ------------------
 5259|      0|        return 0;
 5260|       |
 5261|     44|    lenids = *objidlen;
 5262|     44|    op = objid + lenids;        /* points after the last element */
 5263|       |
 5264|     88|    for (numids = 0; tp; tp = tp->parent, numids++) {
  ------------------
  |  Branch (5264:22): [True: 44, False: 44]
  ------------------
 5265|     44|        if (numids >= lenids)
  ------------------
  |  Branch (5265:13): [True: 0, False: 44]
  ------------------
 5266|      0|            continue;
 5267|     44|        --op;
 5268|     44|        *op = tp->subid;
 5269|     44|    }
 5270|       |
 5271|     44|    *objidlen = numids;
 5272|     44|    if (numids > lenids) {
  ------------------
  |  Branch (5272:9): [True: 0, False: 44]
  ------------------
 5273|      0|        return 0;
 5274|      0|    }
 5275|       |
 5276|     44|    if (numids < lenids)
  ------------------
  |  Branch (5276:9): [True: 44, False: 0]
  ------------------
 5277|     44|        memmove(objid, op, numids * sizeof(oid));
 5278|       |
 5279|     44|    return numids;
 5280|     44|}
mib.c:_add_strings_to_oid:
 5324|    404|{
 5325|    404|    oid             subid;
 5326|    404|    char           *fcp, *ecp, *cp2 = NULL;
 5327|    404|    char            doingquote;
 5328|    404|    int             len = -1;
 5329|    404|#ifndef NETSNMP_DISABLE_MIB_LOADING
 5330|    404|    struct tree    *tp2 = NULL;
 5331|    404|    struct index_list *in_dices = NULL;
 5332|    404|    int             pos = -1;
 5333|    404|    int             check =
 5334|    404|        !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   48|    404|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                      !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   76|    404|#define NETSNMP_DS_LIB_DONT_CHECK_RANGE    16   /* don't check values for ranges on send */
  ------------------
 5335|    404|    int             do_hint = !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   48|    404|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  int             do_hint = !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   90|    404|#define NETSNMP_DS_LIB_NO_DISPLAY_HINT     30 /* don't apply DISPLAY-HINTs */
  ------------------
 5336|    404|    int             len_index = 1000000;
 5337|       |
 5338|    404|    while (cp && tp && tp->child_list) {
  ------------------
  |  Branch (5338:12): [True: 404, False: 0]
  |  Branch (5338:18): [True: 404, False: 0]
  |  Branch (5338:24): [True: 0, False: 404]
  ------------------
 5339|      0|        fcp = cp;
 5340|      0|        tp2 = tp->child_list;
 5341|       |        /*
 5342|       |         * Isolate the next entry 
 5343|       |         */
 5344|      0|        cp2 = strchr(cp, '.');
 5345|      0|        if (cp2)
  ------------------
  |  Branch (5345:13): [True: 0, False: 0]
  ------------------
 5346|      0|            *cp2++ = '\0';
 5347|       |
 5348|       |        /*
 5349|       |         * Search for the appropriate child 
 5350|       |         */
 5351|      0|        if (isdigit((unsigned char)(*cp))) {
  ------------------
  |  Branch (5351:13): [True: 0, False: 0]
  ------------------
 5352|      0|            subid = strtoul(cp, &ecp, 0);
 5353|      0|            if (*ecp)
  ------------------
  |  Branch (5353:17): [True: 0, False: 0]
  ------------------
 5354|      0|                goto bad_id;
 5355|      0|            while (tp2 && tp2->subid != subid)
  ------------------
  |  Branch (5355:20): [True: 0, False: 0]
  |  Branch (5355:27): [True: 0, False: 0]
  ------------------
 5356|      0|                tp2 = tp2->next_peer;
 5357|      0|        } else {
 5358|      0|            while (tp2 && strcmp(tp2->label, fcp))
  ------------------
  |  Branch (5358:20): [True: 0, False: 0]
  |  Branch (5358:27): [True: 0, False: 0]
  ------------------
 5359|      0|                tp2 = tp2->next_peer;
 5360|      0|            if (!tp2)
  ------------------
  |  Branch (5360:17): [True: 0, False: 0]
  ------------------
 5361|      0|                goto bad_id;
 5362|      0|            subid = tp2->subid;
 5363|      0|        }
 5364|      0|        if (*objidlen >= maxlen)
  ------------------
  |  Branch (5364:13): [True: 0, False: 0]
  ------------------
 5365|      0|            goto bad_id;
 5366|      0|	while (tp2 && tp2->next_peer && tp2->next_peer->subid == subid)
  ------------------
  |  Branch (5366:9): [True: 0, False: 0]
  |  Branch (5366:16): [True: 0, False: 0]
  |  Branch (5366:34): [True: 0, False: 0]
  ------------------
 5367|      0|	    tp2 = tp2->next_peer;
 5368|      0|        objid[*objidlen] = subid;
 5369|      0|        (*objidlen)++;
 5370|       |
 5371|      0|        cp = cp2;
 5372|      0|        if (!tp2)
  ------------------
  |  Branch (5372:13): [True: 0, False: 0]
  ------------------
 5373|      0|            break;
 5374|      0|        tp = tp2;
 5375|      0|    }
 5376|       |
 5377|    404|    if (tp && !tp->child_list) {
  ------------------
  |  Branch (5377:9): [True: 404, False: 0]
  |  Branch (5377:15): [True: 404, False: 0]
  ------------------
 5378|    404|        if ((tp2 = tp->parent)) {
  ------------------
  |  Branch (5378:13): [True: 0, False: 404]
  ------------------
 5379|      0|            if (tp2->indexes)
  ------------------
  |  Branch (5379:17): [True: 0, False: 0]
  ------------------
 5380|      0|                in_dices = tp2->indexes;
 5381|      0|            else if (tp2->augments) {
  ------------------
  |  Branch (5381:22): [True: 0, False: 0]
  ------------------
 5382|      0|                tp2 = find_tree_node(tp2->augments, -1);
 5383|      0|                if (tp2)
  ------------------
  |  Branch (5383:21): [True: 0, False: 0]
  ------------------
 5384|      0|                    in_dices = tp2->indexes;
 5385|      0|            }
 5386|      0|        }
 5387|    404|        tp = NULL;
 5388|    404|    }
 5389|       |
 5390|    404|    while (cp && in_dices) {
  ------------------
  |  Branch (5390:12): [True: 404, False: 0]
  |  Branch (5390:18): [True: 0, False: 404]
  ------------------
 5391|      0|        fcp = cp;
 5392|       |
 5393|      0|        tp = find_tree_node(in_dices->ilabel, -1);
 5394|      0|        if (!tp)
  ------------------
  |  Branch (5394:13): [True: 0, False: 0]
  ------------------
 5395|      0|            break;
 5396|      0|        switch (tp->type) {
 5397|      0|        case TYPE_INTEGER:
  ------------------
  |  |  157|      0|#define TYPE_INTEGER        3
  ------------------
  |  Branch (5397:9): [True: 0, False: 0]
  ------------------
 5398|      0|        case TYPE_INTEGER32:
  ------------------
  |  |  170|      0|#define TYPE_INTEGER32      16
  ------------------
  |  Branch (5398:9): [True: 0, False: 0]
  ------------------
 5399|      0|        case TYPE_UINTEGER:
  ------------------
  |  |  168|      0|#define TYPE_UINTEGER       14
  ------------------
  |  Branch (5399:9): [True: 0, False: 0]
  ------------------
 5400|      0|        case TYPE_UNSIGNED32:
  ------------------
  |  |  169|      0|#define TYPE_UNSIGNED32     15
  ------------------
  |  Branch (5400:9): [True: 0, False: 0]
  ------------------
 5401|      0|        case TYPE_TIMETICKS:
  ------------------
  |  |  162|      0|#define TYPE_TIMETICKS      8
  ------------------
  |  Branch (5401:9): [True: 0, False: 0]
  ------------------
 5402|       |            /*
 5403|       |             * Isolate the next entry 
 5404|       |             */
 5405|      0|            cp2 = strchr(cp, '.');
 5406|      0|            if (cp2)
  ------------------
  |  Branch (5406:17): [True: 0, False: 0]
  ------------------
 5407|      0|                *cp2++ = '\0';
 5408|      0|            if (isdigit((unsigned char)(*cp))) {
  ------------------
  |  Branch (5408:17): [True: 0, False: 0]
  ------------------
 5409|      0|                subid = strtoul(cp, &ecp, 0);
 5410|      0|                if (*ecp)
  ------------------
  |  Branch (5410:21): [True: 0, False: 0]
  ------------------
 5411|      0|                    goto bad_id;
 5412|      0|            } else {
 5413|      0|                if (tp->enums) {
  ------------------
  |  Branch (5413:21): [True: 0, False: 0]
  ------------------
 5414|      0|                    struct enum_list *ep = tp->enums;
 5415|      0|                    while (ep && strcmp(ep->label, cp))
  ------------------
  |  Branch (5415:28): [True: 0, False: 0]
  |  Branch (5415:34): [True: 0, False: 0]
  ------------------
 5416|      0|                        ep = ep->next;
 5417|      0|                    if (!ep)
  ------------------
  |  Branch (5417:25): [True: 0, False: 0]
  ------------------
 5418|      0|                        goto bad_id;
 5419|      0|                    subid = ep->value;
 5420|      0|                } else
 5421|      0|                    goto bad_id;
 5422|      0|            }
 5423|      0|            if (check && tp->ranges) {
  ------------------
  |  Branch (5423:17): [True: 0, False: 0]
  |  Branch (5423:26): [True: 0, False: 0]
  ------------------
 5424|      0|                struct range_list *rp = tp->ranges;
 5425|      0|                int             ok = 0;
 5426|      0|                if (tp->type == TYPE_INTEGER ||
  ------------------
  |  |  157|      0|#define TYPE_INTEGER        3
  ------------------
  |  Branch (5426:21): [True: 0, False: 0]
  ------------------
 5427|      0|                    tp->type == TYPE_INTEGER32) {
  ------------------
  |  |  170|      0|#define TYPE_INTEGER32      16
  ------------------
  |  Branch (5427:21): [True: 0, False: 0]
  ------------------
 5428|      0|                  while (!ok && rp) {
  ------------------
  |  Branch (5428:26): [True: 0, False: 0]
  |  Branch (5428:33): [True: 0, False: 0]
  ------------------
 5429|      0|                    if ((rp->low <= (int) subid)
  ------------------
  |  Branch (5429:25): [True: 0, False: 0]
  ------------------
 5430|      0|                        && ((int) subid <= rp->high))
  ------------------
  |  Branch (5430:28): [True: 0, False: 0]
  ------------------
 5431|      0|                        ok = 1;
 5432|      0|                    else
 5433|      0|                        rp = rp->next;
 5434|      0|                  }
 5435|      0|                } else { /* check unsigned range */
 5436|      0|                  while (!ok && rp) {
  ------------------
  |  Branch (5436:26): [True: 0, False: 0]
  |  Branch (5436:33): [True: 0, False: 0]
  ------------------
 5437|      0|                    if (((unsigned int)rp->low <= subid)
  ------------------
  |  Branch (5437:25): [True: 0, False: 0]
  ------------------
 5438|      0|                        && (subid <= (unsigned int)rp->high))
  ------------------
  |  Branch (5438:28): [True: 0, False: 0]
  ------------------
 5439|      0|                        ok = 1;
 5440|      0|                    else
 5441|      0|                        rp = rp->next;
 5442|      0|                  }
 5443|      0|                }
 5444|      0|                if (!ok)
  ------------------
  |  Branch (5444:21): [True: 0, False: 0]
  ------------------
 5445|      0|                    goto bad_id;
 5446|      0|            }
 5447|      0|            if (*objidlen >= maxlen)
  ------------------
  |  Branch (5447:17): [True: 0, False: 0]
  ------------------
 5448|      0|                goto bad_id;
 5449|      0|            objid[*objidlen] = subid;
 5450|      0|            (*objidlen)++;
 5451|      0|            break;
 5452|      0|        case TYPE_IPADDR:
  ------------------
  |  |  159|      0|#define TYPE_IPADDR         5
  ------------------
  |  Branch (5452:9): [True: 0, False: 0]
  ------------------
 5453|      0|            if (*objidlen + 4 > maxlen)
  ------------------
  |  Branch (5453:17): [True: 0, False: 0]
  ------------------
 5454|      0|                goto bad_id;
 5455|      0|            for (subid = 0; cp && subid < 4; subid++) {
  ------------------
  |  Branch (5455:29): [True: 0, False: 0]
  |  Branch (5455:35): [True: 0, False: 0]
  ------------------
 5456|      0|                fcp = cp;
 5457|      0|                cp2 = strchr(cp, '.');
 5458|      0|                if (cp2)
  ------------------
  |  Branch (5458:21): [True: 0, False: 0]
  ------------------
 5459|      0|                    *cp2++ = 0;
 5460|      0|                objid[*objidlen] = strtoul(cp, &ecp, 0);
 5461|      0|                if (*ecp)
  ------------------
  |  Branch (5461:21): [True: 0, False: 0]
  ------------------
 5462|      0|                    goto bad_id;
 5463|      0|                if (check && objid[*objidlen] > 255)
  ------------------
  |  Branch (5463:21): [True: 0, False: 0]
  |  Branch (5463:30): [True: 0, False: 0]
  ------------------
 5464|      0|                    goto bad_id;
 5465|      0|                (*objidlen)++;
 5466|      0|                cp = cp2;
 5467|      0|            }
 5468|      0|            break;
 5469|      0|        case TYPE_OCTETSTR:
  ------------------
  |  |  156|      0|#define TYPE_OCTETSTR       2
  ------------------
  |  Branch (5469:9): [True: 0, False: 0]
  ------------------
 5470|      0|            if (tp->ranges && !tp->ranges->next
  ------------------
  |  Branch (5470:17): [True: 0, False: 0]
  |  Branch (5470:31): [True: 0, False: 0]
  ------------------
 5471|      0|                && tp->ranges->low == tp->ranges->high)
  ------------------
  |  Branch (5471:20): [True: 0, False: 0]
  ------------------
 5472|      0|                len = tp->ranges->low;
 5473|      0|            else
 5474|      0|                len = -1;
 5475|      0|            pos = 0;
 5476|      0|            if (*cp == '"' || *cp == '\'') {
  ------------------
  |  Branch (5476:17): [True: 0, False: 0]
  |  Branch (5476:31): [True: 0, False: 0]
  ------------------
 5477|      0|                doingquote = *cp++;
 5478|       |                /*
 5479|       |                 * insert length if requested 
 5480|       |                 */
 5481|      0|                if (!in_dices->isimplied && len == -1) {
  ------------------
  |  Branch (5481:21): [True: 0, False: 0]
  |  Branch (5481:45): [True: 0, False: 0]
  ------------------
 5482|      0|                    if (doingquote == '\'') {
  ------------------
  |  Branch (5482:25): [True: 0, False: 0]
  ------------------
 5483|      0|                        snmp_set_detail
 5484|      0|                            ("'-quote is for fixed length strings");
 5485|      0|                        return 0;
 5486|      0|                    }
 5487|      0|                    if (*objidlen >= maxlen)
  ------------------
  |  Branch (5487:25): [True: 0, False: 0]
  ------------------
 5488|      0|                        goto bad_id;
 5489|      0|                    len_index = *objidlen;
 5490|      0|                    (*objidlen)++;
 5491|      0|                } else if (doingquote == '"') {
  ------------------
  |  Branch (5491:28): [True: 0, False: 0]
  ------------------
 5492|      0|                    snmp_set_detail
 5493|      0|                        ("\"-quote is for variable length strings");
 5494|      0|                    return 0;
 5495|      0|                }
 5496|       |
 5497|      0|		cp2 = _apply_escapes(cp, doingquote);
 5498|      0|		if (!cp2) goto bad_id;
  ------------------
  |  Branch (5498:7): [True: 0, False: 0]
  ------------------
 5499|      0|		else {
 5500|      0|		    unsigned char *new_val;
 5501|      0|		    int new_val_len;
 5502|      0|		    int parsed_hint = 0;
 5503|      0|		    const char *parsed_value;
 5504|       |
 5505|      0|		    if (do_hint && tp->hint) {
  ------------------
  |  Branch (5505:11): [True: 0, False: 0]
  |  Branch (5505:22): [True: 0, False: 0]
  ------------------
 5506|      0|			parsed_value = parse_octet_hint(tp->hint, cp,
 5507|      0|			                                &new_val, &new_val_len);
 5508|      0|			parsed_hint = parsed_value == NULL;
 5509|      0|		    }
 5510|      0|		    if (parsed_hint) {
  ------------------
  |  Branch (5510:11): [True: 0, False: 0]
  ------------------
 5511|      0|			int i;
 5512|      0|			for (i = 0; i < new_val_len; i++) {
  ------------------
  |  Branch (5512:16): [True: 0, False: 0]
  ------------------
 5513|      0|			    if (*objidlen >= maxlen) goto bad_id;
  ------------------
  |  Branch (5513:12): [True: 0, False: 0]
  ------------------
 5514|      0|			    objid[ *objidlen ] = new_val[i];
 5515|      0|			    (*objidlen)++;
 5516|      0|			    pos++;
 5517|      0|			}
 5518|      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]
  |  |  ------------------
  ------------------
 5519|      0|		    } else {
 5520|      0|			while(*cp) {
  ------------------
  |  Branch (5520:10): [True: 0, False: 0]
  ------------------
 5521|      0|			    if (*objidlen >= maxlen) goto bad_id;
  ------------------
  |  Branch (5521:12): [True: 0, False: 0]
  ------------------
 5522|      0|			    objid[ *objidlen ] = *cp++;
 5523|      0|			    (*objidlen)++;
 5524|      0|			    pos++;
 5525|      0|			}
 5526|      0|		    }
 5527|      0|		}
 5528|       |		
 5529|      0|		cp2++;
 5530|      0|                if (!*cp2)
  ------------------
  |  Branch (5530:21): [True: 0, False: 0]
  ------------------
 5531|      0|                    cp2 = NULL;
 5532|      0|                else if (*cp2 != '.')
  ------------------
  |  Branch (5532:26): [True: 0, False: 0]
  ------------------
 5533|      0|                    goto bad_id;
 5534|      0|                else
 5535|      0|                    cp2++;
 5536|      0|		if (check) {
  ------------------
  |  Branch (5536:7): [True: 0, False: 0]
  ------------------
 5537|      0|                    if (len == -1) {
  ------------------
  |  Branch (5537:25): [True: 0, False: 0]
  ------------------
 5538|      0|                        struct range_list *rp = tp->ranges;
 5539|      0|                        int             ok = 0;
 5540|      0|                        while (rp && !ok)
  ------------------
  |  Branch (5540:32): [True: 0, False: 0]
  |  Branch (5540:38): [True: 0, False: 0]
  ------------------
 5541|      0|                            if (rp->low <= pos && pos <= rp->high)
  ------------------
  |  Branch (5541:33): [True: 0, False: 0]
  |  Branch (5541:51): [True: 0, False: 0]
  ------------------
 5542|      0|                                ok = 1;
 5543|      0|                            else
 5544|      0|                                rp = rp->next;
 5545|      0|                        if (!ok)
  ------------------
  |  Branch (5545:29): [True: 0, False: 0]
  ------------------
 5546|      0|                            goto bad_id;
 5547|      0|                        if (!in_dices->isimplied)
  ------------------
  |  Branch (5547:29): [True: 0, False: 0]
  ------------------
 5548|      0|                            objid[len_index] = pos;
 5549|      0|                    } else if (pos != len)
  ------------------
  |  Branch (5549:32): [True: 0, False: 0]
  ------------------
 5550|      0|                        goto bad_id;
 5551|      0|		}
 5552|      0|		else if (len == -1 && !in_dices->isimplied)
  ------------------
  |  Branch (5552:12): [True: 0, False: 0]
  |  Branch (5552:25): [True: 0, False: 0]
  ------------------
 5553|      0|		    objid[len_index] = pos;
 5554|      0|            } else {
 5555|      0|                if (!in_dices->isimplied && len == -1) {
  ------------------
  |  Branch (5555:21): [True: 0, False: 0]
  |  Branch (5555:45): [True: 0, False: 0]
  ------------------
 5556|      0|                    fcp = cp;
 5557|      0|                    cp2 = strchr(cp, '.');
 5558|      0|                    if (cp2)
  ------------------
  |  Branch (5558:25): [True: 0, False: 0]
  ------------------
 5559|      0|                        *cp2++ = 0;
 5560|      0|                    len = strtoul(cp, &ecp, 0);
 5561|      0|                    if (*ecp)
  ------------------
  |  Branch (5561:25): [True: 0, False: 0]
  ------------------
 5562|      0|                        goto bad_id;
 5563|      0|                    if (*objidlen + len + 1 >= maxlen)
  ------------------
  |  Branch (5563:25): [True: 0, False: 0]
  ------------------
 5564|      0|                        goto bad_id;
 5565|      0|                    objid[*objidlen] = len;
 5566|      0|                    (*objidlen)++;
 5567|      0|                    cp = cp2;
 5568|      0|                }
 5569|      0|                while (len && cp) {
  ------------------
  |  Branch (5569:24): [True: 0, False: 0]
  |  Branch (5569:31): [True: 0, False: 0]
  ------------------
 5570|      0|                    fcp = cp;
 5571|      0|                    cp2 = strchr(cp, '.');
 5572|      0|                    if (cp2)
  ------------------
  |  Branch (5572:25): [True: 0, False: 0]
  ------------------
 5573|      0|                        *cp2++ = 0;
 5574|      0|                    objid[*objidlen] = strtoul(cp, &ecp, 0);
 5575|      0|                    if (*ecp)
  ------------------
  |  Branch (5575:25): [True: 0, False: 0]
  ------------------
 5576|      0|                        goto bad_id;
 5577|      0|                    if (check && objid[*objidlen] > 255)
  ------------------
  |  Branch (5577:25): [True: 0, False: 0]
  |  Branch (5577:34): [True: 0, False: 0]
  ------------------
 5578|      0|                        goto bad_id;
 5579|      0|                    (*objidlen)++;
 5580|      0|                    len--;
 5581|      0|                    cp = cp2;
 5582|      0|                }
 5583|      0|            }
 5584|      0|            break;
 5585|      0|        case TYPE_OBJID:
  ------------------
  |  |  155|      0|#define TYPE_OBJID          1
  ------------------
  |  Branch (5585:9): [True: 0, False: 0]
  ------------------
 5586|      0|            in_dices = NULL;
 5587|      0|            cp2 = cp;
 5588|      0|            break;
 5589|      0|	case TYPE_NETADDR:
  ------------------
  |  |  158|      0|#define TYPE_NETADDR        4
  ------------------
  |  Branch (5589:2): [True: 0, False: 0]
  ------------------
 5590|      0|	    fcp = cp;
 5591|      0|	    cp2 = strchr(cp, '.');
 5592|      0|	    if (cp2)
  ------------------
  |  Branch (5592:10): [True: 0, False: 0]
  ------------------
 5593|      0|		*cp2++ = 0;
 5594|      0|	    subid = strtoul(cp, &ecp, 0);
 5595|      0|	    if (*ecp)
  ------------------
  |  Branch (5595:10): [True: 0, False: 0]
  ------------------
 5596|      0|		goto bad_id;
 5597|      0|	    if (*objidlen + 1 >= maxlen)
  ------------------
  |  Branch (5597:10): [True: 0, False: 0]
  ------------------
 5598|      0|		goto bad_id;
 5599|      0|	    objid[*objidlen] = subid;
 5600|      0|	    (*objidlen)++;
 5601|      0|	    cp = cp2;
 5602|      0|	    if (subid == 1) {
  ------------------
  |  Branch (5602:10): [True: 0, False: 0]
  ------------------
 5603|      0|		for (len = 0; cp && len < 4; len++) {
  ------------------
  |  Branch (5603:17): [True: 0, False: 0]
  |  Branch (5603:23): [True: 0, False: 0]
  ------------------
 5604|      0|		    fcp = cp;
 5605|      0|		    cp2 = strchr(cp, '.');
 5606|      0|		    if (cp2)
  ------------------
  |  Branch (5606:11): [True: 0, False: 0]
  ------------------
 5607|      0|			*cp2++ = 0;
 5608|      0|		    subid = strtoul(cp, &ecp, 0);
 5609|      0|		    if (*ecp)
  ------------------
  |  Branch (5609:11): [True: 0, False: 0]
  ------------------
 5610|      0|			goto bad_id;
 5611|      0|		    if (*objidlen + 1 >= maxlen)
  ------------------
  |  Branch (5611:11): [True: 0, False: 0]
  ------------------
 5612|      0|			goto bad_id;
 5613|      0|		    if (check && subid > 255)
  ------------------
  |  Branch (5613:11): [True: 0, False: 0]
  |  Branch (5613:20): [True: 0, False: 0]
  ------------------
 5614|      0|			goto bad_id;
 5615|      0|		    objid[*objidlen] = subid;
 5616|      0|		    (*objidlen)++;
 5617|      0|		    cp = cp2;
 5618|      0|		}
 5619|      0|	    }
 5620|      0|	    else {
 5621|      0|		in_dices = NULL;
 5622|      0|	    }
 5623|      0|	    break;
 5624|      0|        default:
  ------------------
  |  Branch (5624:9): [True: 0, False: 0]
  ------------------
 5625|      0|            snmp_log(LOG_ERR, "Unexpected index type: %d %s %s\n",
 5626|      0|                     tp->type, in_dices->ilabel, cp);
 5627|      0|            in_dices = NULL;
 5628|      0|            cp2 = cp;
 5629|      0|            break;
 5630|      0|        }
 5631|      0|        cp = cp2;
 5632|      0|        if (in_dices)
  ------------------
  |  Branch (5632:13): [True: 0, False: 0]
  ------------------
 5633|      0|            in_dices = in_dices->next;
 5634|      0|    }
 5635|       |
 5636|    404|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 5637|  3.42k|    while (cp) {
  ------------------
  |  Branch (5637:12): [True: 3.33k, False: 90]
  ------------------
 5638|  3.33k|        fcp = cp;
 5639|  3.33k|        switch (*cp) {
 5640|    206|        case '0':
  ------------------
  |  Branch (5640:9): [True: 206, False: 3.13k]
  ------------------
 5641|    435|        case '1':
  ------------------
  |  Branch (5641:9): [True: 229, False: 3.10k]
  ------------------
 5642|    646|        case '2':
  ------------------
  |  Branch (5642:9): [True: 211, False: 3.12k]
  ------------------
 5643|    843|        case '3':
  ------------------
  |  Branch (5643:9): [True: 197, False: 3.14k]
  ------------------
 5644|  1.03k|        case '4':
  ------------------
  |  Branch (5644:9): [True: 194, False: 3.14k]
  ------------------
 5645|  1.23k|        case '5':
  ------------------
  |  Branch (5645:9): [True: 194, False: 3.14k]
  ------------------
 5646|  1.43k|        case '6':
  ------------------
  |  Branch (5646:9): [True: 200, False: 3.13k]
  ------------------
 5647|  1.75k|        case '7':
  ------------------
  |  Branch (5647:9): [True: 327, False: 3.01k]
  ------------------
 5648|  1.95k|        case '8':
  ------------------
  |  Branch (5648:9): [True: 196, False: 3.14k]
  ------------------
 5649|  2.15k|        case '9':
  ------------------
  |  Branch (5649:9): [True: 205, False: 3.13k]
  ------------------
 5650|  2.15k|            cp2 = strchr(cp, '.');
 5651|  2.15k|            if (cp2)
  ------------------
  |  Branch (5651:17): [True: 2.06k, False: 98]
  ------------------
 5652|  2.06k|                *cp2++ = 0;
 5653|  2.15k|            subid = strtoul(cp, &ecp, 0);
 5654|  2.15k|            if (*ecp)
  ------------------
  |  Branch (5654:17): [True: 17, False: 2.14k]
  ------------------
 5655|     17|                goto bad_id;
 5656|  2.14k|            if (*objidlen >= maxlen)
  ------------------
  |  Branch (5656:17): [True: 1, False: 2.14k]
  ------------------
 5657|      1|                goto bad_id;
 5658|  2.14k|            objid[*objidlen] = subid;
 5659|  2.14k|            (*objidlen)++;
 5660|  2.14k|            break;
 5661|    626|        case '"':
  ------------------
  |  Branch (5661:9): [True: 626, False: 2.71k]
  ------------------
 5662|    954|        case '\'':
  ------------------
  |  Branch (5662:9): [True: 328, False: 3.00k]
  ------------------
 5663|    954|            doingquote = *cp++;
 5664|    954|            if (*cp == '\0')
  ------------------
  |  Branch (5664:17): [True: 13, False: 941]
  ------------------
 5665|     13|                goto bad_id;
 5666|       |            /*
 5667|       |             * insert length if requested 
 5668|       |             */
 5669|    941|            if (doingquote == '"') {
  ------------------
  |  Branch (5669:17): [True: 619, False: 322]
  ------------------
 5670|    619|                if (*objidlen >= maxlen)
  ------------------
  |  Branch (5670:21): [True: 1, False: 618]
  ------------------
 5671|      1|                    goto bad_id;
 5672|    618|                objid[*objidlen] = len = strchr(cp, doingquote) - cp;
 5673|    618|                (*objidlen)++;
 5674|    618|            }
 5675|       |
 5676|  2.82k|            while (*cp && *cp != doingquote) {
  ------------------
  |  Branch (5676:20): [True: 2.78k, False: 39]
  |  Branch (5676:27): [True: 1.88k, False: 894]
  ------------------
 5677|  1.88k|                if (*objidlen >= maxlen)
  ------------------
  |  Branch (5677:21): [True: 7, False: 1.88k]
  ------------------
 5678|      7|                    goto bad_id;
 5679|  1.88k|                objid[*objidlen] = *cp++;
 5680|  1.88k|                (*objidlen)++;
 5681|  1.88k|            }
 5682|    933|            if (!*cp)
  ------------------
  |  Branch (5682:17): [True: 39, False: 894]
  ------------------
 5683|     39|                goto bad_id;
 5684|    894|            cp2 = cp + 1;
 5685|    894|            if (!*cp2)
  ------------------
  |  Branch (5685:17): [True: 10, False: 884]
  ------------------
 5686|     10|                cp2 = NULL;
 5687|    884|            else if (*cp2 == '.')
  ------------------
  |  Branch (5687:22): [True: 872, False: 12]
  ------------------
 5688|    872|                cp2++;
 5689|     12|            else
 5690|     12|                goto bad_id;
 5691|    882|            break;
 5692|    882|        default:
  ------------------
  |  Branch (5692:9): [True: 224, False: 3.11k]
  ------------------
 5693|    224|            goto bad_id;
 5694|  3.33k|        }
 5695|  3.02k|        cp = cp2;
 5696|  3.02k|    }
 5697|     90|    return 1;
 5698|       |
 5699|    314|  bad_id:
 5700|    314|    {
 5701|    314|        char            buf[256];
 5702|    314|#ifndef NETSNMP_DISABLE_MIB_LOADING
 5703|    314|        if (in_dices)
  ------------------
  |  Branch (5703:13): [True: 0, False: 314]
  ------------------
 5704|      0|            snprintf(buf, sizeof(buf), "Index out of range: %s (%s)",
 5705|      0|                    fcp, in_dices->ilabel);
 5706|    314|        else if (tp)
  ------------------
  |  Branch (5706:18): [True: 0, False: 314]
  ------------------
 5707|      0|            snprintf(buf, sizeof(buf), "Sub-id not found: %s -> %s", tp->label, fcp);
 5708|    314|        else
 5709|    314|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 5710|    314|            snprintf(buf, sizeof(buf), "%s", fcp);
 5711|       |
 5712|    314|        snmp_set_detail(buf);
 5713|    314|    }
 5714|    314|    return 0;
 5715|    404|}

netsnmp_init_mib_internals:
  700|    152|{
  701|    152|    register struct tok *tp;
  702|    152|    register int    b, i;
  703|    152|    int             max_modc;
  704|       |
  705|    152|    if (tree_head)
  ------------------
  |  Branch (705:9): [True: 151, False: 1]
  ------------------
  706|    151|        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|    350|{
 1243|    350|    struct tree    *tp, *headtp;
 1244|    350|    int             count, *int_p;
 1245|       |
 1246|    350|    if (!name || !*name)
  ------------------
  |  Branch (1246:9): [True: 0, False: 350]
  |  Branch (1246:18): [True: 2, False: 348]
  ------------------
 1247|      2|        return (NULL);
 1248|       |
 1249|    348|    headtp = tbuckets[NBUCKET(name_hash(name))];
  ------------------
  |  |  530|    348|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|    348|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1250|    459|    for (tp = headtp; tp; tp = tp->next) {
  ------------------
  |  Branch (1250:23): [True: 155, False: 304]
  ------------------
 1251|    155|        if (tp->label && !label_compare(tp->label, name)) {
  ------------------
  |  | 1236|    155|#define	label_compare	strcmp
  ------------------
  |  Branch (1251:13): [True: 155, False: 0]
  |  Branch (1251:26): [True: 44, False: 111]
  ------------------
 1252|       |
 1253|     44|            if (modid == -1)    /* Any module */
  ------------------
  |  Branch (1253:17): [True: 44, False: 0]
  ------------------
 1254|     44|                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|    155|    }
 1262|       |
 1263|    304|    return (NULL);
 1264|    348|}
find_best_tree_node:
 1342|    307|{
 1343|    307|    struct tree    *tp, *best_so_far = NULL, *retptr;
 1344|    307|    u_int           old_match = MAX_BAD, new_match = MAX_BAD;
  ------------------
  |  | 1271|    307|#define MAX_BAD 0xffffff
  ------------------
                  u_int           old_match = MAX_BAD, new_match = MAX_BAD;
  ------------------
  |  | 1271|    307|#define MAX_BAD 0xffffff
  ------------------
 1345|       |
 1346|    307|    if (!pattrn || !*pattrn)
  ------------------
  |  Branch (1346:9): [True: 0, False: 307]
  |  Branch (1346:20): [True: 1, False: 306]
  ------------------
 1347|      1|        return (NULL);
 1348|       |
 1349|    306|    if (!tree_top)
  ------------------
  |  Branch (1349:9): [True: 0, False: 306]
  ------------------
 1350|      0|        tree_top = get_tree_head();
 1351|       |
 1352|  1.19k|    for (tp = tree_top; tp; tp = tp->next_peer) {
  ------------------
  |  Branch (1352:25): [True: 905, False: 294]
  ------------------
 1353|    905|        if (!tp->reported && tp->label)
  ------------------
  |  Branch (1353:13): [True: 905, False: 0]
  |  Branch (1353:30): [True: 905, False: 0]
  ------------------
 1354|    905|            new_match = compute_match(tp->label, pattrn);
 1355|    905|        tp->reported = 1;
 1356|       |
 1357|    905|        if (new_match < old_match) {
  ------------------
  |  Branch (1357:13): [True: 45, False: 860]
  ------------------
 1358|     45|            best_so_far = tp;
 1359|     45|            old_match = new_match;
 1360|     45|        }
 1361|    905|        if (new_match == 0)
  ------------------
  |  Branch (1361:13): [True: 12, False: 893]
  ------------------
 1362|     12|            break;              /* this is the best result we can get */
 1363|    893|        if (tp->child_list) {
  ------------------
  |  Branch (1363:13): [True: 0, False: 893]
  ------------------
 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|    893|    }
 1374|    306|    if (match)
  ------------------
  |  Branch (1374:9): [True: 0, False: 306]
  ------------------
 1375|      0|        *match = old_match;
 1376|    306|    return (best_so_far);
 1377|    307|}
which_module:
 3835|    145|{
 3836|    145|    struct module  *mp;
 3837|       |
 3838|    145|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3838:28): [True: 0, False: 145]
  ------------------
 3839|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1236|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (3839:13): [True: 0, False: 0]
  ------------------
 3840|      0|            return (mp->modid);
 3841|       |
 3842|    145|    DEBUGMSGTL(("parse-mibs", "Module %s not found\n", name));
  ------------------
  |  |   66|    145|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    145|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 145]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 145]
  |  |  ------------------
  ------------------
 3843|    145|    return (-1);
 3844|    145|}
netsnmp_read_module:
 4111|    152|{
 4112|    152|    int status = 0;
 4113|    152|    status = read_module_internal(name);
 4114|       |
 4115|    152|    if (status == MODULE_NOT_FOUND) {
  ------------------
  |  |  513|    152|#define MODULE_NOT_FOUND	0
  ------------------
  |  Branch (4115:9): [True: 152, False: 0]
  ------------------
 4116|    152|        if (!read_module_replacements(name))
  ------------------
  |  Branch (4116:13): [True: 142, False: 10]
  ------------------
 4117|    142|            print_module_not_found(name);
 4118|    152|    } else if (status == MODULE_SYNTAX_ERROR) {
  ------------------
  |  |  520|      0|#define MODULE_SYNTAX_ERROR     4
  ------------------
  |  Branch (4118:16): [True: 0, False: 0]
  ------------------
 4119|      0|        gMibError = 0;
 4120|      0|        gLoop = 1;
 4121|       |
 4122|      0|        strncat(gMibNames, " ", sizeof(gMibNames) - strlen(gMibNames) - 1);
 4123|      0|        strncat(gMibNames, name, sizeof(gMibNames) - strlen(gMibNames) - 1);
 4124|      0|    }
 4125|       |
 4126|    152|    return tree_head;
 4127|    152|}
parse.c:name_hash:
  687|    443|{
  688|    443|    int             hash = 0;
  689|    443|    const char     *cp;
  690|       |
  691|    443|    if (!name)
  ------------------
  |  Branch (691:9): [True: 0, False: 443]
  ------------------
  692|      0|        return 0;
  693|  5.82k|    for (cp = name; *cp; cp++)
  ------------------
  |  Branch (693:21): [True: 5.38k, False: 443]
  ------------------
  694|  5.38k|        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.38k]
  ------------------
  695|    443|    return (hash);
  696|    443|}
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|    905|{
 1276|    905|#if defined(HAVE_REGEX_H) && defined(HAVE_REGCOMP)
 1277|    905|    int             rc;
 1278|    905|    regex_t         parsetree;
 1279|    905|    regmatch_t      pmatch;
 1280|    905|    rc = regcomp(&parsetree, key, REG_ICASE | REG_EXTENDED);
 1281|    905|    if (rc == 0)
  ------------------
  |  Branch (1281:9): [True: 842, False: 63]
  ------------------
 1282|    842|        rc = regexec(&parsetree, search_base, 1, &pmatch, 0);
 1283|    905|    regfree(&parsetree);
 1284|    905|    if (rc == 0) {
  ------------------
  |  Branch (1284:9): [True: 56, False: 849]
  ------------------
 1285|       |        /*
 1286|       |         * found 
 1287|       |         */
 1288|     56|        return pmatch.rm_so;
 1289|     56|    }
 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|    849|    return MAX_BAD;
  ------------------
  |  | 1271|    849|#define MAX_BAD 0xffffff
  ------------------
 1325|    905|}
parse.c:read_module_internal:
 4019|    152|{
 4020|    152|    struct module  *mp;
 4021|       |
 4022|    152|    netsnmp_init_mib_internals();
 4023|       |
 4024|    152|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (4024:28): [True: 0, False: 152]
  ------------------
 4025|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1236|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (4025:13): [True: 0, False: 0]
  ------------------
 4026|      0|            return read_from_file(mp, name);
 4027|       |
 4028|    152|    return MODULE_NOT_FOUND;
  ------------------
  |  |  513|    152|#define MODULE_NOT_FOUND	0
  ------------------
 4029|    152|}
parse.c:print_error:
  780|    134|{
  781|    134|    erroneousMibs++;
  782|    134|    if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    134|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (782:9): [True: 134, False: 0]
  ------------------
  783|    134|                                NETSNMP_DS_LIB_MIB_ERRORS))
  ------------------
  |  |   59|    134|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  784|    134|	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:
 3899|    152|{
 3900|    152|    struct module_compatability *mcp;
 3901|       |
 3902|  3.34k|    for (mcp = module_map_head; mcp; mcp = mcp->next) {
  ------------------
  |  Branch (3902:33): [True: 3.20k, False: 142]
  ------------------
 3903|  3.20k|        if (!label_compare(mcp->old_module, name)) {
  ------------------
  |  | 1236|  3.20k|#define	label_compare	strcmp
  ------------------
  |  Branch (3903:13): [True: 10, False: 3.19k]
  ------------------
 3904|     10|            if (netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     10|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3904:17): [True: 0, False: 10]
  ------------------
 3905|     10|				   NETSNMP_DS_LIB_MIB_WARNINGS)) {
  ------------------
  |  |  114|     10|#define NETSNMP_DS_LIB_MIB_WARNINGS         0
  ------------------
 3906|      0|                snmp_log(LOG_WARNING,
 3907|      0|                         "Loading replacement module %s for %s (%s)\n",
 3908|      0|                         mcp->new_module, name, File);
 3909|      0|	    }
 3910|     10|            (void) netsnmp_read_module(mcp->new_module);
 3911|     10|            return 1;
 3912|     10|        }
 3913|  3.20k|    }
 3914|    142|    return 0;
 3915|    152|}
parse.c:print_module_not_found:
  798|    142|{
  799|    142|    if (first_err_module) {
  ------------------
  |  Branch (799:9): [True: 1, False: 141]
  ------------------
  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|    142|    if (!last_err_module || strcmp(cp, last_err_module))
  ------------------
  |  Branch (804:9): [True: 1, False: 141]
  |  Branch (804:29): [True: 133, False: 8]
  ------------------
  805|    134|        print_error("Cannot find module", cp, CONTINUE);
  ------------------
  |  |  162|    134|#define CONTINUE    -1
  ------------------
  806|    142|    if (last_err_module)
  ------------------
  |  Branch (806:9): [True: 141, False: 1]
  ------------------
  807|    141|        free(last_err_module);
  808|    142|    last_err_module = strdup(cp);
  809|    142|}

snmp_set_detail:
  538|    314|{
  539|    314|    if (detail_string != NULL) {
  ------------------
  |  Branch (539:9): [True: 314, False: 0]
  ------------------
  540|    314|        strlcpy(snmp_detail, detail_string, sizeof(snmp_detail));
  541|    314|        snmp_detail_f = 1;
  542|    314|    }
  543|    314|}

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

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|    314|{ 
   27|    314|	size_t src_len = strlen(src); 
   28|    314|	size_t new_len; 
   29|       |
   30|    314|	if (len == 0) {
  ------------------
  |  Branch (30:6): [True: 0, False: 314]
  ------------------
   31|      0|		return (src_len);
   32|      0|	}
   33|       |
   34|    314|        if (src_len >= len) {
  ------------------
  |  Branch (34:13): [True: 9, False: 305]
  ------------------
   35|      9|		new_len = len - 1;
   36|    305|	} else {
   37|    305|                new_len = src_len;
   38|    305|	}
   39|       |
   40|    314|        memcpy(dest, src, new_len); 
   41|    314|	dest[new_len] = '\0'; 
   42|    314|	return (src_len); 
   43|    314|}

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|    545|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   54|    545|    oid *root = malloc(MAX_OID_LEN * sizeof(oid));
  ------------------
  |  |  120|    545|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
   55|    545|    size_t rootlen = MAX_OID_LEN;
  ------------------
  |  |  120|    545|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
   56|    545|    char *input;
   57|       |
   58|    545|    input = strndup((const char *)data, size);
   59|    545|    if (root && input)
  ------------------
  |  Branch (59:9): [True: 545, False: 0]
  |  Branch (59:17): [True: 545, False: 0]
  ------------------
   60|    545|        snmp_parse_oid((const char *)input, root, &rootlen);
   61|    545|    free(root);
   62|    545|    free(input);
   63|    545|    return 0; 
   64|    545|}

