Annotation of 43BSDReno/contrib/isode-beta/quipu/service.c, revision 1.1.1.1

1.1       root        1: /* service.c - */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/quipu/RCS/service.c,v 7.1 90/03/15 11:19:10 mrose Exp $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/quipu/RCS/service.c,v 7.1 90/03/15 11:19:10 mrose Exp $
                      9:  *
                     10:  *
                     11:  * $Log:       service.c,v $
                     12:  * Revision 7.1  90/03/15  11:19:10  mrose
                     13:  * quipu-sync
                     14:  * 
                     15:  * Revision 7.0  89/11/23  22:18:06  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 "quipu/util.h"
                     32: #include "quipu/commonarg.h"
                     33: #include "quipu/dua.h"
                     34: #include "quipu/sequence.h"
                     35: 
                     36: #define MAXSERV 20
                     37: static char default_service [BUFSIZ] = { 0 };
                     38: static char * serv_vec [MAXSERV];
                     39: static int  serv_argc;
                     40: static int default_serv_set = 0;
                     41: extern DN user_name;
                     42: extern int chase_flag;
                     43: static char do_shuffle;
                     44: int    copy_flag;
                     45: extern struct certificate *my_certificate;
                     46: char * result_sequence = NULLCP;
                     47: struct dua_sequence * current_sequence = NULL_DS;
                     48: struct dua_sequence * top_sequence = NULL_DS;
                     49: 
                     50: 
                     51: set_default_service (opt)
                     52: PS opt;
                     53: {
                     54:        if (default_service [0] == 0) {
                     55:                serv_argc = 0;
                     56:                return (OK);
                     57:        }
                     58: 
                     59:        if ((serv_argc = sstr2arg (default_service, MAXSERV, serv_vec, " \t")) == -1) {
                     60:                ps_print (opt,"Invalid default service controls");
                     61:                return (NOTOK);
                     62:        } else {
                     63:                default_serv_set = 1;
                     64:                return (OK);
                     65:        }
                     66: }
                     67: 
                     68: int get_default_service (ca)
                     69: CommonArgs * ca;
                     70: {
                     71: PS opt;
                     72: char buffer [LINESIZE];
                     73: extern int sizelimit;
                     74: extern int timelimit;
                     75: static CommonArgs sca = default_common_args;
                     76: 
                     77:        *ca = sca;  /* struct copy */
                     78:        ca->ca_servicecontrol.svc_sizelimit = sizelimit;
                     79:        ca->ca_servicecontrol.svc_timelimit = timelimit;
                     80:        
                     81:        if ((opt = ps_alloc (str_open)) == NULLPS) {
                     82:                (void) fprintf (stderr,"ps_alloc error\n");
                     83:                return (NOTOK);
                     84:        }
                     85:                
                     86:        if (str_setup (opt, buffer, LINESIZE, 1) == NOTOK) {
                     87:                (void) fprintf (stderr,"ps_setup error\n");
                     88:                return (NOTOK);
                     89:        }
                     90: 
                     91:        if (! default_serv_set)
                     92:                if (set_default_service (opt) != OK) {
                     93:                        (void) fprintf (stderr,"error (1) - %s\n",buffer);
                     94:                        ps_free (opt);
                     95:                        return (NOTOK);
                     96: 
                     97:                }
                     98: 
                     99:        do_shuffle = FALSE;
                    100: 
                    101:        if (do_service_control (opt,serv_argc, serv_vec, ca) < 0) {
                    102:                (void) fprintf (stderr,"error (2) - %s\n",buffer);
                    103:                ps_free (opt);
                    104:                return (NOTOK);
                    105:        }
                    106: 
                    107:        ps_free (opt);
                    108:        return (OK);
                    109:        
                    110: }
                    111: 
                    112: int service_control (opt,argc, argv, ca)
                    113: PS             opt;
                    114: int             argc;
                    115: char          **argv;
                    116: CommonArgs     *ca;
                    117: {
                    118: 
                    119:        if (get_default_service (ca) != OK) {
                    120:                ps_print (opt,"default service error - check quipurc\n");
                    121:                return (-1);
                    122:        }
                    123:        do_shuffle = TRUE;
                    124:        return (do_service_control (opt,argc, argv, ca));
                    125: }
                    126: 
                    127: int do_service_control (opt,argc, argv, ca)
                    128: PS             opt;
                    129: int             argc;
                    130: char          **argv;
                    131: CommonArgs     *ca;
                    132: {
                    133: 
                    134:        ServiceControl  *sc;
                    135:        int             shuffle_up ();
                    136:        int             x;
                    137:        char            shuffle;
                    138: 
                    139:        sc = &(ca->ca_servicecontrol);
                    140:        copy_flag = TRUE;
                    141: 
                    142:        for (x = 0; x < argc; x++) {
                    143:                shuffle = do_shuffle;
                    144:                
                    145:                if (test_arg (argv[x], "-preferchain",3)) 
                    146:                        sc->svc_options |= SVC_OPT_PREFERCHAIN;
                    147:                else if (test_arg (argv[x], "-nopreferchain",5)) 
                    148:                        sc->svc_options &= ~SVC_OPT_PREFERCHAIN;
                    149:                        
                    150:                else if (test_arg (argv[x], "-localscope",3)) 
                    151:                        sc->svc_options |= SVC_OPT_LOCALSCOPE;
                    152:                else if (test_arg (argv[x], "-nolocalscope",3)) 
                    153:                        sc->svc_options &= (~SVC_OPT_LOCALSCOPE);
                    154:                        
                    155:                else if (test_arg (argv[x], "-dontusecopy",5)) {
                    156:                        copy_flag = FALSE;
                    157:                        sc->svc_options |= SVC_OPT_DONTUSECOPY;
                    158:                } else if (test_arg (argv[x], "-usecopy",1)) {
                    159:                        copy_flag = TRUE;
                    160:                        sc->svc_options &= (~SVC_OPT_DONTUSECOPY);
                    161:                }
                    162: 
                    163:                else if (test_arg (argv[x], "-dontdereferencealias",5)) 
                    164:                        sc->svc_options |= SVC_OPT_DONTDEREFERENCEALIAS;
                    165:                else if (test_arg (argv[x], "-dereferencealias",3)) 
                    166:                        sc->svc_options &= (~SVC_OPT_DONTDEREFERENCEALIAS);
                    167: 
                    168:                else if (test_arg (argv[x], "-low",3)) 
                    169:                        sc->svc_prio = SVC_PRIO_LOW;
                    170:                else if (test_arg (argv[x], "-medium",2)) 
                    171:                        sc->svc_prio = SVC_PRIO_MED;
                    172:                else if (test_arg (argv[x], "-high",1)) 
                    173:                        sc->svc_prio = SVC_PRIO_HIGH;
                    174:                        
                    175:                else if (test_arg (argv[x], "-timelimit",2)) {
                    176:                        if (x + 1 == argc) {    
                    177:                                ps_printf (opt, "We need a number for timelimit.\n");
                    178:                                return (-1);
                    179:                        } else {
                    180:                                if (shuffle)
                    181:                                        shuffle_up (argc--, argv, x);
                    182:                                else
                    183:                                        x++;
                    184: 
                    185:                                if ((sc->svc_timelimit = atoi (argv[x])) < -1) {
                    186:                                        ps_printf (opt, "We need a posative number for timelimit.\n");
                    187:                                        return (-1);
                    188:                                }
                    189:                        }
                    190:                } else if (test_arg (argv[x], "-notimelimit",4)) 
                    191:                        sc->svc_timelimit = -1;
                    192:                        
                    193:                else if (test_arg (argv[x], "-sizelimit",3)) {
                    194:                        if (x + 1 == argc) {
                    195:                                ps_printf (opt, "We need a number for sizelimit.\n");
                    196:                                return (-1);
                    197:                        } else {
                    198:                                if (shuffle)
                    199:                                        shuffle_up (argc--, argv, x);
                    200:                                else
                    201:                                        x++;
                    202: 
                    203:                                if ((sc->svc_sizelimit = atoi (argv[x])) < -1) {
                    204:                                        ps_printf (opt, "We need a posative number for sizelimit.\n");
                    205:                                        return (-1);
                    206:                                }
                    207:                        }
                    208:                } else if (test_arg (argv[x], "-nosizelimit",4)) 
                    209:                        sc->svc_sizelimit = -1;
                    210:                        
                    211:                else if (test_arg (argv[x], "-nochaining",4)) 
                    212:                        sc->svc_options |= SVC_OPT_CHAININGPROHIBIT;
                    213:                else if (test_arg (argv[x], "-chaining",3)) 
                    214:                        sc->svc_options &= (~SVC_OPT_CHAININGPROHIBIT);
                    215:                        
                    216:                else if (test_arg (argv[x], "-norefer",5)) 
                    217:                        chase_flag = 1;
                    218:                else if (test_arg (argv[x], "-refer",3)) 
                    219:                        chase_flag = 2;
                    220: 
                    221:                else if (test_arg(argv[x], "-strong", 3)) {
                    222:                        char *new_version();
                    223:                        struct certificate *cert_cpy();
                    224: 
                    225:                        ca->ca_security = (struct security_parms *)
                    226:                                calloc(1, sizeof(struct security_parms));
                    227:                        ca->ca_security->sp_name = NULLDN;
                    228:                        ca->ca_security->sp_time = new_version();
                    229:                        ca->ca_security->sp_target = '\0';
                    230:                        if (my_certificate != (struct certificate *) 0) {
                    231:                          ca->ca_security->sp_path =
                    232:                                (struct certificate_list *) 
                    233:                                   calloc(1, sizeof(struct certificate_list));
                    234:                          if (ca->ca_security->sp_path != 
                    235:                                (struct certificate_list *) 0) {
                    236:                            ca->ca_security->sp_path->next =
                    237:                                   (struct certificate_list *) 0;
                    238:                            ca->ca_security->sp_path->superior =
                    239:                                   (struct certificate_list *) 0;
                    240:                            ca->ca_security->sp_path->cert =
                    241:                                   cert_cpy(my_certificate);
                    242:                            ca->ca_security->sp_path->reverse =
                    243:                                   (struct certificate *) 0;
                    244:                            }
                    245:                          }
                    246:                        }
                    247: 
                    248:                else if (test_arg (argv[x], "-sequence",3)) {
                    249:                        if (x + 1 == argc) {    
                    250:                                ps_printf (opt, "We need a sequence name.\n");
                    251:                                return (-1);
                    252:                        } else {
                    253:                                if (shuffle)
                    254:                                        shuffle_up (argc--, argv, x);
                    255:                                else
                    256:                                        x++;
                    257:                                if (lexequ (argv[x],"result") == 0) {
                    258:                                        if (x + 1 == argc) {    
                    259:                                                ps_printf (opt, "We need a result sequence name.\n");
                    260:                                                return (-1);
                    261:                                        }
                    262:                                        if (shuffle)
                    263:                                                shuffle_up (argc--, argv, x);
                    264:                                        else
                    265:                                                x++;
                    266:                                        result_sequence = strdup (argv[x]);
                    267:                                } else
                    268:                                        set_sequence (argv[x]);
                    269:                        }
                    270:                } else if (test_arg (argv[x], "-nosequence",5)) 
                    271:                        unset_sequence();
                    272: 
                    273:                else if (do_shuffle)
                    274:                        shuffle = FALSE;
                    275:                else {
                    276:                        ps_printf (opt,"unknown service option %s\n",argv[x]);
                    277:                        return (-1);
                    278:                }
                    279: 
                    280:                if (shuffle) 
                    281:                        shuffle_up (argc--, argv, x--);
                    282:        }
                    283: 
                    284:        return (argc);
                    285: }
                    286: 
                    287: shuffle_up (argc, argv, start)
                    288: register int    argc;
                    289: char          **argv;
                    290: register int    start;
                    291: {
                    292:        register int    x;
                    293: 
                    294:        for (x = start; x < argc; x++)
                    295:                if (x == argc - 1)      /* if it is the last one, then stick
                    296:                                         * a 0 in */
                    297:                        argv[x] = 0;
                    298:                else            /* oterwise put the next one in it's place. */
                    299:                        argv[x] = argv[x + 1];
                    300: }
                    301: 
                    302: new_service (ptr)
                    303: char * ptr;
                    304: {
                    305: 
                    306:        if (ptr != 0) {
                    307:                if (*default_service != 0)
                    308:                        (void) strcat (default_service," ");
                    309:                (void) strcat (default_service,ptr);
                    310:        }
                    311: }
                    312: 
                    313: set_sequence (str)
                    314: char * str;
                    315: {
                    316: struct dua_sequence *ptr;
                    317: 
                    318:        if (lexequ (str,"reset") == 0) {
                    319:                 if (current_sequence == NULL_DS)
                    320:                         return;
                    321:                 current_sequence->ds_data = NULL_DE;
                    322:                 current_sequence->ds_last = NULL_DE;
                    323:                return;
                    324:        }
                    325: 
                    326:        for (ptr = top_sequence; ptr != NULL_DS; ptr=ptr->ds_next)
                    327:                if (lexequ (ptr->ds_name,str) == 0) {
                    328:                        current_sequence = ptr;
                    329:                        return;
                    330:                }
                    331: 
                    332:        ptr = ds_alloc();
                    333:        ptr->ds_name = strdup (str);
                    334:        ptr->ds_data = NULL_DE;
                    335:        ptr->ds_last = NULL_DE;
                    336:        ptr->ds_next = top_sequence;
                    337:        top_sequence = ptr;
                    338:        current_sequence = ptr;
                    339: }
                    340: 
                    341: unset_sequence ()
                    342: {
                    343:        current_sequence = NULL_DS;
                    344: }
                    345: 
                    346: add_sequence (adn)
                    347: DN adn;
                    348: {
                    349: struct dua_seq_entry * ptr;
                    350: register int x=1;
                    351: 
                    352:        if (current_sequence == NULL_DS)
                    353:                return (0);
                    354:        
                    355:        for (ptr=current_sequence->ds_data; ptr != NULL_DE; ptr=ptr->de_next,x++) 
                    356:                if (dn_cmp (adn,ptr->de_name) == 0)
                    357:                        return (x);
                    358: 
                    359:        ptr = de_alloc();
                    360:        ptr->de_name = dn_cpy (adn);
                    361:        ptr->de_next = NULL_DE;
                    362:        if (current_sequence->ds_data == NULL_DE) 
                    363:                current_sequence->ds_data = ptr;
                    364:        else
                    365:                current_sequence->ds_last->de_next = ptr;
                    366:        current_sequence->ds_last = ptr;
                    367:                
                    368:        return (x);
                    369: }
                    370: 
                    371: DN sequence_dn(y)
                    372: int y;
                    373: {
                    374: struct dua_seq_entry * ptr;
                    375: register int x = 1;
                    376: 
                    377:        if (current_sequence == NULL_DS)
                    378:                return (NULLDN);
                    379: 
                    380:        for (ptr=current_sequence->ds_data; 
                    381:                (ptr != NULL_DE) && (x<y); 
                    382:                ptr=ptr->de_next,x++) 
                    383:                        ;               
                    384: 
                    385:        if (ptr == NULL_DE)
                    386:                return (NULLDN);
                    387:        if ( x == y )
                    388:                return (ptr->de_name);
                    389:        return (NULLDN);
                    390:                        
                    391: }
                    392: 
                    393: 
                    394: show_sequence (RPS,str)
                    395: PS RPS;
                    396: char * str;
                    397: {
                    398: struct dua_seq_entry * ptr;
                    399: register int x = 1;
                    400: 
                    401:        if (str != NULLCP)
                    402:                set_sequence (str);
                    403: 
                    404:        if (current_sequence == NULL_DS) {
                    405:                ps_print (RPS,"No sequence set!\n");
                    406:                return;
                    407:        }
                    408: 
                    409:        if (strcmp (current_sequence -> ds_name, "default"))
                    410:            ps_printf (RPS,"Sequence %s contains:-\n",
                    411:                       current_sequence->ds_name);
                    412: 
                    413:        for (ptr=current_sequence->ds_data; ptr != NULL_DE; ptr=ptr->de_next, x++) {
                    414:                ps_printf (RPS,"%-3d @",x);
                    415:                dn_print (RPS,ptr->de_name,EDBOUT);
                    416:                ps_print (RPS,"\n");
                    417:        }
                    418: }
                    419: 

unix.superglobalmegacorp.com

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