• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ resolve_name函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中resolve_name函数的典型用法代码示例。如果您正苦于以下问题:C++ resolve_name函数的具体用法?C++ resolve_name怎么用?C++ resolve_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了resolve_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: find_master_ip

/********************************************************
find the IP address of the master browser or DMB for a workgroup
*********************************************************/
BOOL
find_master_ip (char *group, struct in_addr * master_ip)
{
    if (resolve_name (group, master_ip, 0x1D))
        return True;

    return resolve_name (group, master_ip, 0x1B);
}
开发者ID:GarothLongint,项目名称:mc,代码行数:11,代码来源:namequery.c


示例2: torture_nbt_browse

/*
  test nbt dgram operations
*/
bool torture_nbt_browse(struct torture_context *torture)
{
	const char *address;
	struct nbt_name name;
	TALLOC_CTX *mem_ctx = talloc_new(NULL);
	NTSTATUS status;
	bool ret = true;
	
	name.name = lpcfg_workgroup();
	name.type = NBT_NAME_BROWSER;
	name.scope = NULL;

	/* do an initial name resolution to find its IP */
	status = resolve_name(&name, mem_ctx, &address, torture->ev);
	if (!NT_STATUS_IS_OK(status)) {
		printf("Failed to resolve %s - %s\n",
		       name.name, nt_errstr(status));
		talloc_free(mem_ctx);
		return false;
	}

	talloc_free(mem_ctx);

	return ret;
}
开发者ID:Alexandr-Galko,项目名称:samba,代码行数:28,代码来源:browse.c


示例3: cli_connect

/****************************************************************************
open the client sockets
****************************************************************************/
BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip)
{
	extern pstring user_socket_options;
	int fd;

	fstrcpy(cli->desthost, host);

	if (!ip || ip->s_addr == 0)
	{
		if (!resolve_name(cli->desthost, &cli->dest_ip, 0x20))
		{
			return False;
		}
		if (ip)
			*ip = cli->dest_ip;
	}
	else
	{
		cli->dest_ip = *ip;
	}

	if (cli->port == 0)
		cli->port = 139;	/* Set to default */

	fd = open_socket_out(SOCK_STREAM, &cli->dest_ip,
				  cli->port, 20000);
	if (fd == -1 || !smb_set_fd(cli->hnd, fd))
		return False;

	set_socket_options(fd, user_socket_options);

	return True;
}
开发者ID:pombredanne,项目名称:cliffs,代码行数:36,代码来源:cliconnect.c


示例4: net_lookup_host

