ARB
Classes | Macros | Functions | Variables
ad_load.cxx File Reference
#include <cctype>
#include <ctime>
#include <netinet/in.h>
#include <sys/stat.h>
#include <arbdbt.h>
#include <arb_str.h>
#include <arb_file.h>
#include <arb_defs.h>
#include <arb_progress.h>
#include <arb_zfile.h>
#include <BufferedFileReader.h>
#include "gb_key.h"
#include "gb_localdata.h"
#include "gb_map.h"
#include "gb_load.h"
#include "ad_io_inline.h"
Include dependency graph for ad_load.cxx:

Go to the source code of this file.

Classes

struct  BufferedPipeReader
 

Macros

#define FILESIZE_GRANULARITY   1024
 
#define DEBUG_DUMP_INDENTED(d, s)
 

Functions

void GB_set_verbose ()
 
static const chargetToken (char **line)
 
static GB_ERROR set_protection_level (GB_MAIN_TYPE *Main, GBDATA *gbd, const char *p)
 
static GB_ERROR gb_parse_ascii_rek (LineReader &r, GBCONTAINER *gb_parent, const char *parent_name)
 
static GB_ERROR gb_parse_ascii (LineReader &r, GBCONTAINER *gb_parent)
 
static GB_ERROR gb_read_ascii_beyond_header (FILE *in, const char *path, GBCONTAINER *gbc)
 
static long gb_recover_corrupt_file (GBCONTAINER *gbc, FILE *in, GB_ERROR recovery_reason, bool loading_quick_save)
 
static long gb_read_bin_rek_V2 (FILE *in, GBCONTAINER *gbc_dest, long nitems, long version, long reversed, long deep, arb_progress &progress)
 
static GBDATAgb_search_system_folder_rek (GBDATA *gbd)
 
static void gb_search_system_folder (GBDATA *gb_main)
 
bool read_keyword (const char *expected_keyword, FILE *in, GBCONTAINER *gbc)
 
static long gb_read_bin (FILE *in, GBCONTAINER *gbc, bool allowed_to_load_diff, arb_progress &progress)
 
void GB_set_next_main_idx (long idx)
 
GB_MAIN_IDX gb_make_main_idx (GB_MAIN_TYPE *Main)
 
bool is_binary_db_id (int id)
 
bool has_ascii_db_id (uint32_t bin_id, FILE *in)
 
static GB_ERROR init_tmp_branch (GBDATA *gb_main)
 
static GBDATAGB_login (const char *cpath, const char *opent, const char *user)
 
GBDATAGB_open (const char *path, const char *opent)
 
GB_ERROR GBT_check_arb_file (const char *name)
 

Variables

static int gb_verbose_mode = 0
 
static long gb_next_main_idx_for_mapfile = 0
 

Macro Definition Documentation

#define FILESIZE_GRANULARITY   1024

Definition at line 35 of file ad_load.cxx.

Referenced by GB_login(), and gb_read_bin_rek_V2().

#define DEBUG_DUMP_INDENTED (   d,
  s 
)

Definition at line 376 of file ad_load.cxx.

Referenced by gb_read_bin_rek_V2().

Function Documentation

void GB_set_verbose ( void  )

Definition at line 31 of file ad_load.cxx.

Referenced by ARB_main(), and probe_read_data_base().

static const char* getToken ( char **  line)
static

Definition at line 48 of file ad_load.cxx.

References line.

Referenced by gb_parse_ascii_rek().

static GB_ERROR set_protection_level ( GB_MAIN_TYPE Main,
GBDATA gbd,
const char p 
)
static
static GB_ERROR gb_parse_ascii_rek ( LineReader r,
GBCONTAINER gb_parent,
const char parent_name 
)
static
static GB_ERROR gb_parse_ascii ( LineReader r,
GBCONTAINER gb_parent 
)
static
static GB_ERROR gb_read_ascii_beyond_header ( FILE *  in,
const char path,
GBCONTAINER gbc 
)
static
static long gb_recover_corrupt_file ( GBCONTAINER gbc,
FILE *  in,
GB_ERROR  recovery_reason,
bool  loading_quick_save 
)
static
static long gb_read_bin_rek_V2 ( FILE *  in,
GBCONTAINER gbc_dest,
long  nitems,
long  version,
long  reversed,
long  deep,
arb_progress progress 
)
static

