这篇教程C++ yp_match函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中yp_match函数的典型用法代码示例。如果您正苦于以下问题:C++ yp_match函数的具体用法?C++ yp_match怎么用?C++ yp_match使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了yp_match函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: _yp_gethostnamadrstatic struct hostent *_yp_gethostnamadr(int type, const void *data){ static char *domain = NULL; struct hostent *h = NULL; const char *name; char buf[MAXHOSTNAMELEN]; char *res = NULL; int r, len; if (!domain && _yp_check(&domain) == 0) { errno = 0; /* ignore yp_bind errors */ return (NULL); } if (type == ASR_GETHOSTBYNAME) { name = data; len = strlen(name); r = yp_match(domain, "hosts.byname", name, len, &res, &len); } else { if (inet_ntop(AF_INET, data, buf, sizeof buf) == NULL) return (NULL); len = strlen(buf); r = yp_match(domain, "hosts.byaddr", buf, len, &res, &len); } if (r == 0) { h = hostent_from_yp(AF_INET, res); } else { errno = 0; /* ignore error if not found */ } if (res) free(res); return (h);}
开发者ID:clongeau,项目名称:opensmtpd,代码行数:35,
示例2: ypgetpwnamstruct passwd *ypgetpwnam(char *nam){ static struct passwd pwent; int reason, vallen, secure = 0; char *val; /* * Get local domain */ if (!domain && (reason = yp_get_default_domain(&domain))) { fprintf(stderr, "%s: can't get local YP domain. Reason: %s/n", __progname, yperr_string(reason)); exit(1); } if (!yp_match(domain, "master.passwd.byname", nam, strlen(nam), &val, &vallen)) secure = 1; else if (yp_match(domain, "passwd.byname", nam, strlen(nam), &val, &vallen)) return (NULL); val[vallen] = '/0'; if (__yplin) free(__yplin); if (!(__yplin = malloc(vallen + 1))) err(1, NULL); strlcpy(__yplin, val, vallen + 1); free(val); return(interpret(&pwent, __yplin, secure));}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:33,
示例3: ypgetpwuidstruct passwd *ypgetpwuid(uid_t uid){ static struct passwd pwent; int reason, vallen, secure = 0; char namebuf[16], *val; if (!domain && (reason = yp_get_default_domain(&domain))) { fprintf(stderr, "%s: can't get local YP domain. Reason: %s/n", __progname, yperr_string(reason)); exit(1); } snprintf(namebuf, sizeof namebuf, "%u", (u_int)uid); if (!yp_match(domain, "master.passwd.byuid", namebuf, strlen(namebuf), &val, &vallen)) secure = 1; else if (yp_match(domain, "passwd.byuid", namebuf, strlen(namebuf), &val, &vallen)) return (NULL); val[vallen] = '/0'; if (__yplin) free(__yplin); if (!(__yplin = malloc(vallen + 1))) err(1, NULL); strlcpy(__yplin, val, vallen + 1); free(val); return(interpret(&pwent, __yplin, secure));}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:31,
示例4: ypgetpwnamstatic intypgetpwnam(const char *nam, struct passwd *pwd){ char *val; int reason, vallen, namlen = (int)strlen(nam); int flags; int ok; flags = ok = 0; val = NULL; reason = yp_match(domain, "master.passwd.byname", nam, namlen, &val, &vallen); if (reason == YPERR_MAP) { reason = yp_match(domain, "passwd.byname", nam, namlen, &val, &vallen); flags = _PASSWORD_OLDFMT; } if (reason != 0) goto out; if (pw_scan(val, pwd, &flags) == 0) goto out; ok = 1; val = NULL; /* Don't free the memory, it is still in use */out: if (val) free(val); return ok;}
开发者ID:DragonQuan,项目名称:minix3,代码行数:30,
示例5: _nss_nis_getntohost_renum nss_status_nss_nis_getntohost_r (const struct ether_addr *addr, struct etherent *eth, char *buffer, size_t buflen, int *errnop){ if (addr == NULL) { *errnop = EINVAL; return NSS_STATUS_UNAVAIL; } char *domain; if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; char buf[33]; int nlen = snprintf (buf, sizeof (buf), "%x:%x:%x:%x:%x:%x", (int) addr->ether_addr_octet[0], (int) addr->ether_addr_octet[1], (int) addr->ether_addr_octet[2], (int) addr->ether_addr_octet[3], (int) addr->ether_addr_octet[4], (int) addr->ether_addr_octet[5]); char *result; int len; int yperr = yp_match (domain, "ethers.byaddr", buf, nlen, &result, &len); if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); if (retval == NSS_STATUS_TRYAGAIN) *errnop = errno; return retval; } if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } char *p = strncpy (buffer, result, len); buffer[len] = '/0'; while (isspace (*p)) ++p; free (result); int parse_res = _nss_files_parse_etherent (p, eth, (void *) buffer, buflen, errnop); if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; else return NSS_STATUS_NOTFOUND; } return NSS_STATUS_SUCCESS;}
开发者ID:JamesLinus,项目名称:glibc-mips,代码行数:60,
示例6: ypgetpwnamstruct passwd *ypgetpwnam(char *nam, int secure){ static struct passwd pwent; int reason, vallen; char *val; reason = yp_match(domain, secure ? "master.passwd.byname" : "passwd.byname", nam, strlen(nam), &val, &vallen); switch (reason) { case 0: break; default: return (NULL); } val[vallen] = '/0'; if (__yplin) free(__yplin); __yplin = (char *)malloc(vallen + 1); if (__yplin == NULL) pw_error(NULL, 1, 1); strlcpy(__yplin, val, vallen + 1); free(val); return (interpret(&pwent, __yplin, secure));}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:27,
示例7: _getservbyname_ypstatic int_getservbyname_yp(struct servent_data *sed){ char *result; int resultlen; char buf[YPMAXRECORD + 2]; if(!sed->yp_domain) { if(yp_get_default_domain(&sed->yp_domain)) return (0); } snprintf(buf, sizeof(buf), "%s/%s", sed->yp_name, sed->yp_proto); sed->yp_name = 0; sed->yp_proto = NULL; if (yp_match(sed->yp_domain, "services.byname", buf, strlen(buf), &result, &resultlen)) { return(0); } /* getservent() expects lines terminated with /n -- make it happy */ snprintf(sed->line, sizeof sed->line, "%.*s/n", resultlen, result); free(result); return(1);}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:28,
示例8: nis_matchstatic PyObject *nis_match (PyObject *self, PyObject *args, PyObject *kwdict){ char *match; char *domain = NULL; int keylen, len; char *key, *map; int err; PyObject *res; int fix; static char *kwlist[] = {"key", "map", "domain", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwdict, "s#s|s:match", kwlist, &key, &keylen, &map, &domain)) return NULL; if (!domain && ((err = yp_get_default_domain(&domain)) != 0)) return nis_error(err); map = nis_mapname (map, &fix); if (fix) keylen++; Py_BEGIN_ALLOW_THREADS err = yp_match (domain, map, key, keylen, &match, &len); Py_END_ALLOW_THREADS if (fix) len--; if (err != 0) return nis_error(err); res = PyUnicode_FromStringAndSize (match, len); free (match); return res;}
开发者ID:cocoatomo,项目名称:CTPython,代码行数:32,
示例9: nis_matchstatic PyObject *nis_match (PyObject *self, PyObject *args){ char *match; char *domain; int keylen, len; char *key, *map; int err; PyObject *res; int fix; if (!PyArg_Parse(args, "(t#s)", &key, &keylen, &map)) return NULL; if ((err = yp_get_default_domain(&domain)) != 0) return nis_error(err); map = nis_mapname (map, &fix); if (fix) keylen++; Py_BEGIN_ALLOW_THREADS err = yp_match (domain, map, key, keylen, &match, &len); Py_END_ALLOW_THREADS if (fix) len--; if (err != 0) return nis_error(err); res = PyString_FromStringAndSize (match, len); free (match); return res;}
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:29,
示例10: _nss_nis_setnetgrentenum nss_status_nss_nis_setnetgrent (const char *group, struct __netgrent *netgrp){ char *domain; int len; enum nss_status status; status = NSS_STATUS_SUCCESS; if (group == NULL || group[0] == '/0') return NSS_STATUS_UNAVAIL; if (yp_get_default_domain (&domain)) return NSS_STATUS_UNAVAIL; internal_nis_endnetgrent (netgrp); status = yperr2nss (yp_match (domain, "netgroup", group, strlen (group), &netgrp->data, &len)); if (status == NSS_STATUS_SUCCESS) { /* Our implementation of yp_match already allocates a buffer which is one byte larger than the value in LEN specifies and the last byte is filled with NUL. So we can simply use that buffer. */ assert (len > 0); assert (malloc_usable_size (netgrp->data) >= len + 1); assert (netgrp->data[len] == '/0'); netgrp->data_size = len; netgrp->cursor = netgrp->data; } return status;}
开发者ID:mbref,项目名称:glibc-236-microblaze,代码行数:35,
示例11: host2ip/** Return IP address given host name 'host'.* If 'host' is "", set to INADDR_ANY.*/struct in_addr host2ip(char *host){ struct in_addr in; register struct hostent *hep; /* Check whether this is a dotted decimal. */ if (!host || *host == '/0') { in.s_addr = INADDR_ANY; } else if ((in.s_addr = inet_addr(host)) != -1) { } /* Attempt to resolve host name via DNS. */ else if ((hep = gethostbyname(host))) { in = *(struct in_addr *)(hep->h_addr_list[0]); } /* As a last resort, try YP. */ else { static char *domain = 0; /* YP domain */ char *value; /* key value */ int value_len; /* length of returned value */ if (!domain) yp_get_default_domain(&domain); if (yp_match(domain, "hosts.byname", host, strlen(host), &value, &value_len) == 0) { in.s_addr = inet_addr(value); } } return in;} /* host2ip */
开发者ID:huanat,项目名称:rtptools,代码行数:32,
示例12: get_nis_passwordchar *get_nis_password(char *user, char *nisdomain, char *nismap){ static char *val = NULL; char *password = NULL; int vallen, res;#ifdef DEBUG printf("Domain is set to %s/n", nisdomain); printf("YP Map is set to %s/n", nismap);#endif /* Free last entry */ if (val) { free(val); val = NULL; } /* Get NIS entry */ res = yp_match(nisdomain, nismap, user, strlen(user), &val, &vallen); switch (res) { case NO_YPERR: /* username = */ (void) strtok(val, ":"); password = strtok(NULL, ",:"); return password; case YPERR_YPBIND: syslog(LOG_ERR, "Squid Authentication through ypbind failure: can't communicate with ypbind"); return NULL; case YPERR_KEY: /* No such key in map */ return NULL; default: return NULL; }}
开发者ID:CoolerVoid,项目名称:squid,代码行数:35,
示例13: nis_userdbInitvoid nis_userdbInit(void){ char *data; int len, yperr; domainname=rcfg_lookup(conf.cf, "etc.nisdomain"); if(domainname==NULL) { yp_get_default_domain(&domainname); } yp_bind(domainname); yperr=yp_match(domainname, conf.userdb, "blah", 4, &data, &len); if(yperr==YPERR_MAP) { fprintf(stderr, "Warning, table %s not found in NIS, setting to %s/n", conf.userdb, NIS_DEFAULTUDB); conf.userdb=NIS_DEFAULTUDB; } conf.udb.u_exists=nis_u_exists; conf.udb.getuser=nis_getuser; conf.udb.listusers=nis_listusers; conf.udb.storeuser=nis_storeuser; conf.udb.deleteuser=nis_deleteuser; conf.udb.eraseuserdb=nis_eraseuserdb; conf.udb.parseusers=nis_parseusers;}
开发者ID:dustin,项目名称:pageserv,代码行数:32,
示例14: nis_getuserstruct user nis_getuser(char *name){ struct user u; char *data; int yperr, len, times[2]; memset(&u, 0x00, sizeof(u)); yperr=yp_match(domainname, conf.userdb, name, strlen(name), &data, &len); if(!yperr) { strcpy(u.name, strtok(data, ":")); strcpy(u.passwd, strtok(NULL, ":")); strcpy(u.pageid, strtok(NULL, ":")); strcpy(u.statid, strtok(NULL, ":")); times[0]=atoi(strtok(NULL, ":")); times[1]=atoi(strtok(NULL, ":")); u.times=pack_timebits(times[0], times[1]); free(data); } return(u);}
开发者ID:dustin,项目名称:pageserv,代码行数:26,
示例15: _nss_nis_getsecretkeyenum nss_status_nss_nis_getsecretkey (const char *netname, char *skey, char *passwd, int *errnop){ enum nss_status retval; char buf[2 * (HEXKEYBYTES + 1)]; char *domain, *result; int len; skey[0] = 0; if (netname == NULL || passwd == NULL) { *errnop = EINVAL; return NSS_STATUS_UNAVAIL; } domain = strchr (netname, '@'); if (!domain) { *errnop = EINVAL; return NSS_STATUS_UNAVAIL; } ++domain; retval = yperr2nss (yp_match (domain, "publickey.byname", netname, strlen (netname), &result, &len)); if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_NOTFOUND) *errnop = ENOENT; else if (retval == NSS_STATUS_TRYAGAIN) *errnop = errno; return retval; } if (result != NULL) { char *p = strchr (result, ':'); if (p == NULL) return NSS_STATUS_SUCCESS; ++p; strncpy (buf, p, 2 * (HEXKEYBYTES + 1)); buf[2 * (HEXKEYBYTES + 1)] = '/0'; if (!xdecrypt (buf, passwd)) return NSS_STATUS_SUCCESS; if (memcmp (buf, &(buf[HEXKEYBYTES]), KEYCHECKSUMSIZE) != 0) return NSS_STATUS_SUCCESS; buf[HEXKEYBYTES] = '/0'; strcpy (skey, buf); } return NSS_STATUS_SUCCESS;}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:57,
示例16: _getservbyport_ypstatic int_getservbyport_yp(struct servent_data *sed){ char *result; int resultlen; char buf[YPMAXRECORD + 2]; int rv; snprintf(buf, sizeof(buf), "%d/%s", ntohs(sed->yp_port), sed->yp_proto); sed->yp_port = 0; sed->yp_proto = NULL; if (!sed->yp_domain) { if (yp_get_default_domain(&sed->yp_domain)) return (0); } /* * We have to be a little flexible here. Ideally you're supposed * to have both a services.byname and a services.byport map, but * some systems have only services.byname. FreeBSD cheats a little * by putting the services.byport information in the same map as * services.byname so that either case will work. We allow for both * possibilities here: if there is no services.byport map, we try * services.byname instead. */ if ((rv = yp_match(sed->yp_domain, "services.byport", buf, strlen(buf), &result, &resultlen))) { if (rv == YPERR_MAP) { if (yp_match(sed->yp_domain, "services.byname", buf, strlen(buf), &result, &resultlen)) return(0); } else return(0); } /* getservent() expects lines terminated with /n -- make it happy */ snprintf(sed->line, sizeof sed->line, "%.*s/n", resultlen, result); free(result); return(1);}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:44,
示例17: _nss_nis_getspnam_renum nss_status_nss_nis_getspnam_r (const char *name, struct spwd *sp, char *buffer, size_t buflen, int *errnop){ struct parser_data *data = (void *) buffer; enum nss_status retval; char *domain, *result, *p; int len, parse_res; if (name == NULL) { *errnop = EINVAL; return NSS_STATUS_UNAVAIL; } if (yp_get_default_domain (&domain)) return NSS_STATUS_UNAVAIL; retval = yperr2nss (yp_match (domain, "shadow.byname", name, strlen (name), &result, &len)); if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_NOTFOUND) *errnop = ENOENT; else if (retval == NSS_STATUS_TRYAGAIN) *errnop = errno; return retval; } if ((size_t) (len + 1) > buflen) { free (result); *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } p = strncpy (buffer, result, len); buffer[len] = '/0'; while (isspace (*p)) ++p; free (result); parse_res = _nss_files_parse_spent (p, sp, data, buflen, errnop); if (parse_res < 1) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; else { *errnop = ENOENT; return NSS_STATUS_NOTFOUND; } } return NSS_STATUS_SUCCESS;}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:56,
示例18: _nss_nis_getsecretkeyenum nss_status_nss_nis_getsecretkey (const char *netname, char *skey, char *passwd, int *errnop){ skey[0] = 0; if (netname == NULL || passwd == NULL) { *errnop = EINVAL; return NSS_STATUS_UNAVAIL; } char *domain = strchr (netname, '@'); if (domain == NULL) { *errnop = EINVAL; return NSS_STATUS_UNAVAIL; } ++domain; char *result; int len; int yperr = yp_match (domain, "publickey.byname", netname, strlen (netname), &result, &len); if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) { enum nss_status retval = yperr2nss (yperr); if (retval == NSS_STATUS_TRYAGAIN) *errnop = errno; return retval; } if (result != NULL) { char *p = strchr (result, ':'); if (p != NULL) { char buf[2 * (HEXKEYBYTES + 1)]; ++p; strncpy (buf, p, 2 * (HEXKEYBYTES + 1)); buf[2 * HEXKEYBYTES + 1] = '/0'; if (xdecrypt (buf, passwd) && memcmp (buf, &(buf[HEXKEYBYTES]), KEYCHECKSUMSIZE) == 0) { buf[HEXKEYBYTES] = '/0'; strcpy (skey, buf); } } free (result); } return NSS_STATUS_SUCCESS;}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:56,
示例19: _nss_nis_gethostton_renum nss_status_nss_nis_gethostton_r (const char *name, struct etherent *eth, char *buffer, size_t buflen, int *errnop){ if (name == NULL) { *errnop = EINVAL; return NSS_STATUS_UNAVAIL; } char *domain; if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; char *result; int len; int yperr = yp_match (domain, "ethers.byname", name, strlen (name), &result, &len); if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); if (retval == NSS_STATUS_TRYAGAIN) *errnop = errno; return retval; } if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } char *p = strncpy (buffer, result, len); buffer[len] = '/0'; while (isspace (*p)) ++p; free (result); int parse_res = _nss_files_parse_etherent (p, eth, (void *) buffer, buflen, errnop); if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; else return NSS_STATUS_NOTFOUND; } return NSS_STATUS_SUCCESS;}
开发者ID:JamesLinus,项目名称:glibc-mips,代码行数:52,
示例20: ypclnt_getchar *ypclnt_get(ypclnt_t *ypc, const char *key){ char *value; int len, r; r = yp_match(ypc->domain, ypc->map, key, (int)strlen(key), &value, &len); if (r != 0) { ypclnt_error(ypc, __func__, "%s", yperr_string(r)); return (NULL); } return (value);}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:14,
示例21: _nss_nis_netname2userenum nss_status_nss_nis_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp, gid_t *gidp, int *gidlenp, gid_t *gidlist, int *errnop){ char *domain; int yperr; char *lookup; int len; domain = strchr (netname, '@'); if (!domain) { *errnop = EINVAL; return NSS_STATUS_UNAVAIL; } /* Point past the '@' character */ ++domain; lookup = NULL; yperr = yp_match (domain, "netid.byname", netname, strlen (netname), &lookup, &len); switch (yperr) { case YPERR_SUCCESS: break; /* the successful case */ case YPERR_DOMAIN: case YPERR_KEY: *errnop = ENOENT; return NSS_STATUS_NOTFOUND; case YPERR_MAP: default: return NSS_STATUS_UNAVAIL; } if (lookup) { enum nss_status err; lookup[len] = '/0'; err = parse_netid_str (lookup, uidp, gidp, gidlenp, gidlist); free (lookup); return err; } else { *errnop = ENOENT; return NSS_STATUS_NOTFOUND; } return NSS_STATUS_SUCCESS;}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:50,
示例22: _nss_nis_getrpcbynumber_renum nss_status_nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc, char *buffer, size_t buflen, int *errnop){ char *domain; if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; char buf[32]; int nlen = snprintf (buf, sizeof (buf), "%d", number); char *result; int len; int yperr = yp_match (domain, "rpc.bynumber", buf, nlen, &result, &len); if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); if (retval == NSS_STATUS_TRYAGAIN) *errnop = errno; return retval; } if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } char *p = strncpy (buffer, result, len); buffer[len] = '/0'; while (isspace (*p)) ++p; free (result); int parse_res = _nss_files_parse_rpcent (p, rpc, (void *) buffer, buflen, errnop); if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; else return NSS_STATUS_NOTFOUND; } else return NSS_STATUS_SUCCESS;}
开发者ID:riscv,项目名称:riscv-glibc,代码行数:49,
示例23: _nss_nis_getgrgid_renum nss_status_nss_nis_getgrgid_r (gid_t gid, struct group *grp, char *buffer, size_t buflen, int *errnop){ char *domain; if (__builtin_expect (yp_get_default_domain (&domain), 0)) return NSS_STATUS_UNAVAIL; char buf[32]; int nlen = sprintf (buf, "%lu", (unsigned long int) gid); char *result; int len; int yperr = yp_match (domain, "group.bygid", buf, nlen, &result, &len); if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) { enum nss_status retval = yperr2nss (yperr); if (retval == NSS_STATUS_TRYAGAIN) *errnop = errno; return retval; } if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) { free (result); *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } char *p = strncpy (buffer, result, len); buffer[len] = '/0'; while (isspace (*p)) ++p; free (result); int parse_res = _nss_files_parse_grent (p, grp, (void *) buffer, buflen, errnop); if (__builtin_expect (parse_res < 1, 0)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; else return NSS_STATUS_NOTFOUND; } return NSS_STATUS_SUCCESS;}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:48,
示例24: eui64_ntohost/* * Map an EUI-64 to a hostname. Use either /etc/eui64 or NIS/YP. */inteui64_ntohost(char *hostname, size_t len, const struct eui64 *id){ FILE *fp; char buf[BUFSIZ + 2]; struct eui64 local_eui64; char local_host[MAXHOSTNAMELEN];#ifdef YP char *result; int resultlen; char eui64_a[24]; char *yp_domain;#endif if ((fp = fopen(_PATH_EUI64, "re")) == NULL) return (1); while (fgets(buf,BUFSIZ,fp)) { if (buf[0] == '#') continue;#ifdef YP if (buf[0] == '+') { if (yp_get_default_domain(&yp_domain)) continue; eui64_ntoa(id, eui64_a, sizeof(eui64_a)); if (yp_match(yp_domain, "eui64.byid", eui64_a, strlen(eui64_a), &result, &resultlen)) { continue; } strncpy(buf, result, resultlen); buf[resultlen] = '/0'; free(result); }#endif if (eui64_line(buf, &local_eui64, local_host, sizeof(local_host)) == 0) { if (bcmp(&local_eui64.octet[0], &id->octet[0], EUI64_LEN) == 0) { /* We have a match */ strcpy(hostname, local_host); fclose(fp); return(0); } } } fclose(fp); return (1);}
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:50,
示例25: nis0_findstatic intnis0_find(void *handle, uschar *filename, const uschar *keystring, int length, uschar **result, uschar **errmsg, uint *do_cache){int rc;uschar *nis_data;int nis_data_length;do_cache = do_cache; /* Placate picky compilers */if ((rc = yp_match(CCS handle, CCS filename, CCS keystring, length + 1, CSS &nis_data, &nis_data_length)) == 0) { *result = string_copy(nis_data); (*result)[nis_data_length] = 0; /* remove final '/n' */ return OK; }return (rc == YPERR_KEY || rc == YPERR_MAP)? FAIL : DEFER;}
开发者ID:Exim,项目名称:exim,代码行数:17,
示例26: ether_ntohost/* * Map an ethernet address to a hostname. Use either /etc/ethers or NIS/YP. */intether_ntohost(char *hostname, const struct ether_addr *e){ FILE *fp; char buf[BUFSIZ + 2]; struct ether_addr local_ether; char local_host[MAXHOSTNAMELEN];#ifdef YP char *result; int resultlen; char *ether_a; char *yp_domain;#endif if ((fp = fopen(_PATH_ETHERS, "r")) == NULL) return (1); while (fgets(buf,BUFSIZ,fp)) { if (buf[0] == '#') continue;#ifdef YP if (buf[0] == '+') { if (yp_get_default_domain(&yp_domain)) continue; ether_a = ether_ntoa(e); if (yp_match(yp_domain, "ethers.byaddr", ether_a, strlen(ether_a), &result, &resultlen)) { continue; } strncpy(buf, result, resultlen); buf[resultlen] = '/0'; free(result); }#endif if (!ether_line(buf, &local_ether, local_host)) { if (!bcmp((char *)&local_ether.octet[0], (char *)&e->octet[0], 6)) { /* We have a match. */ strcpy(hostname, local_host); fclose(fp); return(0); } } } fclose(fp); return (1);}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:49,
示例27: sizeof/* If we haven't found the entry, we give a SUCCESS and an empty key back. Solaris docu says: sizeof (pkey) == HEXKEYBYTES + 1.*/enum nss_status_nss_nis_getpublickey (const char *netname, char *pkey, int *errnop){ enum nss_status retval; char *domain, *result; int len; pkey[0] = 0; if (netname == NULL) { *errnop = EINVAL; return NSS_STATUS_UNAVAIL; } domain = strchr (netname, '@'); if (!domain) { *errnop = EINVAL; return NSS_STATUS_UNAVAIL; } ++domain; retval = yperr2nss (yp_match (domain, "publickey.byname", netname, strlen (netname), &result, &len)); if (retval != NSS_STATUS_SUCCESS) { if (retval == NSS_STATUS_NOTFOUND) *errnop = ENOENT; else if (retval == NSS_STATUS_TRYAGAIN) *errnop = errno; return retval; } if (result != NULL) { char *p = strchr (result, ':'); if (p != NULL) *p = 0; strncpy (pkey, result, HEXKEYBYTES + 1); pkey[HEXKEYBYTES] = '/0'; } return NSS_STATUS_SUCCESS;}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:48,
示例28: _revnetgr_lookupstatic int_revnetgr_lookup(char* lookupdom, char* map, const char* str, const char* dom, const char* group){ int y, rv, rot; char key[MAXHOSTNAMELEN]; char *result; int resultlen; for (rot = 0; ; rot++) { switch (rot) { case 0: snprintf(key, MAXHOSTNAMELEN, "%s.%s", str, dom ? dom : lookupdom); break; case 1: snprintf(key, MAXHOSTNAMELEN, "%s.*", str); break; case 2: snprintf(key, MAXHOSTNAMELEN, "*.%s", dom ? dom : lookupdom); break; case 3: snprintf(key, MAXHOSTNAMELEN, "*.*"); break; default: return (0); } y = yp_match(lookupdom, map, key, strlen(key), &result, &resultlen); if (y == 0) { rv = _listmatch(result, group, resultlen); free(result); if (rv) return (1); } else if (y != YPERR_KEY) { /* * If we get an error other than 'no * such key in map' then something is * wrong and we should stop the search. */ return (-1); } }}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:45,
示例29: eui64_hostton/* * Map a hostname to an EUI-64 using /etc/eui64 or NIS/YP. */inteui64_hostton(const char *hostname, struct eui64 *id){ FILE *fp; char buf[BUFSIZ + 2]; struct eui64 local_eui64; char local_host[MAXHOSTNAMELEN];#ifdef YP char *result; int resultlen; char *yp_domain;#endif if ((fp = fopen(_PATH_EUI64, "re")) == NULL) return (1); while (fgets(buf,BUFSIZ,fp)) { if (buf[0] == '#') continue;#ifdef YP if (buf[0] == '+') { if (yp_get_default_domain(&yp_domain)) continue; if (yp_match(yp_domain, "eui64.byname", hostname, strlen(hostname), &result, &resultlen)) { continue; } strncpy(buf, result, resultlen); buf[resultlen] = '/0'; free(result); }#endif if (eui64_line(buf, &local_eui64, local_host, sizeof(local_host)) == 0) { if (strcmp(hostname, local_host) == 0) { /* We have a match */ bcopy(&local_eui64, id, sizeof(struct eui64)); fclose(fp); return(0); } } } fclose(fp); return (1);}
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:47,
注:本文中的yp_match函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ yr_arena_write_data函数代码示例 C++ yp_get_default_domain函数代码示例 |