当前位置: 首页>>代码示例>>C++>>正文


C++ resolve_name函数代码示例

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


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


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