Definition at line 380 of file ad_load.cxx.

References arb_progress::aborted(), GB_MAIN_TYPE::allow_corrupt_file_recovery, GBDATA::as_container(), GBDATA::as_entry(), buffer, GB_MAIN_TYPE::clock, gb_flag_types::compressed_data, GBDATA::create_extended(), GBCONTAINER::d, DEBUG_DUMP_INDENTED, arb_progress::error_if_aborted(), gb_header_flags::ever_changed, FILESIZE_GRANULARITY, gb_header_flags::flags, gb_header_list::flags, GBDATA::flags, GBDATA::flags2, GBENTRY::free_data(), gb_assert, GB_BITS, GB_BYTE, GB_BYTES, gb_create_header_array(), GB_DATA_LIST_HEADER(), GB_DB, gb_delete_entry(), GB_DELETED, GB_export_error(), GB_FLOAT, GB_FLOATS, gb_get_number(), GB_give_buffer(), GB_give_buffer_size(), GB_HEADER_LIST_GBD(), GB_increase_buffer(), GB_INT, GB_internal_error(), GB_INTS, GB_MAIN(), gb_make_container(), gb_make_entry(), GB_OBSOLETE, gb_read_bin_error(), gb_recover_corrupt_file(), GB_STRING, GB_STRING_SHRT, GB_warning(), GBCONTAINER_MAIN(), GBS_global_string(), GBTUM_SHORT_STRING_SIZE, gb_data_base_type_union::i, implicated, arb_progress::inc_to(), GBDATA::index, GBENTRY::index_check_out(), GBENTRY::info, GBENTRY::insert_data(), GB_MAIN_TYPE::keycnt, GB_MAIN_TYPE::keys, gb_flag_types2::last_updated, gb_data_list::nheader, gb_Key::nref_last_saved, NULp, quark2key(), gb_flag_types::security_delete, gb_flag_types::security_read, gb_flag_types::security_write, gb_header_flags::set_change(), SET_GB_HEADER_LIST_GBD(), GBDATA::touch_creation_and_update(), type, GBDATA::type(), and gb_flag_types::unused.

Referenced by gb_read_bin().

static GBDATA* gb_search_system_folder_rek ( GBDATA gbd)
static
static void gb_search_system_folder ( GBDATA gb_main)
static
bool read_keyword ( const char expected_keyword,
FILE *  in,
GBCONTAINER gbc 
)
inline

Definition at line 640 of file ad_load.cxx.

References gb_assert, gb_read_bin_error(), gb_read_in_uint32(), and GBS_global_string().

Referenced by gb_read_bin().

static long gb_read_bin ( FILE *  in,
GBCONTAINER gbc,
bool  allowed_to_load_diff,
arb_progress progress 
)
static
void GB_set_next_main_idx ( long  idx)

Definition at line 918 of file ad_load.cxx.

Referenced by ARB_main().

GB_MAIN_IDX gb_make_main_idx ( GB_MAIN_TYPE Main)

Definition at line 922 of file ad_load.cxx.

References gb_assert, gb_main_array, GB_MAIN_ARRAY_SIZE, GB_random(), initialized, NULp, and short.

Referenced by GB_login(), and gb_save_mapfile().

bool is_binary_db_id ( int  id)
inline

Definition at line 982 of file ad_load.cxx.

References GBTUM_MAGIC_NUMBER, and GBTUM_MAGIC_REVERSED.

Referenced by GB_login(), and GBT_check_arb_file().

bool has_ascii_db_id ( uint32_t  bin_id,
FILE *  in 
)
inline

Definition at line 987 of file ad_load.cxx.

References buffer, and reverse_byteorder().

Referenced by GB_login(), and GBT_check_arb_file().

static GB_ERROR init_tmp_branch ( GBDATA gb_main)
static

Definition at line 1010 of file ad_load.cxx.

References error(), GB_await_error(), GB_CREATE_CONTAINER, GB_search(), GB_set_temporary(), and NULp.

Referenced by GB_login().

