46 if (!gbd) gbd =
GBT_create(father, key, delete_level);
72 #define GBT_SUM_LEN 4096 // maximum length of path
96 int len_of_prefix = strlen(prefix);
100 sprintf(&prefix[len_of_prefix],
"/%s", key);
119 char *prefix = scanner->
buffer;
136 char *to_insert =
NULp;
147 to_insert[0] = key[0];
153 scanner->
result.put(to_insert);
194 static int avoid_deadlock = 0;
196 if (!avoid_deadlock) {
202 for (gb_msg =
GB_entry(gb_pending_messages,
"msg"); gb_msg;) {
210 gb_msg = gb_next_msg;
224 GBDATA *gb_pending_messages;
232 #if defined(DEBUG) && 0
263 fprintf(stderr,
"GBT_message: Failed to write message '%s'\n(Reason: %s)\n", msg, error);
341 static long result_var;
343 result = &result_var;
363 static float result_var;
365 result = &result_var;
414 static long result_var;
416 result = &result_var;
428 gb_assert(default_value == default_value);
436 static float result_var;
438 result = &result_var;
543 if (!strchr(path,
':')) {
582 if (verbose)
GB_warningf(
"[waiting for DBENTRY '%s']", entry);
593 if (timeout && timeout->
passed())
break;
597 if (gbd && verbose)
GB_warningf(
"[found DBENTRY '%s']", entry);
620 if (error && !error[0])
return NULp;
629 static bool client_is_macro_executor =
false;
631 if (!client_is_macro_executor) {
633 client_is_macro_executor =
true;
640 if (client_is_macro_executor) {
649 error = ta.
close(error);
664 #if defined(DUMP_AUTH_HANDSHAKE)
665 # define IF_DUMP_HANDSHAKE(cmd) cmd
667 # define IF_DUMP_HANDSHAKE(cmd)
674 if (gb_macro_error) {
676 if (prev_error && prev_error[0]) {
677 if (!strstr(prev_error, curr_error)) {
692 if (gb_macro_error) {
714 bool wait_for_app =
false;
727 wait_for_app = !
error;
738 while (wait_for_app) {
749 IF_DUMP_HANDSHAKE(fprintf(stderr,
"AUTH_HANDSHAKE [got authAck %li]\n", ack_pid));
754 if (old_pid != ack_pid) {
759 wait_for_app =
false;
760 IF_DUMP_HANDSHAKE(fprintf(stderr,
"AUTH_HANDSHAKE [granted permission to execute macros to pid %li]\n", ack_pid));
779 if (timeout && timeout->
passed()) {
780 wait_for_app =
false;
781 error =
"remote application did not answer (within timeout)";
876 if (in_ARBMACROHOME) {
880 " '%s' exist both.\n"
881 " You have to rename or delete one of them!)",
882 macro_name, in_ARBMACROHOME, in_ARBMACRO);
884 else reassign(result, in_ARBMACROHOME);
887 if (in_ARBMACRO) reassign(result, in_ARBMACRO);
892 free(in_ARBMACROHOME);
901 const char *
result = fullpath+strlen(dir);
902 if (result[0] ==
'/')
return result+1;
935 char *perl_args =
NULp;
938 const char *with_all_marked =
GB_path_in_ARBHOME(
"PERL_SCRIPTS/MACROS/with_all_marked.pl");
961 #define TEST_EXPECT_SCANNED_EQUALS(path,expected) do { \
962 GB_transaction ta(gb_main); \
964 GBT_scan_db(fields, gb_main, path); \
965 TEST_EXPECT_STRARRAY_CONTAINS(fields, ',', expected); \
968 void TEST_scan_db() {
972 TEST_EXPECT_SCANNED_EQUALS(
NULp,
973 "\x03""alignment/aligned,\x03""alignment/alignment_len,\falignment/alignment_name,\falignment/alignment_rem,\falignment/alignment_type,\x03""alignment/alignment_write_security,\x03""alignment/auto_format,"
976 "\fextended/acc,\fextended/ali_16s/_TYPE,\x06""extended/ali_16s/bits,\fextended/ali_16s/data,\fextended/aligned,\x03""extended/errors,\fextended/full_name,\fextended/name,"
977 "\nfloats,\tints,\tints_empty,"
978 "\x03key_data/key/key_hidden,\fkey_data/key/key_name,\x03key_data/key/key_type,"
979 "\fspecies/AL,\x03species/ARB_color,\fspecies/acc,\fspecies/ali_16s/data,\x06species/bits_test,\x04species/float_test,\fspecies/full_name,\fspecies/name,\fspecies/seqcheck,\fspecies/tax,"
980 "\fstr,\fstr_percent,\fuse");
982 TEST_EXPECT_SCANNED_EQUALS(
"species",
"\f/AL,\x03/ARB_color,\f/acc,\f/ali_16s/data,\x06/bits_test,\x04/float_test,\f/full_name,\f/name,\f/seqcheck,\f/tax");
989 static arb_test::match_expectation macroFoundAs(
const char *shortName,
const char *expectedFullName_tmp,
const char *expectedRelName,
const char *partOfError) {
990 char *expectedFullName = nulldup(expectedFullName_tmp);
1017 free(expectedFullName);
1018 return all().ofgroup(expected);
1021 #define TEST_FULLMACRO_EQUALS(shortName,fullName,relName) TEST_EXPECTATION(macroFoundAs(shortName, fullName, relName, NULp))
1022 #define TEST_FULLMACRO_FAILS(shortName,expectedErrorPart) TEST_EXPECTATION(macroFoundAs(shortName, NULp, NULp, expectedErrorPart))
1024 void TEST_find_macros() {
1027 #define TEST "_dolog" // name of a macro existing in ../lib/macros
1028 #define RESERVED "reserved4ut" // name of a macro NOT existing in ../lib/macros
1029 #define TEST_AMC TEST ".amc"
1030 #define RESERVED_AMC RESERVED ".amc"
1044 TEST_FULLMACRO_FAILS(RESERVED,
"Failed to detect");
1051 TEST_FULLMACRO_FAILS(
TEST,
"ambiguous macro name");
1054 TEST_FULLMACRO_EQUALS(RESERVED, res_amc, RESERVED_AMC);
1063 #endif // UNIT_TESTS
GB_ERROR GB_begin_transaction(GBDATA *gbd)
GB_ERROR GBK_system(const char *system_command)
GBDATA * GB_open(const char *path, const char *opent)
GB_ERROR GB_commit_transaction(GBDATA *gbd)
void GB_warning(const char *message)
long GB_read_int(GBDATA *gbd)
GBDATA * GB_child(GBDATA *father)
GB_ERROR GB_incur_error()
#define implicated(hypothesis, conclusion)
const char * granted() const
const char * result() const
void GB_atclose_callback(GBDATA *gbd, const DatabaseCallback &atClose)
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
GBDATA * GB_searchOrCreate_string(GBDATA *gb_container, const char *fieldpath, const char *default_value)
GB_ERROR GB_add_callback(GBDATA *gbd, GB_CB_TYPE type, const DatabaseCallback &dbcb)
long GBS_incr_hash(GB_HASH *hs, const char *key)
size_t hash_size(size_t estimated_elements)
GBDATA * GB_nextEntry(GBDATA *entry)
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
char * ARB_strdup(const char *str)
const char * authAck() const
char * GB_read_as_string(GBDATA *gbd)
#define MACRO_TRIGGER_TERMINATED
const char * GBS_global_string(const char *templat,...)
void GBS_free_hash(GB_HASH *hs)
int GB_unlink(const char *path)
const char * value() const
NOT4PERL gb_getenv_hook GB_install_getenv_hook(gb_getenv_hook hook)
const char * authReq() const
GB_ERROR GB_push_transaction(GBDATA *gbd)
GB_ERROR GB_delete(GBDATA *&source)
static HelixNrInfo * start
GB_ERROR GB_check_hkey(const char *key) __ATTR__USERESULT
#define TEST_PUBLISH(testfunction)
GB_ERROR GB_export_error(const char *error)
GB_ERROR GB_await_error()
GBDATA * GB_create_container(GBDATA *father, const char *key)
GB_TYPES GB_read_type(GBDATA *gbd)
void GB_warningf(const char *templat,...)
TYPE * ARB_alloc(size_t nelem)
GB_CSTR GB_read_key_pntr(GBDATA *gbd)
#define is_equal_to_NULL()
GBDATA * GB_create(GBDATA *father, const char *key, GB_TYPES type)
long GB_number_of_subentries(GBDATA *gbd)
void GBS_hash_do_const_loop(const GB_HASH *hs, gb_hash_const_loop_type func, void *client_data)
#define TEST_REJECT(cond)
static char const * macro_name
void GB_disable_path(GBDATA *gbd, const char *path)
static void error(const char *msg)
GBDATA * GB_get_root(GBDATA *gbd)
#define GBT_SAI_INDEX_SIZE
GB_CSTR GB_path_in_ARBHOME(const char *relative_path)
expectation_group & add(const expectation &e)
GBDATA * GB_searchOrCreate_int(GBDATA *gb_container, const char *fieldpath, long default_value)
#define MACRO_TRIGGER_ERROR
float GB_read_float(GBDATA *gbd)
const char *(* gb_getenv_hook)(const char *varname)
#define GBT_SPECIES_INDEX_SIZE
GB_CSTR GB_path_in_ARBLIB(const char *relative_path)
GB_ERROR GB_pop_transaction(GBDATA *gbd)
#define does_differ_from_NULL()
GB_ERROR GB_write_float(GBDATA *gbd, float f)
GB_ERROR GB_create_index(GBDATA *gbd, const char *key, GB_CASE case_sens, long estimated_size) __ATTR__USERESULT
GB_ERROR GB_write_int(GBDATA *gbd, long i)
#define does_contain(val)
GB_CSTR GB_concat_path(GB_CSTR anypath_left, GB_CSTR anypath_right)
GB_ERROR GB_export_errorf(const char *templat,...)
#define ERROR_CONTAINER_PATH
const char * awar() const
GB_ERROR close(GB_ERROR error)
char * GBK_singlequote(const char *arg)
GBDATA * GB_searchOrCreate_float(GBDATA *gb_container, const char *fieldpath, float default_value)
GB_DbScanner(StrArray &result_)
char * GB_read_string(GBDATA *gbd)
GB_ERROR GB_write_byte(GBDATA *gbd, int i)
GB_ERROR GB_write_security_delete(GBDATA *gbd, unsigned long level)
#define TEST_EXPECT_NO_ERROR(call)
GB_CSTR GB_getenvARBMACRO(void)
bool GB_is_readablefile(const char *filename)
#define TEST_EXPECT_DIFFERENT(expr, want)
bool ARB_strBeginsWith(const char *str, const char *with)
GBDATA * GB_nextChild(GBDATA *child)
GB_transaction ta(gb_var)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
GBDATA * GBT_get_SAI_data(GBDATA *gb_main)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
GB_CSTR GB_getenvARBMACROHOME(void)
static const char * action_name[]
#define TEST_EXPECT_EQUAL(expr, want)
const char * action() const
GBDATA * GB_entry(GBDATA *father, const char *key)
char * GBS_global_string_copy(const char *templat,...)
void GB_close(GBDATA *gbd)
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)