source: trunk/kitgen/starfish-noyp.patch@ 182

Last change on this file since 182 was 175, checked in by demin, 12 years ago

initial commit

File size: 5.1 KB
  • starfishCmd.c

    diff -pruN starfish/starfishCmd.c starfish-patched/starfishCmd.c
    old new  
    5353
    5454#include "starfishInt.h"
    5555
    56 #if defined(sun) && defined (__SVR4)
    57 #include <rpc/rpcent.h>
    58 #else
    59 #include <rpc/rpc.h>
    60 #endif
    61 
    62 #if defined(__OpenBSD__)
    63 #include <rpcsvc/ypclnt.h>
    64 #endif
    65 
    66 #include <rpcsvc/yp_prot.h>
    67 
    6856#include <sys/ioctl.h>
    6957#include <netinet/in.h>
    7058#include <net/if.h>
    7159
    7260#define KEEPALIVE       1
    7361
    74 #define YP_SUCC         0
    75 #define YP_FAIL         1
    76 
    7762#define SYS_ERROR       -1
    7863
    7964#define BUFLEN          256
    static int Starfish_NetdbMap  
    115100  char *cmd, char *subcmd));
    116101
    117102/************************************************************************/
    118 /* Support functions.                                                   */
    119 /************************************************************************/
    120 
    121 static int Callback(int status, char *key, int keylen, char *val, int vallen,
    122   char *data)
    123   {
    124     Tcl_Interp *interp = (Tcl_Interp *) data;
    125 
    126     switch (status)
    127       {
    128         case YP_TRUE:
    129           key[keylen] = 0;
    130           val[vallen] = 0;
    131           Tcl_AppendResult(interp, "{", key, " ", val, "}", (char *) NULL);
    132           return YP_SUCC;
    133           break;
    134         case YP_NOMORE:
    135           break;
    136         default:
    137           Tcl_AppendResult(interp, "cannot lookup NIS map", (char *) NULL);
    138           break;
    139       }
    140 
    141     return YP_FAIL;
    142   }
    143 
    144 /************************************************************************/
    145103/* Subcommand functions.                                                */
    146104/************************************************************************/
    147105
    Starfish_NetdbIp(Tcl_Interp *interp, int  
    860818    return TCL_ERROR;
    861819}
    862820
    863 /*
    864  *----------------------------------------------------------------------
    865  *
    866  * Starfish_NetdbMap --
    867  *
    868  *      This procedure is invoked to process the default case of the
    869  *      "netdb" command.
    870  *      See the user documentation for details on what it does.
    871  *
    872  * Results:
    873  *      A standard Tcl result.
    874  *
    875  * Side effects:
    876  *      See the user documentation.
    877  *
    878  *----------------------------------------------------------------------
    879  */
    880 
    881 static int
    882 Starfish_NetdbMap(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[],
    883   char *cmd, char *subcmd)
    884 {
    885     struct ypall_callback obj;
    886     char *self, *domain, *map, *key, *val;
    887     int result, keylen, vallen;
    888 
    889     /*
    890      * Process the default "netdb" command option:
    891      */
    892 
    893     result = yp_get_default_domain(&domain);
    894 
    895     if (result != YP_SUCC) {
    896         Tcl_AppendResult(interp, "NIS domain not set", (char *) NULL);
    897         return TCL_ERROR;
    898     }
    899 
    900     switch (objc)
    901       {
    902         case 2:
    903           map           = Tcl_GetString(objv[1]);
    904 
    905           obj.foreach   = Callback;
    906           obj.data      = (char *) interp;
    907 
    908           result = yp_all(domain, map, &obj);
    909 
    910           if (result != YP_SUCC)
    911             {
    912               Tcl_AppendResult(interp,
    913                                "cannot lookup NIS map \"", map, "\"",
    914                                (char *) NULL);
    915               return TCL_ERROR;
    916             }
    917 
    918           return TCL_OK;
    919           break;
    920 
    921         case 3:
    922           map           = Tcl_GetString(objv[1]);
    923           key           = Tcl_GetString(objv[2]);
    924 
    925           result = yp_match(domain, map, key, strlen(key), &val, &vallen);
    926 
    927           if (result != YP_SUCC)
    928             {
    929               Tcl_AppendResult(interp,
    930                                "cannot match NIS map \"", map, "\"",
    931                                (char *) NULL);
    932               return TCL_ERROR;
    933             }
    934 
    935           val[vallen] = 0;
    936           Tcl_AppendResult(interp, val, (char *) NULL);
    937           return TCL_OK;
    938           break;
    939 
    940         default:
    941           Tcl_AppendResult(interp, "wrong # args: should be \"",
    942             cmd, " map ?key?\"", (char *) NULL);
    943           return TCL_ERROR;
    944           break;
    945       }
    946 }
    947 
    948821/************************************************************************/
    949822/* Entry points.                                                        */
    950823/************************************************************************/
    Starfish_NetdbCmd(ClientData clientData,  
    995868    } else if (strcmp(subcmd, "ip")             == 0) {
    996869        result = Starfish_NetdbIp(interp, objc, objv, cmd, subcmd);
    997870    } else {
    998         result = Starfish_NetdbMap(interp, objc, objv, cmd, subcmd);
     871          Tcl_AppendResult(interp, "wrong # args: should be \"",
     872                cmd, " map ?key?\"", (char *) NULL);
     873        result = TCL_ERROR;
    999874    }
    1000875
    1001876#ifdef TCL_THREADS
  • starfishInit.c

    diff -pruN starfish/starfishInit.c starfish-patched/starfishInit.c
    old new Starfish_Init(Tcl_Interp *interp)  
    8686    }
    8787#endif
    8888
    89 #ifdef STARFISH_FORCE_PACKAGE
    90     /* Ordinarily we are loaded as part of an enclosing package definition.
    91     */
    9289    result = Tcl_PkgProvide(interp, STARFISH_PACKAGE, STARFISH_VERSION);
    9390    if (result != TCL_OK) {
    9491        return result;
    9592    }
    96 #endif
    9793
    9894    Starfish_Limit();
    9995    Starfish_InitSafeCmds(interp);
    Starfish_SafeInit(Tcl_Interp *interp)  
    115111  {
    116112    int result;
    117113
    118 #ifdef STARFISH_FORCE_PACKAGE
    119     /* Ordinarily we are loaded as part of an enclosing package definition.
    120     */
    121114    result = Tcl_PkgProvide(interp, STARFISH_PACKAGE, STARFISH_VERSION);
    122115    if (result != TCL_OK) {
    123116        return result;
    124117    }
    125 #endif
    126118
    127119    Starfish_Limit();
    128120    Starfish_InitSafeCmds(interp);
Note: See TracBrowser for help on using the repository browser.