/* lookup a hostname giving an IP */
static int net_lookup_host(int argc, const char **argv)
{
	struct in_addr ip;
	int name_type = 0x20;
	const char *name = argv[0];
	char *p;

	if (argc == 0) 
		return net_lookup_usage(argc, argv);

	p = strchr_m(name,'#');
	if (p) {
		*p = '\0';
		sscanf(++p,"%x",&name_type);
	}
	
	if (!resolve_name(name, &ip, name_type)) {
		/* we deliberately use DEBUG() here to send it to stderr 
		   so scripts aren't mucked up */
		DEBUG(0,("Didn't find %s#%02x\n", name, name_type));
		return -1;
	}

	d_printf("%s\n", inet_ntoa(ip));
	return 0;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:27,代码来源:net_lookup.c


示例5: samba_resolve_name

static inline int samba_resolve_name(const char *name, struct in_addr *return_ip, int name_type)
{
	struct sockaddr_storage addr;
	int res = resolve_name(name, &addr, name_type);
	*return_ip = ((struct sockaddr_in*)&addr)->sin_addr;
	return res;
}
开发者ID:ElecardSTB,项目名称:elecard-apps,代码行数:7,代码来源:SambaQuery.c


示例6: net_lookup_host

/* lookup a hostname giving an IP */
static int net_lookup_host(struct net_context *c, int argc, const char **argv)
{
	struct sockaddr_storage ss;
	int name_type = 0x20;
	char addr[INET6_ADDRSTRLEN];
	const char *name = argv[0];
	char *p;

	if (argc == 0)
		return net_lookup_usage(c, argc, argv);

	p = strchr_m(name,'#');
	if (p) {
		*p = '\0';
		sscanf(++p,"%x",&name_type);
	}

	if (!resolve_name(name, &ss, name_type, false)) {
		/* we deliberately use DEBUG() here to send it to stderr
		   so scripts aren't mucked up */
		DEBUG(0,("Didn't find %s#%02x\n", name, name_type));
		return -1;
	}

	print_sockaddr(addr, sizeof(addr), &ss);
	d_printf("%s\n", addr);
	return 0;
}
开发者ID:DavidMulder,项目名称:samba,代码行数:29,代码来源:net_lookup.c


示例7: virt_lstat64

asmlinkage long virt_lstat64(char * filename, struct stat64 * statbuf, long flags)
{
	long ret;
	char *newfilename;

	if(!cwd_virtual()) {
		ret = (*orig_lstat64)(filename, statbuf, flags);
		if(ret != -ENOENT) 
			return ret;
	}
	else 
		ret = 0;

	newfilename = resolve_name(filename, 1, 0);
	if(!newfilename) {
		if(ret)
			return ret;
		else
			return (*orig_lstat64)(filename, statbuf, flags);
	}
	if(IS_ERR(newfilename))
		return PTR_ERR(newfilename);

	DEB((KERN_INFO "LSTAT64: trying '%s'\n", newfilename));

	ret = do_orig_stat64(orig_lstat64, newfilename, statbuf, flags);
	kfree(newfilename);

	DEB((KERN_INFO "LSTAT64: result %li\n", ret));

	return ret;
}
开发者ID:lb1a,项目名称:avfs,代码行数:32,代码来源:redir.c


示例8: virt_lstat

asmlinkage int virt_lstat(const char *filename, struct stat *statbuf)
{
	int ret;
	char *newfilename;

	if(!cwd_virtual()) {
		ret = (*orig_lstat)(filename, statbuf);
		if(ret != -ENOENT) 
			return ret;
	}
	else 
		ret = 0;

	newfilename = resolve_name(filename, 1, 0);
	if(!newfilename) {
		if(ret)
			return ret;
		else
			return (*orig_lstat)(filename, statbuf);
	}
	if(IS_ERR(newfilename))
		return PTR_ERR(newfilename);

	DEB((KERN_INFO "LSTAT: trying '%s'\n", newfilename));

	ret = do_orig_stat(orig_lstat, newfilename, statbuf);
	kfree(newfilename);

	DEB((KERN_INFO "LSTAT: result %i\n", ret));

	return ret;
}
开发者ID:lb1a,项目名称:avfs,代码行数:32,代码来源:redir.c


示例9: load_subscriber_address

// load a unicast address from configuration
int load_subscriber_address(struct subscriber *subscriber)
{
  if (subscriber_is_reachable(subscriber)&REACHABLE)
    return 0;
  int i = config_host_list__get(&config.hosts, (const sid_t*)subscriber->sid);
  // No unicast configuration? just return.
  if (i == -1)
    return 1;
  const struct config_host *hostc = &config.hosts.av[i].value;
  overlay_interface *interface = NULL;
  if (*hostc->interface){
    interface = overlay_interface_find_name(hostc->interface);
    if (!interface)
      return WHY("Can't fund configured interface");
  }
  struct sockaddr_in addr;
  bzero(&addr, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_addr = hostc->address;
  addr.sin_port = htons(hostc->port);
  if (addr.sin_addr.s_addr==INADDR_NONE){
    if (interface || overlay_interface_get_default()){
      if (resolve_name(hostc->host, &addr.sin_addr))
	return -1;
    }else{
      // interface isnt up yet
      return 1;
    }
  }
  if (config.debug.overlayrouting)
    DEBUGF("Loaded address %s:%d for %s", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port), alloca_tohex_sid(subscriber->sid));
  return overlay_send_probe(subscriber, addr, interface, OQ_MESH_MANAGEMENT);
}
开发者ID:Ivan-du-toit,项目名称:batphone,代码行数:34,代码来源:overlay_link.c


示例10: memset

int SockLib::client_init(const char *servername) {
	if (servername == 0) {
		SysLogger::inst()->err("init params error");
		return -1;
	}
	
	if (init()) {
		SysLogger::inst()->err("socket init error");
		return -1;
	}

	SysLogger::inst()->out("ftp_tcp starting on host: [%s]", hostname);
	
	//connect to the server
	memset(&ServerAddr, 0, sizeof(ServerAddr)); /* Zero out structure */
	ServerAddr.sin_family = AF_INET; /* Internet address family */
	ServerAddr.sin_addr.s_addr = resolve_name(servername); /* Server IP address */
	ServerAddr.sin_port = htons(SERVER_RECV_PORT); /* Server port */
	if (connect(sock, (struct sockaddr *) &ServerAddr, sizeof(ServerAddr)) < 0) {
		SysLogger::inst()->err("Faild to connect to server: %s", servername);
		//closesocket(sock);
		//WSACleanup();
		return -1;
	}


	return 0;
}
开发者ID:bruciemuco,项目名称:all-projects-concordia,代码行数:28,代码来源:socklib.cpp


示例11: print_ldap_srvlist

static void print_ldap_srvlist(struct dns_rr_srv *dclist, int numdcs )
{
	struct in_addr ip;
	int i;

	for ( i=0; i<numdcs; i++ ) {
		if ( resolve_name(dclist[i].hostname, &ip, 0x20) ) {
			d_printf("%s:%d\n", inet_ntoa(ip), dclist[i].port); 
		}
	}
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:11,代码来源:net_lookup.c


示例12: _XlcFileName

char *
_XlcFileName(
    XLCd lcd,
    const char *category)
{
    char *siname;
    char cat[XLC_BUFSIZE], dir[XLC_BUFSIZE];
    int i, n;
    char *args[NUM_LOCALEDIR];
    char *file_name = NULL;

    if (lcd == (XLCd)NULL)
	return NULL;

    siname = XLC_PUBLIC(lcd, siname);

    if (category)
	lowercase(cat, category);
    else
	cat[0] = '\0';
    xlocaledir(dir,XLC_BUFSIZE);
    n = _XlcParsePath(dir, args, NUM_LOCALEDIR);
    for (i = 0; i < n; ++i) {
	char buf[PATH_MAX], *name;

	if (args[i] == NULL)
	    continue;

	name = NULL;
	if (snprintf(buf, PATH_MAX, "%s/%s.dir", args[i], cat) < PATH_MAX) {
	    name = resolve_name(siname, buf, RtoL);
	}
	if (name == NULL) {
	    continue;
	}
	if (*name == '/') {
	    /* supposed to be absolute path name */
	    file_name = name;
	} else {
	    if (snprintf(buf, PATH_MAX, "%s/%s", args[i], name) < PATH_MAX)
		file_name = strdup(buf);
	    else
		file_name = NULL;
	    Xfree(name);
	}
	if (file_name && isreadable(file_name)) {
	    break;
	}
	Xfree(file_name);
	file_name = NULL;
	/* Then, try with next dir */
    }
    return file_name;
}
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:54,代码来源:lcFile.c


示例13: virt_readlink

asmlinkage int virt_readlink(const char *filename, char *buf, int bufsiz)
{
	int ret;
	mm_segment_t old_fs;
	char *newfilename;
	char *locbuf;
	int len;
	
	if(!cwd_virtual()) {
		ret = (*orig_readlink)(filename, buf, bufsiz);
		if(ret != -ENOENT) 
			return ret;
	}
	else 
		ret = 0;

	newfilename = resolve_name(filename, 1, 0);
	if(!newfilename) {
		if(ret)
			return ret;
		else
			return (*orig_readlink)(filename, buf, bufsiz);
	}
	if(IS_ERR(newfilename))
		return PTR_ERR(newfilename);

	DEB((KERN_INFO "READLINK: trying '%s'\n", newfilename));

	/* bufsiz is legal (already checked by sys_readlink) */
	len = bufsiz;
	if(bufsiz > PAGE_SIZE)
		len = PAGE_SIZE;
			
	locbuf = (char *) __get_free_page(GFP_USER);
			
	ret = -ENOMEM;
	if(locbuf) {
		old_fs = get_fs();
		set_fs(get_ds());
		ret =  (*orig_readlink)(newfilename, locbuf, len);
		set_fs(old_fs);

		if(ret >= 0)
			if(copy_to_user(buf, locbuf, len))
				ret = -EFAULT;
		free_page((unsigned long) locbuf);
	}
	kfree(newfilename);

	DEB((KERN_INFO "READLINK: result %i\n", ret));
	
	return ret;
}
开发者ID:lb1a,项目名称:avfs,代码行数:53,代码来源:redir.c


示例14: main

int main(int argc, char *argv[])
{
    struct addrset *set;
    char line[1024];
    int i;

#ifdef WIN32
    win_init();
#endif

    set = addrset_new();

    options_init();

    for (i = 1; i < argc; i++) {
        if (!addrset_add_spec(set, argv[i], o.af, !o.nodns)) {
            fprintf(stderr, "Error adding spec \"%s\".\n", argv[i]);
            exit(1);
        }
    }

    while (fgets(line, sizeof(line), stdin) != NULL) {
        char *s, *hostname;
        struct addrinfo *addrs;

        s = line;
        while ((hostname = strtok(s, " \t\n")) != NULL) {
            int rc;

            s = NULL;

            rc = resolve_name(hostname, &addrs);
            if (rc != 0) {
                fprintf(stderr, "Error resolving \"%s\": %s.\n", hostname, gai_strerror(rc));
                continue;
            }
            if (addrs == NULL) {
                fprintf(stderr, "No addresses found for \"%s\".\n", hostname);
                continue;
            }

            /* Check just the first address returned. */
            if (addrset_contains(set, addrs->ai_addr))
                    printf("%s\n", hostname);

            freeaddrinfo(addrs);
        }
    }

    addrset_free(set);

    return 0;
}
开发者ID:TomSellers,项目名称:nmap,代码行数:53,代码来源:addrset.c


示例15: cli_connect

BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip)
{
	extern pstring user_socket_options;
	int name_type = 0x20;
	char *p;

	/* reasonable default hostname */
	if (!host)
		host = "*SMBSERVER";

	fstrcpy(cli->desthost, host);
	
	/* allow hostnames of the form NAME#xx and do a netbios lookup */
	if ((p = strchr(cli->desthost, '#'))) {
		name_type = strtol(p+1, NULL, 16);		
		*p = 0;
	}
	
	if (!ip || is_zero_ip(*ip)) {
		if (!resolve_name(cli->desthost, &cli->dest_ip, name_type)) {
			return False;
		}
		if (ip)
			*ip = cli->dest_ip;
	} else {
		cli->dest_ip = *ip;
	}

	if (getenv("LIBSMB_PROG")) {
		cli->fd = sock_exec(getenv("LIBSMB_PROG"));
	} else {
		/* try 445 first, then 139 */
		int port = cli->port?cli->port:445;
		cli->fd = open_socket_out(SOCK_STREAM, &cli->dest_ip, 
					  port, cli->timeout);
		if (cli->fd == -1 && cli->port == 0) {
			port = 139;
			cli->fd = open_socket_out(SOCK_STREAM, &cli->dest_ip, 
						  port, cli->timeout);
		}
		if (cli->fd != -1) cli->port = port;
	}
	if (cli->fd == -1) {
		DEBUG(1,("Error connecting to %s (%s)\n",
			 inet_ntoa(*ip),strerror(errno)));
		return False;
	}

	set_socket_options(cli->fd,user_socket_options);

	return True;
}
开发者ID:jophxy,项目名称:samba,代码行数:52,代码来源:cliconnect.c


示例16: _XlcFileName

char *
_XlcFileName(
    XLCd lcd,
    const char *category)
{
    char *siname;
    char cat[XLC_BUFSIZE], dir[XLC_BUFSIZE];
    int i, n;
    char *args[NUM_LOCALEDIR];
    char *file_name = NULL;

    if (lcd == (XLCd)NULL)
	return NULL;

    siname = XLC_PUBLIC(lcd, siname);

    lowercase(cat, category);
    xlocaledir(dir,XLC_BUFSIZE);
    n = _XlcParsePath(dir, args, NUM_LOCALEDIR);
    for (i = 0; i < n; ++i) {
	char buf[PATH_MAX], *name;

	name = NULL;
	if ((5 + (args[i] ? strlen (args[i]) : 0) +
	    (cat ? strlen (cat) : 0)) < PATH_MAX) {
	    sprintf(buf, "%s/%s.dir", args[i], cat);
	    name = resolve_name(siname, buf, RtoL);
	}
	if (name == NULL) {
	    continue;
	}
	if (*name == '/') {
	    /* supposed to be absolute path name */
	    file_name = name;
	} else {
	    file_name = Xmalloc(2 + (args[i] ? strlen (args[i]) : 0) +
				(name ? strlen (name) : 0));
	    if (file_name != NULL)
		sprintf(file_name, "%s/%s", args[i], name);
	    Xfree(name);
	}
	if (isreadable(file_name)) {
	    break;
	}
	Xfree(file_name);
	file_name = NULL;
	/* Then, try with next dir */
    }
    return file_name;
}
开发者ID:Magister,项目名称:x11rdp_xorg71,代码行数:50,代码来源:lcFile.c


示例17: ejs_resolve_name

static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv)
{
    int result = -1;
    struct nbt_name name;
    TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx());
    NTSTATUS nt_status;
    const char *reply_addr;

    /* validate arguments */
    if (argc < 2 || argc > 3) {
        ejsSetErrorMsg(eid, "resolveName invalid arguments");
        goto done;
    }

    if (argv[0]->type != MPR_TYPE_OBJECT) {
        ejsSetErrorMsg(eid, "resolvename invalid arguments");
        goto done;
    }

    if (argv[1]->type != MPR_TYPE_STRING) {
        ejsSetErrorMsg(eid, "resolveName invalid arguments");
        goto done;
    }

    if (argc == 2) {
        make_nbt_name_client(&name, mprToString(argv[1]));
    } else {
        if (!mprVarIsNumber(argv[1]->type)) {
            ejsSetErrorMsg(eid, "resolveName invalid arguments");
            goto done;
        }
        make_nbt_name(&name, mprToString(argv[1]), mprToInt(argv[2]));
    }

    result = 0;

    nt_status = resolve_name(&name, tmp_ctx, &reply_addr, event_context_find(tmp_ctx));

    if (NT_STATUS_IS_OK(nt_status)) {
        mprSetPropertyValue(argv[0], "value", mprString(reply_addr));
    }

    mpr_Return(eid, mprNTSTATUS(nt_status));

