ARB
Classes | Macros | Functions | Variables
ad_save_load.cxx File Reference
#include <unistd.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <arb_file.h>
#include <arb_diff.h>
#include <arb_zfile.h>
#include <arb_defs.h>
#include <arb_strbuf.h>
#include "gb_key.h"
#include "gb_map.h"
#include "gb_load.h"
#include "ad_io_inline.h"
#include <arb_misc.h>
#include <SigHandler.h>
Include dependency graph for ad_save_load.cxx:

Go to the source code of this file.

Classes

class  ArbDBWriter
 

Macros

#define GB_PUT(c, out)   do { if (c>=10) c+='A'-10; else c += '0'; *(out++) = (char)c; } while (0)
 
#define GB_PUT_OUT(c, out)   do { if (c>=10) c+='A'-10; else c += '0'; putc(c, out); } while (0)
 
#define SUPPORTED_COMPRESSION_FLAGS   "zBx"
 

Functions

chargb_findExtension (char *path)
 
charSTATIC_BUFFER (SmartCharPtr &strvar, int minlen)
 
GB_CSTR gb_oldQuicksaveName (GB_CSTR path, int nr)
 
GB_CSTR gb_quicksaveName (GB_CSTR path, int nr)
 
GB_CSTR gb_mapfile_name (GB_CSTR path)
 
GB_CSTR GB_mapfile (GBDATA *gb_main)
 
static GB_CSTR gb_overwriteName (GB_CSTR path)
 
static GB_CSTR gb_reffile_name (GB_CSTR path)
 
static chargb_full_path (const char *path)
 
static GB_ERROR gb_delete_reference (const char *master)
 
static GB_ERROR gb_create_reference (const char *master)
 
static GB_ERROR gb_add_reference (const char *master, const char *changes)
 
static GB_ERROR gb_remove_quick_saved (GB_MAIN_TYPE *Main, const char *path)
 
static GB_ERROR gb_remove_all_but_main (GB_MAIN_TYPE *Main, const char *path)
 
static GB_ERROR deleteSuperfluousQuicksaves (GB_MAIN_TYPE *Main)
 
static GB_ERROR renameQuicksaves (GB_MAIN_TYPE *Main)
 
long gb_ascii_2_bin (const char *source, GBENTRY *gbe)
 
static GB_BUFFER gb_bin_2_ascii (GBENTRY *gbe)
 
static bool gb_write_childs (FILE *out, GBCONTAINER *gbc, GBCONTAINER *&gb_writeFrom, GBCONTAINER *gb_writeTill, int indent)
 
static bool gb_write_one_child (FILE *out, GBDATA *gb, GBCONTAINER *&gb_writeFrom, GBCONTAINER *gb_writeTill, int indent)
 
long gb_read_bin_error (FILE *in, GBDATA *gbd, const char *text)
 
static int gb_is_writeable (gb_header_list *header, GBDATA *gbd, long version, long diff_save)
 
static int gb_write_bin_sub_containers (FILE *out, GBCONTAINER *gbc, long version, long diff_save, int is_root)
 
static long gb_write_bin_rek (FILE *out, GBDATA *gbd, long version, long diff_save, long index_of_master_file)
 
static int gb_write_bin (FILE *out, GBCONTAINER *gbc, uint32_t version)
 
GB_ERROR GB_save (GBDATA *gb, const char *path, const char *savetype)
 
GB_ERROR GB_create_parent_directory (const char *path)
 
GB_ERROR GB_create_directory (const char *path)
 
GB_ERROR GB_save_in_arbprop (GBDATA *gb, const char *path, const char *savetype)
 
static GB_ERROR protect_corruption_error (const char *savepath)
 
const charGB_get_supported_compression_flags (bool verboose)
 
GB_ERROR GB_start_streamed_save_as (GBDATA *gbd, const char *path, const char *savetype, ArbDBWriter *&writer)
 
GB_ERROR GB_stream_save_part (ArbDBWriter *writer, GBDATA *from, GBDATA *till)
 
GB_ERROR GB_finish_stream_save (ArbDBWriter *&writer)
 
GB_ERROR GB_save_as (GBDATA *gbd, const char *path, const char *savetype)
 
