1*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 2*7c478bd9Sstevel@tonic-gate 3*7c478bd9Sstevel@tonic-gate /* 4*7c478bd9Sstevel@tonic-gate * Copyright 1987, 1988 by MIT Student Information Processing Board 5*7c478bd9Sstevel@tonic-gate * 6*7c478bd9Sstevel@tonic-gate * For copyright information, see copyright.h. 7*7c478bd9Sstevel@tonic-gate */ 8*7c478bd9Sstevel@tonic-gate #include "ss_internal.h" 9*7c478bd9Sstevel@tonic-gate #include "copyright.h" 10*7c478bd9Sstevel@tonic-gate #define size sizeof(ss_data *) 11*7c478bd9Sstevel@tonic-gate 12*7c478bd9Sstevel@tonic-gate 13*7c478bd9Sstevel@tonic-gate int ss_create_invocation(subsystem_name, version_string, info_ptr, 14*7c478bd9Sstevel@tonic-gate request_table_ptr, code_ptr) 15*7c478bd9Sstevel@tonic-gate char *subsystem_name, *version_string; 16*7c478bd9Sstevel@tonic-gate char *info_ptr; 17*7c478bd9Sstevel@tonic-gate ss_request_table *request_table_ptr; 18*7c478bd9Sstevel@tonic-gate int *code_ptr; 19*7c478bd9Sstevel@tonic-gate { 20*7c478bd9Sstevel@tonic-gate register int sci_idx; 21*7c478bd9Sstevel@tonic-gate register ss_data *new_table; 22*7c478bd9Sstevel@tonic-gate register ss_data **table; 23*7c478bd9Sstevel@tonic-gate 24*7c478bd9Sstevel@tonic-gate *code_ptr = 0; 25*7c478bd9Sstevel@tonic-gate table = _ss_table; 26*7c478bd9Sstevel@tonic-gate new_table = (ss_data *) malloc(sizeof(ss_data)); 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate if (table == (ss_data **) NULL) { 29*7c478bd9Sstevel@tonic-gate table = (ss_data **) malloc(2 * size); 30*7c478bd9Sstevel@tonic-gate table[0] = table[1] = (ss_data *)NULL; 31*7c478bd9Sstevel@tonic-gate } 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate for (sci_idx = 1; table[sci_idx] != (ss_data *)NULL; sci_idx++) 34*7c478bd9Sstevel@tonic-gate ; 35*7c478bd9Sstevel@tonic-gate table = (ss_data **) realloc((char *)table, 36*7c478bd9Sstevel@tonic-gate ((unsigned)sci_idx+2)*size); 37*7c478bd9Sstevel@tonic-gate table[sci_idx+1] = (ss_data *) NULL; 38*7c478bd9Sstevel@tonic-gate table[sci_idx] = new_table; 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate new_table->subsystem_name = subsystem_name; 41*7c478bd9Sstevel@tonic-gate new_table->subsystem_version = version_string; 42*7c478bd9Sstevel@tonic-gate new_table->argv = (char **)NULL; 43*7c478bd9Sstevel@tonic-gate new_table->current_request = (char *)NULL; 44*7c478bd9Sstevel@tonic-gate new_table->info_dirs = (char **)malloc(sizeof(char *)); 45*7c478bd9Sstevel@tonic-gate *new_table->info_dirs = (char *)NULL; 46*7c478bd9Sstevel@tonic-gate new_table->info_ptr = info_ptr; 47*7c478bd9Sstevel@tonic-gate new_table->prompt = malloc((unsigned)strlen(subsystem_name)+4); 48*7c478bd9Sstevel@tonic-gate strcpy(new_table->prompt, subsystem_name); 49*7c478bd9Sstevel@tonic-gate strcat(new_table->prompt, ": "); 50*7c478bd9Sstevel@tonic-gate #ifdef silly 51*7c478bd9Sstevel@tonic-gate new_table->abbrev_info = ss_abbrev_initialize("/etc/passwd", code_ptr); 52*7c478bd9Sstevel@tonic-gate #else 53*7c478bd9Sstevel@tonic-gate new_table->abbrev_info = NULL; 54*7c478bd9Sstevel@tonic-gate #endif 55*7c478bd9Sstevel@tonic-gate new_table->flags.escape_disabled = 0; 56*7c478bd9Sstevel@tonic-gate new_table->flags.abbrevs_disabled = 0; 57*7c478bd9Sstevel@tonic-gate new_table->rqt_tables = 58*7c478bd9Sstevel@tonic-gate (ss_request_table **) calloc(2, sizeof(ss_request_table *)); 59*7c478bd9Sstevel@tonic-gate *(new_table->rqt_tables) = request_table_ptr; 60*7c478bd9Sstevel@tonic-gate *(new_table->rqt_tables+1) = (ss_request_table *) NULL; 61*7c478bd9Sstevel@tonic-gate _ss_table = table; 62*7c478bd9Sstevel@tonic-gate return(sci_idx); 63*7c478bd9Sstevel@tonic-gate } 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate void 66*7c478bd9Sstevel@tonic-gate ss_delete_invocation(sci_idx) 67*7c478bd9Sstevel@tonic-gate int sci_idx; 68*7c478bd9Sstevel@tonic-gate { 69*7c478bd9Sstevel@tonic-gate register ss_data *t; 70*7c478bd9Sstevel@tonic-gate int ignored_code; 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate t = ss_info(sci_idx); 73*7c478bd9Sstevel@tonic-gate free(t->prompt); 74*7c478bd9Sstevel@tonic-gate free((char *)t->rqt_tables); 75*7c478bd9Sstevel@tonic-gate while(t->info_dirs[0] != (char *)NULL) 76*7c478bd9Sstevel@tonic-gate ss_delete_info_dir(sci_idx, t->info_dirs[0], &ignored_code); 77*7c478bd9Sstevel@tonic-gate free((char *)t->info_dirs); 78*7c478bd9Sstevel@tonic-gate free((char *)t); 79*7c478bd9Sstevel@tonic-gate } 80