done:
    talloc_free(tmp_ctx);
    return result;
}
开发者ID:sangfo,项目名称:WMI_cmd,代码行数:48,代码来源:smbcalls_nbt.c


示例18: start_filter

static void start_filter(char *desthost)
{
	int s, c;
	struct in_addr dest_ip;

	CatchChild();

	/* start listening on port 445 locally */
	s = open_socket_in(SOCK_STREAM, 445, 0, 0, True);
	
	if (s == -1) {
		d_printf("bind failed\n");
		exit(1);
	}

	if (listen(s, 5) == -1) {
		d_printf("listen failed\n");
	}

	if (!resolve_name(desthost, &dest_ip, 0x20)) {
		d_printf("Unable to resolve host %s\n", desthost);
		exit(1);
	}

	while (1) {
		fd_set fds;
		int num;
		struct sockaddr addr;
		socklen_t in_addrlen = sizeof(addr);
		
		FD_ZERO(&fds);
		FD_SET(s, &fds);

		num = sys_select_intr(s+1,&fds,NULL,NULL,NULL);
		if (num > 0) {
			c = accept(s, &addr, &in_addrlen);
			if (c != -1) {
				if (fork() == 0) {
					close(s);
					filter_child(c, dest_ip);
					exit(0);
				} else {
					close(c);
				}
			}
		}
	}
}
开发者ID:StephenMacras,项目名称:dsl-n55u-bender,代码行数:48,代码来源:smbfilter.c


