netsnmp_ds_get_boolean:
  242|  2.23k|{
  243|  2.23k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  4.46k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (243:9): [True: 0, False: 2.23k]
  |  Branch (243:24): [True: 0, False: 2.23k]
  ------------------
  244|  2.23k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  2.23k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (244:2): [True: 0, False: 2.23k]
  |  Branch (244:17): [True: 0, False: 2.23k]
  ------------------
  245|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  246|      0|    }
  247|       |
  248|  2.23k|    return (netsnmp_ds_booleans[storeid][which/8] & (1 << (which % 8))) ? 1:0;
  ------------------
  |  Branch (248:12): [True: 0, False: 2.23k]
  ------------------
  249|  2.23k|}
netsnmp_ds_get_int:
  268|     14|{
  269|     14|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|     28|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (269:9): [True: 0, False: 14]
  |  Branch (269:24): [True: 0, False: 14]
  ------------------
  270|     14|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|     14|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (270:2): [True: 0, False: 14]
  |  Branch (270:17): [True: 0, False: 14]
  ------------------
  271|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  272|      0|    }
  273|       |
  274|     14|    return netsnmp_ds_integers[storeid][which];
  275|     14|}
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.10k|{
  313|  1.10k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  2.20k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (313:9): [True: 0, False: 1.10k]
  |  Branch (313:24): [True: 0, False: 1.10k]
  ------------------
  314|  1.10k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  1.10k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (314:2): [True: 0, False: 1.10k]
  |  Branch (314:17): [True: 0, False: 1.10k]
  ------------------
  315|      0|        return NULL;
  316|      0|    }
  317|       |
  318|  1.10k|    return netsnmp_ds_strings[storeid][which];
  319|  1.10k|}

