aboutsummaryrefslogtreecommitdiff
path: root/src/gdbmtool.h
AgeCommit message (Collapse)AuthorFiles
2021-11-20Rearrange the directory structureSergey Poznyakoff1
Sources for the libgdbm library reside in src/. Sources for building accompanying tools are moved to the tools/ subdirectory.
2021-11-16Fix memory leaks in gdbmshellSergey Poznyakoff1
* configure.ac: Don't use $YACC and $LEX (undefined since f4c143fbdf). * src/gdbmshell.c (run_command): Free arglist if not saved to last_args. * src/gdbmtool.c (gdbmtool_init): Correctly report unrecognized long options. * src/gdbmtool.h (YY_LOCATION_PRINT): Define to locus_print. (locus_print): New proto. * src/gram.y: Define destructors for various symbols. * src/lex.l: Save source file names in a linked list. Don't free source name in input_context_pop, because yypush might refer to it via yyloc stack even after readinf eof (e.g. when printing location). The collected list is freed at program exit. (locus_print): New function. * src/parseopt.c (parseopt_free): New function. (parseopt_first): Call parseopt_free. (parseopt_next): Call parseopt_free, depending on the result. * src/var.c (variable) <freehook>: New member. (errormask_freehook): New function. Set it as freehook for errorexit and errormask. (variables_free): Call freehook, if defined.
2021-10-17Change build process: explicitly require bison and flexSergey Poznyakoff1
2021-09-09Add missing includeSergey Poznyakoff1
* src/gdbmtool.h: Include string.h
2021-09-03Change semantics of the errorexit variable.Sergey Poznyakoff1
The "errorexit" variable is a string variable with the same syntax as errormask. If a GDBM error is reported and the corresponding gdbm_errno value is listed in this variable, further script execution is aborted. Setting it as boolean value is equivalent to set errorexit="all". * src/gdbmshell.c (all handlers): Return a GDBMSHELL_* error code. (closedb): Unset the fd variable only after closing the database. (run_command): If handler reported GDBM error and gdbm_errno is listed in the errorexit variable, return 1 (which will cause YYABORT in parser). * src/gdbmtool.h (VAR_ERR_GDBM): New variable error code. (variable_has_errno): New function. (gdbm_error_is_masked): Rewrite using variable_has_errno. * src/gram.y: Abort if run_command or run_last_command return !0. Handle VAR_ERR_GDBM. * src/var.c (variable): New member: data. (errorexit variable): Change type to VART_STRING; install sethook and typeconv. (variable_unset): When unsetting string variable, free and reset its value. (cachesize_sethook,centfree_sethook) (coalesce_sethook): Return VAR_ERR_GDBM on gdbmshell_setopt error. (errormask_sethook): Keep the mask vector in the data member. Handle conversions from boolean. (errorexit_sethook): Call errormask_sethook unless in interactive session.
2021-09-03New gdbmtool variables: errorexit and errormask.Sergey Poznyakoff1
Boolean errorexit controls whether script terminates upon first erroneous return from run_command or its derivatives. The variable can be set only in non-interactive mode. errormask is a comma-delimited list of GDBM error codes that are masked, i.e. that won't trigger a diagnostic message if they occur. * src/gdbmshell.c (all handlers): Return integer value indicating success (0) or failure (!0). * src/gdbmtool.h (input_context_drain): New function. (run_last_command): Return integer. * src/gram.y: abort if run_command returns error and "errorexit" is set. * src/input-argv.c (instream_argv_read): Bugfix. * src/lex.l (input_context_drain): New function. * src/var.c: New variables: errorexit and errormask.
2021-08-13Revise gdbmtool error messagesSergey Poznyakoff1
* src/gdbmshell.c: Revise error messages. Use dberror where appropriate. * src/gdbmtool.h (dberror): New proto. * src/gram.y (dberror): New function.
2021-08-13gdbmtool: always provide stdin streamSergey Poznyakoff1
* src/Makefile.am (libgdbmapp_a_SOURCES): Add input-std.c * src/gdbmshell.c (input_history_begin): Improve diagnostic message. * src/gdbmtool.c (instream_default_create): New define. (gdbmtool_init): Use instream_default_create. * src/gdbmtool.h [WITH_READLINE] (instream_readline_create_: New proto. (input_stream_name): New proto. * src/input-rl.c (instream_stdin_create): Rename to instream_readline_create. Fall back to instream_stdin_create if stdin is not connected to a tty. * src/lex.l (input_stream_name): New function.
2021-08-13Re-implement input history handling to minimize linking requirementsSergey Poznyakoff1
Applications using gbdmshell don't need to link with libreadline, unless they use instream_stdin_create with readline support. * src/gdbmshell.c (input_history_begin) (input_history_handler): New functions. (gdbmshell_run): Remove calls to input_init()/input_done(). * src/gdbmtool.h (instream): New fields: in_history_size, in_history_get. (input_init,input_done): Remove. (instream_history_size,instream_history_get): New functions. (input_history_handler,input_history_begin): Remove. * src/input-rl.c: Incorporate history handling into the stream itself. * src/input-std.c (input_init,input_done): Remove placeholders. * src/lex.l (input_history_size,input_history_get): New functions.
2021-08-12gdbmtool: setting database option affects the current databaseSergey Poznyakoff1
* src/gdbmshell.c (gdbmshell_setopt): New function. * src/gdbmtool.h (gdbmshell_setopt): New proto. * src/var.c: Provide set hooks for: cachesize, coalesce, and centfree.
2021-08-12gdbmshell: get rid of remaining globalsSergey Poznyakoff1
Use gdbmshell variables instead * src/gdbmshell.c (file_name, file_descr) (open_mode, open_format): Remove globals. (opendb,checkdb) (open_handler,import_handler) (status_handler): Use variables instead of globals. (command_tab): Mark the "open" parameter as optional. * src/gdbmtool.c (gdbmtool_init): Use variables instead of globals. * src/gdbmtool.h (file_name, file_descr) (open_mode, open_format): Remove globals. * src/lex.l: Use variables instead of globals. * src/var.c (variable): Rename hook to sethook. New field: typeconv. (vartab): New variables: "filename", "fd". (variable_get): Use typeconv if provided. * tests/gdbmtool/base.exp: Fix expected output. * tests/gdbmtool00.at: Likewise. * tests/gdbmtool01.at: Likewise.
2021-08-10Move gdbmtool shell functions to the library.Sergey Poznyakoff1
* src/Makefile.am (libgdbmapp_a_SOURCES): Move gdbm shell support to the library. * src/gdbmtool.c: Move shell support to another file. * src/gdbmtool.h (file_descr): New extern. (gdbmshell, gdbmshell_run) (variables_init, variables_free): New functions. * src/gdbmtool.supp: New file. * src/var.c (VAR_IS_SET): Change definition. (variable): New member: init. (variable_set): Change meaning of VARF_INIT. (variables_free,variables_init): New protos. * src/gdbmtool.c: New file.
2021-08-10gdbmtool: separate command parameters and environmentSergey Poznyakoff1
2021-08-10gdbmtool: rewrite handler parameter functions; fix memory leaksSergey Poznyakoff1
* src/input-null.c: New file. * src/Makefile.am: Add input-null.c * src/mem.c (e2nrealloc): New function. * src/gdbmapp.h (e2nrealloc): New proto. * src/gdbmtool.c (quit_handler): Exit from parser instead of exiting from the program. (param): Remove global. (param_expand,param_push_arg,param_free): New functions for handling parameters. (param_free_argv): Take a single argument. Clear all parameters up to argc. (run_command): Rewrite parameter handling using new functions. (main): Call input_init() after the input stream has been set up. Call yylex_destroy when finished. * src/gdbmtool.h (instream_null_create): New proto. (handler_param): Change type of argc to size_t. New field argmax. (HANDLER_PARAM_INITIALIZER): New define. (yylex_destroy): New proto. * src/input-rl.c (history_file_name): New static. (get_history_file_name): Initialize history_file_name. (input_init): Initialize input history only in interactive mode. (input_done): Free input history only in interactive mode.
2021-08-03gdbmtool: control the format in which new databases are createdSergey Poznyakoff1
* src/gdbmload.c (_gdbm_str2fmt): New function. * src/proto.h (_gdbm_str2fmt): New proto. * src/gdbmtool.c (open_format): New global variable. (opendb): Add open_format to gdbm_open flags * src/gdbmtool.h (open_format): New extern. * src/var.c: Handle the "format" variable. * doc/gdbm.texi: Document the changes.
2021-01-02Update copyright yearsSergey Poznyakoff1
2020-12-23Update copyright yearsSergey Poznyakoff1
2020-10-09Implement tagged structure initializers.Sergey Poznyakoff1
* NEWS: Document changes. * doc/gdbm.texi: Document changes. * src/datconv.c (datum_scan_tag): Implement tagged structure initialization. * src/gdbmtool.c (kvlist_free): Made extern. (kvlist_find): New function. * src/gdbmtool.h (kvlist_find, kvlist_free) (dsegm_list_find): New protos. (dsegm_free_list): Rename to dsegm_list_free. All uses changed. * src/gram.y: Forbid duplicate tags in kvlist.
2019-04-08Update copyright yearsSergey Poznyakoff1
2018-05-24Various fixesSergey Poznyakoff1
* src/input-std.c: Bugfix * doc/gdbm.texi: Document changes. * README: Update. * configure.ac: New option --enable-gdbmtool-debug. * src/Makefile.am: Conditionally augment AM_YFLAGS and AM_LFLAGS with options that enable debugging. * src/gdbmtool.c: Conditionally enable --lex-trace and --gram-trace options. * src/gram.y: Likewise. * src/lex.l: Likewise. * tests/Makefile.am: Remove architecure-dependent tests. * tests/testsuite.at: Likewise.
2018-05-23gdbmtool: accept commands from command line as well as from fileSergey Poznyakoff1
Commands can be supplied to gdbmtool in three ways: 1. From a file, using the --file (-f) option: gdbmtool -f comfile 2. From the command line, if first argument is the database name: gdbmtool test.db count \; fetch mykey \; avail Note the use of semicolon to delimit commands. 3. From the interactive shell, if neither of the above is used. * src/Makefile.am: Add new sources. * src/gdbmtool.c: Use new stream functions for input. * src/gdbmtool.h (setsource): Remove proto. (instream_t): New data type. (instream_name, instream_read) (instream_close, instream_interactive) (instream_eq): New functions. (instream_stdin_create) (instream_argv_create) (instream_file_create) (interactive, input_context_push): New protos. * src/gram.y: Accept ; in place of newline. * src/input-argv.c: New file. * src/input-file.c: New file. * src/input-rl.c: Rewrite to provide instream_t API. * src/input-std.c: Likewise. * src/lex.l: Rewrite. * tests/.gitignore: Update. * tests/Makefile.am: Add new tests. Incorporate DejaGNU tests. * tests/config/default.exp: New file. * tests/gdbmtool/base.exp: New file. * tests/gdbmtool00.at: New file. * tests/gdbmtool01.at: New file. * tests/gdbmtool02.at: New file. * tests/testsuite.at: Include new tests.
2018-01-01Happy GNU YearSergey Poznyakoff1
2017-01-02Happy GNU YearSergey Poznyakoff1
2016-07-25Add debug info.Sergey Poznyakoff1
* configure.ac: Fix description wording. * src/Makefile.am [GDBM_COND_DEBUG_ENABLE]: Don't define GDBM_DEBUG_ENABLE. * tests/Makefile.am: Likewise. * src/debug.c (gdbm_debug_printer) (gdbm_debug_flags): New globals. (gdbm_debug_token, gdbm_debug_parse_state) (gdbm_debug_datum): New functions. * src/gdbm.h.in [@GDBM_DEBUG_ENABLE@]: Define GDBM_DEBUG_ENABLE. (gdbm_debug_printer_t): New typedef. (gdbm_debug_printer, gdbm_debug_flags): New externs. (GDBM_DEBUG_ERR,GDBM_DEBUG_OPEN) (GDBM_DEBUG_READ,GDBM_DEBUG_STORE) (GDBM_DEBUG_LOOKUP,GDBM_DEBUG_ALL): New defines. (gdbm_debug_token,gdbm_debug_parse_state) (gdbm_debug_datum): New protos. * src/gdbmdefs.h (GDBM_DEBUG,GDBM_DEBUG_DATUM): New macros. * src/findkey.c: Add debugging info. * src/gdbmfetch.c: Likewise. * src/gdbmopen.c: Likewise. * src/gdbmseq.c: Likewise. * src/gdbmstore.c: Likewise. * src/gdbmtool.c (open_handler): Allow the use of ~/ (command) <repeat,variadic>: New members. (run_command): Handle variadic functions. (run_last_command): New command. In interactive mode, repeats the last command if it was marked with repeat=1 (currently, only "next"). New command: "debug". (all functions): Use terror instead of fprintf(stderr,...); * src/gdbmtool.h (handler_param) <vararg>: New member. (run_last_command): New proto. * src/gram.y: Call run_last_command) on empty input. * tests/gtload.c: New option: -debug=
2016-07-13gdbmtool: define macros for accessing typed handler arguments.Sergey Poznyakoff1
* src/gdbmtool.h (PARAM_STRING, PARAM_DATUM) (PARAM_KVPAIR): New defines. * src/gdbmtool.c: Use above for accessing handler arguments.
2016-07-12Line-editing support in gdbmtoolSergey Poznyakoff1
* configure.ac: Check if GNU Readline is available. * src/Makefile.am: Add new files. * src/input-rl.c: New file. * src/input-std.c: New file. * src/gdbmtool.c (handler_param): Move declaration to the header file. (quit_handler): Call input_done. (command_tab): Add the "history" command. (command_generator): New function. (slist_new_s, slist_new_l) (slist_insert): New functions. (main): Call input_init and input_done. * src/gdbmtool.h: New protos. * src/gram.y: Use slist_insert to construct string lists. * src/lex.l (read_input): Remove. Use input_read instead. (print_prompt_at_bol): New function. (print_prompt): Remove. (make_prompt): New function. * NEWS: Document changes. * README: Document readline support. * doc/gdbm.texi: Document line editing in gdbmtool. * doc/gdbmtool.1: Likewise.
2016-05-16Minor improvementsSergey Poznyakoff1
* src/gdbmtool.c (_gdbm_print_bucket_cache): Use %zu to print size_t. * src/gdbmtool.h (variable_unset): New proto. (yyerror): Argument is char const *. src/gram.y: Likewise. * src/lex.l: Add option noinput * src/parseopt.c (print_option_descr): Use fwrite instead of printf. * src/var.c: Fix initializers to suppress warnings.
2014-05-23Compatibility bugfixesSergey Poznyakoff1
* THANKS: Add Thomas Klausner. * src/gdbmtool.h: Rename ARG_ constants to GDBM_ARG_ * src/gdbmtool.c: Likewise. * tests/create00.at: Use modern sort -k syntax. * tests/dbmcreate00.at: Likewise. * tests/dbmdel00.at: Likewise. * tests/delete00.at: Likewise.
2013-05-15Add "pager" variable and "unset" command.Sergey Poznyakoff1
* src/gdbmtool.c (command_tab) <unset>: New command. (run_command): Get pager value from the variable. * src/gdbmtool.h (VAR_ERR_NOTSET): New error code. (variable_is_true): New function. Replaces variable_is_set, which changed semantics. * src/gram.y: Implement the unset command. * src/var.c: Support the "unset variable" notion. (VARF_INIT): New flag. (VAR_IS_SET): New define. (vartab): Mark initialized variables with VARF_INIT. New variable "pager". (open_hook): v can be NULL. (variable_set): NULL value unsets the variable. (variable_unset): New function. (variable_get): Return VAR_ERR_NOTSET if the variable is not set. (variable_is_true): Renamed from variable_is_set. (variable_is_set): New function. * src/gdbmdefs.h: Fix some typos.
2013-05-14Change variable support.Sergey Poznyakoff1
* src/util.c: New file. * src/Makefile.am: Add new files. * src/gdbmtool.c (open_mode): New variable. (terror): Remove. (mkfilename, tildexpand): Move to util.c (opendb): Use open_mode. (import_handler): Likewise. (optab): New option -N (--norc). * src/gdbmtool.h (vparse_error): Rename to vlerror. (parse_error): Rename to lerror. (syntax_error): Rename tp terror. All uses updated. (VAR_ERR_FAILURE): Remove. (VAR_ERR_BADVALUE): New error code. (variable_mode_name): Remove. (mkfilename, tildexpand) (vgetyn, getyn): New protos. * src/lex.l (initialized): New static. (setsource): Set initialized. (vlerror): Print locus only if the lexer has been initialized. * src/var.c: Rewrite.
2013-05-14Provide "open" and "close" commands; implement new variables.Sergey Poznyakoff1
* src/datconv.c (datum_format): Don't print field delimiter after the last field. (dsprint): Bugfix. * src/gdbmload.c (gdbm_load_from_file): Return GDBM_NO_DBNAME when loading from bdb dump and the database pointer is NULL. * src/gdbmtool.c (opendb, checkdb): New auxiliary functions. (begin handlers): call checkdb. (import_handler): Special handling for GDBM_NO_DBNAME. (status_handler): Print more info. (command_tab): Call checkdb prior to handlers that expect an open database. New commands: open, close (gdbmarg_string, gdbmarg_datum) (gdbmarg_kvpair): Take pointer to locus as the 2nd argument. All uses changed. (coerce): Include locus info in the diagnostic message. (main): Don't open database right away. * src/gdbmtool.h (GDBMTOOL_DEFFILE): New define. (gdbmarg) <loc>: New member. (VART_INT): New variable typ.e (VAR_ERR_FAILURE): New error code. (variable_is_set, varible_mode_name): New protos. * src/gram.y: Provide printable token names for error messages. Pass locus to gdbmarg initialization functions. * src/lex.l (vparse_error): Fix output. * src/var.c (variable) <v.num, hook, hook_data>: New members. (vartab): Define more variables. (variable_set): Accept value of any valid datatype. (variable_mode_name, variable_is_set): New functions.
2013-05-14Cleanup.Sergey Poznyakoff1
* src/datconv.c (s_float): Use strtod. (datum_scan_notag, datum_scan_tag): Made static. (dsprint): New function. * src/gdbmtool.c (status_handler): Print ket and content definitions. (slist_new): Bugfix (missing return statement). * src/gdbmtool.h: Add new prototypes. * src/lex.l: Remove unused variables, set option nounput.
2013-05-14Implement rc files and "source" command; improve lexical analyzer.Sergey Poznyakoff1
* src/gdbmtool.c (interactive): Move to lex.l; (mkfilename, tildexpand): New functions. (command_tab) <source>: New command. (main): Source rc file, if present. * src/gdbmtool.h (setsource): Change return type and signature. * src/lex.l: Implement context stack. Change DEF to be an exclusive state. * src/gdbmapp.h (estrdup): Argument is const. * src/mem.c: Likewise.
2013-05-13Add support for Berkeley dump format version 3 (read-only).Sergey Poznyakoff1
* src/gdbmapp.h: Include gettext.h and locale.h. * src/gdbmload.c: Support for Berkeley dump format, version 3.
2013-05-13Add "set" and "define" to the main command table.Sergey Poznyakoff1
* src/gdbmtool.c: Include gram.h (command) <tok>: New member. (command_tab): List "define" and "set". (find_command): Rewrite as command_lookup, with different return type and signature. (run_command): Take struct command * as its first argument. * src/gdbmtool.h (command_lookup): New proto. (run_command): Change signature. (datadef_locate): Rename to datadef_lookup. All uses changed. * src/gram.y: Update. * src/lex.l: Change handling of IDENT rules.
2013-05-13Implement shell variables in gdbmtool.Sergey Poznyakoff1
* src/var.c: New file. * src/datconv.c (datum_format): Remove the "delim" parameter, use "delim1" and "delim2" shell variables instead. * src/gdbmtool.c: Remove "prompt" command. Use "set ps[12]" instead. (print_prompt): Move to lex.l * src/gdbmtool.h (variable_set) (variable_get, variable_print_all): New protos. * src/gram.y: Handle the "set" command. * src/lex.l: Update.
2013-05-13Handle structured key and content data in gdbmtool.Sergey Poznyakoff1
* src/datconv.c: New file. * src/Makefile.am (gdbmtool_SOURCES): Add datconv.c. * src/gdbmtool.h (slist, kvpair): New structures. (gdbmarg): Keep various types of data depending on the value of the type member. (slist_new, slist_free) (kvpair_string, kvpair_list): New protos. (gdbmarg_new): Remove. (gdbmarg_string, gdbmarg_datum) (gdbmarg_kvpair, gdbmarg_free) (gdbmarg_destroy): New protos. (xd_expand, xd_store, datadef_locate): New protos. (field, dsegm): New structs. (dsegm_new, dsegm_new_field, dsegm_free_list): New protos. * src/gdbmtool.c: Rewrite. * src/gram.y: Change grammar to allow for defining key and content structure and for supplying structured data as arguments to fetch, store and similar functions. * src/lex.l: Handle new token types. * tests/dtload.c (main): Fix parser. * tests/gtload.c: Likewise.
2013-05-11Rewrite gdbmtool parser.Sergey Poznyakoff1
* src/testgdbm.c: Remove. * src/gdbmtool.c: New file. * src/gdbmtool.h: New file. * src/gram.y: New file. * src/lex.l: New file. * src/Makefile.am: Update.

Return to:

Send suggestions and report system problems to the System administrator.