示例19: start_filter

static void start_filter(char *desthost)
{
	int s, c;
	struct sockaddr_storage dest_ss;
	struct sockaddr_storage my_ss;

	CatchChild();

	/* start listening on port 445 locally */

	zero_sockaddr(&my_ss);
	s = open_socket_in(SOCK_STREAM, TCP_SMB_PORT, 0, &my_ss, True);

	if (s == -1) {
		d_printf("bind failed\n");
		exit(1);
	}

	if (listen(s, 5) == -1) {
		d_printf("listen failed\n");
	}

	if (!resolve_name(desthost, &dest_ss, 0x20, false)) {
		d_printf("Unable to resolve host %s\n", desthost);
		exit(1);
	}

	while (1) {
		int num, revents;
		struct sockaddr_storage ss;
		socklen_t in_addrlen = sizeof(ss);

		num = poll_intr_one_fd(s, POLLIN|POLLHUP, -1, &revents);
		if ((num > 0) && (revents & (POLLIN|POLLHUP|POLLERR))) {
			c = accept(s, (struct sockaddr *)&ss, &in_addrlen);
			if (c != -1) {
				if (fork() == 0) {
					close(s);
					filter_child(c, &dest_ss);
					exit(0);
				} else {
					close(c);
				}
			}
		}
	}
}
开发者ID:dmitry-shavyrin,项目名称:samba4_embedded_build,代码行数:47,代码来源:smbfilter.c