get_tree_head:
 2157|     51|{
 2158|     51|    return (tree_head);
 2159|     51|}
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);
  ------------------
  |  | 1647|      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);
  ------------------
  |  | 1647|      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);
  ------------------
  |  | 1647|      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|    414|{
 3018|    414|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3019|    414|    struct tree    *root = tree_top;
 3020|    414|    char            buf[SPRINT_MAX_LEN];
 3021|    414|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3022|    414|    int             ret, max_out_len;
 3023|    414|    char           *name, ch;
 3024|    414|    const char     *cp;
 3025|       |
 3026|    414|    cp = input;
 3027|  2.97k|    while ((ch = *cp)) {
  ------------------
  |  Branch (3027:12): [True: 2.87k, False: 96]
  ------------------
 3028|  2.87k|        if (('0' <= ch && ch <= '9')
  ------------------
  |  Branch (3028:14): [True: 2.28k, False: 592]
  |  Branch (3028:27): [True: 520, False: 1.76k]
  ------------------
 3029|  2.35k|            || ('a' <= ch && ch <= 'z')
  ------------------
  |  Branch (3029:17): [True: 1.40k, False: 957]
  |  Branch (3029:30): [True: 1.38k, False: 14]
  ------------------
 3030|    971|            || ('A' <= ch && ch <= 'Z')
  ------------------
  |  Branch (3030:17): [True: 370, False: 601]
  |  Branch (3030:30): [True: 348, False: 22]
  ------------------
 3031|    623|            || ch == '-')
  ------------------
  |  Branch (3031:16): [True: 305, False: 318]
  ------------------
 3032|  2.55k|            cp++;
 3033|    318|        else
 3034|    318|            break;
 3035|  2.87k|    }
 3036|    414|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3037|    414|    if (ch == ':')
  ------------------
  |  Branch (3037:9): [True: 0, False: 414]
  ------------------
 3038|      0|        return get_node(input, output, out_len);
 3039|    414|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3040|       |
 3041|    414|    if (*input == '.')
  ------------------
  |  Branch (3041:9): [True: 5, False: 409]
  ------------------
 3042|      5|        input++;
 3043|    409|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3044|    409|    else if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_READ_UCD_STYLE_OID)) {
  ------------------
  |  |   48|    409|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  else if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_READ_UCD_STYLE_OID)) {
  ------------------
  |  |   85|    409|#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: 409]
  ------------------
 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|    414|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3057|       |
 3058|    414|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3059|    414|    if ((root == NULL) && (tree_head != NULL)) {
  ------------------
  |  Branch (3059:9): [True: 414, False: 0]
  |  Branch (3059:27): [True: 363, False: 51]
  ------------------
 3060|    363|        root = tree_head;
 3061|    363|    }
 3062|     51|    else if (root == NULL) {
  ------------------
  |  Branch (3062:14): [True: 51, False: 0]
  ------------------
 3063|     51|        SET_SNMP_ERROR(SNMPERR_NOMIB);
  ------------------
  |  |   43|     51|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 3064|     51|        *out_len = 0;
 3065|     51|        return 0;
 3066|     51|    }
 3067|    363|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 3068|    363|    name = strdup(input);
 3069|    363|    max_out_len = *out_len;
 3070|    363|    *out_len = 0;
 3071|    363|#ifndef NETSNMP_DISABLE_MIB_LOADING
 3072|    363|    if ((ret =
  ------------------
  |  Branch (3072:9): [True: 274, False: 89]
  ------------------
 3073|    363|         _add_strings_to_oid(root, name, output, out_len,
 3074|    363|                             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|    274|    {
 3081|    274|        if (ret == 0)
  ------------------
  |  Branch (3081:13): [True: 274, False: 0]
  ------------------
 3082|    274|            ret = SNMPERR_UNKNOWN_OBJID;
  ------------------
  |  |  242|    274|#define SNMPERR_UNKNOWN_OBJID		(-58)
  ------------------
 3083|    274|        SET_SNMP_ERROR(ret);
  ------------------
  |  |   43|    274|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 3084|    274|        SNMP_FREE(name);
  ------------------
  |  |   62|    274|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 274, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 274]
  |  |  ------------------
  ------------------
 3085|    274|        return 0;
 3086|    274|    }
 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|    363|}
get_module_node:
 5183|    489|{
 5184|    489|    int             modid, rc = 0;
 5185|    489|    struct tree    *tp;
 5186|    489|    char           *name, *cp;
 5187|       |
 5188|    489|    if (!strcmp(module, "ANY"))
  ------------------
  |  Branch (5188:9): [True: 357, False: 132]
  ------------------
 5189|    357|        modid = -1;
 5190|    132|    else {
 5191|    132|        netsnmp_read_module(module);
 5192|    132|        modid = which_module(module);
 5193|    132|        if (modid == -1)
  ------------------
  |  Branch (5193:13): [True: 132, False: 0]
  ------------------
 5194|    132|            return 0;
 5195|    132|    }
 5196|       |
 5197|       |    /*
 5198|       |     * Isolate the first component of the name ... 
 5199|       |     */
 5200|    357|    name = strdup(fname);
 5201|    357|    if (name == NULL)
  ------------------
  |  Branch (5201:9): [True: 0, False: 357]
  ------------------
 5202|      0|        return -1;
 5203|    357|    cp = strchr(name, '.');
 5204|    357|    if (cp != NULL) {
  ------------------
  |  Branch (5204:9): [True: 57, False: 300]
  ------------------
 5205|     57|        *cp = '\0';
 5206|     57|        cp++;
 5207|     57|    }
 5208|       |    /*
 5209|       |     * ... and locate it in the tree. 
 5210|       |     */
 5211|    357|    tp = find_tree_node(name, modid);
 5212|    357|    if (tp) {
  ------------------
  |  Branch (5212:9): [True: 35, False: 322]
  ------------------
 5213|     35|        size_t          maxlen = *objidlen;
 5214|       |
 5215|       |        /*
 5216|       |         * Set the first element of the object ID 
 5217|       |         */
 5218|     35|        if (node_to_oid(tp, objid, objidlen)) {
  ------------------
  |  Branch (5218:13): [True: 35, False: 0]
  ------------------
 5219|     35|            rc = 1;
 5220|       |
 5221|       |            /*
 5222|       |             * If the name requested was more than one element,
 5223|       |             * tag on the rest of the components 
 5224|       |             */
 5225|     35|            if (cp != NULL)
  ------------------
  |  Branch (5225:17): [True: 5, False: 30]
  ------------------
 5226|      5|                rc = _add_strings_to_oid(tp, cp, objid, objidlen, maxlen);
 5227|     35|        }
 5228|     35|    }
 5229|       |
 5230|       |    SNMP_FREE(name);
  ------------------
  |  |   62|    357|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 357, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 357]
  |  |  ------------------
  ------------------
 5231|    357|    return (rc);
 5232|    357|}
get_wild_node:
 5724|    324|{
 5725|    324|    struct tree    *tp = find_best_tree_node(name, tree_head, NULL);
 5726|    324|    if (!tp)
  ------------------
  |  Branch (5726:9): [True: 296, False: 28]
  ------------------
 5727|    296|        return 0;
 5728|     28|    return get_node(tp->label, objid, objidlen);
 5729|    324|}
get_node:
 5733|    489|{
 5734|    489|    const char     *cp;
 5735|    489|    char            ch;
 5736|    489|    int             res;
 5737|       |
 5738|    489|    cp = name;
 5739|  9.88k|    while ((ch = *cp))
  ------------------
  |  Branch (5739:12): [True: 9.76k, False: 119]
  ------------------
 5740|  9.76k|        if (('0' <= ch && ch <= '9')
  ------------------
  |  Branch (5740:14): [True: 9.13k, False: 629]
  |  Branch (5740:27): [True: 3.80k, False: 5.33k]
  ------------------
 5741|  5.95k|            || ('a' <= ch && ch <= 'z')
  ------------------
  |  Branch (5741:17): [True: 1.72k, False: 4.23k]
  |  Branch (5741:30): [True: 1.71k, False: 14]
  ------------------
 5742|  4.24k|            || ('A' <= ch && ch <= 'Z')
  ------------------
  |  Branch (5742:17): [True: 3.47k, False: 771]
  |  Branch (5742:30): [True: 3.45k, False: 23]
  ------------------
 5743|    794|            || ch == '-')
  ------------------
  |  Branch (5743:16): [True: 424, False: 370]
  ------------------
 5744|  9.39k|            cp++;
 5745|    370|        else
 5746|    370|            break;
 5747|    489|    if (ch != ':')
  ------------------
  |  Branch (5747:9): [True: 356, False: 133]
  ------------------
 5748|    356|        if (*name == '.')
  ------------------
  |  Branch (5748:13): [True: 4, False: 352]
  ------------------
 5749|      4|            res = get_module_node(name + 1, "ANY", objid, objidlen);
 5750|    352|        else
 5751|    352|            res = get_module_node(name, "ANY", objid, objidlen);
 5752|    133|    else {
 5753|    133|        char           *module;
 5754|       |        /*
 5755|       |         *  requested name is of the form
 5756|       |         *      "module:subidentifier"
 5757|       |         */
 5758|    133|        module = (char *) malloc((size_t) (cp - name + 1));
 5759|    133|        if (!module)
  ------------------
  |  Branch (5759:13): [True: 0, False: 133]
  ------------------
 5760|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 5761|    133|        sprintf(module, "%.*s", (int) (cp - name), name);
 5762|    133|        cp++;                   /* cp now point to the subidentifier */
 5763|    133|        if (*cp == ':')
  ------------------
  |  Branch (5763:13): [True: 4, False: 129]
  ------------------
 5764|      4|            cp++;
 5765|       |
 5766|       |        /*
 5767|       |         * 'cp' and 'name' *do* go that way round! 
 5768|       |         */
 5769|    133|        res = get_module_node(cp, module, objid, objidlen);
 5770|    133|        SNMP_FREE(module);
  ------------------
  |  |   62|    133|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 133, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 133]
  |  |  ------------------
  ------------------
 5771|    133|    }
 5772|    489|    if (res == 0) {
  ------------------
  |  Branch (5772:9): [True: 459, False: 30]
  ------------------
 5773|    459|        SET_SNMP_ERROR(SNMPERR_UNKNOWN_OBJID);
  ------------------
  |  |   43|    459|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 5774|    459|    }
 5775|       |
 5776|    489|    return res;
 5777|    489|}