GB_ERROR GB_delete_database (GB_CSTR filename)
 
GB_ERROR GB_save_quick_as (GBDATA *gbd, const char *path)
 
GB_ERROR GB_save_quick (GBDATA *gbd, const char *refpath)
 
void GB_disable_path (GBDATA *gbd, const char *path)
 
long GB_last_saved_clock (GBDATA *gb_main)
 
GB_ULONG GB_last_saved_time (GBDATA *gb_main)
 

Variables

GB_MAIN_TYPEgb_main_array [GB_MAIN_ARRAY_SIZE]
 
static bool seen_corrupt_data = false
 

Macro Definition Documentation

#define GB_PUT (   c,
  out 
)    do { if (c>=10) c+='A'-10; else c += '0'; *(out++) = (char)c; } while (0)

Definition at line 358 of file ad_save_load.cxx.

Referenced by gb_bin_2_ascii().

#define GB_PUT_OUT (   c,
  out 
)    do { if (c>=10) c+='A'-10; else c += '0'; putc(c, out); } while (0)

Definition at line 419 of file ad_save_load.cxx.

Referenced by gb_write_one_child().

#define SUPPORTED_COMPRESSION_FLAGS   "zBx"

Function Documentation

char* gb_findExtension ( char path)

Definition at line 30 of file ad_save_load.cxx.

References NULp.

Referenced by GB_login(), gb_mapfile_name(), gb_oldQuicksaveName(), gb_quicksaveName(), and gb_reffile_name().

char* STATIC_BUFFER ( SmartCharPtr &  strvar,
int  minlen 
)
inline
GB_CSTR gb_oldQuicksaveName ( GB_CSTR  path,
int  nr 
)

Definition at line 57 of file ad_save_load.cxx.

References gb_findExtension(), and STATIC_BUFFER().

Referenced by GB_login(), and gb_remove_quick_saved().

GB_CSTR gb_quicksaveName ( GB_CSTR  path,
int  nr 
)
GB_CSTR gb_mapfile_name ( GB_CSTR  path)
GB_CSTR GB_mapfile ( GBDATA gb_main)

Definition at line 102 of file ad_save_load.cxx.

References GB_MAIN(), gb_mapfile_name(), and GB_MAIN_TYPE::path.

Referenced by run_command().

static GB_CSTR gb_overwriteName ( GB_CSTR  path)
static
static GB_CSTR gb_reffile_name ( GB_CSTR  path)
static
static char* gb_full_path ( const char path)
static
static GB_ERROR gb_delete_reference ( const char master)
static

Definition at line 147 of file ad_save_load.cxx.

References error(), gb_full_path(), gb_reffile_name(), GB_unlink_or_warn(), and NULp.

Referenced by ArbDBWriter::finishSave().

static GB_ERROR gb_create_reference ( const char master)
static
static GB_ERROR gb_add_reference ( const char master,
const char changes 
)
static
static GB_ERROR gb_remove_quick_saved ( GB_MAIN_TYPE Main,
const char path 
)
static
static GB_ERROR gb_remove_all_but_main ( GB_MAIN_TYPE Main,
const char path 
)
static
static GB_ERROR deleteSuperfluousQuicksaves ( GB_MAIN_TYPE Main)
static
static GB_ERROR renameQuicksaves ( GB_MAIN_TYPE Main)
static
long gb_ascii_2_bin ( const char source,
GBENTRY gbe 
)

Definition at line 284 of file ad_save_load.cxx.

References A_TO_I, gb_flag_types::compressed_data, GBDATA::flags, and s.

Referenced by gb_parse_ascii_rek().

static GB_BUFFER gb_bin_2_ascii ( GBENTRY gbe)
static
static bool gb_write_childs ( FILE *  out,
GBCONTAINER gbc,
GBCONTAINER *&  gb_writeFrom,
GBCONTAINER gb_writeTill,
int  indent 
)
static

write database entries to stream (used by ASCII database save)

Parameters
outoutput stream
gbccontainer to write (including all subentries if gb_writeFrom and gb_writeTill are NULp).
gb_writeFromif specified -> assume opening tag of container gb_writeFrom and all its subentries have already been written. Save closing tag and all following containers.
gb_writeTillif specified -> write till opening tag of container gb_writeTill
indentindentation for container gbc
Returns
true if closing containers shall be written

