ss_internal.h revision 65f0aab98b20b5994a726ab90d355248bcddfffd
1/*
2 * Copyright 1987, 1988 by MIT Student Information Processing Board
3 *
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.
12 */
13
14#ifndef _ss_ss_internal_h
15#define _ss_ss_internal_h __FILE__
16#include <stdio.h>
17#include <string.h>
18#include <stdlib.h>
19
20#define PROTOTYPE(p) p
21typedef void * pointer;
22
23#include "ss.h"
24
25typedef char BOOL;
26
27typedef struct _ss_abbrev_entry {
28    char *name;			/* abbrev name */
29    char **abbrev;		/* new tokens to insert */
30    unsigned int beginning_of_line : 1;
31} ss_abbrev_entry;
32
33typedef struct _ss_abbrev_list {
34    int n_abbrevs;
35    ss_abbrev_entry *first_abbrev;
36} ss_abbrev_list;
37
38typedef struct {
39/*    char *path; */
40    ss_abbrev_list abbrevs[127];
41} ss_abbrev_info;
42
43typedef struct _ss_data {	/* init values */
44    /* this subsystem */
45    const char *subsystem_name;
46    const char *subsystem_version;
47    /* current request info */
48    int argc;
49    char **argv;		/* arg list */
50    char const *current_request; /* primary name */
51    /* info directory for 'help' */
52    char **info_dirs;
53    /* to be extracted by subroutines */
54    pointer info_ptr;		/* (void *) NULL */
55    /* for ss_listen processing */
56    char *prompt;
57    ss_request_table **rqt_tables;
58    ss_abbrev_info *abbrev_info;
59    struct {
60	unsigned int  escape_disabled : 1,
61		      abbrevs_disabled : 1;
62    } flags;
63    /*
64     * Dynamic usage of readline library if present
65     */
66    void *readline_handle;
67    void (*readline_shutdown)(struct _ss_data *info);
68    char *(*readline)(const char *);
69    void (*add_history)(const char *);
70    void (*redisplay)(void);
71    char **(*rl_completion_matches)(const char *,
72				    char *(*completer)(const char *, int));
73    /* to get out */
74    int abort;			/* exit subsystem */
75    int exit_status;
76} ss_data;
77
78#define CURRENT_SS_VERSION 1
79
80#define	ss_info(sci_idx)	(_ss_table[sci_idx])
81#define	ss_current_request(sci_idx,code_ptr)	\
82     (*code_ptr=0,ss_info(sci_idx)->current_request)
83void ss_add_info_dir (int sci_idx, char *info_dir, int *code_ptr);
84void ss_delete_info_dir (int sci_idx, char *info_dir, int *code_ptr);
85int ss_execute_line(int sci_idx, char *line_ptr);
86char **ss_parse(int sci_idx, char *line_ptr, int *argc_ptr);
87ss_abbrev_info *ss_abbrev_initialize(char *, int *);
88void ss_page_stdin(void);
89void ss_list_requests(int, char const * const *, int, pointer);
90int ss_execute_command(int sci_idx, char *argv[]);
91int ss_pager_create(void);
92char *ss_safe_getenv(const char *arg);
93char **ss_rl_completion(const char *text, int start, int end);
94
95extern ss_data **_ss_table;
96extern char *ss_et_msgs[];
97
98#ifdef USE_SIGPROCMASK
99/* fake sigmask, sigblock, sigsetmask */
100#include <signal.h>
101#define sigmask(x) (1L<<(x)-1)
102#define sigsetmask(x) sigprocmask(SIG_SETMASK,&x,NULL)
103static int _fake_sigstore;
104#define sigblock(x) (_fake_sigstore=x,sigprocmask(SIG_BLOCK,&_fake_sigstore,0))
105#endif
106#endif /* _ss_internal_h */
107