Annotation of 43BSDReno/contrib/isode-beta/others/lookup/lookup.c, revision 1.1.1.1

1.1       root        1: /* lookup.c - password lookup service -- initiator */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/others/lookup/RCS/lookup.c,v 7.1 90/07/01 21:04:26 mrose Exp $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/others/lookup/RCS/lookup.c,v 7.1 90/07/01 21:04:26 mrose Exp $
                      9:  *
                     10:  *
                     11:  * $Log:       lookup.c,v $
                     12:  * Revision 7.1  90/07/01  21:04:26  mrose
                     13:  * pepsy
                     14:  * 
                     15:  * Revision 7.0  89/11/23  22:56:36  mrose
                     16:  * Release 6.0
                     17:  * 
                     18:  */
                     19: 
                     20: /*
                     21:  *                               NOTICE
                     22:  *
                     23:  *    Acquisition, use, and distribution of this module and related
                     24:  *    materials are subject to the restrictions of a license agreement.
                     25:  *    Consult the Preface in the User's Manual for the full terms of
                     26:  *    this agreement.
                     27:  *
                     28:  */
                     29: 
                     30: 
                     31: #include <stdio.h>
                     32: #include "PasswordLookup-types.h"      /* type definitions */
                     33: #include "ryinitiator.h"               /* for generic interctive initiators */
                     34: #include "PasswordLookup-ops.h"                /* operation definitions */
                     35: 
                     36: /*    DATA */
                     37: 
                     38: static char *myservice = "passwdstore";
                     39: 
                     40: static char *mycontext = "isode passwd lookup demo";
                     41: static char *mypci = "isode passwd lookup demo pci";
                     42: 
                     43: 
                     44:                                        /* ARGUMENTS */
                     45: int    do_lookupUser (), do_lookupUID (), do_help (), do_quit ();
                     46: 
                     47:                                        /* RESULTS */
                     48: int    lookup_result ();
                     49: 
                     50:                                        /* ERRORS */
                     51: int    lookup_error ();
                     52: 
                     53: 
                     54: static struct dispatch dispatches[] = {
                     55:     "lookupUser", operation_PasswordLookup_lookupUser,
                     56:     do_lookupUser, &_ZPasswordLookup_mod, _ZUserNamePasswordLookup,
                     57:     lookup_result, lookup_error,
                     58:     "find user by name",
                     59: 
                     60:     "lookupUID", operation_PasswordLookup_lookupUID,
                     61:     do_lookupUID, &_ZPasswordLookup_mod, _ZUserIDPasswordLookup,
                     62:     lookup_result, lookup_error,
                     63:     "find user by id",
                     64: 
                     65:     "help", 0,
                     66:     do_help, (modtyp *) 0, 0,
                     67:     NULLIFP, NULLIFP,
                     68:     "print this information",
                     69: 
                     70:     "quit", 0,
                     71:     do_quit, (modtyp *) 0, 0,
                     72:     NULLIFP, NULLIFP,
                     73:     "terminate the association and exit",
                     74: 
                     75:     NULL
                     76: };
                     77: 
                     78: /*    MAIN */
                     79: 
                     80: /* ARGSUSED */
                     81: 
                     82: main (argc, argv, envp)
                     83: int    argc;
                     84: char  **argv,
                     85:       **envp;
                     86: {
                     87:     (void) ryinitiator (argc, argv, myservice, mycontext, mypci,
                     88:                        table_PasswordLookup_Operations, dispatches, do_quit);
                     89: 
                     90:     exit (0);                  /* NOTREACHED */
                     91: }
                     92: 
                     93: /*    ARGUMENTS */
                     94: 
                     95: /* ARGSUSED */
                     96: 
                     97: static int  do_lookupUser (sd, ds, args, arg)
                     98: int    sd;
                     99: struct dispatch *ds;
                    100: char  **args;
                    101: register struct type_PasswordLookup_UserName **arg;
                    102: {
                    103:     char   *cp;
                    104: 
                    105:     if ((cp = *args++) == NULL) {
                    106:        advise (NULLCP, "usage: lookupUser username");
                    107:        return NOTOK;
                    108:     }
                    109: 
                    110:     if ((*arg = str2qb (cp, strlen (cp), 1)) == NULL)
                    111:            adios (NULLCP, "out of memory");
                    112: 
                    113:     return OK;
                    114: }
                    115: 
                    116: /*  */
                    117: 
                    118: /* ARGSUSED */
                    119: 
                    120: static int  do_lookupUID (sd, ds, args, arg)
                    121: int    sd;
                    122: struct dispatch *ds;
                    123: char  **args;
                    124: register struct type_PasswordLookup_UserID **arg;
                    125: {
                    126:     char   *cp;
                    127: 
                    128:     if ((cp = *args++) == NULL) {
                    129:        advise (NULLCP, "usage: lookupUID userid");
                    130:        return NOTOK;
                    131:     }
                    132: 
                    133:     if ((*arg = (struct type_PasswordLookup_UserID *) calloc (1, sizeof **arg))
                    134:            == NULL)
                    135:        adios (NULLCP, "out of memory");
                    136: 
                    137:     (*arg) -> parm = atoi (cp);
                    138: 
                    139:     return OK;
                    140: }
                    141: 
                    142: /*  */
                    143: 
                    144: /* ARGSUSED */
                    145: 
                    146: static int  do_help (sd, ds, args, dummy)
                    147: int    sd;
                    148: register struct dispatch *ds;
                    149: char  **args;
                    150: caddr_t *dummy;
                    151: {
                    152:     printf ("\nCommands are:\n");
                    153:     for (ds = dispatches; ds -> ds_name; ds++)
                    154:        printf ("%s\t%s\n", ds -> ds_name, ds -> ds_help);
                    155: 
                    156:     return NOTOK;
                    157: }
                    158: 
                    159: /*  */
                    160: 
                    161: /* ARGSUSED */
                    162: 
                    163: static int  do_quit (sd, ds, args, dummy)
                    164: int    sd;
                    165: struct dispatch *ds;
                    166: char  **args;
                    167: caddr_t *dummy;
                    168: {
                    169:     struct AcSAPrelease acrs;
                    170:     register struct AcSAPrelease   *acr = &acrs;
                    171:     struct AcSAPindication  acis;
                    172:     register struct AcSAPindication *aci = &acis;
                    173:     register struct AcSAPabort *aca = &aci -> aci_abort;
                    174: 
                    175:     if (AcRelRequest (sd, ACF_NORMAL, NULLPEP, 0, NOTOK, acr, aci) == NOTOK)
                    176:        acs_adios (aca, "A-RELEASE.REQUEST");
                    177: 
                    178:     if (!acr -> acr_affirmative) {
                    179:        (void) AcUAbortRequest (sd, NULLPEP, 0, aci);
                    180:        adios (NULLCP, "release rejected by peer: %d", acr -> acr_reason);
                    181:     }
                    182: 
                    183:     ACRFREE (acr);
                    184: 
                    185:     exit (0);
                    186: }
                    187: 
                    188: /*    RESULTS */
                    189: 
                    190: /* ARGSUSED */
                    191: 
                    192: static int  lookup_result (sd, id, dummy, result, roi)
                    193: int    sd,
                    194:        id,
                    195:        dummy;
                    196: register struct type_PasswordLookup_Passwd *result;
                    197: struct RoSAPindication *roi;
                    198: {
                    199:     print_qb (result -> name);
                    200:     putchar (':');
                    201:     print_qb (result -> passwd);
                    202:     printf (":%d:%d:", result -> uid -> parm, result -> gid -> parm);
                    203:     print_qb (result -> gecos);
                    204:     putchar (':');
                    205:     print_qb (result -> dir);
                    206:     putchar (':');
                    207:     print_qb (result -> shell);
                    208:     putchar ('\n');
                    209: 
                    210:     return OK;
                    211: }
                    212: 
                    213: 
                    214: static print_qb (q)
                    215: register struct qbuf *q;
                    216: {
                    217:     register struct qbuf *p;
                    218: 
                    219:     if (q == NULL)
                    220:        return;
                    221: 
                    222:     for (p = q -> qb_forw; p != q; p = p -> qb_forw)
                    223:        printf ("%*.*s", p -> qb_len, p -> qb_len, p -> qb_data);
                    224: }
                    225: 
                    226: /*    ERRORS */
                    227: 
                    228: /* ARGSUSED */
                    229: 
                    230: static int  lookup_error (sd, id, error, parameter, roi)
                    231: int    sd,
                    232:        id,
                    233:        error;
                    234: caddr_t parameter;
                    235: struct RoSAPindication *roi;
                    236: {    
                    237:     register struct RyError *rye;
                    238: 
                    239:     if (error == RY_REJECT) {
                    240:        advise (NULLCP, "%s", RoErrString ((int) parameter));
                    241:        return OK;
                    242:     }
                    243: 
                    244:     if (rye = finderrbyerr (table_PasswordLookup_Errors, error))
                    245:        advise (NULLCP, "%s",  rye -> rye_name);
                    246:     else
                    247:        advise (NULLCP, "Error %d", error);
                    248: 
                    249:     return OK;
                    250: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.