Definition at line 541 of file ad_save_load.cxx.

References gb_assert, GB_child(), GB_nextChild(), and gb_write_one_child().

Referenced by gb_write_one_child().

static bool gb_write_one_child ( FILE *  out,
GBDATA gb,
GBCONTAINER *&  gb_writeFrom,
GBCONTAINER gb_writeTill,
int  indent 
)
static

parameters same as for gb_write_childs() The differences between both functions are:

  • gb_write_one_child can be called for entries and writes container tags if called with a container
  • gb_write_childs can only be called with containers and does NOT write enclosing container tags

Definition at line 423 of file ad_save_load.cxx.

References ARB_float_2_ascii(), GBDATA::as_container(), GBDATA::as_entry(), GBDATA::flags, GBDATA::flags2, gb_assert, gb_bin_2_ascii(), GB_BITS, GB_BYTE, GB_BYTES, GB_DB, GB_FLOAT, GB_FLOATS, GB_get_db_path(), GB_INT, GB_INTS, GB_KEY(), GB_OBSOLETE, GB_PUT_OUT, GB_read_bits_pntr(), GB_read_byte(), GB_read_char_pntr(), GB_read_flag(), GB_read_float(), GB_read_int(), GB_STRING, GB_SYSTEM_FOLDER, GB_warningf(), gb_write_childs(), GBS_fwrite_string(), GBDATA::is_container(), gb_flag_types2::last_updated, NULp, s, gb_flag_types::security_delete, gb_flag_types::security_read, gb_flag_types::security_write, and GBDATA::type().

Referenced by gb_write_childs().

long gb_read_bin_error ( FILE *  in,
GBDATA gbd,
const char text 
)

Definition at line 567 of file ad_save_load.cxx.

References GB_export_errorf(), GB_KEY(), GB_print_error(), and long.

Referenced by gb_read_bin(), gb_read_bin_rek_V2(), and read_keyword().

static int gb_is_writeable ( gb_header_list header,
GBDATA gbd,
long  version,
long  diff_save 
)
static
static int gb_write_bin_sub_containers ( FILE *  out,
GBCONTAINER gbc,
long  version,
long  diff_save,
int  is_root 
)
static
static long gb_write_bin_rek ( FILE *  out,
GBDATA gbd,
long  version,
long  diff_save,
long  index_of_master_file 
)
static
static int gb_write_bin ( FILE *  out,
GBCONTAINER gbc,
uint32_t  version 
)
static
GB_ERROR GB_save ( GBDATA gb,
const char path,
const char savetype 
)

save database

Parameters
gbdatabase root
pathfilename (if NULp -> use name stored in DB; otherwise store name in DB)
savetype
See also
GB_save_as()

Definition at line 804 of file ad_save_load.cxx.

References GB_MAIN(), and GB_save_as().

Referenced by ARB_main(), MG_save_cb(), NT_save_as_cb(), react_to_command(), and saveArb().

GB_ERROR GB_create_parent_directory ( const char path)
GB_ERROR GB_create_directory ( const char path)
GB_ERROR GB_save_in_arbprop ( GBDATA gb,
const char path,
const char savetype 
)

save database inside arb-properties-directory. Automatically creates subdirectories as needed.

Parameters
gbdatabase root
pathfilename (if NULp -> use name stored in DB)
savetype
See also
GB_save_as()

Definition at line 840 of file ad_save_load.cxx.

References ARB_strdup(), error(), GB_create_parent_directory(), GB_MAIN(), GB_path_in_arbprop(), and GB_save_as().

Referenced by AW_root::save_properties().

static GB_ERROR protect_corruption_error ( const char savepath)
static
const char* GB_get_supported_compression_flags ( bool  verboose)
GB_ERROR GB_start_streamed_save_as ( GBDATA gbd,
const char path,
const char savetype,
ArbDBWriter *&  writer 
)

special save implementation for use in pipelines (e.g. silva) 'savetype' has contain 'a' (ascii) 'writer' has to be NULp (object will be constructed and assigned to)

