17c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 27c478bd9Sstevel@tonic-gate 37c478bd9Sstevel@tonic-gate /* 47c478bd9Sstevel@tonic-gate * Copyright 1987, 1988 by MIT Student Information Processing Board 57c478bd9Sstevel@tonic-gate * 67c478bd9Sstevel@tonic-gate * For copyright information, see copyright.h. 77c478bd9Sstevel@tonic-gate */ 87c478bd9Sstevel@tonic-gate #include "ss_internal.h" 97c478bd9Sstevel@tonic-gate #include "copyright.h" 107c478bd9Sstevel@tonic-gate #define size sizeof(ss_data *) 117c478bd9Sstevel@tonic-gate 127c478bd9Sstevel@tonic-gate 137c478bd9Sstevel@tonic-gate int ss_create_invocation(subsystem_name, version_string, info_ptr, 147c478bd9Sstevel@tonic-gate request_table_ptr, code_ptr) 157c478bd9Sstevel@tonic-gate char *subsystem_name, *version_string; 167c478bd9Sstevel@tonic-gate char *info_ptr; 177c478bd9Sstevel@tonic-gate ss_request_table *request_table_ptr; 187c478bd9Sstevel@tonic-gate int *code_ptr; 197c478bd9Sstevel@tonic-gate { 207c478bd9Sstevel@tonic-gate register int sci_idx; 217c478bd9Sstevel@tonic-gate register ss_data *new_table; 227c478bd9Sstevel@tonic-gate register ss_data **table; 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gate *code_ptr = 0; 257c478bd9Sstevel@tonic-gate table = _ss_table; 267c478bd9Sstevel@tonic-gate new_table = (ss_data *) malloc(sizeof(ss_data)); 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate if (table == (ss_data **) NULL) { 297c478bd9Sstevel@tonic-gate table = (ss_data **) malloc(2 * size); 307c478bd9Sstevel@tonic-gate table[0] = table[1] = (ss_data *)NULL; 317c478bd9Sstevel@tonic-gate } 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate for (sci_idx = 1; table[sci_idx] != (ss_data *)NULL; sci_idx++) 347c478bd9Sstevel@tonic-gate ; 357c478bd9Sstevel@tonic-gate table = (ss_data **) realloc((char *)table, 367c478bd9Sstevel@tonic-gate ((unsigned)sci_idx+2)*size); 377c478bd9Sstevel@tonic-gate table[sci_idx+1] = (ss_data *) NULL; 387c478bd9Sstevel@tonic-gate table[sci_idx] = new_table; 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate new_table->subsystem_name = subsystem_name; 417c478bd9Sstevel@tonic-gate new_table->subsystem_version = version_string; 427c478bd9Sstevel@tonic-gate new_table->argv = (char **)NULL; 437c478bd9Sstevel@tonic-gate new_table->current_request = (char *)NULL; 447c478bd9Sstevel@tonic-gate new_table->info_dirs = (char **)malloc(sizeof(char *)); 457c478bd9Sstevel@tonic-gate *new_table->info_dirs = (char *)NULL; 467c478bd9Sstevel@tonic-gate new_table->info_ptr = info_ptr; 477c478bd9Sstevel@tonic-gate new_table->prompt = malloc((unsigned)strlen(subsystem_name)+4); 487c478bd9Sstevel@tonic-gate strcpy(new_table->prompt, subsystem_name); 497c478bd9Sstevel@tonic-gate strcat(new_table->prompt, ": "); 507c478bd9Sstevel@tonic-gate #ifdef silly 517c478bd9Sstevel@tonic-gate new_table->abbrev_info = ss_abbrev_initialize("/etc/passwd", code_ptr); 527c478bd9Sstevel@tonic-gate #else 537c478bd9Sstevel@tonic-gate new_table->abbrev_info = NULL; 547c478bd9Sstevel@tonic-gate #endif 557c478bd9Sstevel@tonic-gate new_table->flags.escape_disabled = 0; 567c478bd9Sstevel@tonic-gate new_table->flags.abbrevs_disabled = 0; 577c478bd9Sstevel@tonic-gate new_table->rqt_tables = 587c478bd9Sstevel@tonic-gate (ss_request_table **) calloc(2, sizeof(ss_request_table *)); 597c478bd9Sstevel@tonic-gate *(new_table->rqt_tables) = request_table_ptr; 607c478bd9Sstevel@tonic-gate *(new_table->rqt_tables+1) = (ss_request_table *) NULL; 617c478bd9Sstevel@tonic-gate _ss_table = table; 627c478bd9Sstevel@tonic-gate return(sci_idx); 637c478bd9Sstevel@tonic-gate } 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate void 667c478bd9Sstevel@tonic-gate ss_delete_invocation(sci_idx) 677c478bd9Sstevel@tonic-gate int sci_idx; 687c478bd9Sstevel@tonic-gate { 697c478bd9Sstevel@tonic-gate register ss_data *t; 707c478bd9Sstevel@tonic-gate int ignored_code; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate t = ss_info(sci_idx); 737c478bd9Sstevel@tonic-gate free(t->prompt); 74*56a424ccSmp153739 free(t->rqt_tables); 757c478bd9Sstevel@tonic-gate while(t->info_dirs[0] != (char *)NULL) 767c478bd9Sstevel@tonic-gate ss_delete_info_dir(sci_idx, t->info_dirs[0], &ignored_code); 777c478bd9Sstevel@tonic-gate free((char *)t->info_dirs); 787c478bd9Sstevel@tonic-gate free((char *)t); 797c478bd9Sstevel@tonic-gate } 80