1*6a54128fSAndroid Build Coastguard Worker /* 2*6a54128fSAndroid Build Coastguard Worker * Copyright 1987, 1988 by MIT Student Information Processing Board 3*6a54128fSAndroid Build Coastguard Worker * 4*6a54128fSAndroid Build Coastguard Worker * Permission to use, copy, modify, and distribute this software and 5*6a54128fSAndroid Build Coastguard Worker * its documentation for any purpose is hereby granted, provided that 6*6a54128fSAndroid Build Coastguard Worker * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in 7*6a54128fSAndroid Build Coastguard Worker * advertising or publicity pertaining to distribution of the software 8*6a54128fSAndroid Build Coastguard Worker * without specific, written prior permission. M.I.T. and the 9*6a54128fSAndroid Build Coastguard Worker * M.I.T. S.I.P.B. make no representations about the suitability of 10*6a54128fSAndroid Build Coastguard Worker * this software for any purpose. It is provided "as is" without 11*6a54128fSAndroid Build Coastguard Worker * express or implied warranty. 12*6a54128fSAndroid Build Coastguard Worker */ 13*6a54128fSAndroid Build Coastguard Worker 14*6a54128fSAndroid Build Coastguard Worker #ifndef _ss_ss_internal_h 15*6a54128fSAndroid Build Coastguard Worker #define _ss_ss_internal_h __FILE__ 16*6a54128fSAndroid Build Coastguard Worker #include <stdio.h> 17*6a54128fSAndroid Build Coastguard Worker #include <string.h> 18*6a54128fSAndroid Build Coastguard Worker #include <stdlib.h> 19*6a54128fSAndroid Build Coastguard Worker 20*6a54128fSAndroid Build Coastguard Worker #define PROTOTYPE(p) p 21*6a54128fSAndroid Build Coastguard Worker typedef void * pointer; 22*6a54128fSAndroid Build Coastguard Worker 23*6a54128fSAndroid Build Coastguard Worker #include "ss.h" 24*6a54128fSAndroid Build Coastguard Worker 25*6a54128fSAndroid Build Coastguard Worker typedef char BOOL; 26*6a54128fSAndroid Build Coastguard Worker 27*6a54128fSAndroid Build Coastguard Worker typedef struct _ss_abbrev_entry { 28*6a54128fSAndroid Build Coastguard Worker char *name; /* abbrev name */ 29*6a54128fSAndroid Build Coastguard Worker char **abbrev; /* new tokens to insert */ 30*6a54128fSAndroid Build Coastguard Worker unsigned int beginning_of_line : 1; 31*6a54128fSAndroid Build Coastguard Worker } ss_abbrev_entry; 32*6a54128fSAndroid Build Coastguard Worker 33*6a54128fSAndroid Build Coastguard Worker typedef struct _ss_abbrev_list { 34*6a54128fSAndroid Build Coastguard Worker int n_abbrevs; 35*6a54128fSAndroid Build Coastguard Worker ss_abbrev_entry *first_abbrev; 36*6a54128fSAndroid Build Coastguard Worker } ss_abbrev_list; 37*6a54128fSAndroid Build Coastguard Worker 38*6a54128fSAndroid Build Coastguard Worker typedef struct { 39*6a54128fSAndroid Build Coastguard Worker /* char *path; */ 40*6a54128fSAndroid Build Coastguard Worker ss_abbrev_list abbrevs[127]; 41*6a54128fSAndroid Build Coastguard Worker } ss_abbrev_info; 42*6a54128fSAndroid Build Coastguard Worker 43*6a54128fSAndroid Build Coastguard Worker typedef struct _ss_data { /* init values */ 44*6a54128fSAndroid Build Coastguard Worker /* this subsystem */ 45*6a54128fSAndroid Build Coastguard Worker const char *subsystem_name; 46*6a54128fSAndroid Build Coastguard Worker const char *subsystem_version; 47*6a54128fSAndroid Build Coastguard Worker /* current request info */ 48*6a54128fSAndroid Build Coastguard Worker int argc; 49*6a54128fSAndroid Build Coastguard Worker char **argv; /* arg list */ 50*6a54128fSAndroid Build Coastguard Worker char const *current_request; /* primary name */ 51*6a54128fSAndroid Build Coastguard Worker /* info directory for 'help' */ 52*6a54128fSAndroid Build Coastguard Worker char **info_dirs; 53*6a54128fSAndroid Build Coastguard Worker /* to be extracted by subroutines */ 54*6a54128fSAndroid Build Coastguard Worker pointer info_ptr; /* (void *) NULL */ 55*6a54128fSAndroid Build Coastguard Worker /* for ss_listen processing */ 56*6a54128fSAndroid Build Coastguard Worker char *prompt; 57*6a54128fSAndroid Build Coastguard Worker ss_request_table **rqt_tables; 58*6a54128fSAndroid Build Coastguard Worker ss_abbrev_info *abbrev_info; 59*6a54128fSAndroid Build Coastguard Worker struct { 60*6a54128fSAndroid Build Coastguard Worker unsigned int escape_disabled : 1, 61*6a54128fSAndroid Build Coastguard Worker abbrevs_disabled : 1; 62*6a54128fSAndroid Build Coastguard Worker } flags; 63*6a54128fSAndroid Build Coastguard Worker /* 64*6a54128fSAndroid Build Coastguard Worker * Dynamic usage of readline library if present 65*6a54128fSAndroid Build Coastguard Worker */ 66*6a54128fSAndroid Build Coastguard Worker void *readline_handle; 67*6a54128fSAndroid Build Coastguard Worker void (*readline_shutdown)(struct _ss_data *info); 68*6a54128fSAndroid Build Coastguard Worker char *(*readline)(const char *); 69*6a54128fSAndroid Build Coastguard Worker void (*add_history)(const char *); 70*6a54128fSAndroid Build Coastguard Worker void (*redisplay)(void); 71*6a54128fSAndroid Build Coastguard Worker char **(*rl_completion_matches)(const char *, 72*6a54128fSAndroid Build Coastguard Worker char *(*completer)(const char *, int)); 73*6a54128fSAndroid Build Coastguard Worker /* to get out */ 74*6a54128fSAndroid Build Coastguard Worker int abort; /* exit subsystem */ 75*6a54128fSAndroid Build Coastguard Worker int exit_status; 76*6a54128fSAndroid Build Coastguard Worker } ss_data; 77*6a54128fSAndroid Build Coastguard Worker 78*6a54128fSAndroid Build Coastguard Worker #define CURRENT_SS_VERSION 1 79*6a54128fSAndroid Build Coastguard Worker 80*6a54128fSAndroid Build Coastguard Worker #define ss_info(sci_idx) (_ss_table[sci_idx]) 81*6a54128fSAndroid Build Coastguard Worker #define ss_current_request(sci_idx,code_ptr) \ 82*6a54128fSAndroid Build Coastguard Worker (*code_ptr=0,ss_info(sci_idx)->current_request) 83*6a54128fSAndroid Build Coastguard Worker void ss_add_info_dir (int sci_idx, char *info_dir, int *code_ptr); 84*6a54128fSAndroid Build Coastguard Worker void ss_delete_info_dir (int sci_idx, char *info_dir, int *code_ptr); 85*6a54128fSAndroid Build Coastguard Worker int ss_execute_line(int sci_idx, char *line_ptr); 86*6a54128fSAndroid Build Coastguard Worker char **ss_parse(int sci_idx, char *line_ptr, int *argc_ptr); 87*6a54128fSAndroid Build Coastguard Worker ss_abbrev_info *ss_abbrev_initialize(char *, int *); 88*6a54128fSAndroid Build Coastguard Worker void ss_page_stdin(void) __SS_ATTR((noreturn)); 89*6a54128fSAndroid Build Coastguard Worker void ss_list_requests(int, char const * const *, int, pointer); 90*6a54128fSAndroid Build Coastguard Worker int ss_execute_command(int sci_idx, char *argv[]); 91*6a54128fSAndroid Build Coastguard Worker int ss_pager_create(void); 92*6a54128fSAndroid Build Coastguard Worker char *ss_safe_getenv(const char *arg); 93*6a54128fSAndroid Build Coastguard Worker char **ss_rl_completion(const char *text, int start, int end); 94*6a54128fSAndroid Build Coastguard Worker 95*6a54128fSAndroid Build Coastguard Worker extern ss_data **_ss_table; 96*6a54128fSAndroid Build Coastguard Worker extern char *ss_et_msgs[]; 97*6a54128fSAndroid Build Coastguard Worker extern char *_ss_pager_name; 98*6a54128fSAndroid Build Coastguard Worker 99*6a54128fSAndroid Build Coastguard Worker #ifdef USE_SIGPROCMASK 100*6a54128fSAndroid Build Coastguard Worker /* fake sigmask, sigblock, sigsetmask */ 101*6a54128fSAndroid Build Coastguard Worker #include <signal.h> 102*6a54128fSAndroid Build Coastguard Worker #define sigmask(x) (1L<<(x)-1) 103*6a54128fSAndroid Build Coastguard Worker #define sigsetmask(x) sigprocmask(SIG_SETMASK,&x,NULL) 104*6a54128fSAndroid Build Coastguard Worker static int _fake_sigstore; 105*6a54128fSAndroid Build Coastguard Worker #define sigblock(x) (_fake_sigstore=x,sigprocmask(SIG_BLOCK,&_fake_sigstore,0)) 106*6a54128fSAndroid Build Coastguard Worker #endif 107*6a54128fSAndroid Build Coastguard Worker #endif /* _ss_internal_h */ 108