diff --git a/src/modules/Yp/yp.c b/src/modules/Yp/yp.c index 4be807b0a691c63f8d822e430e8dd47f14543f40..d62d40cedd18695625cd94b9a81a9ca12ce6fc20 100644 --- a/src/modules/Yp/yp.c +++ b/src/modules/Yp/yp.c @@ -28,9 +28,10 @@ #include "builtin_functions.h" #include "module_support.h" -RCSID("$Id: yp.c,v 1.12 1998/03/28 14:32:57 grubba Exp $"); +RCSID("$Id: yp.c,v 1.13 1998/05/23 12:47:11 grubba Exp $"); -#define YPERROR(fun,err) do{if(err)error("yp->%s(): %s\n", (fun), yperr_string( err ));}while(0) +#define YPERROR(fun,err) do{ if(err) error("yp->%s(): %s\n", (fun), \ + yperr_string(err)); }while(0) struct my_yp_domain { @@ -44,9 +45,12 @@ static void f_default_yp_domain(INT32 args) { int err; char *ret; - pop_n_elems( args ); + err = yp_get_default_domain(&ret); - YPERROR( "dafult_yp_domain", err ); + + YPERROR( "default_yp_domain", err ); + + pop_n_elems( args ); push_text( ret ); } @@ -54,9 +58,12 @@ static void f_server(INT32 args) { int err; char *ret; + err = yp_master(this->domain, sp[-1].u.string->str, &ret); - pop_n_elems( args ); + YPERROR( "server", err ); + + pop_n_elems( args ); push_text( ret ); } @@ -77,7 +84,10 @@ static void f_create(INT32 args) } this->domain = strdup( sp[-args].u.string->str ); err = yp_bind( this->domain ); + YPERROR("create", err); + + pop_n_elems(args); } static void f_all(INT32 args) @@ -104,13 +114,14 @@ static void f_all(INT32 args) num++; } while(!err); - pop_n_elems(args); if(err != YPERR_NOMORE) { free_mapping( res_map ); YPERROR( "all", err ); } + this->last_size = num; + pop_n_elems(args); push_mapping( res_map ); } @@ -137,19 +148,23 @@ void f_map(INT32 args) &retkey, &retkeylen, &retval, &retlen); } while(!err); - pop_n_elems(args); if(err != YPERR_NOMORE) YPERROR( "all", err ); + + pop_n_elems(args); } static void f_order(INT32 args) { int err; unsigned long ret; + check_all_args("yp->order", args, BIT_STRING, 0); err = yp_order( this->domain, sp[-args].u.string->str, &ret); + YPERROR("order", err ); + pop_n_elems( args ); push_int( (INT32) ret ); } @@ -166,15 +181,17 @@ static void f_match(INT32 args) sp[-args+1].u.string->str, sp[-args+1].u.string->len, &retval, &retlen ); - pop_n_elems( args ); if(err == YPERR_KEY) { + pop_n_elems( args ); push_int(0); sp[-1].subtype = NUMBER_UNDEFINED; return; } YPERROR( "match", err ); + + pop_n_elems( args ); push_string(make_shared_binary_string( retval, retlen )); }