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

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

netsnmp_init_mib_internals:
  700|    174|{
  701|    174|    register struct tok *tp;
  702|    174|    register int    b, i;
  703|    174|    int             max_modc;
  704|       |
  705|    174|    if (tree_head)
  ------------------
  |  Branch (705:9): [True: 173, False: 1]
  ------------------
  706|    173|        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|    379|{
 1243|    379|    struct tree    *tp, *headtp;
 1244|    379|    int             count, *int_p;
 1245|       |
 1246|    379|    if (!name || !*name)
  ------------------
  |  Branch (1246:9): [True: 0, False: 379]
  |  Branch (1246:18): [True: 2, False: 377]
  ------------------
 1247|      2|        return (NULL);
 1248|       |
 1249|    377|    headtp = tbuckets[NBUCKET(name_hash(name))];
  ------------------
  |  |  530|    377|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|    377|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1250|    500|    for (tp = headtp; tp; tp = tp->next) {
  ------------------
  |  Branch (1250:23): [True: 157, False: 343]
  ------------------
 1251|    157|        if (tp->label && !label_compare(tp->label, name)) {
  ------------------
  |  | 1236|    157|#define	label_compare	strcmp
  ------------------
  |  Branch (1251:13): [True: 157, False: 0]
  |  Branch (1251:26): [True: 34, False: 123]
  ------------------
 1252|       |
 1253|     34|            if (modid == -1)    /* Any module */
  ------------------
  |  Branch (1253:17): [True: 34, False: 0]
  ------------------
 1254|     34|                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|    157|    }
 1262|       |
 1263|    343|    return (NULL);
 1264|    377|}
find_best_tree_node:
 1342|    345|{
 1343|    345|    struct tree    *tp, *best_so_far = NULL, *retptr;
 1344|    345|    u_int           old_match = MAX_BAD, new_match = MAX_BAD;
  ------------------
  |  | 1271|    345|#define MAX_BAD 0xffffff
  ------------------
                  u_int           old_match = MAX_BAD, new_match = MAX_BAD;
  ------------------
  |  | 1271|    345|#define MAX_BAD 0xffffff
  ------------------
 1345|       |
 1346|    345|    if (!pattrn || !*pattrn)
  ------------------
  |  Branch (1346:9): [True: 0, False: 345]
  |  Branch (1346:20): [True: 1, False: 344]
  ------------------
 1347|      1|        return (NULL);
 1348|       |
 1349|    344|    if (!tree_top)
  ------------------
  |  Branch (1349:9): [True: 30, False: 314]
  ------------------
 1350|     30|        tree_top = get_tree_head();
 1351|       |
 1352|  1.26k|    for (tp = tree_top; tp; tp = tp->next_peer) {
  ------------------
  |  Branch (1352:25): [True: 932, False: 333]
  ------------------
 1353|    932|        if (!tp->reported && tp->label)
  ------------------
  |  Branch (1353:13): [True: 932, False: 0]
  |  Branch (1353:30): [True: 932, False: 0]
  ------------------
 1354|    932|            new_match = compute_match(tp->label, pattrn);
 1355|    932|        tp->reported = 1;
 1356|       |
 1357|    932|        if (new_match < old_match) {
  ------------------
  |  Branch (1357:13): [True: 36, False: 896]
  ------------------
 1358|     36|            best_so_far = tp;
 1359|     36|            old_match = new_match;
 1360|     36|        }
 1361|    932|        if (new_match == 0)
  ------------------
  |  Branch (1361:13): [True: 11, False: 921]
  ------------------
 1362|     11|            break;              /* this is the best result we can get */
 1363|    921|        if (tp->child_list) {
  ------------------
  |  Branch (1363:13): [True: 0, False: 921]
  ------------------
 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|    921|    }
 1374|    344|    if (match)
  ------------------
  |  Branch (1374:9): [True: 0, False: 344]
  ------------------
 1375|      0|        *match = old_match;
 1376|    344|    return (best_so_far);
 1377|    345|}
which_module:
 3801|    166|{
 3802|    166|    struct module  *mp;
 3803|       |
 3804|    166|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3804:28): [True: 0, False: 166]
  ------------------
 3805|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1236|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (3805:13): [True: 0, False: 0]
  ------------------
 3806|      0|            return (mp->modid);
 3807|       |
 3808|    166|    DEBUGMSGTL(("parse-mibs", "Module %s not found\n", name));
  ------------------
  |  |   66|    166|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    166|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 166]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 166]
  |  |  ------------------
  ------------------
 3809|    166|    return (-1);
 3810|    166|}