clear_tree_flags:
 5814|    324|{
 5815|  1.14k|    for (; tp; tp = tp->next_peer) {
  ------------------
  |  Branch (5815:12): [True: 819, False: 324]
  ------------------
 5816|    819|        tp->reported = 0;
 5817|    819|        if (tp->child_list)
  ------------------
  |  Branch (5817:13): [True: 0, False: 819]
  ------------------
 5818|      0|            clear_tree_flags(tp->child_list);
 5819|    819|     /*RECURSE*/}
 5820|    324|}
snmp_parse_oid:
 6073|    550|{
 6074|    550|#ifndef NETSNMP_DISABLE_MIB_LOADING
 6075|    550|    size_t          savlen = *rootlen;
 6076|    550|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 6077|    550|    char           *tmpbuf = NULL;
 6078|    550|    const char     *suffix, *prefix;
 6079|       |
 6080|    550|    suffix = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    550|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 6081|    550|                                   NETSNMP_DS_LIB_OIDSUFFIX);
  ------------------
  |  |  163|    550|#define NETSNMP_DS_LIB_OIDSUFFIX         12
  ------------------
 6082|    550|    prefix = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    550|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 6083|    550|                                   NETSNMP_DS_LIB_OIDPREFIX);
  ------------------
  |  |  164|    550|#define NETSNMP_DS_LIB_OIDPREFIX         13
  ------------------
 6084|    550|    if ((suffix && suffix[0]) || (prefix && prefix[0])) {
  ------------------
  |  Branch (6084:10): [True: 0, False: 550]
  |  Branch (6084:20): [True: 0, False: 0]
  |  Branch (6084:35): [True: 0, False: 550]
  |  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|    550|#ifndef NETSNMP_DISABLE_MIB_LOADING
 6100|    550|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    550|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (6100:9): [True: 0, False: 550]
  ------------------
 6101|    550|                               NETSNMP_DS_LIB_RANDOM_ACCESS)
  ------------------
  |  |   74|    550|#define NETSNMP_DS_LIB_RANDOM_ACCESS	   14   /* random access to oid labels */
  ------------------
 6102|    550|        || strchr(argv, ':')) {
  ------------------
  |  Branch (6102:12): [True: 136, False: 414]
  ------------------
 6103|    136|        if (get_node(argv, root, rootlen))
  ------------------
  |  Branch (6103:13): [True: 1, False: 135]
  ------------------
 6104|      1|            goto out;
 6105|    414|    } else if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    414|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (6105:16): [True: 0, False: 414]
  ------------------
 6106|    414|                                      NETSNMP_DS_LIB_REGEX_ACCESS)) {
  ------------------
  |  |   75|    414|#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|    414|    } else {
 6111|    414|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 6112|    414|        if (read_objid(argv, root, rootlen))
  ------------------
  |  Branch (6112:13): [True: 89, False: 325]
  ------------------
 6113|     89|            goto out;
 6114|    325|#ifndef NETSNMP_DISABLE_MIB_LOADING
 6115|    325|        *rootlen = savlen;
 6116|    325|        if (get_node(argv, root, rootlen))
  ------------------
  |  Branch (6116:13): [True: 1, False: 324]
  ------------------
 6117|      1|            goto out;
 6118|    324|        *rootlen = savlen;
 6119|    324|        DEBUGMSGTL(("parse_oid", "wildly parsing\n"));
  ------------------
  |  |   66|    324|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    324|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 324]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 324]
  |  |  ------------------
  ------------------
 6120|    324|	clear_tree_flags(tree_head);
 6121|    324|        if (get_wild_node(argv, root, rootlen))
  ------------------
  |  Branch (6121:13): [True: 28, False: 296]
  ------------------
 6122|     28|            goto out;
 6123|    324|    }
 6124|    431|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 6125|       |
 6126|    431|    root = NULL;
 6127|       |
 6128|    550|out:
 6129|    550|    free(tmpbuf);
 6130|    550|    return root;
 6131|    431|}