Actual saving of data is triggered by GB_stream_save_part(). When done with saving part, call GB_finish_stream_save() - even in case of error!

Definition at line 1320 of file ad_save_load.cxx.

References gb_assert, GB_MAIN(), and ArbDBWriter::startSaveAs().

GB_ERROR GB_stream_save_part ( ArbDBWriter writer,
GBDATA from,
GBDATA till 
)

saves a part of the database.

save complete database: GB_stream_save_part(w, gb_main, gb_main);

save database in parts: GB_stream_save_part(w, gb_main, gb_some_container); forall (gb_some_sub_container) { // you may create/modify gb_some_sub_container here GB_stream_save_part(w, gb_some_sub_container, gb_some_sub_container); // you may delete/modify gb_some_sub_container here } GB_stream_save_part(w, gb_some_container, gb_main);

Note: gb_some_sub_container has to be a child of gb_some_container

Definition at line 1332 of file ad_save_load.cxx.

References GBDATA::as_container(), error(), GBDATA::is_container(), and ArbDBWriter::saveFromTill().

GB_ERROR GB_finish_stream_save ( ArbDBWriter *&  writer)

complete save-process started with GB_start_streamed_save_as() Has to be called (even if GB_start_streamed_save_as or GB_stream_save_part has returned an error!)

Definition at line 1358 of file ad_save_load.cxx.

References error(), ArbDBWriter::finishSave(), and NULp.

GB_ERROR GB_save_as ( GBDATA gbd,
const char path,
const char savetype 
)

Save whole database

Parameters
gbddatabase root
pathfilename (if NULp -> use name stored in DB)
savetype'a' ascii 'b' binary 'm' save mapfile (only together with binary)

'f' force saving even in disabled path to a different directory (out of order save) 'S' save to stdout (used in arb_2_ascii when saving to stdout; also useful for debugging)

Extra compression flags: 'z' stream through gzip/pigz 'B' stream through bzip2 'x' stream through xz

Definition at line 1371 of file ad_save_load.cxx.

References gb_assert, GB_MAIN(), NULp, RETURN_ERROR, and GB_MAIN_TYPE::save_as().

Referenced by ARB_main(), FINAL_TYPE< SEQTYPE >::ArbWriter(), calc_pvp(), FINAL_TYPE< SEQTYPE >::finish(), GB_save(), GB_save_in_arbprop(), main(), pd_export_pt_server(), and run_command().

GB_ERROR GB_delete_database ( GB_CSTR  filename)

Definition at line 1418 of file ad_save_load.cxx.

References error(), GB_await_error(), gb_remove_all_but_main(), GB_unlink(), and NULp.

Referenced by nt_delete_database().

GB_ERROR GB_save_quick_as ( GBDATA gbd,
const char path 
)

Definition at line 1511 of file ad_save_load.cxx.

References GB_MAIN(), and GB_MAIN_TYPE::save_quick_as().

Referenced by MG_save_quick_result_cb(), and NT_save_quick_as_cb().

GB_ERROR GB_save_quick ( GBDATA gbd,
const char refpath 
)

Definition at line 1593 of file ad_save_load.cxx.

References GB_MAIN(), and GB_MAIN_TYPE::save_quick().

Referenced by NT_save_quick_cb().

void GB_disable_path ( GBDATA gbd,
const char path 
)

Definition at line 1598 of file ad_save_load.cxx.

References GB_MAIN(), GBS_eval_env(), and NULp.

Referenced by GBT_open().

long GB_last_saved_clock ( GBDATA gb_main)

Definition at line 1603 of file ad_save_load.cxx.

References GB_MAIN(), and GB_MAIN_TYPE::last_saved_transaction.

Referenced by nt_disconnect_from_db().

GB_ULONG GB_last_saved_time ( GBDATA gb_main)

Definition at line 1607 of file ad_save_load.cxx.

References GB_MAIN(), and GB_MAIN_TYPE::last_saved_time.

Referenced by nt_disconnect_from_db().

Variable Documentation

Definition at line 28 of file ad_save_load.cxx.

Referenced by gb_make_main_idx(), gb_read_bin(), and GB_MAIN_TYPE::release_main_idx().

bool seen_corrupt_data = false
static