netsnmp_read_module:
 4077|    174|{
 4078|    174|    int status = 0;
 4079|    174|    status = read_module_internal(name);
 4080|       |
 4081|    174|    if (status == MODULE_NOT_FOUND) {
  ------------------
  |  |  513|    174|#define MODULE_NOT_FOUND	0
  ------------------
  |  Branch (4081:9): [True: 174, False: 0]
  ------------------
 4082|    174|        if (!read_module_replacements(name))
  ------------------
  |  Branch (4082:13): [True: 163, False: 11]
  ------------------
 4083|    163|            print_module_not_found(name);
 4084|    174|    } else if (status == MODULE_SYNTAX_ERROR) {
  ------------------
  |  |  520|      0|#define MODULE_SYNTAX_ERROR     4
  ------------------
  |  Branch (4084:16): [True: 0, False: 0]
  ------------------
 4085|      0|        gMibError = 0;
 4086|      0|        gLoop = 1;
 4087|       |
 4088|      0|        strncat(gMibNames, " ", sizeof(gMibNames) - strlen(gMibNames) - 1);
 4089|      0|        strncat(gMibNames, name, sizeof(gMibNames) - strlen(gMibNames) - 1);
 4090|      0|    }
 4091|       |
 4092|    174|    return tree_head;
 4093|    174|}
parse.c:name_hash:
  687|    472|{
  688|    472|    int             hash = 0;
  689|    472|    const char     *cp;
  690|       |
  691|    472|    if (!name)
  ------------------
  |  Branch (691:9): [True: 0, False: 472]
  ------------------
  692|      0|        return 0;
  693|  6.69k|    for (cp = name; *cp; cp++)
  ------------------
  |  Branch (693:21): [True: 6.21k, False: 472]
  ------------------
  694|  6.21k|        hash += tolower((unsigned char)(*cp));
  ------------------
  |  Branch (694:17): [True: 0, False: 0]
  |  Branch (694:17): [True: 0, False: 0]
  |  Branch (694:17): [Folded, False: 6.21k]
  ------------------
  695|    472|    return (hash);
  696|    472|}
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|    932|{
 1276|    932|#if defined(HAVE_REGEX_H) && defined(HAVE_REGCOMP)
 1277|    932|    int             rc;
 1278|    932|    regex_t         parsetree;
 1279|    932|    regmatch_t      pmatch;
 1280|    932|    rc = regcomp(&parsetree, key, REG_ICASE | REG_EXTENDED);
 1281|    932|    if (rc == 0)
  ------------------
  |  Branch (1281:9): [True: 875, False: 57]
  ------------------
 1282|    875|        rc = regexec(&parsetree, search_base, 1, &pmatch, 0);
 1283|    932|    regfree(&parsetree);
 1284|    932|    if (rc == 0) {
  ------------------
  |  Branch (1284:9): [True: 40, False: 892]
  ------------------
 1285|       |        /*
 1286|       |         * found 
 1287|       |         */
 1288|     40|        return pmatch.rm_so;
 1289|     40|    }
 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|    892|    return MAX_BAD;
  ------------------
  |  | 1271|    892|#define MAX_BAD 0xffffff
  ------------------
 1325|    932|}
parse.c:read_module_internal:
 3985|    174|{
 3986|    174|    struct module  *mp;
 3987|       |
 3988|    174|    netsnmp_init_mib_internals();
 3989|       |
 3990|    174|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3990:28): [True: 0, False: 174]
  ------------------
 3991|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1236|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (3991:13): [True: 0, False: 0]
  ------------------
 3992|      0|            return read_from_file(mp, name);
 3993|       |
 3994|    174|    return MODULE_NOT_FOUND;
  ------------------
  |  |  513|    174|#define MODULE_NOT_FOUND	0
  ------------------
 3995|    174|}
parse.c:print_error:
  780|    154|{
  781|    154|    erroneousMibs++;
  782|    154|    if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    154|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (782:9): [True: 154, False: 0]
  ------------------
  783|    154|                                NETSNMP_DS_LIB_MIB_ERRORS))
  ------------------
  |  |   59|    154|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  784|    154|	return;
  785|      0|    DEBUGMSGTL(("parse-mibs", "\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  786|      0|    if (type == ENDOFFILE)
  ------------------
  |  |  163|      0|#define ENDOFFILE   0
  ------------------
  |  Branch (786:9): [True: 0, False: 0]
  ------------------
  787|      0|        snmp_log(LOG_ERR, "%s (EOF): At line %d in %s\n", str, mibLine,
  788|      0|                 File);
  789|      0|    else if (token && *token)
  ------------------
  |  Branch (789:14): [True: 0, False: 0]
  |  Branch (789:23): [True: 0, False: 0]
  ------------------
  790|      0|        snmp_log(LOG_ERR, "%s (%s): At line %d in %s\n", str, token,
  791|      0|                 mibLine, File);
  792|      0|    else
  793|      0|        snmp_log(LOG_ERR, "%s: At line %d in %s\n", str, mibLine, File);
  794|      0|}
parse.c:read_module_replacements:
 3865|    174|{
 3866|    174|    struct module_compatability *mcp;
 3867|       |
 3868|  3.83k|    for (mcp = module_map_head; mcp; mcp = mcp->next) {
  ------------------
  |  Branch (3868:33): [True: 3.66k, False: 163]
  ------------------
 3869|  3.66k|        if (!label_compare(mcp->old_module, name)) {
  ------------------
  |  | 1236|  3.66k|#define	label_compare	strcmp
  ------------------
  |  Branch (3869:13): [True: 11, False: 3.65k]
  ------------------
 3870|     11|            if (netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     11|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3870:17): [True: 0, False: 11]
  ------------------
 3871|     11|				   NETSNMP_DS_LIB_MIB_WARNINGS)) {
  ------------------
  |  |  114|     11|#define NETSNMP_DS_LIB_MIB_WARNINGS         0
  ------------------
 3872|      0|                snmp_log(LOG_WARNING,
 3873|      0|                         "Loading replacement module %s for %s (%s)\n",
 3874|      0|                         mcp->new_module, name, File);
 3875|      0|	    }
 3876|     11|            (void) netsnmp_read_module(mcp->new_module);
 3877|     11|            return 1;
 3878|     11|        }
 3879|  3.66k|    }
 3880|    163|    return 0;
 3881|    174|}
parse.c:print_module_not_found:
  798|    163|{
  799|    163|    if (first_err_module) {
  ------------------
  |  Branch (799:9): [True: 1, False: 162]
  ------------------
  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|    163|    if (!last_err_module || strcmp(cp, last_err_module))
  ------------------
  |  Branch (804:9): [True: 1, False: 162]
  |  Branch (804:29): [True: 153, False: 9]
  ------------------
  805|    154|        print_error("Cannot find module", cp, CONTINUE);
  ------------------
  |  |  162|    154|#define CONTINUE    -1
  ------------------
  806|    163|    if (last_err_module)
  ------------------
  |  Branch (806:9): [True: 162, False: 1]
  ------------------
  807|    162|        free(last_err_module);
  808|    163|    last_err_module = strdup(cp);
  809|    163|}

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

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

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

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

