diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2006-11-10 13:08:48 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2006-11-10 13:08:48 +0000 |
commit | b279ad846720add3b262db9e5b10c96390393a44 (patch) | |
tree | 2a25cf3b47982aa448f267ca291927fe7adf15c2 /testnss.c | |
parent | 58a82990fc8284539113f0b4b05002a434eeeb59 (diff) |
implement NSS-side ethers database lookups plus test code
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/libnss_ldapd@79 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'testnss.c')
-rw-r--r-- | testnss.c | 51 |
1 files changed, 51 insertions, 0 deletions
@@ -124,6 +124,15 @@ static void printhost(struct hostent *host) printf(" h_addr_list[%d]=NULL\n",i); } +static void printether(struct etherent *ether) +{ + printf("struct etherent {\n" + " e_name=\"%s\",\n" + " e_addr=%s\n" + "}\n", + ether->e_name,ether_ntoa(&(ether->e_addr))); +} + /* the main program... */ int main(int argc,char *argv[]) { @@ -131,6 +140,7 @@ int main(int argc,char *argv[]) struct aliasent aliasresult; struct group groupresult; struct hostent hostresult; + struct etherent etherresult; char buffer[1024]; enum nss_status res; int errnocp,h_errnocp; @@ -349,5 +359,46 @@ int main(int argc,char *argv[]) res=_nss_ldap_endhostent(); printf("status=%s\n",nssstatus(res)); + /* test ether_hostton() */ + printf("\nTEST ether_hostton()\n"); + res=_nss_ldap_gethostton_r("appelscha",ðerresult,buffer,1024,&errnocp); + printf("status=%s\n",nssstatus(res)); + if (res==NSS_STATUS_SUCCESS) + printether(ðerresult); + else + { + printf("errno=%d:%s\n",(int)errno,strerror(errno)); + printf("errnocp=%d:%s\n",(int)errnocp,strerror(errnocp)); + } + + /* test ether_ntohost() */ + printf("\nTEST ether_ntohost()\n"); + res=_nss_ldap_getntohost_r(ether_aton("0:13:72:a4:39:c7"), + ðerresult,buffer,1024,&errnocp); + printf("status=%s\n",nssstatus(res)); + if (res==NSS_STATUS_SUCCESS) + printether(ðerresult); + else + { + printf("errno=%d:%s\n",(int)errno,strerror(errno)); + printf("errnocp=%d:%s\n",(int)errnocp,strerror(errnocp)); + } + + + /* test {set,get,end}etherent() */ + printf("\nTEST {set,get,end}etherent()\n"); + res=_nss_ldap_setetherent(1); + printf("status=%s\n",nssstatus(res)); + while ((res=_nss_ldap_getetherent_r(ðerresult,buffer,1024,&errnocp))==NSS_STATUS_SUCCESS) + { + printf("status=%s\n",nssstatus(res)); + printether(ðerresult); + } + printf("status=%s\n",nssstatus(res)); + printf("errno=%d:%s\n",(int)errno,strerror(errno)); + printf("errnocp=%d:%s\n",(int)errnocp,strerror(errnocp)); + res=_nss_ldap_endetherent(); + printf("status=%s\n",nssstatus(res)); + return 0; } |