1 /* This file is part of GDBM, the GNU data base manager.
2 Copyright (C) 1990, 1991, 1993, 2007, 2011, 2013 Free Software Foundation,
5 GDBM is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
10 GDBM is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
27 /* Position in input file */
30 char *file; /* file name */
31 unsigned line; /* line number */
32 unsigned col; /* column number */
35 /* Location in input file */
38 struct point beg, end;
41 typedef struct locus gdbm_yyltype_t;
43 #define YYLTYPE gdbm_yyltype_t
45 #define YYLLOC_DEFAULT(Current, Rhs, N) \
50 (Current).beg = YYRHSLOC(Rhs, 1).beg; \
51 (Current).end = YYRHSLOC(Rhs, N).end; \
55 (Current).beg = YYRHSLOC(Rhs, 0).end; \
56 (Current).end = (Current).beg; \
61 #define YY_LOCATION_PRINT(File, Loc) \
64 if ((Loc).beg.col == 0) \
65 fprintf (File, "%s:%u", \
68 else if (strcmp ((Loc).beg.file, (Loc).end.file)) \
69 fprintf (File, "%s:%u.%u-%s:%u.%u", \
71 (Loc).beg.line, (Loc).beg.col, \
73 (Loc).end.line, (Loc).end.col); \
74 else if ((Loc).beg.line != (Loc).end.line) \
75 fprintf (File, "%s:%u.%u-%u.%u", \
77 (Loc).beg.line, (Loc).beg.col, \
78 (Loc).end.line, (Loc).end.col); \
79 else if ((Loc).beg.col != (Loc).end.col) \
80 fprintf (File, "%s:%u.%u-%u", \
82 (Loc).beg.line, (Loc).beg.col, \
85 fprintf (File, "%s:%u.%u", \
92 void vlerror (struct locus *loc, const char *fmt, va_list ap);
93 void lerror (struct locus *loc, const char *fmt, ...);
95 void terror (const char *fmt, ...);
97 void print_prompt (void);
99 int setsource (const char *filename, int intr);
101 extern char *file_name;
102 extern int interactive;
103 extern int open_mode;
105 #define GDBMTOOLRC ".gdbmtoolrc"
106 #define GDBMTOOL_DEFFILE "junk.gdbm"
115 struct slist *slist_new (char *s);
116 void slist_free (struct slist *);
134 struct kvpair *kvpair_string (struct locus *loc, char *val);
135 struct kvpair *kvpair_list (struct locus *loc, struct slist *s);
143 /* Argument to a command handler */
146 struct gdbmarg *next;
154 struct kvpair *kvpair;
158 /* List of arguments */
161 struct gdbmarg *head, *tail;
164 void gdbmarglist_init (struct gdbmarglist *, struct gdbmarg *);
165 void gdbmarglist_add (struct gdbmarglist *, struct gdbmarg *);
166 void gdbmarglist_free (struct gdbmarglist *lst);
168 struct gdbmarg *gdbmarg_string (char *, struct locus *);
169 struct gdbmarg *gdbmarg_datum (datum *, struct locus *);
170 struct gdbmarg *gdbmarg_kvpair (struct kvpair *kvl, struct locus *);
172 int gdbmarg_free (struct gdbmarg *arg);
173 void gdbmarg_destroy (struct gdbmarg **parg);
176 int command_lookup (const char *str, struct locus *loc, struct command **pcmd);
178 int run_command (struct command *cmd, struct gdbmarglist *arglist);
181 void xd_expand (struct xdatum *xd, size_t size);
182 void xd_store (struct xdatum *xd, void *val, size_t size);
189 int (*format) (FILE *, void *ptr, int size);
190 int (*scan) (struct xdatum *xd, char *str);
193 struct datadef *datadef_lookup (const char *name);
197 struct datadef *type;
217 struct dsegm *dsegm_new (int type);
218 struct dsegm *dsegm_new_field (struct datadef *type, char *id, int dim);
219 void dsegm_free_list (struct dsegm *dp);
225 extern struct dsegm *dsdef[];
227 #define VART_STRING 0
231 #define VAR_OK 0 /* operation succeeded */
232 #define VAR_ERR_NOTSET 1 /* Only for variable_get:
233 variable is not set */
234 #define VAR_ERR_NOTDEF 2 /* no such variable */
235 #define VAR_ERR_BADTYPE 3 /* variable cannot be coerced to the
236 requested type (software error) */
237 #define VAR_ERR_BADVALUE 4 /* Only for variable_set: the value is
238 not valid for this variable. */
240 int variable_set (const char *name, int type, void *val);
241 int variable_get (const char *name, int type, void **val);
242 int variable_is_set (const char *name);
243 int variable_is_true (const char *name);
244 void variable_print_all (FILE *fp);
247 int unescape (int c);
249 void begin_def (void);
253 int yyerror (char *s);
256 void datum_format (FILE *fp, datum const *dat, struct dsegm *ds);
257 int datum_scan (datum *dat, struct dsegm *ds, struct kvpair *kv);
258 void dsprint (FILE *fp, int what, struct dsegm *ds);
260 char *mkfilename (const char *dir, const char *file, const char *suf);
261 char *tildexpand (char *s);
262 int vgetyn (const char *prompt, va_list ap);
263 int getyn (const char *prompt, ...);