#include #include #define DOMAINNAME "cs-snuent" #define YPMAP "passwd.byname" #pragma ident "ypfirst.c 10/29/06 CAM" /* * ypfirst.c * * Working yp_first() example. * */ int main( int argc, char **argv ) { char **outkey; int *outkey_len; char **outval; int *outval_len; int yp_first_ret; outkey = (char**) malloc(sizeof(char*)); /* Allocate */ (void) memset((void *)outkey, 0, sizeof(char*)); /* Initalize */ outval = (char**) malloc(sizeof(char*)); /* Allocate */ (void) memset((void *)outval, 0, sizeof(char*)); /* Initalize */ if( (yp_first_ret = yp_first( DOMAINNAME, YPMAP, outkey, outkey_len, outval, outval_len ) ) != 0 ) { printf("Problem: yp_first returned nonzero. (%s)\n", yp_first_ret); } printf("'%s'='%s'", *outkey, *outval); /*N.B. appears both strings are terminated with '\n'.*/ (void) free((void *)outkey); (void) free((void *)outval); return 0; }