static GBDATA* GB_login ( const char cpath,
const char opent,
const char user 
)
static

open an ARB database

Parameters
cpatharb database. May be
  • full path of database. (loads DB plus newest quicksave, if any quicksaves exist)
  • full path of a quicksave file (loads DB with specific quicksave)
  • ":" connects to a running ARB DB server (e.g. ARB_NT, arb_db_server)
opentcontains one or more of the following characters:
  • 'r' read
  • 'w' write (w/o 'r' it overwrites existing database)
  • 'c' create (if not found)
  • 's' read only ???
  • 'D' looks for default in $ARBHOME/lib/arb_default if file is not found in $ARB_PROP (only works combined with mode 'c')
  • memory usage (only used for client-DB, i.e. if DB-name is ':'):
    • 't' small memory usage
    • 'm' medium
    • 'b' big
    • 'h' huge
  • 'R' allow corrupt file recovery + opening quicks with no master
  • 'N' assume new database format (does not check whether to convert old->new compression)
userusername
Returns
DB root node (or NULp, in which case an error has been exported)
See also
GB_open() and GBT_open()

Definition at line 1022 of file ad_load.cxx.

References GB_MAIN_TYPE::allow_corrupt_file_recovery, ARB_strBeginsWith(), ARB_strdup(), ARB_zfclose(), ARB_zfopen(), ASSERT_RESULT, GB_MAIN_TYPE::clock, arb_progress::done(), GB_MAIN_TYPE::dummy_father, error(), FILESIZE_GRANULARITY, gb_assert, GB_await_error(), GB_begin_transaction(), GB_clear_error(), GB_commit_transaction(), gb_convert_V2_to_V3(), gb_create_key(), gb_delete_dummy_father(), GB_disable_quicksave(), GB_export_error(), gb_findExtension(), GB_informationf(), GB_init_gb(), GB_install_pid(), gb_load_key_data_and_dictionaries(), gb_make_container(), gb_make_main_idx(), GB_MIND_CASE, gb_oldQuicksaveName(), gb_open_all, gb_open_read_only_all, GB_print_error(), GB_property_file(), gb_quicksaveName(), gb_read_ascii_beyond_header(), gb_read_bin(), gb_read_in_uint32(), gb_resort_system_folder_to_top(), gb_scan_directory(), GB_SCAN_NEW_QUICK, GB_SCAN_NO_QUICK, GB_SCAN_OLD_QUICK, GB_size_of_FILE(), GB_time_of_file(), GB_warning(), gbcm_login(), gbcm_logout(), GBK_terminatef(), GBS_global_string(), GBS_string_matches(), GBT_install_message_handler(), GBTUM_MAGIC_NUMBER, has_ascii_db_id(), gb_scandir::highest_quick_index, init_tmp_branch(), is_binary_db_id(), GB_MAIN_TYPE::is_server(), gb_quick_save::last_index, GB_MAIN_TYPE::login_remote(), GBCONTAINER::main_idx, GB_MAIN_TYPE::mark_as_server(), gb_scandir::newest_quick_index, NULp, GB_MAIN_TYPE::opentype, GB_MAIN_TYPE::qs, GB_MAIN_TYPE::root_container, GB_MAIN_TYPE::security_level, GBDATA::server_id, gb_scandir::type, warning(), ZFILE_AUTODETECT, and ZFILE_UNCOMPRESSED.

Referenced by GB_open().

GBDATA* GB_open ( const char path,
const char opent 
)
GB_ERROR GBT_check_arb_file ( const char name)

Checks whether a file is an arb file (or ':')

Returns
NULp if it is an arb file

Definition at line 1369 of file ad_load.cxx.

References ARB_zfclose(), ARB_zfopen(), error(), gb_assert, GB_is_regularfile(), gb_read_in_uint32(), GBS_global_string(), has_ascii_db_id(), is_binary_db_id(), NULp, and ZFILE_AUTODETECT.

Referenced by check_argument_for_mode(), and detectArgType().

Variable Documentation

int gb_verbose_mode = 0
static

Definition at line 30 of file ad_load.cxx.

long gb_next_main_idx_for_mapfile = 0
static

Definition at line 916 of file ad_load.cxx.