示例20: get_dc_name_via_netlogon

static BOOL get_dc_name_via_netlogon(const struct winbindd_domain *domain,
				     fstring dcname, struct in_addr *dc_ip)
{
	struct winbindd_domain *our_domain;
	NTSTATUS result;
	struct winbindd_cm_conn *conn;
	TALLOC_CTX *mem_ctx;

	fstring tmp;
	char *p;

	if (IS_DC)
		return False;

	if (domain->primary)
		return False;

	if ((our_domain = find_our_domain()) == NULL)
		return False;

	result = get_connection_from_cache(our_domain, PIPE_NETLOGON, &conn);
	if (!NT_STATUS_IS_OK(result))
		return False;

	if ((mem_ctx = talloc_init("get_dc_name_via_netlogon")) == NULL)
		return False;

	result = cli_netlogon_getdcname(conn->cli, mem_ctx, domain->name, tmp);

	talloc_destroy(mem_ctx);

	if (!NT_STATUS_IS_OK(result))
		return False;

	/* cli_netlogon_getdcname gives us a name with \\ */
	p = tmp;
	if (*p == '\\') p+=1;
	if (*p == '\\') p+=1;

	fstrcpy(dcname, p);

	if (!resolve_name(dcname, dc_ip, 0x20))
		return False;

	return True;
}
开发者ID:vilpalu,项目名称:GPL_2.6.31,代码行数:46,代码来源:winbindd_cm.c



注:本文中的resolve_name函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ resolve_ref函数代码示例发布时间:2022-05-30
下一篇:
C++ resolve_hostname函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap