static char *lookup_byname_backend(const char *name) { const char *p; char *ip, *ipp; size_t nbt_len; wbcErr result; nbt_len = strlen(name); if (nbt_len > MAX_NETBIOSNAME_LEN - 1) { return NULL; } p = strchr(name, '.'); if (p != NULL) { return NULL; } result = wbcResolveWinsByName(name, &ip); if (result != WBC_ERR_SUCCESS) { return NULL; } ipp = strchr(ip, '\t'); if (ipp != NULL) { *ipp = '\0'; } return ip; }
static bool wbinfo_wins_byname(const char *name) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; char *ip = NULL; wbc_status = wbcResolveWinsByName(name, &ip); if (!WBC_ERROR_IS_OK(wbc_status)) { return false; } /* Display response */ d_printf("%s\n", ip); wbcFreeMemory(ip); return true; }
static bool test_wbc_resolve_winsbyname(struct torture_context *tctx) { const char *name; char *ip; wbcErr ret; name = torture_setting_string(tctx, "host", NULL); ret = wbcResolveWinsByName(name, &ip); if (is_ipaddress(name)) { torture_assert_wbc_equal(tctx, ret, WBC_ERR_DOMAIN_NOT_FOUND, "wbcResolveWinsByName failed"); } else { torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByName failed"); } return true; }