"Fossies" - the Fresh Open Source Software Archive

Member "nss_ldap-265/tests/ldaptest.pl" (6 Nov 2009, 2294 Bytes) of package /linux/privat/old/nss_ldap-265.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 
    3 #
    4 # $Header: /home/project/cvs/nss_ldap/tests/ldaptest.pl,v 1.2 2001/01/09 00:21:21 lukeh Exp $
    5 #
    6 
    7 
    8 sub printarr {
    9   foreach (@_) {
   10     print $_." ";
   11   }
   12   print "\n";
   13 }
   14 sub printhost {
   15   foreach (@_) {
   16     if ($_ !~ /^[\w\.\d]+$/) {
   17       @addr = unpack('C4',$_);
   18       print $addr[0].".".$addr[1].".".$addr[2].".".$addr[3]." ";
   19     } else {
   20       print $_." ";
   21     }
   22   }
   23   print "\n";
   24 }
   25 
   26 
   27 print "*** getpwnam ***\n";
   28 printarr(getpwnam("root"));
   29 print "*** getpwuid ***\n";
   30 printarr(getpwuid(0));
   31 print "*** setpwent ***\n";
   32 setpwent();
   33 print "*** getpwent ***\n";
   34 while(@ent = getpwent()) {
   35   printarr(@ent);
   36 }
   37 print "*** endpwent ***\n";
   38 endpwent();
   39 print "*** getgrnam ***\n";
   40 printarr(getgrnam("wheel"));
   41 print "*** getgrgid ***\n";
   42 printarr(getgrgid(10));
   43 print "*** setgrent ***\n";
   44 setgrent();
   45 print "*** getgrent ***\n";
   46 while(@ent = getgrent()) {
   47   printarr(@ent);
   48 }
   49 print "*** endgrent ***\n";
   50 endgrent();
   51 print "*** gethostbyname ***\n";
   52 printhost(gethostbyname("localhost"));
   53 print "*** gethostbyaddr ***\n";
   54 printhost(gethostbyaddr(pack(C4,(127,0,0,1)),2));
   55 print "*** sethostent ***\n";
   56 sethostent(0);
   57 print "*** gethostent ***\n";
   58 while(@ent = gethostent()) {
   59   printhost(@ent);
   60 }
   61 print "*** endhostent ***\n";
   62 endhostent();
   63 # I dont appear to have networks. but we'll try anyway.
   64 print "*** getnetbyname ***\n";
   65 printhost(getnetbyname("localnet"));
   66 print "*** getnetbyaddr ***\n";
   67 # this may not be the right call. who uses 'networks' anyways!?
   68 printhost(getnetbyaddr(127,2));
   69 print "*** setnetent ***\n";
   70 setnetent(0);
   71 print "*** getnetent ***\n";
   72 while(@ent = getnetent()) {
   73   printhost(@ent);
   74 }
   75 print "*** endnetent ***\n";
   76 endnetent();
   77 print "*** getservbyname ***\n";
   78 printarr(getservbyname("telnet","tcp"));
   79 print "*** getservbyport ***\n";
   80 printarr(getservbyport(23,"tcp"));
   81 print "*** setservent ***\n";
   82 setservent(0);
   83 print "*** getservent ***\n";
   84 while(@ent = getservent()) {
   85   printarr(@ent);
   86 }
   87 print "*** endservent ***\n";
   88 endservent();
   89 print "*** getprotobyname ***\n";
   90 printarr(getprotobyname("icmp"));
   91 print "*** getprotobynumber ***\n";
   92 printarr(getprotobynumber(1));
   93 print "*** setprotoent ***\n";
   94 setprotoent(0);
   95 print "*** getprotoent ***\n";
   96 while(@ent = getprotoent()) {
   97   printarr(@ent);
   98 }
   99 print "*** endprotoent ***\n";
  100 endprotoent();
  101