Whamcloud - gitweb
libext2fs.texinfo, ChangeLog:
[tools/e2fsprogs.git] / lib / ss / ss_internal.h
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 #ifdef __STDC__
21
22 #define NOARGS void
23 #define PROTOTYPE(p) p
24 typedef void * pointer;
25
26 #else
27
28 #define NOARGS
29 #define const
30 #define volatile
31 #define PROTOTYPE(p) ()
32 typedef char * pointer;
33
34 #endif /* not __STDC__ */
35
36 #include "ss.h"
37
38 #if defined(__GNUC__)
39 #define LOCAL_ALLOC(x) __builtin_alloca(x)
40 #define LOCAL_FREE(x)
41 #else
42 #if defined(vax)
43 #define LOCAL_ALLOC(x) alloca(x)
44 #define LOCAL_FREE(x)
45 extern pointer alloca PROTOTYPE((unsigned));
46 #else
47 #if defined(__HIGHC__)  /* Barf! */
48 pragma on(alloca);
49 #define LOCAL_ALLOC(x) alloca(x)
50 #define LOCAL_FREE(x)
51 extern pointer alloca PROTOTYPE((unsigned));
52 #else
53 /* no alloca? */
54 #define LOCAL_ALLOC(x) malloc(x)
55 #define LOCAL_FREE(x) free(x)
56 #endif
57 #endif
58 #endif                          /* LOCAL_ALLOC stuff */
59
60 typedef char BOOL;
61
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;
66 } ss_abbrev_entry;
67
68 typedef struct _ss_abbrev_list {
69     int n_abbrevs;
70     ss_abbrev_entry *first_abbrev;
71 } ss_abbrev_list;
72
73 typedef struct {
74 /*    char *path; */
75     ss_abbrev_list abbrevs[127];
76 } ss_abbrev_info;
77
78 typedef struct _ss_data {       /* init values */
79     /* this subsystem */
80     const char *subsystem_name;
81     const char *subsystem_version;
82     /* current request info */
83     int argc;
84     char **argv;                /* arg list */
85     char const *current_request; /* primary name */
86     /* info directory for 'help' */
87     char **info_dirs;
88     /* to be extracted by subroutines */
89     pointer info_ptr;           /* (void *) NULL */
90     /* for ss_listen processing */
91     char *prompt;
92     ss_request_table **rqt_tables;
93     ss_abbrev_info *abbrev_info;
94     struct {
95         unsigned int  escape_disabled : 1,
96                       abbrevs_disabled : 1;
97     } flags;
98     /* to get out */
99     int abort;                  /* exit subsystem */
100     int exit_status;
101 } ss_data;
102
103 #define CURRENT_SS_VERSION 1
104
105 #define ss_info(sci_idx)        (_ss_table[sci_idx])
106 #define ss_current_request(sci_idx,code_ptr)    \
107      (*code_ptr=0,ss_info(sci_idx)->current_request)
108 void ss_delete_info_dir PROTOTYPE((int sci_idx, char *info_dir,
109                                    int *code_ptr));
110 int ss_execute_line PROTOTYPE((int sci_idx, char *line_ptr));
111 char **ss_parse PROTOTYPE((int sci_idx, char *line_ptr, int *argc_ptr));
112 ss_abbrev_info *ss_abbrev_initialize PROTOTYPE((char *, int *));
113 void ss_page_stdin(NOARGS);
114
115 extern ss_data **_ss_table;
116 extern char *ss_et_msgs[];
117
118 #ifdef USE_SIGPROCMASK
119 /* fake sigmask, sigblock, sigsetmask */
120 #include <signal.h>
121 #define sigmask(x) (1L<<(x)-1)
122 #define sigsetmask(x) sigprocmask(SIG_SETMASK,&x,NULL)
123 static int _fake_sigstore;
124 #define sigblock(x) (_fake_sigstore=x,sigprocmask(SIG_BLOCK,&_fake_sigstore,0))
125 #endif
126 #endif /* _ss_internal_h */