changelog for 0.9.1
[posh.git] / proto.h
blob4978e283b100ac10bc00dee8a0fc848fd0f2796a
1 /*
2 * prototypes for PD-KSH
3 * originally generated using "cproto.c 3.5 92/04/11 19:28:01 cthuang "
4 * $Id: proto.h,v 1.3 1994/05/19 18:32:40 michael Exp michael $
5 */
7 #ifdef __GNUC__
8 # define GCC_FUNC_ATTR(x) __attribute__((x))
9 # define GCC_FUNC_ATTR2(x,y) __attribute__((x,y))
10 #else
11 # define GCC_FUNC_ATTR(x)
12 # define GCC_FUNC_ATTR2(x,y)
13 #endif
15 /* alloc.c */
16 void ainit (Area *ap);
17 void afreeall (Area *ap);
18 void * alloc (size_t size, Area *ap);
19 void * aresize (void *ptr, size_t size, Area *ap);
20 void afree (void *ptr, Area *ap);
21 /* c_ksh.c */
22 int c_hash (char **wp);
23 int c_pwd (char **wp);
24 int c_print (char **wp);
25 int c_whence (char **wp);
26 int c_command (char **wp);
27 int c_alias (char **wp);
28 int c_unalias (char **wp);
29 int c_let (char **wp);
30 int c_jobs (char **wp);
31 int c_fgbg (char **wp);
32 int c_kill (char **wp);
33 void getopts_reset (int val);
34 int c_getopts (char **wp);
35 int c_bind (char **wp);
36 /* c_sh.c */
37 int c_shift (char **wp);
38 int c_dot (char **wp);
39 int c_wait (char **wp);
40 int c_read (char **wp);
41 int c_eval (char **wp);
42 int c_trap (char **wp);
43 int c_brkcont (char **wp);
44 int c_exitreturn (char **wp);
45 int c_set (char **wp);
46 int c_unset (char **wp);
47 int c_ulimit (char **wp);
48 int c_times (char **wp);
49 int timex (struct op *t, int f);
50 void timex_hook (struct op *t, char ** volatile *app);
51 /* edit.c: most prototypes in edit.h */
52 void x_init (void);
53 int x_read (char *buf, size_t len);
54 void set_editmode (const char *ed);
55 /* emacs.c: most prototypes in edit.h */
56 int x_bind (const char *a1, const char *a2, int macro,
57 int list);
58 /* eval.c */
59 char * substitute (const char *cp, int f);
60 char ** eval (const char **, int);
61 char * evalstr (const char *, int f);
62 char * evalonestr (const char *, int f);
63 char *debunk (char *dp, const char *sp, size_t dlen);
64 void expand (const char *cp, XPtrV *wp, int f);
65 int glob_str (char *cp, XPtrV *wp, int markdirs);
66 /* exec.c */
67 int fd_clexec (int fd);
68 int execute (struct op * volatile t, volatile int flags, volatile int * volatile xerrok);
69 int shcomexec (char **wp);
70 struct tbl * findfunc (const char *name, int create);
71 int define (const char *name, struct op *t);
72 void builtin (const char *name, int (*func)(int, char **, int), int flags);
73 struct tbl * findcom (const char *name, int flags);
74 void flushcom (int all);
75 char * search (const char *name, const char *path, int mode, int *errnop);
76 int search_access (const char *path, int mode, int *errnop);
77 int pr_menu (char *const *ap);
78 /* expr.c */
79 int evaluate (const char *expr, long *rval, int error_ok);
80 int v_evaluate (struct tbl *vp, const char *expr, volatile int error_ok);
81 /* history.c */
82 void init_histvec (void);
83 void hist_init (Source *s);
84 void hist_finish (void);
85 void histsave (int lno, const char *cmd, int dowrite);
86 #ifdef HISTORY
87 int c_fc (register char **wp);
88 void sethistsize (int n);
89 void sethistfile (const char *name);
90 # ifdef EASY_HISTORY
91 void histappend (const char *cmd, int nl_separate);
92 # endif
93 char ** histpos (void);
94 int histN (void);
95 int histnum (int n);
96 int findhist (int start, int fwd, const char *str, int anchored);
97 #endif /* HISTORY */
98 /* io.c */
99 void errorf (const char *fmt, ...)
100 GCC_FUNC_ATTR2(noreturn, format(printf, 1, 2));
101 void warningf (int fileline, const char *fmt, ...)
102 GCC_FUNC_ATTR(format(printf, 2, 3));
103 void bi_errorf (const char *fmt, ...)
104 GCC_FUNC_ATTR(format(printf, 1, 2));
105 void internal_errorf (int jump, const char *fmt, ...)
106 GCC_FUNC_ATTR(format(printf, 2, 3));
107 void error_prefix (int fileline);
108 void shellf (const char *fmt, ...)
109 GCC_FUNC_ATTR(format(printf, 1, 2));
110 void shprintf (const char *fmt, ...)
111 GCC_FUNC_ATTR(format(printf, 1, 2));
112 #ifdef KSH_DEBUG
113 void kshdebug_init_ (void);
114 void kshdebug_printf_ (const char *fmt, ...)
115 GCC_FUNC_ATTR(format(printf, 1, 2));
116 void kshdebug_dump_ (const char *str, const void *mem, int nbytes);
117 #endif /* KSH_DEBUG */
118 int can_seek (int fd);
119 void initio (void);
120 int ksh_dup2 (int ofd, int nfd, int errok);
121 int savefd (int fd, int noclose);
122 void restfd (int fd, int ofd);
123 void openpipe (int *pv);
124 void closepipe (int *pv);
125 int check_fd (char *name, int mode, const char **emsgp);
126 #ifdef KSH
127 void coproc_init (void);
128 void coproc_read_close (int fd);
129 void coproc_readw_close (int fd);
130 void coproc_write_close (int fd);
131 int coproc_getfd (int mode, const char **emsgp);
132 void coproc_cleanup (int reuse);
133 #endif /* KSH */
134 struct temp *maketemp (Area *ap, Temp_type type, struct temp **tlist);
135 /* jobs.c */
136 void j_init (void);
137 void j_exit (void);
138 void j_change (void);
139 int exchild (struct op *t, int flags, volatile int *xerrok, int close_fd);
140 void startlast (void);
141 int waitlast (void);
142 int waitfor (const char *cp, int *sigp);
143 int j_kill (const char *cp, int sig);
144 int j_resume (const char *cp, int bg);
145 int j_jobs (const char *cp, int slp, int nflag);
146 void j_notify (void);
147 pid_t j_async (void);
148 int j_stopped_running (void);
149 /* lex.c */
150 int yylex (int cf);
151 void yyerror (const char *fmt, ...)
152 GCC_FUNC_ATTR2(noreturn, format(printf, 1, 2));
153 Source * pushs (int type, Area *areap);
154 void set_prompt (int to, Source *s);
155 void pprompt (const char *cp, int ntruncate);
156 /* mail.c */
157 #ifdef KSH
158 void mcheck (void);
159 void mcset (long interval);
160 void mbset (char *p);
161 void mpset (char *mptoparse);
162 #endif /* KSH */
163 /* main.c */
164 int include (const char *name, int argc, char **argv, int intr_ok);
165 int command (const char *comm);
166 int shell (Source *volatile s, int volatile toplevel);
167 void unwind (int i) GCC_FUNC_ATTR(noreturn);
168 void newenv (int type);
169 void quitenv (void);
170 void cleanup_parents_env (void);
171 void cleanup_proc_env (void);
172 void aerror (Area *ap, const char *msg) GCC_FUNC_ATTR(noreturn);
173 /* misc.c */
174 void setctypes (const char *s, int t);
175 void initctypes (void);
176 char * str_save (const char *s, Area *ap);
177 char * str_nsave (const char *s, int n, Area *ap);
178 int option (const char *n);
179 char * getoptions (void);
180 void change_flag (enum sh_flag f, int what, int newval);
181 int parse_args (char **argv, int what, int *setargsp);
182 int getn (const char *as, int *ai);
183 int bi_getn (const char *as, int *ai);
184 char * strerror (int i);
185 int gmatchx (const char *s, const char *p, int isfile);
186 int has_globbing (const char *xp, const char *xpe);
187 const unsigned char *pat_scan (const unsigned char *p, const unsigned char *pe, int match_sep);
188 int xstrcmp (const void *p1, const void *p2);
189 void ksh_getopt_reset (LameGetopt *go, int);
190 int ksh_getopt (char **argv, LameGetopt *go, const char *options);
191 void print_value_quoted (const char *s);
192 void print_columns (struct shf *shf, int n, char *(*func)(void *, int, char *, int), void *arg, int max_width);
193 int strip_nuls (char *buf, int nbytes);
194 char *str_zcpy (char *dst, const char *src, int dsize);
195 int blocking_read (int fd, char *buf, int nbytes);
196 int reset_nonblock (int fd);
197 /* path.c */
198 int make_path (const char *cwd, const char *file,
199 char **pathlist, XString *xsp, int *phys_pathp);
200 void simplify_path (char *path);
201 void set_current_wd (char *path);
202 /* syn.c */
203 void initkeywords (void);
204 struct op * compile (Source *s);
205 /* table.c */
206 void transitional_tinit (struct table *tp, Area *ap);
207 struct tbl * transitional_tsearch (void **tbl_root, const char *n);
208 struct tbl * transitional_tenter (void **tbl_root, const char *n, Area *ap);
209 void transitional_tdelete (void **tbl_root, struct tbl *p);
210 /* trace.c */
211 /* trap.c */
212 void inittraps (void);
213 #ifdef KSH
214 void alarm_init (void);
215 #endif /* KSH */
216 Trap * gettrap (const char *name);
217 RETSIGTYPE trapsig (int i);
218 void intrcheck (void);
219 int fatal_trap_check (void);
220 int trap_pending (void);
221 void runtraps (int intr);
222 void runtrap (Trap *p);
223 void cleartraps (void);
224 void restoresigs (void);
225 void settrap (Trap *p, char *s);
226 int block_pipe (void);
227 void restore_pipe (int restore_dfl);
228 int setsig (Trap *p, handler_t f, int flags);
229 void setexecsig (Trap *p, int restore);
230 /* tree.c */
231 int fptreef (struct shf *f, int indent, const char *fmt, ...);
232 char * snptreef (char *s, int n, const char *fmt, ...);
233 struct op * tcopy (struct op *t, Area *ap);
234 char * wdcopy (const char *wp, Area *ap);
235 char * wdscan (const char *wp, int c);
236 char * wdstrip (const char *wp);
237 void tfree (struct op *t, Area *ap);
238 /* var.c */
239 void newblock (void);
240 void popblock (void);
241 void initvar (void);
242 struct tbl * global (const char *n);
243 struct tbl * local (const char *n, bool_t copy);
244 char * str_val (struct tbl *vp);
245 long intval (struct tbl *vp);
246 int setstr (struct tbl *vq, const char *s, int error_ok);
247 struct tbl *setint_v (struct tbl *vq, struct tbl *vp);
248 void setint (struct tbl *vq, long n);
249 int getint (struct tbl *vp, long *nump);
250 struct tbl * typeset (const char *var, Tflag set, Tflag clr, int field, int base);
251 void unset (struct tbl *vp, int array_ref);
252 char * skip_varname (const char *s, int aok);
253 char *skip_wdvarname (const char *s, int aok);
254 int is_wdvarname (const char *s, int aok);
255 int is_wdvarassign (const char *s);
256 char ** makenv (void);
257 void change_random (void);
258 int array_ref_len (const char *cp);
259 char * arrayname (const char *str);
260 /* version.c */
261 /* vi.c: see edit.h */
264 /* Hack to avoid billions of compile warnings on SunOS 4.1.x */
265 #if defined(MUN) && defined(sun) && !defined(__svr4__)
266 extern void bcopy (const void *src, void *dst, size_t size);
267 extern int fclose (FILE *fp);
268 extern int fprintf (FILE *fp, const char *fmt, ...);
269 extern int fread (void *buf, int size, int num, FILE *fp);
270 extern int ioctl (int fd, int request, void *arg);
271 extern int killpg (int pgrp, int sig);
272 extern int nice (int n);
273 extern int readlink (const char *path, char *buf, int bufsize);
274 extern int setpgrp (int pid, int pgrp);
275 extern int tolower (int);
276 extern int toupper (int);
277 /* Include files aren't included yet */
278 extern int getrlimit ( /* int resource, struct rlimit *rpl */ );
279 extern int getrusage ( /* int who, struct rusage *rusage */ );
280 extern int gettimeofday ( /* struct timeval *tv, struct timezone *tz */ );
281 extern int setrlimit ( /* int resource, struct rlimit *rlp */ );
282 extern int lstat ( /* const char *path, struct stat *buf */ );
283 #endif