xref: /titanic_50/usr/src/lib/krb5/ss/ss_internal.h (revision 753a6d457b330b1b29b2d3eefcd0831116ce950d)
1 /*
2  * Copyright 1987, 1988 by MIT Student Information Processing Board
3  *
4  * For copyright information, see copyright.h.
5  */
6 
7 /*
8  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
9  * Use is subject to license terms.
10  */
11 
12 
13 #ifndef _ss_ss_internal_h
14 #define _ss_ss_internal_h __FILE__
15 #include <stdio.h>
16 #include <string.h>
17 #include <unistd.h>
18 #ifdef HAVE_STDLIB_H
19 #include <stdlib.h>
20 #endif
21 
22 typedef void * pointer;
23 
24 #include <ss/ss.h>
25 
26 #if defined(__GNUC__)
27 #define LOCAL_ALLOC(x) __builtin_alloca(x)
28 #define LOCAL_FREE(x)
29 #else
30 #if defined(vax)
31 #define LOCAL_ALLOC(x) alloca(x)
32 #define LOCAL_FREE(x)
33 extern pointer alloca (unsigned);
34 #else
35 #if defined(__HIGHC__)	/* Barf! */
36 pragma on(alloca);
37 #define LOCAL_ALLOC(x) alloca(x)
38 #define LOCAL_FREE(x)
39 extern pointer alloca (unsigned);
40 #else
41 /* no alloca? */
42 #define LOCAL_ALLOC(x) malloc(x)
43 #define LOCAL_FREE(x) free(x)
44 #endif
45 #endif
46 #endif				/* LOCAL_ALLOC stuff */
47 
48 typedef char BOOL;
49 
50 typedef struct _ss_abbrev_entry {
51     char *name;			/* abbrev name */
52     char **abbrev;		/* new tokens to insert */
53     unsigned int beginning_of_line : 1;
54 } ss_abbrev_entry;
55 
56 typedef struct _ss_abbrev_list {
57     int n_abbrevs;
58     ss_abbrev_entry *first_abbrev;
59 } ss_abbrev_list;
60 
61 typedef struct {
62 /*    char *path; */
63     ss_abbrev_list abbrevs[127];
64 } ss_abbrev_info;
65 
66 typedef struct _ss_data {	/* init values */
67     /* this subsystem */
68     char *subsystem_name;
69     char *subsystem_version;
70     /* current request info */
71     int argc;
72     char **argv;		/* arg list */
73     char const *current_request; /* primary name */
74     /* info directory for 'help' */
75     char **info_dirs;
76     /* to be extracted by subroutines */
77     pointer info_ptr;		/* (void *) NULL */
78     /* for ss_listen processing */
79     char *prompt;
80     ss_request_table **rqt_tables;
81     ss_abbrev_info *abbrev_info;
82     struct {
83 	unsigned int  escape_disabled : 1,
84 		      abbrevs_disabled : 1;
85     } flags;
86     /* to get out */
87     int abort;			/* exit subsystem */
88     int exit_status;
89 } ss_data;
90 
91 #define CURRENT_SS_VERSION 1
92 
93 #define	ss_info(sci_idx)	(_ss_table[sci_idx])
94 #define	ss_current_request(sci_idx,code_ptr)	\
95      (*code_ptr=0,ss_info(sci_idx)->current_request)
96 void ss_unknown_function();
97 void ss_delete_info_dir();
98 /* Solaris Kerberos */
99 int ss_parse (int, char *, int *, char ***, int);
100 ss_abbrev_info *ss_abbrev_initialize (char *, int *);
101 void ss_page_stdin (void);
102 int ss_pager_create (void);
103 void ss_self_identify __SS_PROTO;
104 void ss_subsystem_name __SS_PROTO;
105 void ss_subsystem_version __SS_PROTO;
106 void ss_unimplemented __SS_PROTO;
107 
108 extern ss_data **_ss_table;
109 extern char *ss_et_msgs[];
110 
111 #ifndef HAVE_STDLIB_H
112 extern pointer malloc (unsigned);
113 extern pointer realloc (pointer, unsigned);
114 extern pointer calloc (unsigned, unsigned);
115 #endif
116 
117 #if defined(USE_SIGPROCMASK) && !defined(POSIX_SIGNALS)
118 /* fake sigmask, sigblock, sigsetmask */
119 #include <signal.h>
120 #ifdef sigmask
121 #undef sigmask
122 #endif
123 #define sigmask(x) (1L<<(x)-1)
124 #define sigsetmask(x) sigprocmask(SIG_SETMASK,&x,NULL)
125 static int _fake_sigstore;
126 #define sigblock(x) (_fake_sigstore=x,sigprocmask(SIG_BLOCK,&_fake_sigstore,0))
127 #endif
128 #endif /* _ss_internal_h */
129