2 * Copyright 1987, 1988 by MIT Student Information Processing Board
4 * Permission to use, copy, modify, and distribute this software and
5 * its documentation for any purpose is hereby granted, provided that
6 * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
7 * advertising or publicity pertaining to distribution of the software
8 * without specific, written prior permission. M.I.T. and the
9 * M.I.T. S.I.P.B. make no representations about the suitability of
10 * this software for any purpose. It is provided "as is" without
11 * express or implied warranty.
14 #ifndef _ss_ss_internal_h
15 #define _ss_ss_internal_h __FILE__
23 #define PROTOTYPE(p) p
24 typedef void * pointer;
31 #define PROTOTYPE(p) ()
32 typedef char * pointer;
34 #endif /* not __STDC__ */
39 #define LOCAL_ALLOC(x) __builtin_alloca(x)
43 #define LOCAL_ALLOC(x) alloca(x)
45 extern pointer alloca PROTOTYPE((unsigned));
47 #if defined(__HIGHC__) /* Barf! */
49 #define LOCAL_ALLOC(x) alloca(x)
51 extern pointer alloca PROTOTYPE((unsigned));
54 #define LOCAL_ALLOC(x) malloc(x)
55 #define LOCAL_FREE(x) free(x)
58 #endif /* LOCAL_ALLOC stuff */
62 typedef struct _ss_abbrev_entry {
63 char *name; /* abbrev name */
64 char **abbrev; /* new tokens to insert */
65 unsigned int beginning_of_line : 1;
68 typedef struct _ss_abbrev_list {
70 ss_abbrev_entry *first_abbrev;
75 ss_abbrev_list abbrevs[127];
78 typedef struct _ss_data { /* init values */
80 const char *subsystem_name;
81 const char *subsystem_version;
82 /* current request info */
84 char **argv; /* arg list */
85 char const *current_request; /* primary name */
86 /* info directory for 'help' */
88 /* to be extracted by subroutines */
89 pointer info_ptr; /* (void *) NULL */
90 /* for ss_listen processing */
92 ss_request_table **rqt_tables;
93 ss_abbrev_info *abbrev_info;
95 unsigned int escape_disabled : 1,
99 * Dynamic usage of readline library if present
101 void *readline_handle;
102 void (*readline_shutdown)(struct _ss_data *info);
103 char *(*readline)(const char *);
104 void (*add_history)(const char *);
106 char **(*rl_completion_matches)(const char *,
107 char *(*completer)(const char *, int));
109 int abort; /* exit subsystem */
113 #define CURRENT_SS_VERSION 1
115 #define ss_info(sci_idx) (_ss_table[sci_idx])
116 #define ss_current_request(sci_idx,code_ptr) \
117 (*code_ptr=0,ss_info(sci_idx)->current_request)
118 void ss_add_info_dir PROTOTYPE((int sci_idx, char *info_dir,
120 void ss_delete_info_dir PROTOTYPE((int sci_idx, char *info_dir,
122 int ss_execute_line PROTOTYPE((int sci_idx, char *line_ptr));
123 char **ss_parse PROTOTYPE((int sci_idx, char *line_ptr, int *argc_ptr));
124 ss_abbrev_info *ss_abbrev_initialize PROTOTYPE((char *, int *));
125 void ss_page_stdin(NOARGS);
126 void ss_list_requests PROTOTYPE((int, char const * const *, int, pointer));
127 int ss_execute_command PROTOTYPE((int sci_idx, char *argv[]));
128 int ss_pager_create(NOARGS);
129 char **ss_rl_completion(const char *text, int start, int end);
131 extern ss_data **_ss_table;
132 extern char *ss_et_msgs[];
134 #ifdef USE_SIGPROCMASK
135 /* fake sigmask, sigblock, sigsetmask */
137 #define sigmask(x) (1L<<(x)-1)
138 #define sigsetmask(x) sigprocmask(SIG_SETMASK,&x,NULL)
139 static int _fake_sigstore;
140 #define sigblock(x) (_fake_sigstore=x,sigprocmask(SIG_BLOCK,&_fake_sigstore,0))
142 #endif /* _ss_internal_h */