mib.c:node_to_oid:
 5254|     35|{
 5255|     35|    size_t          numids, lenids;
 5256|     35|    oid            *op;
 5257|       |
 5258|     35|    if (!tp || !objid || !objidlen)
  ------------------
  |  Branch (5258:9): [True: 0, False: 35]
  |  Branch (5258:16): [True: 0, False: 35]
  |  Branch (5258:26): [True: 0, False: 35]
  ------------------
 5259|      0|        return 0;
 5260|       |
 5261|     35|    lenids = *objidlen;
 5262|     35|    op = objid + lenids;        /* points after the last element */
 5263|       |
 5264|     70|    for (numids = 0; tp; tp = tp->parent, numids++) {
  ------------------
  |  Branch (5264:22): [True: 35, False: 35]
  ------------------
 5265|     35|        if (numids >= lenids)
  ------------------
  |  Branch (5265:13): [True: 0, False: 35]
  ------------------
 5266|      0|            continue;
 5267|     35|        --op;
 5268|     35|        *op = tp->subid;
 5269|     35|    }
 5270|       |
 5271|     35|    *objidlen = numids;
 5272|     35|    if (numids > lenids) {
  ------------------
  |  Branch (5272:9): [True: 0, False: 35]
  ------------------
 5273|      0|        return 0;
 5274|      0|    }
 5275|       |
 5276|     35|    if (numids < lenids)
  ------------------
  |  Branch (5276:9): [True: 35, False: 0]
  ------------------
 5277|     35|        memmove(objid, op, numids * sizeof(oid));
 5278|       |
 5279|     35|    return numids;
 5280|     35|}
