26 # include <rpc/types.h>
27 # warning "Please remove the above include if it works w/o under OSX"
35 #define INIT_TYPE_NAME(t) GB_TYPES_name[t] = #t
42 memset(GB_TYPES_name, 0,
sizeof(GB_TYPES_name));
62 const char *name =
NULp;
65 static char *unknownType =
NULp;
78 if (
GB_MAIN(gbd)->get_transaction_level() == 0) {
79 error =
"No transaction running";
82 error =
"Entry has been deleted";
106 "but your current security level is only %i",
111 fprintf(stderr,
"%s\n", error);
140 #define RETURN_ERROR_IF_NOT_WRITEABLE_AS_TYPE(gbd,type) \
142 GB_ERROR error = gb_type_writeable_to(type, gbd); \
144 return error_with_dbentry("write", gbd, error); \
148 #define EXPORT_ERROR_AND_RETURN_RES_IF_NOT_READABLE_AS_TYPE(gbd,res,type) \
150 GB_ERROR error = gb_type_readable_from(type, gbd); \
152 error = error_with_dbentry("read", gbd, error); \
153 GB_export_error(error); \
161 #define GB_TEST_READ_NUM(gbd,type,ignored) EXPORT_ERROR_AND_RETURN_RES_IF_NOT_READABLE_AS_TYPE(gbd,0,type)
162 #define GB_TEST_READ_PTR(gbd,type,ignored) EXPORT_ERROR_AND_RETURN_RES_IF_NOT_READABLE_AS_TYPE(gbd,NULp,type)
163 #define GB_TEST_WRITE(gbd,type,ignored) RETURN_ERROR_IF_NOT_WRITEABLE_AS_TYPE(gbd, type)
165 #define GB_TEST_NON_BUFFER(x, gerror) \
167 if (GB_is_in_buffer(x)) { \
168 GBK_terminatef("%s: you are not allowed to write any data, which you get by pntr", gerror); \
177 *res = strtof(str, &end);
179 if (end == str || end[0] != 0) {
196 GBK_terminatef(
"GB_safe_atof(\"%s\", ..) returns error: %s", str, err);
271 buf->
size = initial_size;
276 char *checkOut = buf->
mem;
298 if (size >= buf->
size) {
306 return ptr >= buf->
mem && ptr < buf->
mem+buf->
size;
317 if (size < gb_local->buf1.size) {
318 char *old_buffer = gb_local->
buf1.
mem;
319 size_t old_size = gb_local->
buf1.
size;
323 memcpy(gb_local->
buf1.
mem, old_buffer, old_size);
455 if (inside_shell)
GBK_terminate(
"only one GB_shell allowed");
486 if (one_global_shell.
isSet()) {
501 #if defined(UNIT_TESTS)
502 static bool closed_open_shell_for_unit_tests() {
505 if (gb_local) gb_local->fake_closed_DBs();
540 open_gb_mains =
NULp;
553 if (idx >= open_gb_alloc) {
554 int new_alloc = open_gb_alloc + 10;
556 open_gb_alloc = new_alloc;
558 open_gb_mains[idx] = Main;
566 for (idx = 0; idx<open; ++idx)
if (open_gb_mains[idx] == Main)
break;
571 open_gb_mains[idx] = open_gb_mains[open-1];
575 if (closedDBs == openedDBs) {
611 if (index_pos<0)
break;
612 if (index_pos >= gbc->
d.
nheader)
break;
667 bool quick_exit = Main->
mapped;
680 #if defined(LEAKS_SANITIZED)
718 fprintf(stderr,
"Error in gb_abort_and_close_all_DBs: %s\n", error);
750 xdr_float(&xdrs, &f);
768 #define MIN_CBLISTNODE_SIZE 48 // minimum (found) callbacklist-elementsize
772 #define CBLISTNODE_SIZE MIN_CBLISTNODE_SIZE // assume known minimum (doesnt really matter; only used in db-browser)
776 typedef std::_List_node<gb_callback_list::cbtype> CBLISTNODE_TYPE;
777 const size_t CBLISTNODE_SIZE =
sizeof(CBLISTNODE_TYPE);
781 STATIC_ASSERT_ANNOTATED(MIN_CBLISTNODE_SIZE<=CBLISTNODE_SIZE,
"MIN_CBLISTNODE_SIZE too big (smaller implementation detected)");
788 ?
sizeof(*gbcbl) + gbcbl->
callbacks.size()* CBLISTNODE_SIZE
801 inline long calc_size(
GB_REL_IFES *gbri,
int table_size) {
805 for (
int idx = 0; idx<table_size; ++idx) {
810 size += calc_size(ifes);
822 ?
sizeof(*gbe) + calc_size(gbe->
callback) + calc_size(gbe->
old)
825 inline long calc_size(
GBENTRY *gbe) {
827 ?
sizeof(*gbe) + calc_size(gbe->
ext)
847 void GB_SizeInfo::collect(
GBDATA *gbd) {
859 switch (gbd->
type()) {
861 case GB_FLOAT: size =
sizeof(float);
break;
879 const char *data = gbe->
data();
891 memcpy(ca, da, size);
929 long size = gbe->
size();
936 if (ca[0] == c_0 && ca[1] == c_1) {
944 const char *data = gbe->
data();
951 memcpy(ca+2, da, size+1);
990 if (!res)
return NULp;
992 if (0x01020304U == htonl(0x01020304U)) {
996 int size = gbe->
size();
1001 for (
long i=size; i; i--) {
1002 *(d++) = htonl(*(s++));
1015 if (!i)
return NULp;
1027 res = (
char *)gbe->
data();
1030 long size = gbe->
size();
1031 long full_size = size*
sizeof(float);
1034 xdrmem_create(&xdrs, res, (
int)(full_size), XDR_DECODE);
1037 float *d = (
float *)(
void*)buf2;
1038 for (
long i=size; i; i--) {
1039 xdr_float(&xdrs, d);
1043 return (
float *)(
void*)buf2;
1056 if (!f)
return NULp;
1065 switch (gbd->
type()) {
1087 return GBS_global_string(
"Error: Cannot use %s() with a field of type %i (field=%s)",
1102 switch (gbd->
type()) {
1137 switch (gbd->
type()) {
1164 switch (gbd->
type()) {
1188 static long count = 0;
1191 if (gbd != last_gbd) {
1197 if (index >= 0 && index < count) {
1205 static long count = 0;
1208 if (gbd != last_gbd) {
1214 if (index >= 0 && index < count) {
1236 #define GB_DO_CALLBACKS(gbd) do { if (GB_MAIN(gbd)->get_transaction_level() < 0) gb_do_callbacks(gbd); } while (0)
1241 if (gbe->
info.
i != i) {
1243 gbe->
info.
i = i & 0xff;
1254 if ((
long)((int32_t)i) != i) {
1257 return "GB_INT out of range (signed, 32bit)";
1260 if (gbe->
info.
i != (int32_t)i) {
1272 if (gbe->
info.
ptr != pointer) {
1291 xdr_float(&xdrs, &f);
1323 gbe->
insert_data((
char *)s, stored_size, (
size_t)memsize);
1331 int compression_mask;
1334 compression_mask = 0;
1338 compression_mask = gb_convert_type_2_compression_flags[gb_type] & ks->
compression_mask;
1341 return compression_mask;
1364 if (compression_mask) {
1365 d =
gb_compress_data(gbe, key, s, bytes_size, &memsize, compression_mask,
false);
1376 memsize = bytes_size;
1393 size_t size = strlen(s);
1399 #if defined(DEBUG) && 0
1425 char *d =
gb_compress_bits(bits, size, (
const unsigned char *)c_0, &memsize);
1443 if (0x01020304 != htonl((
GB_UINT4)0x01020304)) {
1449 for (j=size; j; j--) {
1450 *(d++) = htonl(*(s++));
1458 long fullsize = size *
sizeof(float);
1466 float *
s = (
float *)f;
1468 xdrmem_create(&xdrs, buf2, (
int)fullsize, XDR_ENCODE);
1469 for (i=size; i; i--) {
1470 xdr_float(&xdrs, s);
1473 xdr_destroy (&xdrs);
1474 f = (
float*)(
void*)buf2;
1476 return GB_write_pntr(gbd, (
char *)f, size*
sizeof(
float), size);
1490 switch (gbd->
type()) {
1509 switch (gbd->
type()) {
1515 sprintf(buffer,
"%u",
unsigned(byte));
1529 switch (gbd->
type()) {
1534 #if defined(ASSERTION_USED)
1537 sprintf(buffer,
"%i", i);
1552 switch (gbd->
type()) {
1557 #if defined(ASSERTION_USED)
1560 sprintf(buffer,
"%e", f);
1632 int GB_securityLevel::whats_my_security()
const {
1636 void GB_securityLevel::change_my_security(
int level) {
1672 if (!key[0])
GBK_terminate(
"Attempt to create quark from empty key");
1734 if (gb_grandpa && !
GB_FATHER(gb_grandpa)) gb_grandpa =
NULp;
1754 if (gb_up == gb_ancestor)
return true;
1802 if (type ==
GB_DB) {
1814 GB_export_errorf(
"while creating '%s': father (%s) is not of GB_DB type (%i)",
1821 GB_export_error(
"GB_create: pointers only allowed in temporary branches");
1849 if ((*key ==
'\0')) {
1872 switch (source->
type()) {
1901 return prev_mask == 0 ?
false :
true;
1908 if (sec_obj > sec_main) {
1910 "(entry has security level %i, your security level is only %i)",
1993 else gb_clone =
GB_create(gb_destCont, key, gb_source->
type());
2018 return "logic error: it's too late to skip copy of temporary entry";
2020 #if defined(ASSERTION_USED)
2028 return GB_export_errorf(
"incompatible types in gb_copy_explicit (source %s:%u != %s:%u",
2080 std::set<GBQUARK> keyHandled;
2083 if (keyHandled.find(quark) == keyHandled.end()) {
2084 GBDATA *gb_entry = gb_child;
2085 const char *key =
GB_KEY(gb_entry);
2088 while (gb_entry && gb_exist && !error) {
2099 while (gb_entry && !error) {
2106 keyHandled.insert(quark);
2147 return "infinite copy not permitted (destination may not be part of source)";
2210 error =
"GB_clone destination cannot be part of source.";
2213 error =
"GB_clone destination has to be a container.";
2221 while ((*dest++=*source++)) ;
2236 int result_length = 0;
2244 int keylen = strlen(key);
2247 char *neu_result = ARB_alloc<char>(result_length+keylen+1+1);
2250 char *p =
gb_stpcpy(neu_result, result);
2255 freeset(result, neu_result);
2256 result_length += keylen+1;
2265 strcpy(result+1, key);
2266 result[keylen+1] =
';';
2267 result[keylen+2] = 0;
2268 result_length = keylen+2;
2318 if (!gb_parent)
return false;
2326 GB_ERROR GB_MAIN_TYPE::initial_client_transaction() {
2328 transaction_level = 1;
2330 if (!error) ++
clock;
2334 inline GB_ERROR GB_MAIN_TYPE::start_transaction() {
2337 transaction_level = 1;
2338 aborted_transaction = 0;
2360 if (transaction_level>0)
return GBS_global_string(
"attempt to start a NEW transaction (at transaction level %i)", transaction_level);
2361 if (transaction_level == 0)
return start_transaction();
2366 if (transaction_level<=0) {
2367 if (transaction_level<0)
return "GB_abort_transaction: Attempt to abort transaction in no-transaction-mode";
2368 return "GB_abort_transaction: No transaction running";
2370 if (transaction_level>1) {
2371 aborted_transaction = 1;
2378 if (error)
return error;
2382 transaction_level = 0;
2391 if (!transaction_level) {
2392 return "commit_transaction: No transaction running";
2394 if (transaction_level>1) {
2395 return GBS_global_string(
"attempt to commit at transaction level %i", transaction_level);
2397 if (aborted_transaction) {
2398 aborted_transaction = 0;
2404 int warn_deadlock = 100;
2415 if (loop_count>warn_deadlock) {
2416 fprintf(stderr,
"possible deadlock in commit_transaction (callback triggered by callback?). looped %i times.\n", warn_deadlock);
2417 warn_deadlock *= 10;
2422 transaction_level = 0;
2443 transaction_level = 0;
2448 if (transaction_level == 0)
return start_transaction();
2449 if (transaction_level>0) ++transaction_level;
2455 if (transaction_level==0)
return "attempt to pop nested transaction while none running";
2456 if (transaction_level<0)
return NULp;
2458 transaction_level--;
2463 if (
is_client())
return "Tried to disable transactions in a client";
2464 transaction_level = -1;
2471 if (!transaction_level) error =
"send_update_to_server: no transaction running";
2472 else if (
is_server()) error =
"send_update_to_server: only possible from clients (not from server itself)";
2482 (chg_cbl_old != changeCBs.pending.get_tail() ||
2483 del_cbl_old != deleteCBs.pending.get_tail()))
2485 error =
"send_update_to_server triggered a callback (this is not allowed)";
2587 if (error) error_handler(error);
2614 if (error)
return error;
2625 for (index = 0; index < gbc->
d.
nheader; index++) {
2652 freedup(
GB_MAIN(gbd)->qs.quick_save_disabled, reason);
2658 if (client_count<0) {
2659 return "Sorry: this program is not the arbdb server, you cannot resort your data";
2661 if (client_count>0) {
2664 if (!called_from_macro) {
2665 return GBS_global_string(
"There are %li clients (editors, tree programs) connected to this server.\n"
2666 "You need to close these clients before you can run this operation.",
2672 if (listsize <= 0)
return NULp;
2678 for (
long new_index = 0; new_index< listsize; new_index++) {
2679 long old_index = new_order_list[new_index]->
index;
2681 if (old_index < new_index) {
2682 GB_warningf(
"Warning at resort database: entry exists twice: %li and %li",
2683 old_index, new_index);
2690 hl[new_index] = hl[old_index];
2696 if (ngb) ngb->
index = old_index;
2697 if (ogb) ogb->
index = new_index;
2716 if (gb_first == gb_system) {
2721 GBDATA **new_order_list = ARB_calloc<GBDATA*>(len);
2723 new_order_list[0] = gb_system;
2724 for (
int i=1; i<len; i++) {
2725 new_order_list[i] = gb_first;
2726 do gb_first =
GB_nextChild(gb_first);
while (gb_first == gb_system);
2730 free(new_order_list);
2740 #if defined(ASSERTION_USED)
2810 const char *type2char =
"-bcif-B-CIFlSS-%";
2811 return type2char[
type];
2817 for (
int i=0; i<Main->
keycnt; i++) {
2820 printf(
"%3i %20s nref %li\n", i, KEY.
key, KEY.
nref);
2823 printf(
" %3i unused key, next free key = %li\n", i, KEY.
next_free_key);
2834 if (!gbd) { printf(
"NULp\n");
return -1; }
2843 printf(
"(GBDATA*)0x%lx (GBCONTAINER*)0x%lx ", (
long)gbd, (
long)gbd);
2845 if (gbd->rel_father==0) { printf(
"father=NULp\n");
return -1; }
2852 if (!Main) { printf(
"Oops - I have no main entry!!!\n");
return -1; }
2853 if (gbd==Main->
dummy_father) { printf(
"dummy_father!\n");
return -1; }
2859 int size = gbc->
d.
size;
2861 printf(
" father=(GBDATA*)0x%lx\n", (
long)
GB_FATHER(gbd));
2862 if (size < GB_info_deep) {
2867 for (index = 0; index < gbc->
d.
nheader; index++) {
2870 printf(
"\t\t%10s (GBDATA*)0x%lx (GBCONTAINER*)0x%lx\n",
quark2key(Main, quark), (
long)gb_sub, (
long)gb_sub);
2877 if (data) { printf(
"%s", data); free(data); }
2878 printf(
" father=(GBDATA*)0x%lx\n", (
long)
GB_FATHER(gbd));
2896 long subentries = 0;
2899 for (
int index = 0; index<end; index++) {
2915 void TEST_GB_atof() {
2921 #if !defined(DARWIN)
2924 void TEST_999_strtod_replacement() {
2926 const char *old = setlocale(LC_NUMERIC,
"de_DE.UTF-8");
2931 setlocale(LC_NUMERIC, old);
2935 #if defined(ENABLE_CRASH_TESTS)
2936 static void test_another_shell() {
delete new GB_shell; }
2940 void TEST_GB_shell__crashtest() {
2951 void TEST_GB_number_of_subentries() {
2966 TEST_EXPECT_RESULT__NOERROREXPORTED(gb_entry =
GB_create(gb_cont,
"entry",
GB_STRING));
2981 void TEST_POSTCOND_arbdb() {
2983 bool unclosed_GB_shell = closed_open_shell_for_unit_tests();
2991 static void saveAndCompare(
GBDATA *gb_main,
const char *expectedname,
bool
2992 #
if defined(TEST_AUTO_UPDATE)
2996 const char *outputname =
"copied.arb";
3000 #if defined(TEST_AUTO_UPDATE)
3001 if (allowAutoUpdate) {
3002 TEST_COPY_FILE(outputname, expectedname);
3009 void TEST_AFTER_SLOW_copy() {
3025 if (gb_child != gb_all) {
3033 gb_child = gb_next_child;
3039 saveAndCompare(gb_main,
"TEST_copy.arb",
true);
3053 saveAndCompare(gb_main,
"TEST_copy_noProtect.arb",
true);
3070 saveAndCompare(gb_main,
"TEST_copy.arb",
false);
3087 saveAndCompare(gb_main,
"TEST_copy.arb",
false);
3106 "logic error: it's too late to skip copy of temporary entry");
3109 TEST_EXPECT_NORESULT__ERROREXPORTED_CONTAINS(
GB_clone(gb_description, gb_copy),
3110 "GB_clone destination has to be a container");
3113 saveAndCompare(gb_main,
"TEST_loadsave_ascii.arb",
false);
3128 TEST_EXPECT_NORESULT__ERROREXPORTED_CONTAINS(
GB_clone(gb_key, gb_copy),
"GB_clone destination cannot be part of source");
3134 #endif // UNIT_TESTS
GB_ERROR GB_check_key(const char *key) __ATTR__USERESULT
NOT4PERL int32_t GB_read_lossless_int(GBDATA *gbd, GB_ERROR &error)
void gb_remove_callbacks_marked_for_deletion(GBDATA *gbd)
static GB_ERROR GB_safe_atof(const char *str, float *res)
size_t GB_read_string_count(GBDATA *gbd)
GB_ERROR GB_write_floats(GBDATA *gbd, const float *f, long size)
GB_ERROR GB_push_transaction(GBDATA *gbd)
static void alloc_buffer(gb_buffer *buf, size_t size)
STATIC_ASSERT_ANNOTATED(((GB_USERFLAG_ANY+1)&GB_USERFLAG_ANY)==0,"not all bits set in GB_USERFLAG_ANY")
bool legal_user_bitmask(unsigned char bitmask)
GBDATA * GB_open(const char *path, const char *opent)
GB_CBUFFER gb_uncompress_data(GBDATA *gbd, GB_CBUFFER source, size_t size)
NOT4PERL long GB_calc_structure_size(GBDATA *gbd)
#define GB_GET_SECURITY_READ(gb)
GB_ERROR GB_write_security_delete(GBDATA *gbd, unsigned long level)
GB_ERROR GB_clear_temporary(GBDATA *gbd)
bool GB_TYPE_readable_as_string(GB_TYPES type)
void GB_write_user_flag(GBDATA *gbd, unsigned char user_bit, bool state)
GBDATA * GB_get_father(GBDATA *gbd)
#define INIT_TYPE_NAME(t)
GB_ERROR GB_commit_transaction(GBDATA *gbd)
#define TEST_EXPECT_SIMILAR(expr, want, epsilon)
bool GB_is_temporary(GBDATA *gbd)
void gb_free_compress_tree(gb_compress_tree *tree)
GBDATA * GB_child(GBDATA *father)
GB_ERROR GB_incur_error()
char * GB_read_as_string(GBDATA *gbd)
#define implicated(hypothesis, conclusion)
#define GB_TEST_READ_NUM(gbd, type, ignored)
static GB_ERROR gb_copy_explicit(GBDATA *dest, GBDATA *source, CopyMode mode)
unsigned int security_read
GB_ERROR GB_save(GBDATA *gb, const char *path, const char *savetype)
__ATTR__USERESULT GB_ERROR send_update_to_server(GBDATA *gbd) __ATTR__USERESULT
static char * check_out_buffer(gb_buffer *buf)
GB_ERROR GB_delete(GBDATA *&source)
GB_BUFFER gb_compress_data(GBDATA *gbd, int key, GB_CBUFFER source, size_t size, size_t *msize, GB_COMPRESSION_MASK max_compr, bool pre_compressed)
#define GB_PUT_SECURITY_READ(gb, i)
bool GB_is_container(GBDATA *gbd)
void gb_touch_header(GBCONTAINER *gbc)
#define GB_GET_SECURITY_WRITE(gb)
const char * quark2key(GB_MAIN_TYPE *Main, GBQUARK key_quark)
char * GB_read_bytes(GBDATA *gbd)
char * GB_get_subfields(GBDATA *gbd)
static GB_shell * inside_shell
static long GB_read_floats_count(GBDATA *gbd)
gb_data_base_type_union info
GB_MAIN_TYPE * GB_MAIN(GBDATA *gbd)
long GB_read_count(GBDATA *gbd)
void insert_data(const char *Data, long Size, long Memsize)
GBCONTAINER * expect_container() const
void GB_close(GBDATA *gbd)
GB_ERROR GB_copy_dropMarksAndTempstate(GBDATA *dest, GBDATA *source)
GBDATA * GB_get_root(GBDATA *gbd)
long GB_read_from_ints(GBDATA *gbd, long index)
gb_user * users[GB_MAX_USERS]
bool search_system_folder
GBDATA * GB_nextEntry(GBDATA *entry)
gb_compress_tree * bituncompress
unsigned int folded_container
double GB_read_from_floats(GBDATA *gbd, long index)
long gb_create_key(GB_MAIN_TYPE *Main, const char *key, bool create_gb_key)
GB_CSTR GB_read_pntr(GBDATA *gbd)
GB_ERROR GB_resort_data_base(GBDATA *gb_main, GBDATA **new_order_list, long listsize)
GB_ERROR gbcmc_end_sendupdate(GBDATA *gbd)
GB_ERROR GB_copy_full(GBDATA *dest, GBDATA *source)
bool GB_user_flag(GBDATA *gbd, unsigned char user_bit)
static int GB_is_in_buffer(GB_CBUFFER ptr)
#define ASSERT_RESULT(Type, Expected, Expr)
GB_ERROR GB_write_ints(GBDATA *gbd, const GB_UINT4 *i, long size)
GBCONTAINER * gb_create_container(GBCONTAINER *father, const char *key)
char * ARB_strdup(const char *str)
static GB_BUFFER give_buffer(gb_buffer *buf, size_t size)
void GB_internal_errorf(const char *templat,...)
GB_ERROR gbcmc_commit_transaction(GBDATA *gbd)
int GB_nsons(GBDATA *gbd)
const char * GBS_global_string(const char *templat,...)
int GB_read_flag(GBDATA *gbd)
GB_ERROR GB_pop_transaction(GBDATA *gbd)
long GB_read_bytes_count(GBDATA *gbd)
void GB_disable_quicksave(GBDATA *gbd, const char *reason)
GBDATA * GB_create(GBDATA *father, const char *key, GB_TYPES type)
char * GB_read_bits(GBDATA *gbd, char c_0, char c_1)
void GBK_terminatef(const char *templat,...)
CONSTEXPR_INLINE gb_header_list * GB_DATA_LIST_HEADER(gb_data_list &dl)
GB_ERROR gb_commit_transaction_local_rek(GBDATA *&gbd, long mode, int *pson_created)
float GB_atof(const char *str)
bool GB_has_key(GBDATA *gbd, const char *key)
GBQUARK gb_find_or_create_quark(GB_MAIN_TYPE *Main, const char *key)
long GB_read_memuse(GBDATA *gbd)
gb_index_files * GB_INDEX_FILES_NEXT(gb_index_files *ixf)
char * gb_read_cache(GBENTRY *gbe)
int GB_unlink(const char *path)
GB_BUFFER GB_give_buffer2(long size)
#define GB_GET_SECURITY_DELETE(gb)
GB_MAIN_TYPE * GBCONTAINER_MAIN(GBCONTAINER *gbc)
static void run_close_callbacks(GBDATA *gb_main)
gb_flag_types2 & get_user_flags(GBDATA *gbd)
bool call(GBDATA *with, GB_CB_TYPE typemask)
GBCONTAINER * root_container
char * gb_compress_bits(const char *source, long size, const unsigned char *c_0, long *msize)
void forget_hierarchy_cbs()
GB_BUFFER GB_give_buffer(size_t size)
static void gb_delete_entry(GBCONTAINER *&gbc)
void setNull()
set SmartPtr to NULp
GB_ERROR gb_transactable_type(GB_TYPES type, GBDATA *gbd)
GB_ERROR GB_write_security_read(GBDATA *gbd, unsigned long level)
GB_ERROR GB_copy_dropProtectMarksAndTempstate(GBDATA *dest, GBDATA *source)
static unsigned char GB_BIT_compress_data[]
char buffer[MESSAGE_BUFFERSIZE]
GB_CFLOAT * GB_read_floats_pntr(GBDATA *gbd)
const char * ARB_float_2_ascii(const float f)
GBENTRY * gb_create(GBCONTAINER *father, const char *key, GB_TYPES type)
GB_ERROR GB_incur_error_if(bool error_may_occur)
void GB_end_transaction_show_error(GBDATA *gbd, GB_ERROR error, void(*error_handler)(GB_ERROR))
static int gb_info(GBDATA *gbd, int deep)
int gb_get_compression_mask(GB_MAIN_TYPE *Main, GBQUARK key, int gb_type)
void GB_raise_user_flag(GBDATA *gbd, unsigned char user_bit)
GB_ERROR GB_export_error(const char *error)
GB_CSTR GB_read_key_pntr(GBDATA *gbd)
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
GB_ERROR GB_await_error()
char * GB_memdup(const char *source, size_t len)
GB_ERROR gb_unfold(GBCONTAINER *gbc, long deep, int index_pos)
#define TEST_EXPECT(cond)
char * gb_set_undo_sync(GBDATA *gb_main)
void GB_warningf(const char *templat,...)
TYPE * ARB_alloc(size_t nelem)
void gb_untouch_children_and_me(GBCONTAINER *gbc)
NOT4PERL float GB_read_lossless_float(GBDATA *gbd, GB_ERROR &error)
GB_ERROR gbcmc_init_transaction(GBCONTAINER *gbc)
void GBK_install_SIGSEGV_handler(bool dump_backtrace)
GB_ERROR GB_write_bits(GBDATA *gbd, const char *bits, long size, const char *c_0)
bool isSet() const
test if SmartPtr is not NULp
GB_ERROR error_with_dbentry(const char *action, GBDATA *gbd, GB_ERROR error)
NOT4PERL uint8_t GB_read_lossless_byte(GBDATA *gbd, GB_ERROR &error)
long GB_number_of_subentries(GBDATA *gbd)
char * gb_alloc_cache_index(GBENTRY *gbe, size_t size)
void GBK_terminate(const char *error) __ATTR__NORETURN
#define GB_TEST_NON_BUFFER(x, gerror)
GB_ERROR gbcm_unfold_client(GBCONTAINER *gbc, long deep, long index_pos)
GBQUARK GB_find_existing_quark(GBDATA *gbd, const char *key)
static char * gb_stpcpy(char *dest, const char *source)
int gb_convert_type_2_appendix_size[]
static const char * GB_TYPES_2_name(GB_TYPES type)
GB_ERROR GB_write_bytes(GBDATA *gbd, const char *s, long size)
NOT4PERL int GB_give_buffer_size()
GB_ERROR begin_transaction() __ATTR__USERESULT
#define RETURN_ERROR(err)
void gb_abort_transaction_local_rek(GBDATA *&gbd)
float * GB_read_floats(GBDATA *gbd)
GBQUARK key2quark(GB_MAIN_TYPE *Main, const char *key)
static void ensure_inside()
char * gb_disable_undo(GBDATA *gb_main)
bool is_container() const
int GB_read_security_read(GBDATA *gbd)
void announce_db_close(GB_MAIN_TYPE *Main)
static GB_test_shell_closed shell_manager
#define TEST_REJECT(cond)
#define TEST_REJECT_NULL(n)
GB_ERROR push_transaction() __ATTR__USERESULT
bool GB_in_temporary_branch(GBDATA *gbd)
GB_BUFFER gb_uncompress_bits(const char *source, long size, char c_0, char c_1)
char GB_type_2_char(GB_TYPES type)
static void error(const char *msg)
GBDATA * GB_clone(GBDATA *gb_destCont, GBDATA *gb_source)
GB_ERROR gb_delete_force(GBDATA *source)
void GB_flush_cache(GBDATA *gbd)
GBDATA * GB_create_container(GBDATA *father, const char *key)
GB_ERROR GB_write_byte(GBDATA *gbd, int i)
void GB_clear_user_flag(GBDATA *gbd, unsigned char user_bit)
void GB_print_debug_information(struct Unfixed_cb_parameter *, GBDATA *gb_main)
gb_compress_list * bitcompress
#define GB_PUT_SECURITY_WRITE(gb, i)
GB_ERROR GB_write_lossless_int(GBDATA *gbd, int32_t i)
void gb_save_extern_data_in_ts__and_uncache(GBENTRY *gbe)
long GB_read_int(GBDATA *gbd)
bool GB_inside_remote_action(GBDATA *gbd)
const int gb_convert_type_2_compression_flags[]
unsigned int update_in_server
unsigned int security_delete
void gb_untouch_me(GBENTRY *gbe)
long GB_read_clients(GBDATA *gbd)
static void gb_uncache(GBCONTAINER *gbc)
GBCONTAINER * as_container() const
GB_ERROR GB_copy_overlay(GBDATA *dest, GBDATA *source)
void ARB_recalloc(TYPE *&tgt, size_t oelem, size_t nelem)
#define TEST_EXPECT_ZERO_OR_SHOW_ERRNO(iocond)
void * gbm_get_mem(size_t size, long index)
void gb_create_header_array(GBCONTAINER *gbc, int size)
GB_ERROR GB_write_lossless_float(GBDATA *gbd, float f)
GB_ERROR GB_write_autoconv_string(GBDATA *gbd, const char *val)
GB_UINT4 * GB_read_ints(GBDATA *gbd)
void GB_touch(GBDATA *gbd)
GB_CSTR GB_read_bytes_pntr(GBDATA *gbd)
CONSTEXPR_INLINE GBCONTAINER * GB_FATHER(GBDATA *gbd)
GB_ERROR GB_set_temporary(GBDATA *gbd)
GB_ERROR GB_release(GBDATA *gbd)
static GB_ERROR gb_set_compression(GBDATA *source)
GBDATA * GB_get_grandfather(GBDATA *gbd)
GB_ERROR GB_write_int(GBDATA *gbd, long i)
GB_ERROR GB_begin_transaction(GBDATA *gbd)
GB_ERROR GB_write_pntr(GBDATA *gbd, const char *s, size_t bytes_size, size_t stored_size)
gb_index_files * GBCONTAINER_IFS(GBCONTAINER *gbc)
GBQUARK GB_find_or_create_quark(GBDATA *gbd, const char *key)
GB_ERROR gbcmc_begin_transaction(GBDATA *gbd)
GB_ERROR cannot_use_fun4entry(const char *fun, GBDATA *gb_entry)
static GBDATA * gb_remembered_db()
void gb_untouch_children(GBCONTAINER *gbc)
gb_if_entries * GB_IF_ENTRIES_NEXT(gb_if_entries *ie)
ARB_TRANS_TYPE running_client_transaction
GB_ERROR pop_transaction() __ATTR__USERESULT
int gb_read_nr(GBDATA *gbd)
GB_ERROR GB_print_error()
int get_transaction_level() const
GBENTRY * gb_make_entry(GBCONTAINER *father, const char *key, long index_pos, GBQUARK keyq, GB_TYPES type)
int GB_get_transaction_level(GBDATA *gbd)
static void init_buffer(gb_buffer *buf, size_t initial_size)
GB_ERROR GB_no_transaction(GBDATA *gbd)
void GB_test_transaction(GB_MAIN_TYPE *Main)
GBQUARK gb_find_or_create_NULL_quark(GB_MAIN_TYPE *Main, const char *key)
GB_ERROR GB_copy_std(GBDATA *dest, GBDATA *source)
gb_callback_list * callback
unsigned int security_level
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
GB_ERROR GB_export_errorf(const char *templat,...)
static void gb_do_callbacks(GBDATA *gbd)
void GB_internal_error(const char *message)
GBQUARK GB_KEY_QUARK(GBDATA *gbd)
GBDATA * GB_read_pointer(GBDATA *gbd)
long GB_read_clock(GBDATA *gbd)
TYPE * ARB_calloc(size_t nelem)
#define IF_ASSERTION_USED(x)
GBCONTAINER * gb_make_container(GBCONTAINER *father, const char *key, long index_pos, GBQUARK keyq)
#define TEST_EXPECT_NULL(n)
GB_TYPES GB_read_type(GBDATA *gbd)
void GB_write_flag(GBDATA *gbd, long flag)
#define GB_DO_CALLBACKS(gbd)
GB_ERROR commit_transaction() __ATTR__USERESULT
char * GB_read_key(GBDATA *gbd)
static __ATTR__USERESULT GB_ERROR gb_security_error(GBDATA *gbd)
gb_callback_list * close_callbacks
size_t uncompressed_size() const
void gb_save_extern_data_in_ts(GBENTRY *gbe)
GB_CUINT4 * GB_read_ints_pntr(GBDATA *gbd)
static void run_and_destroy_exit_functions(gb_exitfun *fun)
GB_ERROR GB_write_security_write(GBDATA *gbd, unsigned long level)
#define __ATTR__USERESULT
GB_CSTR gb_read_key_pntr(GBDATA *gbd)
char * GB_read_string(GBDATA *gbd)
GB_ERROR gb_copy_checked(GBDATA *dest, GBDATA *source, CopyMode mode)
GB_ERROR gb_write_compressed_pntr(GBENTRY *gbe, const char *s, long memsize, long stored_size)
gb_transaction_save * old
void GB_change_my_security(GBDATA *gbd, int level)
GB_ERROR gbcm_logout(GB_MAIN_TYPE *Main, const char *loginname)
GB_BUFFER GB_increase_buffer(size_t size)
void GBK_dump_backtrace(FILE *out, const char *message)
GB_ERROR gb_resort_system_folder_to_top(GBCONTAINER *gb_main)
gb_compress_list * gb_build_compress_list(const unsigned char *data, long short_flag, long *size)
GB_ERROR GB_test_delete_possible(GBDATA *gb_obj)
GB_ERROR GB_write_float(GBDATA *gbd, float f)
#define GB_TEST_READ_PTR(gbd, type, ignored)
#define GB_PUT_SECURITY_DELETE(gb, i)
GB_ERROR gb_type_readable_from(GB_TYPES type, GBDATA *gbd)
const char * GB_get_db_path(GBDATA *gbd)
#define TEST_EXPECT_NO_ERROR(call)
long GB_read_ints_count(GBDATA *gbd)
#define TEST_EXPECT_SEGFAULT(cb)
gb_compress_tree * gb_build_uncompress_tree(const unsigned char *data, long short_flag, char **end)
void announce_db_open(GB_MAIN_TYPE *Main)
GBENTRY * as_entry() const
#define TEST_EXPECT_ERROR_CONTAINS(call, part)
GB_ERROR GB_write_pointer(GBDATA *gbd, GBDATA *pointer)
#define TEST_EXPECT_TEXTFILE_DIFFLINES(fgot, fwant, diff)
GB_ERROR abort_transaction() __ATTR__USERESULT
bool GB_is_ancestor_of(GBDATA *gb_ancestor, GBDATA *gb_descendant)
int GB_read_security_write(GBDATA *gbd)
GB_ERROR gb_type_writeable_to(GB_TYPES type, GBDATA *gbd)
const char * GB_get_type_name(GBDATA *gbd)
GBDATA * GB_nextChild(GBDATA *child)
GB_REL_IFES * GB_INDEX_FILES_ENTRIES(gb_index_files *ifs)
GB_ERROR GB_write_security_levels(GBDATA *gbd, unsigned long readlevel, unsigned long writelevel, unsigned long deletelevel)
GBDATA * GBT_find_item_rel_item_data(GBDATA *gb_item_data, const char *id_field, const char *id_value)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
GB_ERROR GB_abort_transaction(GBDATA *gbd)
GB_transaction ta(gb_var)
void gbm_free_mem(void *block, size_t size, long index)
int GB_read_byte(GBDATA *gbd)
GB_ERROR GB_write_lossless_byte(GBDATA *gbd, uint8_t byte)
void gb_load_single_key_data(GBDATA *gb_main, GBQUARK q)
GB_MAIN_TYPE * get_any_open_db()
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
const char * GB_KEY(GBDATA *gbd)
GB_ERROR gbcmc_abort_transaction(GBDATA *gbd)
GB_BUFFER GB_give_other_buffer(GB_CBUFFER buffer, long size)
static GBDATA * gb_clone_explicit(GBCONTAINER *gb_destCont, GBDATA *gb_source, CopyMode mode)
void gb_touch_entry(GBDATA *gbd, GB_CHANGE val)
bool GB_readable_as_string(GBDATA *gbd)
int gb_convert_type_2_sizeof[]
#define GB_ENTRIES_ENTRY(entries, idx)
GBCM_ServerResult gbcmc_close(gbcmc_comm *link)
void close_global_shell()
void gb_abort_and_close_all_DBs()
GB_ERROR no_transaction()
const unsigned int GB_CUINT4
void GB_atexit(void(*exitfun)())
bool GB_allow_compression(GBDATA *gb_main, bool allow_compression)
void call_pending_callbacks()
GBQUARK GB_get_quark(GBDATA *gbd)
int GB_read_security_delete(GBDATA *gbd)
GBCONTAINER * gb_get_root(GBENTRY *gbe)
#define TEST_EXPECT_EQUAL(expr, want)
static int is_in_buffer(gb_buffer *buf, GB_CBUFFER ptr)
GBDATA * GB_entry(GBDATA *father, const char *key)
unsigned int security_write
GBCONTAINER * get_father()
GB_ERROR gbcmc_begin_sendupdate(GBDATA *gbd)
unsigned int compressed_data
gb_callback_list * get_callbacks() const
char * GBS_global_string_copy(const char *templat,...)
float GB_read_float(GBDATA *gbd)
GB_CSTR GB_read_bits_pntr(GBDATA *gbd, char c_0, char c_1)
GBCONTAINER * dummy_father
char * GB_check_out_buffer(GB_CBUFFER buffer)
void gb_delete_dummy_father(GBCONTAINER *&gbc)
long GB_read_bits_count(GBDATA *gbd)
#define GB_TEST_WRITE(gbd, type, ignored)
GB_write_int const char s