mib.c:_add_strings_to_oid:
 5324|    368|{
 5325|    368|    oid             subid;
 5326|    368|    char           *fcp, *ecp, *cp2 = NULL;
 5327|    368|    char            doingquote;
 5328|    368|    int             len = -1;
 5329|    368|#ifndef NETSNMP_DISABLE_MIB_LOADING
 5330|    368|    struct tree    *tp2 = NULL;
 5331|    368|    struct index_list *in_dices = NULL;
 5332|    368|    int             pos = -1;
 5333|    368|    int             check =
 5334|    368|        !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   48|    368|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                      !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   76|    368|#define NETSNMP_DS_LIB_DONT_CHECK_RANGE    16   /* don't check values for ranges on send */
  ------------------
 5335|    368|    int             do_hint = !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   48|    368|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  int             do_hint = !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   90|    368|#define NETSNMP_DS_LIB_NO_DISPLAY_HINT     30 /* don't apply DISPLAY-HINTs */
  ------------------
 5336|    368|    int             len_index = 1000000;
 5337|       |
 5338|    368|    while (cp && tp && tp->child_list) {
  ------------------
  |  Branch (5338:12): [True: 368, False: 0]
  |  Branch (5338:18): [True: 368, False: 0]
  |  Branch (5338:24): [True: 0, False: 368]
  ------------------
 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|    368|    if (tp && !tp->child_list) {
  ------------------
  |  Branch (5377:9): [True: 368, False: 0]
  |  Branch (5377:15): [True: 368, False: 0]
  ------------------
 5378|    368|        if ((tp2 = tp->parent)) {
  ------------------
  |  Branch (5378:13): [True: 0, False: 368]
  ------------------
 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|    368|        tp = NULL;
 5388|    368|    }
 5389|       |
 5390|    368|    while (cp && in_dices) {
  ------------------
  |  Branch (5390:12): [True: 368, False: 0]
  |  Branch (5390:18): [True: 0, False: 368]
  ------------------
 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|    368|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 5637|  3.31k|    while (cp) {
  ------------------
  |  Branch (5637:12): [True: 3.22k, False: 89]
  ------------------
 5638|  3.22k|        fcp = cp;
 5639|  3.22k|        switch (*cp) {
 5640|    205|        case '0':
  ------------------
  |  Branch (5640:9): [True: 205, False: 3.02k]
  ------------------
 5641|    404|        case '1':
  ------------------
  |  Branch (5641:9): [True: 199, False: 3.02k]
  ------------------
 5642|    600|        case '2':
  ------------------
  |  Branch (5642:9): [True: 196, False: 3.03k]
  ------------------
 5643|    796|        case '3':
  ------------------
  |  Branch (5643:9): [True: 196, False: 3.03k]
  ------------------
 5644|    998|        case '4':
  ------------------
  |  Branch (5644:9): [True: 202, False: 3.02k]
  ------------------
 5645|  1.19k|        case '5':
  ------------------
  |  Branch (5645:9): [True: 195, False: 3.03k]
  ------------------
 5646|  1.52k|        case '6':
  ------------------
  |  Branch (5646:9): [True: 328, False: 2.89k]
  ------------------
 5647|  1.73k|        case '7':
  ------------------
  |  Branch (5647:9): [True: 211, False: 3.01k]
  ------------------
 5648|  1.92k|        case '8':
  ------------------
  |  Branch (5648:9): [True: 195, False: 3.03k]
  ------------------
 5649|  2.12k|        case '9':
  ------------------
  |  Branch (5649:9): [True: 194, False: 3.03k]
  ------------------
 5650|  2.12k|            cp2 = strchr(cp, '.');
 5651|  2.12k|            if (cp2)
  ------------------
  |  Branch (5651:17): [True: 2.02k, False: 94]
  ------------------
 5652|  2.02k|                *cp2++ = 0;
 5653|  2.12k|            subid = strtoul(cp, &ecp, 0);
 5654|  2.12k|            if (*ecp)
  ------------------
  |  Branch (5654:17): [True: 16, False: 2.10k]
  ------------------
 5655|     16|                goto bad_id;
 5656|  2.10k|            if (*objidlen >= maxlen)
  ------------------
  |  Branch (5656:17): [True: 1, False: 2.10k]
  ------------------
 5657|      1|                goto bad_id;
 5658|  2.10k|            objid[*objidlen] = subid;
 5659|  2.10k|            (*objidlen)++;
 5660|  2.10k|            break;
 5661|    585|        case '"':
  ------------------
  |  Branch (5661:9): [True: 585, False: 2.64k]
  ------------------
 5662|    916|        case '\'':
  ------------------
  |  Branch (5662:9): [True: 331, False: 2.89k]
  ------------------
 5663|    916|            doingquote = *cp++;
 5664|    916|            if (*cp == '\0')
  ------------------
  |  Branch (5664:17): [True: 14, False: 902]
  ------------------
 5665|     14|                goto bad_id;
 5666|       |            /*
 5667|       |             * insert length if requested 
 5668|       |             */
 5669|    902|            if (doingquote == '"') {
  ------------------
  |  Branch (5669:17): [True: 579, False: 323]
  ------------------
 5670|    579|                if (*objidlen >= maxlen)
  ------------------
  |  Branch (5670:21): [True: 2, False: 577]
  ------------------
 5671|      2|                    goto bad_id;
 5672|    577|                objid[*objidlen] = len = strchr(cp, doingquote) - cp;
 5673|    577|                (*objidlen)++;
 5674|    577|            }
 5675|       |
 5676|  2.90k|            while (*cp && *cp != doingquote) {
  ------------------
  |  Branch (5676:20): [True: 2.86k, False: 36]
  |  Branch (5676:27): [True: 2.01k, False: 857]
  ------------------
 5677|  2.01k|                if (*objidlen >= maxlen)
  ------------------
  |  Branch (5677:21): [True: 7, False: 2.00k]
  ------------------
 5678|      7|                    goto bad_id;
 5679|  2.00k|                objid[*objidlen] = *cp++;
 5680|  2.00k|                (*objidlen)++;
 5681|  2.00k|            }
 5682|    893|            if (!*cp)
  ------------------
  |  Branch (5682:17): [True: 36, False: 857]
  ------------------
 5683|     36|                goto bad_id;
 5684|    857|            cp2 = cp + 1;
 5685|    857|            if (!*cp2)
  ------------------
  |  Branch (5685:17): [True: 12, False: 845]
  ------------------
 5686|     12|                cp2 = NULL;
 5687|    845|            else if (*cp2 == '.')
  ------------------
  |  Branch (5687:22): [True: 832, False: 13]
  ------------------
 5688|    832|                cp2++;
 5689|     13|            else
 5690|     13|                goto bad_id;
 5691|    844|            break;
 5692|    844|        default:
  ------------------
  |  Branch (5692:9): [True: 190, False: 3.03k]
  ------------------
 5693|    190|            goto bad_id;
 5694|  3.22k|        }
 5695|  2.94k|        cp = cp2;
 5696|  2.94k|    }
 5697|     89|    return 1;
 5698|       |
 5699|    279|  bad_id:
 5700|    279|    {
 5701|    279|        char            buf[256];
 5702|    279|#ifndef NETSNMP_DISABLE_MIB_LOADING
 5703|    279|        if (in_dices)
  ------------------
  |  Branch (5703:13): [True: 0, False: 279]
  ------------------
 5704|      0|            snprintf(buf, sizeof(buf), "Index out of range: %s (%s)",
 5705|      0|                    fcp, in_dices->ilabel);
 5706|    279|        else if (tp)
  ------------------
  |  Branch (5706:18): [True: 0, False: 279]
  ------------------
 5707|      0|            snprintf(buf, sizeof(buf), "Sub-id not found: %s -> %s", tp->label, fcp);
 5708|    279|        else
 5709|    279|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 5710|    279|            snprintf(buf, sizeof(buf), "%s", fcp);
 5711|       |
 5712|    279|        snmp_set_detail(buf);
 5713|    279|    }
 5714|    279|    return 0;
 5715|    368|}

netsnmp_init_mib_internals:
  700|    146|{
  701|    146|    register struct tok *tp;
  702|    146|    register int    b, i;
  703|    146|    int             max_modc;
  704|       |
  705|    146|    if (tree_head)
  ------------------
  |  Branch (705:9): [True: 145, False: 1]
  ------------------
  706|    145|        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|    357|{
 1243|    357|    struct tree    *tp, *headtp;
 1244|    357|    int             count, *int_p;
 1245|       |
 1246|    357|    if (!name || !*name)
  ------------------
  |  Branch (1246:9): [True: 0, False: 357]
  |  Branch (1246:18): [True: 3, False: 354]
  ------------------
 1247|      3|        return (NULL);
 1248|       |
 1249|    354|    headtp = tbuckets[NBUCKET(name_hash(name))];
  ------------------
  |  |  530|    354|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|    354|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1250|    471|    for (tp = headtp; tp; tp = tp->next) {
  ------------------
  |  Branch (1250:23): [True: 152, False: 319]
  ------------------
 1251|    152|        if (tp->label && !label_compare(tp->label, name)) {
  ------------------
  |  | 1236|    152|#define	label_compare	strcmp
  ------------------
  |  Branch (1251:13): [True: 152, False: 0]
  |  Branch (1251:26): [True: 35, False: 117]
  ------------------
 1252|       |
 1253|     35|            if (modid == -1)    /* Any module */
  ------------------
  |  Branch (1253:17): [True: 35, False: 0]
  ------------------
 1254|     35|                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|    152|    }
 1262|       |
 1263|    319|    return (NULL);
 1264|    354|}
find_best_tree_node:
 1342|    324|{
 1343|    324|    struct tree    *tp, *best_so_far = NULL, *retptr;
 1344|    324|    u_int           old_match = MAX_BAD, new_match = MAX_BAD;
  ------------------
  |  | 1271|    324|#define MAX_BAD 0xffffff
  ------------------
                  u_int           old_match = MAX_BAD, new_match = MAX_BAD;
  ------------------
  |  | 1271|    324|#define MAX_BAD 0xffffff
  ------------------
 1345|       |
 1346|    324|    if (!pattrn || !*pattrn)
  ------------------
  |  Branch (1346:9): [True: 0, False: 324]
  |  Branch (1346:20): [True: 1, False: 323]
  ------------------
 1347|      1|        return (NULL);
 1348|       |
 1349|    323|    if (!tree_top)
  ------------------
  |  Branch (1349:9): [True: 51, False: 272]
  ------------------
 1350|     51|        tree_top = get_tree_head();
 1351|       |
 1352|  1.11k|    for (tp = tree_top; tp; tp = tp->next_peer) {
  ------------------
  |  Branch (1352:25): [True: 806, False: 313]
  ------------------
 1353|    806|        if (!tp->reported && tp->label)
  ------------------
  |  Branch (1353:13): [True: 806, False: 0]
  |  Branch (1353:30): [True: 806, False: 0]
  ------------------
 1354|    806|            new_match = compute_match(tp->label, pattrn);
 1355|    806|        tp->reported = 1;
 1356|       |
 1357|    806|        if (new_match < old_match) {
  ------------------
  |  Branch (1357:13): [True: 36, False: 770]
  ------------------
 1358|     36|            best_so_far = tp;
 1359|     36|            old_match = new_match;
 1360|     36|        }
 1361|    806|        if (new_match == 0)
  ------------------
  |  Branch (1361:13): [True: 10, False: 796]
  ------------------
 1362|     10|            break;              /* this is the best result we can get */
 1363|    796|        if (tp->child_list) {
  ------------------
  |  Branch (1363:13): [True: 0, False: 796]
  ------------------
 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|    796|    }
 1374|    323|    if (match)
  ------------------
  |  Branch (1374:9): [True: 0, False: 323]
  ------------------
 1375|      0|        *match = old_match;
 1376|    323|    return (best_so_far);
 1377|    324|}
which_module:
 3835|    135|{
 3836|    135|    struct module  *mp;
 3837|       |
 3838|    135|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3838:28): [True: 0, False: 135]
  ------------------
 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|    135|    DEBUGMSGTL(("parse-mibs", "Module %s not found\n", name));
  ------------------
  |  |   66|    135|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    135|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 135]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 135]
  |  |  ------------------
  ------------------
 3843|    135|    return (-1);
 3844|    135|}
netsnmp_read_module:
 4111|    146|{
 4112|    146|    int status = 0;
 4113|    146|    status = read_module_internal(name);
 4114|       |
 4115|    146|    if (status == MODULE_NOT_FOUND) {
  ------------------
  |  |  513|    146|#define MODULE_NOT_FOUND	0
  ------------------
  |  Branch (4115:9): [True: 146, False: 0]
  ------------------
 4116|    146|        if (!read_module_replacements(name))
  ------------------
  |  Branch (4116:13): [True: 132, False: 14]
  ------------------
 4117|    132|            print_module_not_found(name);
 4118|    146|    } 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|    146|    return tree_head;
 4127|    146|}
parse.c:name_hash:
  687|    449|{
  688|    449|    int             hash = 0;
  689|    449|    const char     *cp;
  690|       |
  691|    449|    if (!name)
  ------------------
  |  Branch (691:9): [True: 0, False: 449]
  ------------------
  692|      0|        return 0;
  693|  6.33k|    for (cp = name; *cp; cp++)
  ------------------
  |  Branch (693:21): [True: 5.88k, False: 449]
  ------------------
  694|  5.88k|        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.88k]
  ------------------
  695|    449|    return (hash);
  696|    449|}
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|    806|{
 1276|    806|#if defined(HAVE_REGEX_H) && defined(HAVE_REGCOMP)
 1277|    806|    int             rc;
 1278|    806|    regex_t         parsetree;
 1279|    806|    regmatch_t      pmatch;
 1280|    806|    rc = regcomp(&parsetree, key, REG_ICASE | REG_EXTENDED);
 1281|    806|    if (rc == 0)
  ------------------
  |  Branch (1281:9): [True: 767, False: 39]
  ------------------
 1282|    767|        rc = regexec(&parsetree, search_base, 1, &pmatch, 0);
 1283|    806|    regfree(&parsetree);
 1284|    806|    if (rc == 0) {
  ------------------
  |  Branch (1284:9): [True: 41, False: 765]
  ------------------
 1285|       |        /*
 1286|       |         * found 
 1287|       |         */
 1288|     41|        return pmatch.rm_so;
 1289|     41|    }
 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|    765|    return MAX_BAD;
  ------------------
  |  | 1271|    765|#define MAX_BAD 0xffffff
  ------------------
 1325|    806|}
parse.c:read_module_internal:
 4019|    146|{
 4020|    146|    struct module  *mp;
 4021|       |
 4022|    146|    netsnmp_init_mib_internals();
 4023|       |
 4024|    146|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (4024:28): [True: 0, False: 146]
  ------------------
 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|    146|    return MODULE_NOT_FOUND;
  ------------------
  |  |  513|    146|#define MODULE_NOT_FOUND	0
  ------------------
 4029|    146|}
parse.c:print_error:
  780|    122|{
  781|    122|    erroneousMibs++;
  782|    122|    if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    122|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (782:9): [True: 122, False: 0]
  ------------------
  783|    122|                                NETSNMP_DS_LIB_MIB_ERRORS))
  ------------------
  |  |   59|    122|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  784|    122|	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|    146|{
 3900|    146|    struct module_compatability *mcp;
 3901|       |
 3902|  3.12k|    for (mcp = module_map_head; mcp; mcp = mcp->next) {
  ------------------
  |  Branch (3902:33): [True: 2.99k, False: 132]
  ------------------
 3903|  2.99k|        if (!label_compare(mcp->old_module, name)) {
  ------------------
  |  | 1236|  2.99k|#define	label_compare	strcmp
  ------------------
  |  Branch (3903:13): [True: 14, False: 2.98k]
  ------------------
 3904|     14|            if (netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     14|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3904:17): [True: 0, False: 14]
  ------------------
 3905|     14|				   NETSNMP_DS_LIB_MIB_WARNINGS)) {
  ------------------
  |  |  114|     14|#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|     14|            (void) netsnmp_read_module(mcp->new_module);
 3911|     14|            return 1;
 3912|     14|        }
 3913|  2.99k|    }
 3914|    132|    return 0;
 3915|    146|}
parse.c:print_module_not_found:
  798|    132|{
  799|    132|    if (first_err_module) {
  ------------------
  |  Branch (799:9): [True: 1, False: 131]
  ------------------
  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|    132|    if (!last_err_module || strcmp(cp, last_err_module))
  ------------------
  |  Branch (804:9): [True: 1, False: 131]
  |  Branch (804:29): [True: 121, False: 10]
  ------------------
  805|    122|        print_error("Cannot find module", cp, CONTINUE);
  ------------------
  |  |  162|    122|#define CONTINUE    -1
  ------------------
  806|    132|    if (last_err_module)
  ------------------
  |  Branch (806:9): [True: 131, False: 1]
  ------------------
  807|    131|        free(last_err_module);
  808|    132|    last_err_module = strdup(cp);
  809|    132|}

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

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

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

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

