Changeset 8224
- Timestamp:
- 17/11/11 22:48:48 (6 months ago)
- Location:
- branches/dev_elmar
- Files:
-
- 8 removed
- 186 modified
- 18 copied
-
. (modified) (1 prop)
-
AISC_COM/C/aisc_extern.c (modified) (1 diff)
-
AISC_COM/C/aisc_server.h (modified) (1 diff)
-
AISC_COM/C/server.c (modified) (3 diffs)
-
AISC_COM/C/server.h (modified) (1 diff)
-
AISC_MKPTPS/Makefile (modified) (1 diff)
-
AISC_MKPTPS/mkptypes.cxx (modified) (8 diffs)
-
ARBDB/Makefile (modified) (7 diffs)
-
ARBDB/ad_load.cxx (modified) (5 diffs)
-
ARBDB/ad_prot.h (modified) (9 diffs)
-
ARBDB/ad_save_load.cxx (modified) (11 diffs)
-
ARBDB/ad_t_prot.h (modified) (1 diff)
-
ARBDB/adcomm.cxx (modified) (7 diffs)
-
ARBDB/adfile.cxx (modified) (7 diffs)
-
ARBDB/adindex.cxx (modified) (3 diffs)
-
ARBDB/adlang1.cxx (modified) (1 diff)
-
ARBDB/admap.cxx (modified) (2 diffs)
-
ARBDB/adsocket.cxx (modified) (14 diffs)
-
ARBDB/adstring.cxx (modified) (6 diffs)
-
ARBDB/adsystem.cxx (modified) (1 diff)
-
ARBDB/adtables.cxx (modified) (2 diffs)
-
ARBDB/adtcp.cxx (modified) (3 diffs)
-
ARBDB/adtools.cxx (modified) (6 diffs)
-
ARBDB/arbdb.cxx (modified) (4 diffs)
-
ARBDB/arbdb.h (modified) (1 diff)
-
ARBDB/arbdbt.h (modified) (1 diff)
-
ARBDB/gb_memory.h (modified) (1 diff)
-
ARBDB/gb_prot.h (modified) (1 diff)
-
AWT/AWT_canio.cxx (modified) (11 diffs)
-
AWT/AWT_db_browser.cxx (modified) (17 diffs)
-
AWT/AWT_hexdump.cxx (copied) (copied from trunk/AWT/AWT_hexdump.cxx)
-
AWT/AWT_input_mask.cxx (modified) (2 diffs)
-
AWT/AWT_macro.cxx (modified) (1 diff)
-
AWT/AWT_sel_boxes.cxx (modified) (3 diffs)
-
AWT/Makefile (modified) (8 diffs)
-
AWT/awt_hexdump.hxx (copied) (copied from trunk/AWT/awt_hexdump.hxx)
-
AWT/awt_sel_boxes.hxx (modified) (1 diff)
-
AWTC/AWTC_next_neighbours.cxx (modified) (1 diff)
-
AWTI/AWTI_export.cxx (modified) (1 diff)
-
AWTI/AWTI_import.cxx (modified) (3 diffs)
-
AWTI/Makefile (modified) (2 diffs)
-
CONVERTALN/Makefile (modified) (1 diff)
-
CONVERTALN/fconv.cxx (modified) (1 diff)
-
CORE/Makefile (modified) (4 diffs)
-
CORE/arb_core.h (modified) (1 diff)
-
CORE/arb_file.cxx (copied) (copied from trunk/CORE/arb_file.cxx)
-
CORE/arb_file.h (copied) (copied from trunk/CORE/arb_file.h)
-
CORE/arb_msg.cxx (modified) (2 diffs)
-
CORE/arb_msg.h (modified) (2 diffs)
-
CORE/arb_sort.cxx (modified) (1 prop)
-
CORE/arb_strarray.cxx (modified) (1 prop)
-
CORE/arb_strbuf.cxx (modified) (2 diffs)
-
CORE/arb_string.cxx (modified) (1 diff)
-
DBSERVER/Makefile (modified) (2 diffs)
-
DBSERVER/db_server.cxx (modified) (2 diffs)
-
DIST/DI_main.cxx (modified) (1 diff)
-
DIST/DI_matr.cxx (modified) (3 diffs)
-
DIST/DI_mldist.cxx (deleted)
-
DIST/Makefile (modified) (2 diffs)
-
DIST/di_mldist.hxx (deleted)
-
EDIT4/ED4_main.cxx (modified) (3 diffs)
-
EDIT4/ED4_root.cxx (modified) (5 diffs)
-
EDIT4/ED4_search.cxx (modified) (1 diff)
-
EDIT4/Makefile (modified) (1 diff)
-
EDIT4/graph_aligner_gui.cxx (modified) (1 diff)
-
GDE/MOLPHY (deleted)
-
GDE/Makefile (modified) (2 diffs)
-
GDEHELP/ARB_GDEmenus.source (modified) (1 diff)
-
GDEHELP/MENUS/molphy.menu (deleted)
-
GDEHELP/Makefile.helpfiles (modified) (1 diff)
-
GENOM/EXP_main.cxx (modified) (2 diffs)
-
GENOM/GEN_map.cxx (modified) (1 diff)
-
MERGE/MG_main.cxx (modified) (4 diffs)
-
MERGE/Makefile (modified) (1 diff)
-
MULTI_PROBE/MP_noclass.cxx (modified) (1 diff)
-
Makefile (modified) (7 diffs)
-
NALIGNER/ali_other_stuff.hxx (modified) (1 diff)
-
NALIGNER/ali_pt.cxx (modified) (2 diffs)
-
NALIGNER/ali_pt.hxx (modified) (1 diff)
-
NAMES/Makefile (modified) (1 diff)
-
NAMES/names.cxx (modified) (1 diff)
-
NAMES_COM/names_extern.c (modified) (1 diff)
-
NTREE/ColumnStat_2_gnuplot.cxx (modified) (1 diff)
-
NTREE/Makefile (modified) (4 diffs)
-
NTREE/NT_cb.cxx (modified) (1 diff)
-
NTREE/NT_edconf.cxx (modified) (2 diffs)
-
NTREE/NT_extern.cxx (modified) (3 diffs)
-
NTREE/NT_main.cxx (modified) (5 diffs)
-
NTREE/ad_ext.cxx (modified) (1 diff)
-
NTREE/ad_trees.cxx (modified) (1 diff)
-
PARSIMONY/PARS_main.cxx (modified) (3 diffs)
-
PGT/arb_interface.cxx (modified) (2 diffs)
-
PGT/arb_interface.hxx (modified) (2 diffs)
-
PHYLO/PH_display.cxx (modified) (1 diff)
-
PHYLO/PH_main.cxx (modified) (2 diffs)
-
PROBE/Makefile (modified) (6 diffs)
-
PROBE/PT_buildtree.cxx (modified) (10 diffs)
-
PROBE/PT_debug.cxx (modified) (7 diffs)
-
PROBE/PT_etc.cxx (modified) (4 diffs)
-
PROBE/PT_family.cxx (modified) (12 diffs)
-
PROBE/PT_findEx.cxx (modified) (4 diffs)
-
PROBE/PT_io.cxx (modified) (11 diffs)
-
PROBE/PT_main.cxx (modified) (10 diffs)
-
PROBE/PT_match.cxx (modified) (18 diffs)
-
PROBE/PT_new_design.cxx (modified) (27 diffs)
-
PROBE/PT_prefixtree.cxx (modified) (17 diffs)
-
PROBE/needs_libs (modified) (1 diff)
-
PROBE/probe.h (modified) (6 diffs)
-
PROBE/probe_tree.h (modified) (5 diffs)
-
PROBE/pt_prototypes.h (modified) (6 diffs)
-
PROBE_COM/PT_extern.c (modified) (1 diff)
-
PROBE_DESIGN/Makefile (modified) (2 diffs)
-
PROBE_DESIGN/probe_design.cxx (modified) (10 diffs)
-
RNA3D/RNA3D_StructureData.cxx (modified) (1 diff)
-
RNA3D/RNA3D_Textures.cxx (modified) (1 diff)
-
SECEDIT/Makefile (modified) (1 diff)
-
SECEDIT/SEC_db.cxx (modified) (1 diff)
-
SECEDIT/SEC_main.cxx (modified) (1 diff)
-
SERVERCNTRL/Makefile (modified) (1 diff)
-
SERVERCNTRL/servercntrl.cxx (modified) (6 diffs)
-
SERVERCNTRL/servercntrl.h (modified) (1 diff)
-
SH/README (modified) (1 diff)
-
SH/arb_installubuntu4arb.sh (modified) (1 diff)
-
SH/arb_protml (deleted)
-
SL/AW_NAME/AW_names_admin.cxx (modified) (4 diffs)
-
SL/AW_NAME/AW_rename.cxx (modified) (1 diff)
-
SL/AW_NAME/Makefile (modified) (2 diffs)
-
SL/DB_QUERY/db_query.cxx (modified) (1 prop)
-
SL/DB_QUERY/db_query.h (modified) (1 prop)
-
SL/DB_QUERY/db_query_local.h (modified) (1 prop)
-
SL/DB_UI/ui_species.cxx (modified) (1 prop)
-
SL/ITEMS/changekey.cxx (modified) (1 prop)
-
SL/ITEMS/item_sel_list.cxx (modified) (1 prop)
-
SL/ITEMS/item_sel_list.h (modified) (1 prop)
-
SL/ITEMS/items.h (modified) (1 prop)
-
SL/ITEMS/species.cxx (modified) (1 prop)
-
SL/Makefile (modified) (1 diff)
-
SL/NDS/nds.cxx (modified) (1 prop)
-
SL/NDS/nds.h (modified) (1 prop)
-
SL/PRONUC/Makefile (modified) (1 diff)
-
SL/PTCLEAN (copied) (copied from trunk/SL/PTCLEAN)
-
SL/PTCLEAN/Makefile (copied) (copied from trunk/SL/PTCLEAN/Makefile)
-
SL/PTCLEAN/needs_libs (copied) (copied from trunk/SL/PTCLEAN/needs_libs)
-
SL/PTCLEAN/ptclean.cxx (copied) (copied from trunk/SL/PTCLEAN/ptclean.cxx)
-
SL/PTCLEAN/ptclean.h (copied) (copied from trunk/SL/PTCLEAN/ptclean.h)
-
SL/REFENTRIES/refentries.cxx (modified) (1 prop)
-
SL/REFENTRIES/refentries.h (modified) (1 prop)
-
SL/SEQIO/Makefile (modified) (1 diff)
-
SL/SEQIO/seq_export.cxx (modified) (2 diffs)
-
SOURCE_TOOLS/arb_valgrind (modified) (4 diffs)
-
SOURCE_TOOLS/dep.4dummy (modified) (2 diffs)
-
SOURCE_TOOLS/dep.alltargets (modified) (1 diff)
-
SOURCE_TOOLS/dep.libtargets (modified) (1 diff)
-
SOURCE_TOOLS/generate_all_links.sh (modified) (2 diffs)
-
SOURCE_TOOLS/postcompile.pl (modified) (4 diffs)
-
SOURCE_TOOLS/tabBrake.pl (modified) (1 diff)
-
SOURCE_TOOLS/valgrind2grep (modified) (4 diffs)
-
STAT/ST_quality.cxx (modified) (1 diff)
-
TEMPLATES/attributes.h (modified) (1 diff)
-
TEMPLATES/ut_valgrinded.h (modified) (5 diffs)
-
TOOLS/Makefile (modified) (2 diffs)
-
TOOLS/arb_2_ascii.cxx (modified) (1 diff)
-
TOOLS/arb_2_bin.cxx (modified) (1 diff)
-
TOOLS/arb_export_rates.cxx (modified) (1 diff)
-
TOOLS/arb_export_tree.cxx (modified) (1 diff)
-
TOOLS/arb_notify.cxx (modified) (1 diff)
-
TOOLS/arb_perf_test.cxx (modified) (1 diff)
-
TOOLS/arb_probe.cxx (modified) (5 diffs)
-
TOOLS/arb_replace.cxx (modified) (1 diff)
-
TOOLS/arb_test.cxx (modified) (11 diffs)
-
UNIT_TESTER/Makefile (modified) (1 diff)
-
UNIT_TESTER/Makefile.suite (modified) (2 diffs)
-
UNIT_TESTER/README.txt (modified) (1 diff)
-
UNIT_TESTER/TestEnvironment.cxx (modified) (25 diffs)
-
UNIT_TESTER/UnitTester.cxx (modified) (6 diffs)
-
UNIT_TESTER/UnitTester.hxx (modified) (2 diffs)
-
UNIT_TESTER/reporter.pl (modified) (1 diff)
-
UNIT_TESTER/run (modified) (1 prop)
-
UNIT_TESTER/run/TEST_arbdbserver_save_expected.arb (copied) (copied from trunk/UNIT_TESTER/run/TEST_arbdbserver_save_expected.arb)
-
UNIT_TESTER/run/TEST_gpt.arb.expected (copied) (copied from trunk/UNIT_TESTER/run/TEST_gpt.arb.expected)
-
UNIT_TESTER/run/TEST_gpt.arb.pt.expected (copied) (copied from trunk/UNIT_TESTER/run/TEST_gpt.arb.pt.expected)
-
UNIT_TESTER/run/TEST_gpt_src.arb (copied) (copied from trunk/UNIT_TESTER/run/TEST_gpt_src.arb)
-
UNIT_TESTER/run/TEST_pt.arb (deleted)
-
UNIT_TESTER/run/TEST_pt_cleaned_expected.arb (copied) (copied from trunk/UNIT_TESTER/run/TEST_pt_cleaned_expected.arb)
-
UNIT_TESTER/run/TEST_pt_src.arb (copied) (copied from trunk/UNIT_TESTER/run/TEST_pt_src.arb)
-
UNIT_TESTER/run/tools/arb_replace.in (copied) (copied from trunk/UNIT_TESTER/run/tools/arb_replace.in)
-
UNIT_TESTER/run/tools/gene_probe.arb (deleted)
-
UNIT_TESTER/run/tools/gene_probe_expected.arb (deleted)
-
UNIT_TESTER/sockets (copied) (copied from trunk/UNIT_TESTER/sockets)
-
UNIT_TESTER/sockets/README (copied) (copied from trunk/UNIT_TESTER/sockets/README)
-
UNIT_TESTER/test_global.h (modified) (3 diffs)
-
UNIT_TESTER/test_unit.h (modified) (13 diffs)
-
UNIT_TESTER/valgrind/arb_valgrind_logged (modified) (3 diffs)
-
WETC/WETC_main.cxx (modified) (2 diffs)
-
WINDOW/AW_edit.cxx (modified) (2 diffs)
-
WINDOW/AW_file_selection.cxx (modified) (1 diff)
-
WINDOW/AW_help.cxx (modified) (3 diffs)
-
WINDOW/AW_nawar.cxx (modified) (5 diffs)
-
WINDOW/AW_status.cxx (modified) (1 diff)
-
WINDOW/AW_window.cxx (modified) (2 diffs)
-
WINDOW/Makefile (modified) (4 diffs)
-
WINDOW/aw_position.hxx (modified) (7 diffs)
-
WINDOW/aw_root.hxx (modified) (2 diffs)
-
arb_LICENSE.txt (modified) (1 diff)
-
arb_README.txt (modified) (4 diffs)
-
arb_UBUNTU.txt (modified) (1 diff)
-
lib/arb_tcp_org.dat (modified) (1 diff)
-
lib/pictures/ad_gen_create.fig (modified) (1 prop)
-
lib/pictures/awt/export.fig (modified) (1 diff)
-
lib/pictures/awt/secExport.fig (modified) (2 diffs)
-
lib/pictures/dbbrowser.fig (modified) (2 diffs)
-
util/arb_srclst.pl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/dev_elmar
- Property svn:mergeinfo changed from /trunk:7699-7998 to /trunk:7699-8223
-
branches/dev_elmar/AISC_COM/C/aisc_extern.c
r7415 r8224 2 2 #include <string.h> 3 3 #include <aisc.h> 4 #include <attributes.h> 4 5 #include <server.h> 5 6 #include "aisc_extern_privat.h" -
branches/dev_elmar/AISC_COM/C/aisc_server.h
r7415 r8224 12 12 #include <aisc_com.h> 13 13 14 #ifndef ATTRIBUTES_H 15 #include <attributes.h> 16 #endif 14 17 #include <server.h> 15 18 #include <aisc_server_proto.h> -
branches/dev_elmar/AISC_COM/C/server.c
r7945 r8224 29 29 #include "aisc_com.h" 30 30 // AISC_MKPT_PROMOTE:#include <aisc_func_types.h> 31 #include <attributes.h> 31 32 #include "server.h" 32 33 #include "aisc_global.h" … … 186 187 } 187 188 188 static void aisc_server_sigsegv(int /*sig*/) { 189 static SigHandler old_sigsegv_handler; 190 191 static void aisc_server_sigsegv(int sig) { 189 192 sigsegv_occurred = true; 190 191 193 if (catch_sigsegv) { 192 194 siglongjmp(return_after_segv, 666); // never returns 193 195 } 194 195 UNINSTALL_SIGHANDLER(SIGSEGV, aisc_server_sigsegv, SIG_DFL, "aisc_server_sigsegv"); 196 // unexpected SEGV 197 198 UNINSTALL_SIGHANDLER(SIGSEGV, aisc_server_sigsegv, old_sigsegv_handler, "aisc_server_sigsegv"); 199 old_sigsegv_handler(sig); // 200 arb_assert(0); // oops - old handler returned 201 abort(); 196 202 } 197 203 … … 444 450 } 445 451 446 // install signal handlers (asserting none have been installed yet!) 447 ASSERT_RESULT(SigHandler, SIG_DFL, INSTALL_SIGHANDLER(SIGSEGV, aisc_server_sigsegv, "open_aisc_server")); 452 // install signal handlers 453 fprintf(stderr, "Installing signal handler from open_aisc_server\n"); fflush(stderr); 454 old_sigsegv_handler = INSTALL_SIGHANDLER(SIGSEGV, aisc_server_sigsegv, "open_aisc_server"); 448 455 ASSERT_RESULT_PREDICATE(is_default_or_ignore_sighandler, INSTALL_SIGHANDLER(SIGPIPE, aisc_server_sigpipe, "open_aisc_server")); 449 456 -
branches/dev_elmar/AISC_COM/C/server.h
r7415 r8224 8 8 /* define ARB attributes: */ 9 9 #ifndef ATTRIBUTES_H 10 # include <attributes.h> 10 #error You have to include attributes.h before including server.h 11 // it's not possible to include attributes here due to link problems 11 12 #endif 12 13 -
branches/dev_elmar/AISC_MKPTPS/Makefile
r7623 r8224 39 39 mkptypes.o: $(ARBHOME)/INCLUDE/arbtools.h 40 40 mkptypes.o: $(ARBHOME)/INCLUDE/attributes.h 41 mkptypes.o: $(ARBHOME)/INCLUDE/dupstr.h 41 42 mkptypes.o: $(ARBHOME)/INCLUDE/test_global.h 42 43 mkptypes.o: $(ARBHOME)/INCLUDE/test_unit.h -
branches/dev_elmar/AISC_MKPTPS/mkptypes.cxx
r7945 r8224 130 130 }; 131 131 132 static void setSymParts(SymPart*& symParts, const char *parts) { 133 mp_assert(!symParts); 134 132 static void addSymParts(SymPart*& symParts, const char *parts) { 135 133 char *p = strdup(parts); 136 134 const char *sep = ","; … … 189 187 static SymPart *excludedSymParts = 0; // DONT create prototypes if function-name matches one of these parts 190 188 191 inline void setRequiredSymParts(const char *parts) { setSymParts(requiredSymParts, parts); }192 inline void setExcludedSymParts(const char *parts) { setSymParts(excludedSymParts, parts); }189 inline void addRequiredSymParts(const char *parts) { addSymParts(requiredSymParts, parts); } 190 inline void addExcludedSymParts(const char *parts) { addSymParts(excludedSymParts, parts); } 193 191 194 192 inline void freeRequiredSymParts() { freeSymParts(requiredSymParts); } … … 1164 1162 count ++; 1165 1163 if (strcmp(w->string, "static") == 0) isstatic = 1; 1166 else if (strcmp(w->string, "main") == 0) ismain = 1;1164 else if (strcmp(w->string, "main") == 0) ismain = 1; 1167 1165 } 1168 1166 } … … 1453 1451 "\n -m promote declaration of 'main()' (default is to skip it)" 1454 1452 "\n -F part[,part]* only promote declarations for functionnames containing one of the parts" 1455 " if 'part' starts with a '^' functionname has to start with rest of part\n"1456 " -S (like -F) do NOT promote matching declarations (defaults to -S '^TEST_')\n"1453 "\n if 'part' starts with a '^' functionname has to start with rest of part" 1454 "\n -S (like -F) do NOT promote matching declarations (defaults to -S '^TEST_')" 1457 1455 "\n" 1458 1456 "\n -W don't promote types in old style declarations" … … 1468 1466 "\n -g search for GNU extension __attribute__ in comment behind function header" 1469 1467 "\n -G search for ARB macro __ATTR__ in comment behind function header" 1470 " and detect and ignore STATIC/INLINE_ATTRIBUTED() declarations\n"1468 "\n and detect and ignore STATIC/INLINE_ATTRIBUTED() declarations" 1471 1469 "\n" 1472 1470 "\n -P promote /*AISC_MKPT_PROMOTE:forHeader*/ to header" … … 1499 1497 argv++; argc--; 1500 1498 1501 setExcludedSymParts("^TEST_");1499 addExcludedSymParts("^TEST_,^NOTEST_"); // exclude unit tests 1502 1500 1503 1501 iobuf = (char *)malloc(NEWBUFSIZ); … … 1542 1540 t = *argv++; --argc; 1543 1541 if (!t) Usage(); 1544 setRequiredSymParts(t);1542 addRequiredSymParts(t); 1545 1543 break; 1546 1544 } … … 1549 1547 if (!t) Usage(); 1550 1548 freeExcludedSymParts(); 1551 setExcludedSymParts(t);1549 addExcludedSymParts(t); 1552 1550 break; 1553 1551 } -
branches/dev_elmar/ARBDB/Makefile
r7945 r8224 183 183 ad_load.o: $(ARBHOME)/INCLUDE/arb_core.h 184 184 ad_load.o: $(ARBHOME)/INCLUDE/arb_error.h 185 ad_load.o: $(ARBHOME)/INCLUDE/arb_file.h 185 186 ad_load.o: $(ARBHOME)/INCLUDE/arb_msg.h 187 ad_load.o: $(ARBHOME)/INCLUDE/arb_str.h 186 188 ad_load.o: $(ARBHOME)/INCLUDE/arb_string.h 187 189 ad_load.o: $(ARBHOME)/INCLUDE/arbtools.h … … 209 211 ad_save_load.o: $(ARBHOME)/INCLUDE/arb_core.h 210 212 ad_save_load.o: $(ARBHOME)/INCLUDE/arb_error.h 213 ad_save_load.o: $(ARBHOME)/INCLUDE/arb_file.h 211 214 ad_save_load.o: $(ARBHOME)/INCLUDE/arb_msg.h 212 215 ad_save_load.o: $(ARBHOME)/INCLUDE/arb_string.h … … 317 320 adcomm.o: $(ARBHOME)/INCLUDE/arb_core.h 318 321 adcomm.o: $(ARBHOME)/INCLUDE/arb_error.h 322 adcomm.o: $(ARBHOME)/INCLUDE/arb_file.h 319 323 adcomm.o: $(ARBHOME)/INCLUDE/arb_msg.h 320 324 adcomm.o: $(ARBHOME)/INCLUDE/arb_signal.h … … 383 387 adfile.o: $(ARBHOME)/INCLUDE/arb_core.h 384 388 adfile.o: $(ARBHOME)/INCLUDE/arb_error.h 389 adfile.o: $(ARBHOME)/INCLUDE/arb_file.h 385 390 adfile.o: $(ARBHOME)/INCLUDE/arb_msg.h 386 391 adfile.o: $(ARBHOME)/INCLUDE/arb_sort.h … … 528 533 adlang1.o: $(ARBHOME)/INCLUDE/arb_defs.h 529 534 adlang1.o: $(ARBHOME)/INCLUDE/arb_error.h 535 adlang1.o: $(ARBHOME)/INCLUDE/arb_file.h 530 536 adlang1.o: $(ARBHOME)/INCLUDE/arb_msg.h 531 537 adlang1.o: $(ARBHOME)/INCLUDE/arb_strbuf.h … … 598 604 admap.o: $(ARBHOME)/INCLUDE/arb_core.h 599 605 admap.o: $(ARBHOME)/INCLUDE/arb_error.h 606 admap.o: $(ARBHOME)/INCLUDE/arb_file.h 600 607 admap.o: $(ARBHOME)/INCLUDE/arb_msg.h 601 608 admap.o: $(ARBHOME)/INCLUDE/arb_string.h … … 790 797 adsocket.o: $(ARBHOME)/INCLUDE/arb_cs.h 791 798 adsocket.o: $(ARBHOME)/INCLUDE/arb_error.h 799 adsocket.o: $(ARBHOME)/INCLUDE/arb_file.h 792 800 adsocket.o: $(ARBHOME)/INCLUDE/arb_msg.h 793 801 adsocket.o: $(ARBHOME)/INCLUDE/arb_str.h -
branches/dev_elmar/ARBDB/ad_load.cxx
r7945 r8224 15 15 16 16 #include <arbdbt.h> 17 #include <arb_str.h> 18 #include <arb_file.h> 17 19 18 20 #include "gb_storage.h" … … 1358 1360 * - 'c' create (if not found) 1359 1361 * - 's' read only ??? 1360 * - ' d' look for default (if create) in $ARBHOME/lib (any leading '.' is removed )1361 * - 'D' look for default (if create) in $ARBHOME/lib/arb_default (any leading '.' is removed )1362 * - 'D' looks for default in $ARBHOME/lib/arb_default if file is not found in ~/.arb_prop 1363 * (only work combined with mode 'c') 1362 1364 * - memory usage: 1363 1365 * - 't' small memory usage … … 1384 1386 bool dbCreated = false; 1385 1387 1388 gb_assert(strchr(opent, 'd') == NULL); // mode 'd' is deprecated. You have to use 'D' and store your defaults inside ARBHOME/lib/arb_default 1389 1386 1390 if (!opent) opentype = gb_open_all; 1387 1391 else if (strchr(opent, 'w')) opentype = gb_open_all; … … 1504 1508 GB_disable_quicksave((GBDATA *)gbd, "Database Created"); 1505 1509 1506 if (strchr(opent, 'd')||strchr(opent, 'D')) { 1507 // use default settings 1508 const char *pre; 1509 char *found_path; 1510 1511 GB_clear_error(); // with default-files gb_scan_directory (used above) 1512 // creates an error, cause the path is a fake path 1513 1514 if (strchr(opent, 'd')) pre = ""; 1515 else pre = "arb_default/"; 1516 1517 found_path = GBS_find_lib_file(path, pre, false); 1510 if (strchr(opent, 'D')) { // use default settings 1511 GB_clear_error(); // with default-files gb_scan_directory (used above) has created an error, cause the path was a fake path 1512 1513 gb_assert(ARB_strscmp(path, ".arb_prop/") != 0); // do no longer pass path-prefix [deprecated!] 1514 char *found_path = GB_property_file(false, path); 1515 1518 1516 if (!found_path) { 1519 1517 fprintf(stderr, "file %s not found\n", path); … … 1521 1519 } 1522 1520 else { 1523 #if defined(DEBUG) 1524 fprintf(stderr, "Using properties from %s\n", found_path); 1525 #endif // DEBUG 1521 fprintf(stderr, "Using properties from '%s'\n", found_path); 1526 1522 freeset(path, found_path); 1527 1523 input = fopen(path, "rb"); -
branches/dev_elmar/ARBDB/ad_prot.h
r7945 r8224 30 30 /* ad_save_load.cxx */ 31 31 GB_ERROR GB_save(GBDATA *gb, const char *path, const char *savetype); 32 GB_ERROR GB_create_parent_directory(const char *path); 32 33 GB_ERROR GB_create_directory(const char *path); 33 GB_ERROR GB_save_in_ home(GBDATA *gb, const char *path, const char *savetype);34 GB_ERROR GB_save_in_arbprop(GBDATA *gb, const char *path, const char *savetype); 34 35 GB_ERROR GB_save_as(GBDATA *gb, const char *path, const char *savetype); 35 36 GB_ERROR GB_delete_database(GB_CSTR filename); … … 46 47 bool GB_is_client(GBDATA *gbd); 47 48 GBDATA *GBCMC_find(GBDATA *gbd, const char *key, GB_TYPES type, const char *str, GB_CASE case_sens, GB_SEARCH_TYPE gbs); 48 int GBCMC_system(GBDATA *gbd, const char *ss) __ATTR__USERESULT_TODO;49 49 GB_ERROR GB_tell_server_dont_wait(GBDATA *gbd); 50 50 GB_ERROR GB_install_pid(int mode); … … 163 163 char *GB_find_all_files(const char *dir, const char *mask, bool filename_only); 164 164 char *GB_find_latest_file(const char *dir, const char *mask); 165 char *GBS_find_lib_file(const char *filename, const char *libprefix, bool warn_when_not_found); 165 const char *GB_existing_file(const char *file, bool warn_when_not_found); 166 char *GB_lib_file(bool warn_when_not_found, const char *libprefix, const char *filename); 167 char *GB_property_file(bool warn_when_not_found, const char *filename); 166 168 void GBS_read_dir(StrArray &names, const char *dir, const char *mask); 167 169 bool GB_test_textfile_difflines(const char *file1, const char *file2, int expected_difflines, int special_mode); 170 size_t GB_test_mem_equal(const unsigned char *buf1, const unsigned char *buf2, size_t common); 168 171 bool GB_test_files_equal(const char *file1, const char *file2); 169 172 void GBT_transform_names(StrArray &dest, const StrArray &source, char *transform (const char *, void *), void *client_data); … … 175 178 176 179 /* adtcp.cxx */ 180 char *GB_arbtcpdat_path(void); 177 181 const char *GBS_scan_arb_tcp_param(const char *ipPort, const char *wantedParam); 178 182 179 183 #ifdef UNIT_TESTS 180 184 #define TEST_SERVER_ID (-666) 185 #define TEST_GENESERVER_ID (-667) 181 186 #endif 182 187 … … 277 282 char *GB_get_subfields(GBDATA *gbd); 278 283 bool GB_allow_compression(GBDATA *gb_main, bool allow_compression); 279 GB_ERROR GB_set_temporary(GBDATA *gbd) ;284 GB_ERROR GB_set_temporary(GBDATA *gbd) __ATTR__USERESULT; 280 285 GB_ERROR GB_clear_temporary(GBDATA *gbd); 281 286 bool GB_is_temporary(GBDATA *gbd); … … 380 385 381 386 /* adindex.cxx */ 382 GB_ERROR GB_create_index(GBDATA *gbd, const char *key, GB_CASE case_sens, long estimated_size) ;387 GB_ERROR GB_create_index(GBDATA *gbd, const char *key, GB_CASE case_sens, long estimated_size) __ATTR__USERESULT; 383 388 NOT4PERL void GB_dump_indices(GBDATA *gbd); 384 389 GB_ERROR GB_request_undo_type(GBDATA *gb_main, GB_UNDO_TYPE type) __ATTR__USERESULT_TODO; … … 387 392 char *GB_undo_info(GBDATA *gb_main, GB_UNDO_TYPE type); 388 393 GB_ERROR GB_set_undo_mem(GBDATA *gbd, long memsize); 394 395 /* admap.cxx */ 396 bool GB_supports_mapfile(void); 389 397 390 398 /* adquery.cxx */ … … 415 423 /* adsocket.cxx */ 416 424 void GB_usleep(long usec); 417 GB_ULONG GB_time_of_file(const char *path);418 long GB_size_of_file(const char *path);419 long GB_mode_of_file(const char *path);420 long GB_mode_of_link(const char *path);421 bool GB_is_regularfile(const char *path);422 bool GB_is_link(const char *path);423 bool GB_is_executablefile(const char *path);424 bool GB_is_privatefile(const char *path, bool read_private);425 bool GB_is_readablefile(const char *filename);426 bool GB_is_directory(const char *path);427 long GB_getuid_of_file(const char *path);428 int GB_unlink(const char *path);429 void GB_unlink_or_warn(const char *path, GB_ERROR *error);430 char *GB_follow_unix_link(const char *path);431 GB_ERROR GB_symlink(const char *target, const char *link);432 GB_ERROR GB_set_mode_of_file(const char *path, long mode);433 GB_ERROR GB_rename_file(const char *oldpath, const char *newpath);434 425 char *GB_read_fp(FILE *in); 435 426 char *GB_read_file(const char *path); 436 427 char *GB_map_FILE(FILE *in, int writeable); 437 428 char *GB_map_file(const char *path, int writeable); 438 long GB_size_of_FILE(FILE *in);439 429 GB_ULONG GB_time_of_day(void); 440 430 long GB_last_saved_clock(GBDATA *gb_main); 441 431 GB_ULONG GB_last_saved_time(GBDATA *gb_main); 442 432 GB_ERROR GB_textprint(const char *path) __ATTR__USERESULT; 443 GB_ERROR GB_system(const char *system_command) __ATTR__USERESULT;444 433 GB_ERROR GB_xterm(void) __ATTR__USERESULT; 445 434 GB_ERROR GB_xcmd(const char *cmd, bool background, bool wait_only_if_error) __ATTR__USERESULT_TODO; … … 472 461 GB_CSTR GB_path_in_ARBHOME(const char *relative_path); 473 462 GB_CSTR GB_path_in_ARBLIB(const char *relative_path); 463 GB_CSTR GB_path_in_arbprop(const char *relative_path); 474 464 GB_CSTR GB_path_in_ARBHOME(const char *relative_path_left, const char *anypath_right); 475 465 GB_CSTR GB_path_in_ARBLIB(const char *relative_path_left, const char *anypath_right); -
branches/dev_elmar/ARBDB/ad_save_load.cxx
r7945 r8224 13 13 #include <netinet/in.h> 14 14 15 #include <arb_file.h> 16 15 17 #include "gb_map.h" 16 18 #include "gb_load.h" … … 184 186 if (Main) Main->qs.last_index = -1; 185 187 186 gb_assert(!GB_have_error()); // dont export 187 return error; 188 RETURN_ERROR(error); 188 189 } 189 190 … … 192 193 if (!error) GB_unlink_or_warn(gb_mapfile_name(path), &error); // delete old mapfile 193 194 194 gb_assert(!GB_have_error()); // dont export 195 return error; 195 RETURN_ERROR(error); 196 196 } 197 197 … … 833 833 } 834 834 835 GB_ERROR GB_create_parent_directory(const char *path) { 836 GB_ERROR error = NULL; 837 char *parent; 838 GB_split_full_path(path, &parent, NULL, NULL, NULL); 839 if (parent) { 840 if (!GB_is_directory(parent)) error = GB_create_directory(parent); 841 free(parent); 842 } 843 return error; 844 } 845 835 846 GB_ERROR GB_create_directory(const char *path) { 836 847 GB_ERROR error = 0; 837 848 if (!GB_is_directory(path)) { 838 char *parent; 839 GB_split_full_path(path, &parent, NULL, NULL, NULL); 840 if (parent) { 841 if (!GB_is_directory(parent)) error = GB_create_directory(parent); 842 free(parent); 843 } 844 849 error = GB_create_parent_directory(path); 845 850 if (!error) { 846 851 int res = mkdir(path, ACCESSPERMS); 847 852 if (res) error = GB_IO_error("creating directory", path); 848 853 } 849 850 gb_assert(error || GB_is_directory(path));851 852 854 error = GB_failedTo_error("GB_create_directory", path, error); 853 855 } … … 855 857 } 856 858 857 GB_ERROR GB_save_in_ home(GBDATA *gb, const char *path, const char *savetype) {859 GB_ERROR GB_save_in_arbprop(GBDATA *gb, const char *path, const char *savetype) { 858 860 /* savetype 859 861 * 'a' ascii 860 862 * 'b' binary 861 863 * 'bm' binary + mapfile 862 * 0=ascii863 864 * 864 865 * automatically creates subdirectories 865 866 */ 866 GB_ERROR error = 0; 867 char *buffer; 868 const char *env; 869 char *slash; 870 871 env = GB_getenvHOME(); 872 if (!path) path = GB_MAIN(gb)->path; 873 874 buffer = (char *)GB_calloc(sizeof(char), strlen(env) + strlen(path) + 2); 875 876 sprintf(buffer, "%s/%s", env, path); 877 slash = strrchr(buffer, '/'); 878 *slash = 0; 879 error = GB_create_directory(buffer); 880 *slash = '/'; 881 if (!error) error = GB_save_as(gb, buffer, savetype); 882 if (buffer) free(buffer); 867 868 char *fullname = strdup(GB_path_in_arbprop(path ? path : GB_MAIN(gb)->path)); 869 GB_ERROR error = GB_create_parent_directory(fullname); 870 if (!error) error = GB_save_as(gb, fullname, savetype); 871 free(fullname); 872 883 873 return error; 884 874 } … … 938 928 939 929 bool outOfOrderSave = strchr(savetype, 'f'); 940 bool deleteQuickAllowed = !outOfOrderSave ;930 bool deleteQuickAllowed = !outOfOrderSave && !dump_to_stdout; 941 931 { 942 932 int result = 0; … … 1018 1008 } 1019 1009 1020 gb_assert(!GB_have_error()); // dont export 1021 return error; 1010 RETURN_ERROR(error); 1022 1011 } 1023 1012 … … 1129 1118 } 1130 1119 1131 gb_assert(!GB_have_error()); // dont export 1132 return error; 1120 RETURN_ERROR(error); 1133 1121 } 1134 1122 … … 1200 1188 } 1201 1189 1202 gb_assert(!GB_have_error()); // dont export 1203 return error; 1190 RETURN_ERROR(error); 1204 1191 } 1205 1192 … … 1312 1299 1313 1300 // #define TEST_AUTO_UPDATE // uncomment to auto-update binary and quicksave testfiles (needed once after changing ascii testfile or modify_db()) 1314 #define TEST_copy(src, dst) TEST_ASSERT(system(GBS_global_string("cp '%s' '%s'", src, dst)) == 0)1315 1301 1316 1302 #define TEST_loadsave_CLEANUP() TEST_ASSERT(system("rm -f [ab]2[ab]*.* master.* slave.* renamed.* fast.* fast2b.* TEST_loadsave.ARF") == 0) … … 1388 1374 1389 1375 #if defined(TEST_AUTO_UPDATE) 1390 TEST_ copy("a2b.a00", "TEST_loadsave_quick.a00");1376 TEST_COPY_FILE("a2b.a00", "TEST_loadsave_quick.a00"); 1391 1377 #endif // TEST_AUTO_UPDATE 1392 1378 -
branches/dev_elmar/ARBDB/ad_t_prot.h
r7945 r8224 128 128 GB_ERROR GBT_write_float(GBDATA *gb_container, const char *fieldpath, double content); 129 129 GBDATA *GB_test_link_follower(GBDATA *gb_main, GBDATA *gb_link, const char *link); 130 GBDATA *GBT_open(const char *path, const char *opent , const char *disabled_path);130 GBDATA *GBT_open(const char *path, const char *opent); 131 131 GB_ERROR GBT_remote_action(GBDATA *gb_main, const char *application, const char *action_name); 132 132 GB_ERROR GBT_remote_awar(GBDATA *gb_main, const char *application, const char *awar_name, const char *value); -
branches/dev_elmar/ARBDB/adcomm.cxx
r7945 r8224 27 27 #include <SigHandler.h> 28 28 #include <arb_signal.h> 29 #include <arb_file.h> 29 30 30 31 static GBCM_ServerResult gbcms_talking(int con, long *hs, void *sin); … … 48 49 #define GBCM_COMMAND_FIND (GBTUM_MAGIC_NUMBER+8) 49 50 #define GBCM_COMMAND_CLOSE (GBTUM_MAGIC_NUMBER+9) 50 #define GBCM_COMMAND_SYSTEM (GBTUM_MAGIC_NUMBER+10)51 51 #define GBCM_COMMAND_KEY_ALLOC (GBTUM_MAGIC_NUMBER+11) 52 52 #define GBCM_COMMAND_UNDO (GBTUM_MAGIC_NUMBER+12) … … 65 65 #define GBCM_COMMAND_FIND_ERG (GBTUM_MAGIC_NUMBER+0x108000) 66 66 #define GBCM_COMMAND_KEY_ALLOC_RES (GBTUM_MAGIC_NUMBER+0x10b000) 67 #define GBCM_COMMAND_SYSTEM_RETURN (GBTUM_MAGIC_NUMBER+0x10a0000)68 67 #define GBCM_COMMAND_UNDO_CMD (GBTUM_MAGIC_NUMBER+0x10a0001) 69 68 … … 968 967 // command: GBCM_COMMAND_CLOSE 969 968 return GBCM_SERVER_ABORTED; 970 }971 972 static GBCM_ServerResult gbcms_talking_system(int socket, long */*hsin*/, void */*sin*/, GBDATA */*gbd*/) {973 // command: GBCM_COMMAND_SYSTEM974 char *comm = gbcm_read_string(socket);975 976 gbcm_read_flush();977 978 GB_ERROR error = GB_system(comm);979 if (error) {980 GB_warning(error);981 return GBCM_SERVER_FAULT;982 }983 984 if (gbcm_write_two(socket, GBCM_COMMAND_SYSTEM_RETURN, 0)) {985 return GBCM_SERVER_FAULT;986 }987 return gbcm_write_flush(socket);988 969 } 989 970 … … 1134 1115 } 1135 1116 1117 static GBCM_ServerResult gbcms_talking_obsolete(int /*socket*/, long */*hsin*/, void */*sin*/, GBDATA */*gbd*/) { 1118 fputs("Obsolete server function called\n", stderr); 1119 return GBCM_SERVER_FAULT; 1120 } 1121 1136 1122 // ----------------------- 1137 1123 // server talking … … 1150 1136 gbcms_talking_find, // GBCM_COMMAND_FIND 1151 1137 gbcms_talking_close, // GBCM_COMMAND_CLOSE 1152 gbcms_talking_ system, // GBCM_COMMAND_SYSTEM1138 gbcms_talking_obsolete, 1153 1139 gbcms_talking_key_alloc, // GBCM_COMMAND_KEY_ALLOC 1154 1140 gbcms_talking_undo, // GBCM_COMMAND_UNDO … … 1781 1767 } 1782 1768 1783 #if defined(WARN_TODO)1784 #warning GBCMC_system should return GB_ERROR!1785 #endif1786 1787 int GBCMC_system(GBDATA *gbd, const char *ss) { // goes to header: __ATTR__USERESULT_TODO1788 int socket;1789 long gb_result[2];1790 GB_MAIN_TYPE *Main = GB_MAIN(gbd);1791 1792 if (Main->local_mode) {1793 GB_ERROR error = GB_system(ss);1794 if (error) GB_export_error(error);1795 return error != 0;1796 }1797 socket = Main->c_link->socket;1798 1799 if (gbcm_write_two(socket, GBCM_COMMAND_SYSTEM, gbd->server_id)) {1800 GB_export_error(SEND_ERROR());1801 GB_print_error();1802 return -1;1803 }1804 1805 gbcm_write_string(socket, ss);1806 if (gbcm_write_flush(socket)) {1807 GB_export_error("ARB_DB CLIENT ERROR send failed");1808 GB_print_error();1809 return -1;1810 }1811 gbcm_read_two(socket, GBCM_COMMAND_SYSTEM_RETURN, 0, (long *)gb_result);1812 gbcm_read_flush();1813 return 0;1814 }1815 1816 1769 GB_ERROR gbcmc_send_undo_commands(GBDATA *gbd, enum gb_undo_commands command) { // goes to header: __ATTR__USERESULT 1817 1770 // send an undo command -
branches/dev_elmar/ARBDB/adfile.cxx
r7945 r8224 22 22 #include <arb_str.h> 23 23 #include <arb_strarray.h> 24 #include <arb_file.h> 24 25 25 26 #include "gb_local.h" … … 194 195 } 195 196 196 char *GBS_find_lib_file(const char *filename, const char *libprefix, bool warn_when_not_found) { 197 // Searches files in current dir, $HOME, $ARBHOME/lib/libprefix 198 199 char *result = 0; 200 201 if (GB_is_readablefile(filename)) { 202 result = strdup(filename); 203 } 204 else { 205 const char *slash = strrchr(filename, '/'); // look for last slash 206 207 if (slash && filename[0] != '.') { // have absolute path 208 filename = slash+1; // only use filename part 209 slash = 0; 210 } 211 212 const char *fileInHome = GB_concat_full_path(GB_getenvHOME(), filename); 213 214 if (fileInHome && GB_is_readablefile(fileInHome)) { 215 result = strdup(fileInHome); 216 } 217 else { 218 if (slash) filename = slash+1; // now use filename only, even if path starts with '.' 219 220 const char *fileInLib = GB_path_in_ARBLIB(libprefix, filename); 221 222 if (fileInLib && GB_is_readablefile(fileInLib)) { 223 result = strdup(fileInLib); 224 } 225 else { 226 if (warn_when_not_found) { 227 GB_warningf("Don't know where to find '%s'\n" 228 " searched in '.'\n" 229 " searched in $(HOME) (for '%s')\n" 230 " searched in $(ARBHOME)/lib/%s (for '%s')\n", 231 filename, fileInHome, libprefix, fileInLib); 232 } 233 } 234 } 235 } 236 197 const char *GB_existing_file(const char *file, bool warn_when_not_found) { 198 // return 'file' if it's an existing readable file 199 // return NULL otherwise 200 201 gb_assert(file); 202 if (GB_is_readablefile(file)) return file; 203 if (warn_when_not_found) GB_warningf("Could not find '%s'", file); 204 return NULL; 205 } 206 207 char *GB_lib_file(bool warn_when_not_found, const char *libprefix, const char *filename) { 208 // Search a file in '$ARBHOME/lib/libprefix' 209 // Return NULL if not found 210 return nulldup(GB_existing_file(GB_path_in_ARBLIB(libprefix, filename), warn_when_not_found)); 211 } 212 213 char *GB_property_file(bool warn_when_not_found, const char *filename) { 214 // Search a file in '~/.arb_prop' or its default in '$ARBHOME/lib/arb_default' 215 // Return NULL if neighter found 216 217 char *result = nulldup(GB_existing_file(GB_path_in_arbprop(filename), warn_when_not_found)); 218 if (!result) result = GB_lib_file(warn_when_not_found, "arb_default", filename); 237 219 return result; 238 220 } … … 585 567 } 586 568 569 size_t GB_test_mem_equal(const unsigned char *buf1, const unsigned char *buf2, size_t common) { 570 size_t equal_bytes; 571 if (memcmp(buf1, buf2, common) == 0) { 572 equal_bytes = common; 573 } 574 else { 575 equal_bytes = 0; 576 size_t x = 0; // position inside memory 577 while (buf1[x] == buf2[x]) { 578 x++; 579 equal_bytes++; 580 } 581 582 const size_t DUMP = 7; 583 size_t y1 = x >= DUMP ? x-DUMP : 0; 584 size_t y2 = (x+DUMP)>common ? common : (x+DUMP); 585 size_t blockstart = equal_bytes-x; 586 587 for (size_t y = y1; y <= y2; y++) { 588 fprintf(stderr, "[0x%04zx]", blockstart+y); 589 arb_test::print_pair(buf1[y], buf2[y]); 590 fputc(' ', stderr); 591 arb_test::print_hex_pair(buf1[y], buf2[y]); 592 if (x == y) fputs(" <- diff", stderr); 593 fputc('\n', stderr); 594 } 595 if (y2 == common) { 596 fputs("[end of block - truncated]\n", stderr); 597 } 598 } 599 return equal_bytes; 600 } 601 587 602 bool GB_test_files_equal(const char *file1, const char *file2) { 588 603 const char *error = NULL; … … 606 621 607 622 while (!error) { 608 int read1 = fread(buf1, 1, BLOCKSIZE, fp1);609 int read2 = fread(buf2, 1, BLOCKSIZE, fp2);610 int common = read1<read2 ? read1 : read2;623 int read1 = fread(buf1, 1, BLOCKSIZE, fp1); 624 int read2 = fread(buf2, 1, BLOCKSIZE, fp2); 625 size_t common = read1<read2 ? read1 : read2; 611 626 612 627 if (!common) { … … 615 630 } 616 631 617 if (memcmp(buf1, buf2, common) == 0) { 618 equal_bytes += common; 619 } 620 else { 621 int x = 0; 622 while (buf1[x] == buf2[x]) { 623 x++; 624 equal_bytes++; 625 } 632 size_t thiseq = GB_test_mem_equal(buf1, buf2, common); 633 if (thiseq != common) { 626 634 error = "content differs"; 627 628 // x is the position inside the current block 629 const int DUMP = 7; 630 int y1 = x >= DUMP ? x-DUMP : 0; 631 int y2 = (x+DUMP)>common ? common : (x+DUMP); 632 int blockstart = equal_bytes-x; 633 634 for (int y = y1; y <= y2; y++) { 635 fprintf(stderr, "[0x%04x]", blockstart+y); 636 arb_test::print_pair(buf1[y], buf2[y]); 637 fputc(' ', stderr); 638 arb_test::print_hex_pair(buf1[y], buf2[y]); 639 if (x == y) fputs(" <- diff", stderr); 640 fputc('\n', stderr); 641 } 642 if (y2 == common) { 643 fputs("[end of block - truncated]\n", stderr); 644 } 645 } 635 } 636 equal_bytes += thiseq; 646 637 } 647 638 … … 708 699 } 709 700 701 void TEST_find_file() { 702 TEST_ASSERT_EQUAL(GB_existing_file("min_ascii.arb", false), "min_ascii.arb"); 703 TEST_ASSERT_EQUAL(GB_existing_file("nosuchfile", false), NULL); 704 705 char *tcporg = GB_lib_file(false, "", "arb_tcp_org.dat"); 706 TEST_ASSERT_EQUAL(tcporg, GB_path_in_ARBHOME("lib/arb_tcp_org.dat")); 707 TEST_ASSERT_EQUAL(GB_lib_file(true, "bla", "blub"), NULL); 708 free(tcporg); 709 710 char *status = GB_property_file(false, "status.arb"); 711 TEST_ASSERT_EQUAL(status, GB_path_in_ARBHOME("lib/arb_default/status.arb")); 712 TEST_ASSERT_EQUAL(GB_property_file(true, "undhepp"), NULL); 713 free(status); 714 } 715 710 716 // -------------------------------------------------------------------------------- 711 717 // tests for global code included from central ARB headers (located in $ARBHOME/TEMPLATES) … … 755 761 756 762 TEST_ASSERT(correlated( 757 correlated(kermitIsGreen, kermitIsFrog), 758 allFrogsAreGreen && onlyFrogsAreGreen 759 )); 760 } 761 } 762 } 763 correlated(kermitIsGreen, kermitIsFrog), 764 allFrogsAreGreen && onlyFrogsAreGreen 765 )); 766 } 767 } 768 } 769 763 770 764 771 #endif // UNIT_TESTS -
branches/dev_elmar/ARBDB/adindex.cxx
r7945 r8224 120 120 } 121 121 122 GB_ERROR GB_create_index(GBDATA *gbd, const char *key, GB_CASE case_sens, long estimated_size) { 122 GB_ERROR GB_create_index(GBDATA *gbd, const char *key, GB_CASE case_sens, long estimated_size) { // goes to header: __ATTR__USERESULT 123 123 /* Create an index for a database. 124 124 * Uses hash tables - collisions are avoided by using linked lists. … … 127 127 128 128 if (GB_TYPE(gbd) != GB_DB) { 129 error = GB_export_error("GB_create_index used on non CONTAINER Type");129 error = "GB_create_index used on non CONTAINER Type"; 130 130 } 131 131 else if (GB_read_clients(gbd)<0) { 132 error = GB_export_error("No index tables in DB clients allowed");132 error = "No index tables in DB clients allowed"; 133 133 } 134 134 else { … … 171 171 } 172 172 } 173 return error;173 RETURN_ERROR(error); 174 174 } 175 175 -
branches/dev_elmar/ARBDB/adlang1.cxx
r7945 r8224 19 19 #include <arb_defs.h> 20 20 #include <arb_strbuf.h> 21 #include <arb_file.h> 21 22 #include <aw_awar_defs.hxx> 22 23 -
branches/dev_elmar/ARBDB/admap.cxx
r7945 r8224 12 12 #include "gb_storage.h" 13 13 #include "gb_index.h" 14 #include <arb_file.h> 14 15 15 16 #include <static_assert.h> … … 674 675 } 675 676 677 bool GB_supports_mapfile() { 678 #if (MEMORY_TEST == 1) 679 return false; 680 #else 681 return true; 682 #endif 683 } 684 676 685 int gb_is_valid_mapfile(const char *path, gb_map_header *mheader, int verbose) { 677 686 /* Test whether mapfile is valid -
branches/dev_elmar/ARBDB/adsocket.cxx
r7945 r8224 11 11 #include <unistd.h> 12 12 13 #include <cerrno>14 13 #include <climits> 15 14 #include <cstdarg> … … 28 27 #include <arb_str.h> 29 28 #include <arb_strbuf.h> 29 #include <arb_file.h> 30 30 31 31 #include "gb_comm.h" … … 301 301 } 302 302 303 inline bool is_default_or_ignore_or_own_sighandler(SigHandler sh) { 304 return sh == gbcmc_suppress_sigpipe || is_default_or_ignore_sighandler(sh); 305 } 306 303 307 gbcmc_comm *gbcmc_open(const char *path) { 304 308 gbcmc_comm *link = (gbcmc_comm *)GB_calloc(sizeof(gbcmc_comm), 1); … … 313 317 return 0; 314 318 } 315 ASSERT_RESULT_PREDICATE(is_default_or_ignore_ sighandler, INSTALL_SIGHANDLER(SIGPIPE, gbcmc_suppress_sigpipe, "gbcmc_open"));319 ASSERT_RESULT_PREDICATE(is_default_or_ignore_or_own_sighandler, INSTALL_SIGHANDLER(SIGPIPE, gbcmc_suppress_sigpipe, "gbcmc_open")); 316 320 gb_local->iamclient = 1; 317 321 return link; … … 405 409 } 406 410 407 408 static struct stat gb_global_stt;409 410 GB_ULONG GB_time_of_file(const char *path)411 {412 if (path) {413 char *path2 = GBS_eval_env(path);414 if (stat(path2, &gb_global_stt)) {415 free(path2);416 return 0;417 }418 free(path2);419 }420 return gb_global_stt.st_mtime;421 }422 423 long GB_size_of_file(const char *path) {424 if (!path || stat(path, &gb_global_stt)) return -1;425 return gb_global_stt.st_size;426 }427 428 long GB_mode_of_file(const char *path)429 {430 if (path) if (stat(path, &gb_global_stt)) return -1;431 return gb_global_stt.st_mode;432 }433 434 long GB_mode_of_link(const char *path)435 {436 if (path) if (lstat(path, &gb_global_stt)) return -1;437 return gb_global_stt.st_mode;438 }439 440 bool GB_is_regularfile(const char *path) {441 // Warning : returns true for symbolic links to files (use GB_is_link() to test)442 struct stat stt;443 return stat(path, &stt) == 0 && S_ISREG(stt.st_mode);444 }445 446 bool GB_is_link(const char *path) {447 struct stat stt;448 return lstat(path, &stt) == 0 && S_ISLNK(stt.st_mode);449 }450 451 bool GB_is_executablefile(const char *path) {452 struct stat stt;453 bool executable = false;454 455 if (stat(path, &stt) == 0) {456 uid_t my_userid = geteuid(); // effective user id457 if (stt.st_uid == my_userid) { // I am the owner of the file458 executable = !!(stt.st_mode&S_IXUSR); // owner execution permission459 }460 else {461 gid_t my_groupid = getegid(); // effective group id462 if (stt.st_gid == my_groupid) { // I am member of the file's group463 executable = !!(stt.st_mode&S_IXGRP); // group execution permission464 }465 else {466 executable = !!(stt.st_mode&S_IXOTH); // others execution permission467 }468 }469 }470 471 return executable;472 }473 474 bool GB_is_privatefile(const char *path, bool read_private) {475 // return true, if nobody but user has write permission476 // if 'read_private' is true, only return true if nobody but user has read permission477 //478 // Note: Always returns true for missing files!479 //480 // GB_is_privatefile is mainly used to assert that files generated in /tmp have secure permissions481 482 struct stat stt;483 bool isprivate = true;484 485 if (stat(path, &stt) == 0) {486 if (read_private) {487 isprivate = (stt.st_mode & (S_IWGRP|S_IWOTH|S_IRGRP|S_IROTH)) == 0;488 }489 else {490 isprivate = (stt.st_mode & (S_IWGRP|S_IWOTH)) == 0;491 }492 }493 return isprivate;494 }495 496 bool GB_is_readablefile(const char *filename) {497 FILE *in = fopen(filename, "r");498 499 if (in) {500 fclose(in);501 return true;502 }503 return false;504 }505 506 bool GB_is_directory(const char *path) {507 // Warning : returns true for symbolic links to directories (use GB_is_link())508 struct stat stt;509 return stat(path, &stt) == 0 && S_ISDIR(stt.st_mode);510 }511 512 long GB_getuid_of_file(const char *path) {513 struct stat stt;514 if (stat(path, &stt)) return -1;515 return stt.st_uid;516 }517 518 int GB_unlink(const char *path)519 { /*! unlink a file520 * @return521 * 0 success522 * 1 File did not exist523 * -1 Error (use GB_await_error() to retrieve message)524 */525 526 if (unlink(path) != 0) {527 if (errno == ENOENT) {528 return 1;529 }530 GB_export_error(GB_IO_error("removing", path));531 return -1;532 }533 return 0;534 }535 536 void GB_unlink_or_warn(const char *path, GB_ERROR *error) {537 /* Unlinks 'path'538 *539 * In case of a real unlink failure:540 * - if 'error' is given -> set error if not already set541 * - otherwise only warn542 */543 544 if (GB_unlink(path)<0) {545 GB_ERROR unlink_error = GB_await_error();546 if (error && *error == NULL) *error = unlink_error;547 else GB_warning(unlink_error);548 }549 }550 551 char *GB_follow_unix_link(const char *path) { // returns the real path of a file552 char buffer[1000];553 char *path2;554 char *pos;555 char *res;556 int len = readlink(path, buffer, 999);557 if (len<0) return 0;558 buffer[len] = 0;559 if (path[0] == '/') return strdup(buffer);560 561 path2 = strdup(path);562 pos = strrchr(path2, '/');563 if (!pos) {564 free(path2);565 return strdup(buffer);566 }567 *pos = 0;568 res = GBS_global_string_copy("%s/%s", path2, buffer);569 free(path2);570 return res;571 }572 573 GB_ERROR GB_symlink(const char *target, const char *link) {574 if (symlink(target, link)<0) {575 return GBS_global_string("Cannot create symlink '%s' to file '%s'", link, target);576 }577 return 0;578 }579 580 GB_ERROR GB_set_mode_of_file(const char *path, long mode) {581 if (chmod(path, (int)mode)) return GBS_global_string("Cannot change mode of '%s'", path);582 return 0;583 }584 585 GB_ERROR GB_rename_file(const char *oldpath, const char *newpath) {586 long old_mod = GB_mode_of_file(newpath); // keep filemode for existing files587 if (old_mod == -1) old_mod = GB_mode_of_file(oldpath);588 589 GB_ERROR error = NULL;590 if (rename(oldpath, newpath) != 0) {591 error = GB_IO_error("renaming", GBS_global_string("%s into %s", oldpath, newpath));592 }593 else {594 error = GB_set_mode_of_file(newpath, old_mod);595 }596 597 sync(); // why ?598 return error;599 }600 601 411 char *GB_read_fp(FILE *in) { 602 412 /*! like GB_read_file(), but works on already open file … … 685 495 } 686 496 687 long GB_size_of_FILE(FILE *in) {688 int fi = fileno(in);689 struct stat st;690 if (fstat(fi, &st)) {691 GB_export_error("GB_size_of_FILE: sorry file is not readable");692 return -1;693 }694 return st.st_size;695 }696 697 698 497 GB_ULONG GB_time_of_day() { 699 498 timeval tp; … … 714 513 char *fpath = GBS_eval_env(path); 715 514 const char *command = GBS_global_string("arb_textprint '%s' &", fpath); 716 GB_ERROR error = GB _system(command);515 GB_ERROR error = GBK_system(command); 717 516 free(fpath); 718 517 return GB_failedTo_error("print textfile", fpath, error); 719 }720 721 #if defined(WARN_TODO)722 #warning search for '\b(system)\b\s*\(' and use GB_system instead723 #endif724 GB_ERROR GB_system(const char *system_command) {725 // goes to header: __ATTR__USERESULT726 fprintf(stderr, "[Action: '%s']\n", system_command);727 int res = system(system_command);728 GB_ERROR error = NULL;729 if (res) {730 error = GBS_global_string("System call failed (result=%i)\n"731 "System call was '%s'\n"732 "(Note: console window may contain additional information)", res, system_command);733 }734 return error;735 518 } 736 519 … … 739 522 const char *xt = GB_getenvARB_XTERM(); 740 523 const char *command = GBS_global_string("%s &", xt); 741 return GB _system(command);524 return GBK_system(command); 742 525 } 743 526 … … 776 559 } 777 560 778 GB_ERROR error = GB _system(GBS_mempntr(strstruct));561 GB_ERROR error = GBK_system(GBS_mempntr(strstruct)); 779 562 GBS_strforget(strstruct); 780 563 … … 1001 784 GB_CSTR GB_getenvARBMACROHOME() { 1002 785 static const char *amh = 0; 1003 if (!amh) amh = getenv_autodirectory("ARBMACROHOME", "$(HOME)/.arb_prop/macros"); // doc in ../HELP_SOURCE/oldhelp/arb_envar.hlp@ARBMACROHOME786 if (!amh) amh = getenv_autodirectory("ARBMACROHOME", GB_path_in_arbprop("macros")); // doc in ../HELP_SOURCE/oldhelp/arb_envar.hlp@ARBMACROHOME 1004 787 return amh; 1005 788 } … … 1007 790 GB_CSTR GB_getenvARBCONFIG() { 1008 791 static const char *ac = 0; 1009 if (!ac) ac = getenv_autodirectory("ARBCONFIG", "$(HOME)/.arb_prop/cfgSave"); // doc in ../HELP_SOURCE/oldhelp/arb_envar.hlp@ARBCONFIG792 if (!ac) ac = getenv_autodirectory("ARBCONFIG", GB_path_in_arbprop("cfgSave")); // doc in ../HELP_SOURCE/oldhelp/arb_envar.hlp@ARBCONFIG 1010 793 return ac; 1011 794 } … … 1194 977 GB_ULONG usedmemsize = (MIN(net_memsize, max_malloc)*95)/100; // arb uses max. 95 % of available memory (was 70% in the past) 1195 978 1196 #if defined(DEBUG) 979 #if defined(DEBUG) && 0 1197 980 printf("- memsize(real) = %20lu k\n", memsize); 1198 981 printf("- memsize(net) = %20lu k\n", net_memsize); 1199 982 printf("- memsize(max_malloc) = %20lu k\n", max_malloc); 983 printf("- memsize(used by ARB) = %20lu k\n", usedmemsize); 1200 984 #endif // DEBUG 1201 printf("- memsize(used by ARB) = %20lu k\n", usedmemsize);1202 985 1203 986 arb_assert(usedmemsize != 0); … … 1208 991 // --------------------------------------------- 1209 992 // path completion (parts former located in AWT) 993 // @@@ whole section (+ corresponding tests) should move to adfile.cxx 1210 994 1211 995 static int path_toggle = 0; … … 1341 1125 GB_CSTR GB_path_in_ARBLIB(const char *relative_path) { 1342 1126 return GB_path_in_ARBHOME("lib", relative_path); 1127 } 1128 GB_CSTR GB_path_in_arbprop(const char *relative_path) { 1129 return GB_unfold_path("HOME", GB_concat_path(".arb_prop", relative_path)); 1343 1130 } 1344 1131 GB_CSTR GB_path_in_ARBHOME(const char *relative_path_left, const char *anypath_right) { -
branches/dev_elmar/ARBDB/adstring.cxx
r7945 r8224 118 118 long len; 119 119 120 if (!key || key[0] == 0) return GB_export_error("Empty key is not allowed");120 if (!key || key[0] == 0) return "Empty key is not allowed"; 121 121 len = strlen(key); 122 if (len>GB_KEY_LEN_MAX) return GB _export_errorf("Invalid key '%s': too long", key);123 if (len < GB_KEY_LEN_MIN) return GB _export_errorf("Invalid key '%s': too short", key);122 if (len>GB_KEY_LEN_MAX) return GBS_global_string("Invalid key '%s': too long", key); 123 if (len < GB_KEY_LEN_MIN) return GBS_global_string("Invalid key '%s': too short", key); 124 124 125 125 for (i = 0; key[i]; ++i) { … … 129 129 if ((c>='0') && (c<='9')) continue; 130 130 if ((c=='_')) continue; 131 return GB _export_errorf("Invalid character '%c' in '%s'; allowed: a-z A-Z 0-9 '_' ", c, key);131 return GBS_global_string("Invalid character '%c' in '%s'; allowed: a-z A-Z 0-9 '_' ", c, key); 132 132 } 133 133 … … 563 563 char last = *data++; 564 564 565 do{565 while (last) { 566 566 char curr = *data++; 567 567 if (curr == last) { … … 569 569 } 570 570 else { 571 if (repeat >= 10) {571 if (repeat >= 5) { 572 572 dest += sprintf(dest, "%c{%zu}", last, repeat); // insert repeat count 573 573 } … … 580 580 } 581 581 } 582 while (last);583 582 584 583 *dest = 0; … … 1159 1158 } 1160 1159 1160 #define TEST_SHORTENED_EQUALS(Long,Short) do { \ 1161 char *buf = strdup(Long); \ 1162 GBS_shorten_repeated_data(buf); \ 1163 TEST_ASSERT_EQUAL(buf, Short); \ 1164 free(buf); \ 1165 } while(0) 1166 1167 void TEST_GBS_shorten_repeated_data() { 1168 TEST_SHORTENED_EQUALS("12345", "12345"); 1169 TEST_SHORTENED_EQUALS("aaaaaaaaaaaabc", "a{12}bc"); 1170 TEST_SHORTENED_EQUALS("aaaaaaaaaaabc", "a{11}bc"); 1171 TEST_SHORTENED_EQUALS("aaaaaaaaaabc", "a{10}bc"); 1172 TEST_SHORTENED_EQUALS("aaaaaaaaabc", "a{9}bc"); 1173 TEST_SHORTENED_EQUALS("aaaaaaaabc", "a{8}bc"); 1174 TEST_SHORTENED_EQUALS("aaaaaaabc", "a{7}bc"); 1175 TEST_SHORTENED_EQUALS("aaaaaabc", "a{6}bc"); 1176 TEST_SHORTENED_EQUALS("aaaaabc", "a{5}bc"); 1177 TEST_SHORTENED_EQUALS("aaaabc", "aaaabc"); 1178 TEST_SHORTENED_EQUALS("aaabc", "aaabc"); 1179 TEST_SHORTENED_EQUALS("aabc", "aabc"); 1180 TEST_SHORTENED_EQUALS("", ""); 1181 1182 } 1161 1183 #endif 1162 1184 -
branches/dev_elmar/ARBDB/adsystem.cxx
r7945 r8224 215 215 } 216 216 217 GB_ERROR gb_load_key_data_and_dictionaries(GBDATA *gb_main) { 218 GB_MAIN_TYPE *Main = GB_MAIN(gb_main); 217 GB_ERROR gb_load_key_data_and_dictionaries(GBDATA *gb_main) { // goes to header: __ATTR__USERESULT 218 GB_MAIN_TYPE *Main = GB_MAIN(gb_main); 219 GB_ERROR error = NULL; 220 219 221 GBDATA *gb_key_data = gb_search(gb_main, GB_SYSTEM_FOLDER "/" GB_SYSTEM_KEY_DATA, GB_CREATE_CONTAINER, 1); 220 GBDATA *gb_key, *gb_next_key=0; 221 int key; 222 223 Main->gb_key_data = gb_key_data; 224 if (!Main->local_mode) return 0; // do not create anything at the client side 225 226 GB_push_my_security(gb_main); 227 228 // First step: search unused keys and delete them 229 for (gb_key = GB_entry(gb_key_data, "@key"); 230 gb_key; 231 gb_key = gb_next_key) 232 { 233 GBDATA *gb_name = GB_entry(gb_key, "@name"); 234 const char *name = GB_read_char_pntr(gb_name); 235 GBQUARK quark = gb_key_2_quark(Main, name); 236 237 gb_next_key = GB_nextEntry(gb_key); 238 239 if (quark<=0 || quark >= Main->sizeofkeys || !Main->keys[quark].key) { 240 GB_delete(gb_key); // delete unused key 241 } 242 } 243 GB_create_index(gb_key_data, "@name", GB_MIND_CASE, Main->sizeofkeys*2); 244 245 gb_key_2_quark(Main, "@name"); 246 gb_key_2_quark(Main, "@key"); 247 gb_key_2_quark(Main, "@dictionary"); 248 gb_key_2_quark(Main, "compression_mask"); 249 250 for (key=1; key<Main->sizeofkeys; key++) { 251 char *k = Main->keys[key].key; 252 if (!k) continue; 253 gb_load_single_key_data(gb_main, key); 254 } 255 256 257 GB_pop_my_security(gb_main); 258 return 0; 222 if (!gb_key_data) { 223 error = GB_await_error(); 224 } 225 else { 226 Main->gb_key_data = gb_key_data; 227 if (Main->local_mode) { // do not create anything at the client side 228 GB_push_my_security(gb_main); 229 230 // search unused keys and delete them 231 for (GBDATA *gb_key = GB_entry(gb_key_data, "@key"); gb_key && !error;) { 232 GBDATA *gb_next_key = GB_nextEntry(gb_key); 233 GBDATA *gb_name = GB_entry(gb_key, "@name"); 234 if (!gb_name) error = GB_await_error(); 235 else { 236 const char *name = GB_read_char_pntr(gb_name); 237 if (!name) error = GB_await_error(); 238 else { 239 GBQUARK quark = gb_key_2_quark(Main, name); 240 if (quark<=0 || quark >= Main->sizeofkeys || !Main->keys[quark].key) { 241 error = GB_delete(gb_key); // delete unused key 242 } 243 } 244 } 245 gb_key = gb_next_key; 246 } 247 248 if (!error) error = GB_create_index(gb_key_data, "@name", GB_MIND_CASE, Main->sizeofkeys*2); // create key index 249 if (!error) { 250 gb_key_2_quark(Main, "@name"); 251 gb_key_2_quark(Main, "@key"); 252 gb_key_2_quark(Main, "@dictionary"); 253 gb_key_2_quark(Main, "compression_mask"); 254 255 for (int key=1; key<Main->sizeofkeys; key++) { 256 char *k = Main->keys[key].key; 257 if (!k) continue; 258 gb_load_single_key_data(gb_main, key); 259 } 260 } 261 GB_pop_my_security(gb_main); 262 } 263 } 264 RETURN_ERROR(error); 259 265 } 260 266 -
branches/dev_elmar/ARBDB/adtables.cxx
r7945 r8224 90 90 91 91 gb_table_data = GB_search(gb_table_root, "table_data", GB_CREATE_CONTAINER); 92 GB_create_index(gb_table_data, "name", GB_IGNORE_CASE, 256);92 ASSERT_NO_ERROR(GB_create_index(gb_table_data, "name", GB_IGNORE_CASE, 256)); 93 93 94 94 gb_table_name = GB_find_string(gb_table_data, "name", table_name, GB_IGNORE_CASE, SEARCH_GRANDCHILD); … … 123 123 GBDATA *gb_table; 124 124 gb_table_data = GB_search(gb_main, "table_data", GB_CREATE_CONTAINER); 125 GB_create_index(gb_table_data, "name", GB_IGNORE_CASE, 256);125 ASSERT_NO_ERROR(GB_create_index(gb_table_data, "name", GB_IGNORE_CASE, 256)); 126 126 gb_table = GB_entry(gb_table_data, "table"); 127 127 return gb_table; -
branches/dev_elmar/ARBDB/adtcp.cxx
r7945 r8224 220 220 } 221 221 222 char *GB_arbtcpdat_path() { 223 return GB_lib_file(true, "", "arb_tcp.dat"); 224 } 225 222 226 GB_ERROR ArbTcpDat::update() { 223 227 // read arb_tcp.dat (once or if changed on disk) 224 228 GB_ERROR error = 0; 225 229 226 if (!filename) filename = GB S_find_lib_file("arb_tcp.dat", "", true);230 if (!filename) filename = GB_arbtcpdat_path(); 227 231 228 232 if (!filename) { 229 error = GBS_global_string("File $ARBHOME/lib/arb_tcp.dat not found");233 error = "File $ARBHOME/lib/arb_tcp.dat missing or unreadable"; 230 234 } 231 235 else { … … 300 304 // AISC_MKPT_PROMOTE:#ifdef UNIT_TESTS 301 305 // AISC_MKPT_PROMOTE:#define TEST_SERVER_ID (-666) 306 // AISC_MKPT_PROMOTE:#define TEST_GENESERVER_ID (-667) 302 307 // AISC_MKPT_PROMOTE:#endif 303 308 … … 313 318 const char *GBS_ptserver_tag(int id) { 314 319 #ifdef UNIT_TESTS 315 if (id == TEST_SERVER_ID) { 316 return "ARB_TEST_PT_SERVER"; 317 } 320 if (id == TEST_SERVER_ID) return "ARB_TEST_PT_SERVER"; 321 if (id == TEST_GENESERVER_ID) return "ARB_TEST_PT_SERVER_GENE"; 318 322 #endif // UNIT_TESTS 319 323 gb_assert(id >= 0); -
branches/dev_elmar/ARBDB/adtools.cxx
r7945 r8224 17 17 #include <arb_str.h> 18 18 #include <arb_strarray.h> 19 20 #include <algorithm> 21 22 using namespace std; 19 23 20 24 GBDATA *GBT_find_or_create(GBDATA *Main, const char *key, long delete_level) … … 418 422 */ 419 423 424 gb_assert(default_value == default_value); // !nan 425 420 426 GBDATA *gb_float; 421 427 double *result = NULL; … … 428 434 result = &result_var; 429 435 } 436 else { 437 gb_assert(0); 438 } 430 439 GB_pop_transaction(gb_container); 431 440 return result; … … 492 501 * but for fields of type GB_FLOAT 493 502 */ 503 504 gb_assert(content == content); // !nan 505 494 506 GB_ERROR error = GB_push_transaction(gb_container); 495 507 GBDATA *gbd = GB_search(gb_container, fieldpath, GB_FLOAT); … … 513 525 // save & load 514 526 515 GBDATA *GBT_open(const char *path, const char *opent, const char *disabled_path) { 516 /*! Open a database and create an index for species and extended names. 527 GBDATA *GBT_open(const char *path, const char *opent) { 528 /*! Open a database, 529 * create an index for species and extended names (server only!) and 530 * disable saving in the PT_SERVER directory. 517 531 * 518 532 * @param path filename of the DB 519 533 * @param opent see GB_login() 520 * @param disabled_path disable saving in this path. 521 * if disabled_path is NULL, disable saving in the PT_SERVER directory. 534 * @return database handle (or NULL in which case an error is exported) 522 535 * @see GB_open() 523 536 */ 524 537 525 538 GBDATA *gbd = GB_open(path, opent); 526 GBDATA *species_data; 527 GBDATA *extended_data; 528 GBDATA *gb_tmp; 529 long hash_size; 530 531 if (!gbd) return gbd; 532 if (!disabled_path) disabled_path = "$(ARBHOME)/lib/pts/*"; 533 GB_disable_path(gbd, disabled_path); 534 GB_begin_transaction(gbd); 535 536 if (!strchr(path, ':')) { 537 species_data = GB_search(gbd, "species_data", GB_FIND); 538 if (species_data) { 539 hash_size = GB_number_of_subentries(species_data); 540 if (hash_size < GBT_SPECIES_INDEX_SIZE) hash_size = GBT_SPECIES_INDEX_SIZE; 541 GB_create_index(species_data, "name", GB_IGNORE_CASE, hash_size); 542 543 extended_data = GBT_get_SAI_data(gbd); 544 hash_size = GB_number_of_subentries(extended_data); 545 if (hash_size < GBT_SAI_INDEX_SIZE) hash_size = GBT_SAI_INDEX_SIZE; 546 GB_create_index(extended_data, "name", GB_IGNORE_CASE, hash_size); 547 } 548 } 549 gb_tmp = GB_search(gbd, "tmp", GB_CREATE_CONTAINER); 550 GB_set_temporary(gb_tmp); 551 { 552 GB_MAIN_TYPE *Main = GB_MAIN(gbd); 553 Main->table_hash = GBS_create_hash(256, GB_MIND_CASE); 554 GB_install_link_follower(gbd, "REF", GB_test_link_follower); 555 } 556 GBT_install_table_link_follower(gbd); 557 GB_commit_transaction(gbd); 539 if (gbd) { 540 GB_disable_path(gbd, GB_path_in_ARBLIB("pts/*")); 541 GB_ERROR error = NULL; 542 { 543 GB_transaction ta(gbd); 544 545 if (!strchr(path, ':')) { 546 GBDATA *species_data = GB_search(gbd, "species_data", GB_FIND); 547 if (species_data) { 548 long hash_size = max(GB_number_of_subentries(species_data), GBT_SPECIES_INDEX_SIZE); 549 error = GB_create_index(species_data, "name", GB_IGNORE_CASE, hash_size); 550 551 if (!error) { 552 GBDATA *extended_data = GBT_get_SAI_data(gbd); 553 hash_size = max(GB_number_of_subentries(extended_data), GBT_SAI_INDEX_SIZE); 554 error = GB_create_index(extended_data, "name", GB_IGNORE_CASE, hash_size); 555 } 556 } 557 } 558 if (!error) { 559 GBDATA *gb_tmp = GB_search(gbd, "tmp", GB_CREATE_CONTAINER); 560 if (gb_tmp) error = GB_set_temporary(gb_tmp); 561 } 562 563 if (!error) { 564 { 565 GB_MAIN_TYPE *Main = GB_MAIN(gbd); 566 Main->table_hash = GBS_create_hash(256, GB_MIND_CASE); 567 GB_install_link_follower(gbd, "REF", GB_test_link_follower); 568 } 569 GBT_install_table_link_follower(gbd); 570 } 571 } 572 if (error) { 573 GB_close(gbd); 574 gbd = NULL; 575 GB_export_error(error); 576 } 577 } 578 gb_assert(contradicted(gbd, GB_have_error())); 558 579 return gbd; 559 580 } … … 727 748 728 749 static void notify_cb(GBDATA *gb_message, int *cb_info, GB_CB_TYPE cb_type) { 729 GB_remove_callback(gb_message, GB_CB_TYPE(GB_CB_CHANGED|GB_CB_DELETE), notify_cb, cb_info); // @@@ cbproblematic 750 if (cb_type != GB_CB_DELETE) { 751 GB_remove_callback(gb_message, GB_CB_TYPE(GB_CB_CHANGED|GB_CB_DELETE), notify_cb, cb_info); 752 } 730 753 731 754 int cb_done = 0; -
branches/dev_elmar/ARBDB/arbdb.cxx
r7945 r8224 426 426 void GB_shell::ensure_inside() { if (!inside_shell) GBK_terminate("Not inside GB_shell"); } 427 427 428 bool GB_shell::in_shell() { 429 if (!inside_shell) { 430 return false; 431 } 432 return true; 433 } 434 428 435 struct GB_test_shell_closed { 429 436 ~GB_test_shell_closed() { … … 676 683 double GB_read_float(GBDATA *gbd) 677 684 { 678 XDR xdrs;685 XDR xdrs; 679 686 static float f; 687 680 688 GB_TEST_READ(gbd, GB_FLOAT, "GB_read_float"); 681 689 xdrmem_create(&xdrs, &gbd->info.in.data[0], SIZOFINTERN, XDR_DECODE); 682 690 xdr_float(&xdrs, &f); 683 691 xdr_destroy(&xdrs); 692 693 gb_assert(f == f); // !nan 694 684 695 return (double)f; 685 696 } … … 1028 1039 GB_ERROR GB_write_float(GBDATA *gbd, double f) 1029 1040 { 1030 XDR xdrs; 1041 gb_assert(f == f); // !nan 1042 1043 XDR xdrs; 1031 1044 static float f2; 1032 1045 … … 1921 1934 // temporary entries 1922 1935 1923 GB_ERROR GB_set_temporary(GBDATA *gbd) { 1936 GB_ERROR GB_set_temporary(GBDATA *gbd) { // goes to header: __ATTR__USERESULT 1924 1937 /*! if the temporary flag is set, then that entry (including all subentries) will not be saved 1925 1938 * @see GB_clear_temporary() and GB_is_temporary() 1926 1939 */ 1927 1940 1941 GB_ERROR error = NULL; 1928 1942 GB_test_transaction(gbd); 1929 if (GB_GET_SECURITY_DELETE(gbd)>GB_MAIN(gbd)->security_level) 1930 return GB_export_errorf("Security error in GB_set_temporary: %s", GB_read_key_pntr(gbd)); 1931 gbd->flags.temporary = 1; 1932 gb_touch_entry(gbd, GB_NORMAL_CHANGE); 1933 return 0; 1943 1944 if (GB_GET_SECURITY_DELETE(gbd)>GB_MAIN(gbd)->security_level) { 1945 error = GBS_global_string("Security error in GB_set_temporary: %s", GB_read_key_pntr(gbd)); 1946 } 1947 else { 1948 gbd->flags.temporary = 1; 1949 gb_touch_entry(gbd, GB_NORMAL_CHANGE); 1950 } 1951 RETURN_ERROR(error); 1934 1952 } 1935 1953 -
branches/dev_elmar/ARBDB/arbdb.h
r7945 r8224 137 137 138 138 static void ensure_inside(); 139 static bool in_shell(); 139 140 }; 140 141 -
branches/dev_elmar/ARBDB/arbdbt.h
r6490 r8224 6 6 #endif 7 7 8 #define GBT_SPECIES_INDEX_SIZE 10000 9 #define GBT_SAI_INDEX_SIZE 1000 8 #define GBT_SPECIES_INDEX_SIZE 10000L 9 #define GBT_SAI_INDEX_SIZE 1000L 10 10 11 11 #define GB_GROUP_NAME_MAX 256 -
branches/dev_elmar/ARBDB/gb_memory.h
r7201 r8224 27 27 #if defined(UNIT_TESTS) 28 28 #undef MEMORY_TEST 29 #define MEMORY_TEST 0 // test mmapped-DB version in unittests 29 #define MEMORY_TEST 0 // test mmapped-DB version in unittests (recommended setting) 30 30 // #define MEMORY_TEST 1 // test DEBUG DB version in unittests 31 31 #endif -
branches/dev_elmar/ARBDB/gb_prot.h
r7945 r8224 113 113 void gb_load_single_key_data(GBDATA *gb_main, GBQUARK q); 114 114 GB_ERROR gb_save_dictionary_data(GBDATA *gb_main, const char *key, const char *dict, int size); 115 GB_ERROR gb_load_key_data_and_dictionaries(GBDATA *gb_main) ;115 GB_ERROR gb_load_key_data_and_dictionaries(GBDATA *gb_main) __ATTR__USERESULT; 116 116 117 117 /* arbdb.cxx */ -
branches/dev_elmar/AWT/AWT_canio.cxx
r7945 r8224 19 19 #include <arb_defs.h> 20 20 #include <arb_strbuf.h> 21 #include <arb_file.h> 21 22 22 23 using namespace AW; … … 542 543 // -------------------------------------------------------------------------------- 543 544 544 static GB_ERROR canvas_to_xfig(AWT_canvas *ntw, const char *xfig_name, bool add_invisibles) { 545 // if 'add_invisibles' is true => print 2 invisible dots to make fig2dev center correctly 546 547 GB_transaction ta(ntw->gb_main); 548 549 AW_root *awr = ntw->awr; 550 bool draw_all = awr->awar(AWAR_CANIO_CLIP)->read_int(); 551 bool handles = awr->awar(AWAR_CANIO_HANDLES)->read_int(); 552 bool use_color = awr->awar(AWAR_CANIO_COLOR)->read_int(); 553 double border = awr->awar(AWAR_CANIO_BORDERSIZE)->read_float(); 545 static GB_ERROR canvas_to_xfig(AWT_canvas *ntw, const char *xfig_name, bool add_invisibles, double border) { 546 // if 'add_invisibles' is true => print 2 invisible dots to make fig2dev center correctly 547 548 GB_transaction ta(ntw->gb_main); 549 AW_root *awr = ntw->awr; 550 551 bool draw_all = awr->awar(AWAR_CANIO_CLIP)->read_int(); 552 bool handles = awr->awar(AWAR_CANIO_HANDLES)->read_int(); 553 bool use_color = awr->awar(AWAR_CANIO_COLOR)->read_int(); 554 554 555 555 AW_device_print *device = ntw->aww->get_print_device(AW_MIDDLE_AREA); … … 632 632 } 633 633 else { 634 error = canvas_to_xfig(ntw, xfig, true );634 error = canvas_to_xfig(ntw, xfig, true, 0.0); 635 635 if (!error) { 636 636 awr->awar(AWAR_CANIO_FILE_DIR)->touch(); // reload dir to show created xfig 637 error = GB _system(GBS_global_string("xfig %s &", xfig));637 error = GBK_system(GBS_global_string("xfig %s &", xfig)); 638 638 } 639 639 } … … 680 680 681 681 if (!xfig) error = GB_await_error(); 682 if (!error) error = canvas_to_xfig(ntw, xfig, true); 682 if (!error) { 683 double border = awr->awar(AWAR_CANIO_BORDERSIZE)->read_float(); 684 error = canvas_to_xfig(ntw, xfig, true, border); 685 } 683 686 684 687 if (!error) { … … 711 714 cmd.put(' '); cmd.cat(dest); // output 712 715 713 error = GB _system(cmd.get_data());716 error = GBK_system(cmd.get_data()); 714 717 } 715 718 … … 724 727 GB_CSTR gs = GB_getenvARB_GS(); 725 728 GB_CSTR command = GBS_global_string("(%s %s;rm -f %s) &", gs, dest, dest); 726 error = GB _system(command);729 error = GBK_system(command); 727 730 break; 728 731 } … … 732 735 case PDEST_PRINTER: { 733 736 char *prt = awr->awar(AWAR_CANIO_PRINTER)->read_string(); 734 error = GB _system(GBS_global_string("%s %s", prt, dest));737 error = GBK_system(GBS_global_string("%s %s", prt, dest)); 735 738 free(prt); 736 739 GB_unlink_or_warn(dest, &error); … … 743 746 #if defined(DEBUG) && 0 744 747 // show intermediate xfig and unlink it 745 GB _system(GBS_global_string("( xfig %s; rm %s) &", xfig, xfig));748 GBK_system(GBS_global_string("( xfig %s; rm %s) &", xfig, xfig)); 746 749 #else // !defined(DEBUG) 747 750 GB_unlink_or_warn(xfig, &error); … … 798 801 aws->create_toggle(AWAR_CANIO_COLOR); 799 802 800 801 803 aws->at("xfig"); aws->callback(canvas_to_xfig_and_run_xfig, cl_canvas); 802 aws->create_button("START_XFIG", "EXPORT to XFIG", "X"); 803 804 aws->at("cancel"); aws->callback((AW_CB0)AW_POPDOWN); 805 aws->create_button("CLOSE", "CANCEL", "C"); 804 aws->create_autosize_button("START_XFIG", "EXPORT to XFIG", "X"); 806 805 } 807 806 … … 820 819 aws->init(awr, "EXPORT_TREE_AS_XFIG", "EXPORT STRUCTURE TO XFIG"); 821 820 aws->load_xfig("awt/secExport.fig"); 821 822 aws->at("close"); aws->callback((AW_CB0)AW_POPDOWN); 823 aws->create_button("CLOSE", "CLOSE", "C"); 822 824 823 825 aws->at("help"); aws->callback(AW_POPUP_HELP, (AW_CL)"tree2file.hlp"); … … 839 841 840 842 aws->at("xfig"); aws->callback(canvas_to_xfig_and_run_xfig, cl_canvas); 841 aws->create_button("START_XFIG", "EXPORT to XFIG", "X"); 842 843 aws->at("close"); aws->callback((AW_CB0)AW_POPDOWN); 844 aws->create_button("CLOSE", "CLOSE", "C"); 845 846 aws->at("cancel"); aws->callback((AW_CB0)AW_POPDOWN); 847 aws->create_button("CLOSE", "CANCEL", "C"); 843 aws->create_autosize_button("START_XFIG", "EXPORT to XFIG", "X"); 848 844 } 849 845 -
branches/dev_elmar/AWT/AWT_db_browser.cxx
r7945 r8224 13 13 14 14 #include "awt.hxx" 15 15 #include "awt_hexdump.hxx" 16 17 #include <aw_window.hxx> 18 #include <aw_msg.hxx> 19 #include <aw_awar.hxx> 20 21 #include <arb_msg.h> 16 22 #include <arb_str.h> 17 #include <AP_Tree.hxx> 18 #include <aw_window.hxx> 19 #include <aw_awar.hxx> 20 #include <aw_msg.hxx> 21 #include <aw_root.hxx> 23 24 #include <arbdb.h> 22 25 23 26 #include <string> … … 44 47 #define AWAR_DBB_INFO AWAR_DBB_TMP_BASE "/info" 45 48 49 #define AWAR_DUMP_HEX AWAR_DBB_BASE "/hex" 50 #define AWAR_DUMP_ASCII AWAR_DBB_BASE "/ascii" 51 #define AWAR_DUMP_SPACE AWAR_DBB_BASE "/space" 52 #define AWAR_DUMP_WIDTH AWAR_DBB_BASE "/width" 53 #define AWAR_DUMP_BLOCK AWAR_DBB_BASE "/block" 54 46 55 #define HISTORY_PSEUDO_PATH "*history*" 47 56 #define ENTRY_MAX_LENGTH 1000 … … 51 60 SORT_NONE, 52 61 SORT_NAME, 53 SORT_NAME_DB, 62 SORT_CONTAINER, 63 SORT_OCCUR, 54 64 SORT_TYPE, 55 65 SORT_CONTENT, … … 59 69 60 70 const char *sort_order_name[SORT_COUNT] = { 61 " None",71 "Unsorted", 62 72 "Name", 63 "Name (DB)", 73 "Name (Container)", 74 "Name (Occur)", 64 75 "Type", 65 76 "Content", 66 77 }; 67 68 69 78 70 79 // used to sort entries in list … … 84 93 } 85 94 86 inline int cmp_by_container(const list_entry& other) const { 87 return int(type != GB_DB) - int(other.type != GB_DB); 88 } 89 90 inline bool less_than_by_name_container(const list_entry& other) const { 95 inline int cmp_by_container(const list_entry& other) const { return int(type != GB_DB) - int(other.type != GB_DB); } 96 inline int cmp_by_childcount(const list_entry& other) const { return childCount - other.childCount; } 97 98 inline bool less_than_by_container_name(const list_entry& other) const { 91 99 int cmp = cmp_by_container(other); 92 100 if (cmp == 0) return less_than_by_name(other); 93 101 return cmp<0; 94 102 } 103 inline bool less_than_by_childcount_name(const list_entry& other) const { 104 int cmp = cmp_by_childcount(other); 105 if (cmp == 0) return less_than_by_name(other); 106 return cmp<0; 107 } 95 108 96 109 bool operator<(const list_entry& other) const { 97 110 bool is_less = false; 98 111 switch (sort_order) { 112 case SORT_COUNT: break; 99 113 case SORT_NONE: 100 114 awt_assert(0); // not possible … … 105 119 break; 106 120 107 case SORT_NAME_DB: 108 is_less = less_than_by_name_container(other); 121 case SORT_CONTAINER: 122 is_less = less_than_by_container_name(other); 123 break; 124 125 case SORT_OCCUR: 126 is_less = less_than_by_childcount_name(other); 109 127 break; 110 128 … … 113 131 114 132 if (cmp != 0) is_less = cmp<0; 115 else is_less = less_than_by_ name_container(other);133 else is_less = less_than_by_container_name(other); 116 134 117 135 break; … … 125 143 break; 126 144 } 127 default:128 awt_assert(0); // illegal 'sort_order'129 break;130 145 } 131 146 return is_less; … … 139 154 // --------------------- 140 155 156 MemDump make_userdefined_MemDump(AW_root *awr) { 157 bool hex = awr->awar(AWAR_DUMP_HEX)->read_int(); 158 bool ascii = awr->awar(AWAR_DUMP_ASCII)->read_int(); 159 bool space = awr->awar(AWAR_DUMP_SPACE)->read_int(); 160 size_t width = awr->awar(AWAR_DUMP_WIDTH)->read_int(); 161 size_t separate = awr->awar(AWAR_DUMP_BLOCK)->read_int(); 162 163 bool offset = (hex||ascii) && width; 164 165 return MemDump(offset, hex, ascii, width, separate, space); 166 } 167 168 static void hexmode_changed_cb(AW_root *aw_root) { 169 aw_root->awar(AWAR_DBB_BROWSE)->touch(); 170 } 171 141 172 void AWT_create_db_browser_awars(AW_root *aw_root, AW_default aw_def) { 142 aw_root->awar_int(AWAR_DBB_DB, 0, aw_def); // index to internal order of announced databases 143 aw_root->awar_int(AWAR_DBB_ORDER, SORT_NAME_DB, aw_def); // sort order for "browse"-box 144 aw_root->awar_string(AWAR_DBB_PATH, "/", aw_def); // path in database 145 aw_root->awar_string(AWAR_DBB_BROWSE, "", aw_def); // selection in browser (= child name) 146 aw_root->awar_string(AWAR_DBB_INFO, "<select an element>", aw_def); // information about selected item 147 aw_root->awar_string(AWAR_DBB_HISTORY, "", aw_def); // '\n'-separated string containing visited nodes 173 aw_root->awar_int (AWAR_DBB_DB, 0, aw_def); // index to internal order of announced databases 174 aw_root->awar_int (AWAR_DBB_ORDER, SORT_CONTAINER, aw_def); // sort order for "browse"-box 175 aw_root->awar_string(AWAR_DBB_PATH, "/", aw_def); // path in database 176 aw_root->awar_string(AWAR_DBB_BROWSE, "", aw_def); // selection in browser (= child name) 177 aw_root->awar_string(AWAR_DBB_INFO, "<select an element>", aw_def); // information about selected item 178 aw_root->awar_string(AWAR_DBB_HISTORY, "", aw_def); // '\n'-separated string containing visited nodes 179 180 // hex-dump-options 181 aw_root->awar_int(AWAR_DUMP_HEX, 1, aw_def)->add_callback(hexmode_changed_cb); // show hex ? 182 aw_root->awar_int(AWAR_DUMP_ASCII, 1, aw_def)->add_callback(hexmode_changed_cb); // show ascii ? 183 aw_root->awar_int(AWAR_DUMP_SPACE, 1, aw_def)->add_callback(hexmode_changed_cb); // space bytes 184 aw_root->awar_int(AWAR_DUMP_WIDTH, 16, aw_def)->add_callback(hexmode_changed_cb); // bytes/line 185 aw_root->awar_int(AWAR_DUMP_BLOCK, 8, aw_def)->add_callback(hexmode_changed_cb); // separate each bytes 148 186 } 149 187 … … 470 508 } 471 509 472 static void path_changed_cb(AW_root *aw_root); // prototype 473 510 static void child_changed_cb(AW_root *aw_root); // prototype 474 511 static void browsed_node_changed_cb(GBDATA *, int *cl_aw_root, GB_CB_TYPE) { 475 path_changed_cb((AW_root*)cl_aw_root);512 child_changed_cb((AW_root*)cl_aw_root); 476 513 } 477 514 … … 496 533 aww->insert_selection(sel, colon+1, colon+1); 497 534 } 535 } 536 537 538 static char *get_container_description(GBDATA *gbd) { 539 char *content = NULL; 540 const char *known_children[] = { "@name", "name", "key_name", "alignment_name", "group_name", "key_text", 0 }; 541 for (int i = 0; known_children[i]; ++i) { 542 GBDATA *gb_known = GB_entry(gbd, known_children[i]); 543 if (gb_known && GB_read_type(gb_known) != GB_DB && GB_nextEntry(gb_known) == 0) { // exactly one child exits 544 char *asStr = GB_read_as_string(gb_known); 545 content = GBS_global_string_copy("[%s=%s]", known_children[i], asStr); 546 free(asStr); 547 break; 548 } 549 } 550 551 return content; 552 } 553 554 static char *get_dbentry_content(GBDATA *gbd, GB_TYPES type, bool shorten_repeats, const MemDump& dump) { 555 awt_assert(type != GB_DB); 556 557 char *content = NULL; 558 if (!dump.wrapped()) content = GB_read_as_string(gbd); 559 if (!content) { // use dumper 560 long size = GB_read_count(gbd); 561 const int plen = 30; 562 563 GBS_strstruct buf(dump.mem_needed_for_dump(size)+plen); 564 565 if (!dump.wrapped()) buf.nprintf(plen, "<%li bytes>: ", size); 566 dump.dump_to(buf, GB_read_pntr(gbd), size); 567 568 content = buf.release(); 569 shorten_repeats = false; 570 } 571 size_t len = shorten_repeats ? GBS_shorten_repeated_data(content) : strlen(content); 572 if (!dump.wrapped() && len>(ENTRY_MAX_LENGTH+15)) { 573 content[ENTRY_MAX_LENGTH] = 0; 574 freeset(content, GBS_global_string_copy("%s [rest skipped]", content)); 575 } 576 return content; 498 577 } 499 578 … … 569 648 } 570 649 571 if (!is_root) aww->insert_selection(id, GBS_global_string("%-*s parent container", maxkeylen, ".."), BROWSE_CMD_GO_UP); 572 650 if (!is_root) { 651 aww->insert_selection(id, GBS_global_string("%-*s parent container", maxkeylen, ".."), BROWSE_CMD_GO_UP); 652 aww->insert_selection(id, GBS_global_string("%-*s container", maxkeylen, "."), ""); 653 } 654 else { 655 aww->insert_selection(id, GBS_global_string("%-*s root container", maxkeylen, "/"), ""); 656 } 657 573 658 // collect children and sort them 574 659 575 660 vector<list_entry> sorted_children; 576 661 662 MemDump simpleDump(false, true, false); 577 663 for (GBDATA *child = GB_child(node); child; child = GB_nextChild(child)) { 578 664 list_entry entry; … … 587 673 child_count[entry.key_name].count++; 588 674 } 589 590 char *content = 0; 675 char *display = NULL; 591 676 if (entry.type == GB_DB) { 592 // the children listed here are displayed behind the container entry 593 const char *known_children[] = { "@name", "name", "key_name", "alignment_name", "group_name", "key_text", 0 }; 594 for (int i = 0; known_children[i]; ++i) { 595 GBDATA *gb_known = GB_entry(entry.gbd, known_children[i]); 596 597 if (gb_known && GB_read_type(gb_known) != GB_DB && GB_nextEntry(gb_known) == 0) { // exactly one child exits 598 content = GBS_global_string_copy("[%s=%s]", known_children[i], GB_read_as_string(gb_known)); 599 break; 600 } 601 } 602 603 if (!content) content = strdup(""); 677 display = get_container_description(entry.gbd); 604 678 } 605 679 else { 606 content = GB_read_as_string(entry.gbd); 607 if (!content) { 608 long size = GB_read_count(entry.gbd); 609 content = GBS_global_string_copy("<%li bytes binary data>", size); 610 } 611 } 612 613 if (strlen(content)>(ENTRY_MAX_LENGTH+15)) { 614 content[ENTRY_MAX_LENGTH] = 0; 615 freeset(content, GBS_global_string_copy("%s [rest skipped]", content)); 616 } 617 618 entry.content = content; 619 free(content); 620 680 display = get_dbentry_content(entry.gbd, entry.type, true, simpleDump); 681 } 682 if (display) entry.content = display; 621 683 sorted_children.push_back(entry); 622 684 } … … 652 714 DB_browser *browser = get_the_browser(); 653 715 update_browser_selection_list(aw_root, (AW_CL)browser->get_window(aw_root), (AW_CL)browser->get_browser_id()); 654 }655 656 static void child_changed_cb(AW_root *aw_root) {657 static bool avoid_recursion = false;658 659 if (!avoid_recursion) {660 avoid_recursion = true;661 662 char *child = aw_root->awar(AWAR_DBB_BROWSE)->read_string();663 if (strncmp(child, BROWSE_CMD_PREFIX, sizeof(BROWSE_CMD_PREFIX)-1) == 0) {664 // a symbolic browser command665 execute_browser_command(get_the_browser()->get_window(aw_root), child);666 }667 else {668 char *path = aw_root->awar(AWAR_DBB_PATH)->read_string();669 670 char *fullpath;671 if (strcmp(path, "/") == 0) {672 fullpath = GBS_global_string_copy("/%s", child);673 }674 else if (strcmp(path, HISTORY_PSEUDO_PATH) == 0) {675 fullpath = strdup(child);676 }677 else if (child[0] == 0) {678 fullpath = strdup(path);679 }680 else {681 fullpath = GBS_global_string_copy("%s/%s", path, child);682 }683 684 DB_browser *browser = get_the_browser();685 GBDATA *gb_main = browser->get_db();686 GB_transaction dummy(gb_main);687 GBDATA *gb_selected_node = GB_search_numbered(gb_main, fullpath, GB_FIND);688 689 string info;690 info += GBS_global_string("fullpath='%s'\n", fullpath);691 692 if (gb_selected_node == 0) {693 info += "Node does not exist.\n";694 }695 else {696 info += GBS_global_string("Node exists [address=%p]\n", gb_selected_node);697 info += GBS_global_string("key index=%i\n", GB_get_quark(gb_selected_node));698 699 if (GB_read_type(gb_selected_node) == GB_DB) {700 info += "Node type: container\n";701 702 aw_root->awar(AWAR_DBB_BROWSE)->write_string("");703 aw_root->awar(AWAR_DBB_PATH)->write_string(fullpath);704 }705 else {706 info += GBS_global_string("Node type: data [type=%s]\n", GB_get_type_name(gb_selected_node));707 }708 709 info += GBS_global_string("Security: read=%i write=%i delete=%i\n",710 GB_read_security_read(gb_selected_node),711 GB_read_security_write(gb_selected_node),712 GB_read_security_delete(gb_selected_node));713 714 char *callback_info = GB_get_callback_info(gb_selected_node);715 if (callback_info) {716 info = info+"Callbacks:\n"+callback_info+'\n';717 }718 }719 720 aw_root->awar(AWAR_DBB_INFO)->write_string(info.c_str());721 722 free(fullpath);723 free(path);724 }725 free(child);726 727 avoid_recursion = false;728 }729 716 } 730 717 … … 789 776 } 790 777 778 static void child_changed_cb(AW_root *aw_root) { 779 char *child = aw_root->awar(AWAR_DBB_BROWSE)->read_string(); 780 if (strncmp(child, BROWSE_CMD_PREFIX, sizeof(BROWSE_CMD_PREFIX)-1) == 0) { // a symbolic browser command 781 execute_browser_command(get_the_browser()->get_window(aw_root), child); 782 } 783 else { 784 char *path = aw_root->awar(AWAR_DBB_PATH)->read_string(); 785 786 if (strcmp(path, HISTORY_PSEUDO_PATH) == 0) { 787 if (child[0]) aw_root->awar(AWAR_DBB_PATH)->write_string(child); 788 } 789 else { 790 static bool avoid_recursion = false; 791 if (!avoid_recursion) { 792 avoid_recursion = true; 793 794 char *fullpath; 795 if (strcmp(path, "/") == 0) { 796 fullpath = GBS_global_string_copy("/%s", child); 797 } 798 else if (child[0] == 0) { 799 fullpath = strdup(path); 800 } 801 else { 802 fullpath = GBS_global_string_copy("%s/%s", path, child); 803 } 804 805 DB_browser *browser = get_the_browser(); 806 GBDATA *gb_main = browser->get_db(); 807 GB_transaction dummy(gb_main); 808 GBDATA *gb_selected_node = GB_search_numbered(gb_main, fullpath, GB_FIND); 809 810 string info; 811 info += GBS_global_string("fullpath='%s'\n", fullpath); 812 813 if (gb_selected_node == 0) { 814 info += "Node does not exist.\n"; 815 } 816 else { 817 add_to_history(aw_root, fullpath); 818 819 info += GBS_global_string("Node exists [address=%p]\n", gb_selected_node); 820 info += GBS_global_string("Key index | %i\n", GB_get_quark(gb_selected_node)); 821 822 GB_TYPES type = GB_read_type(gb_selected_node); 823 if (type == GB_DB) { 824 info += "Node type | container\n"; 825 info += GBS_global_string("Entries | %li\n", GB_number_of_subentries(gb_selected_node)); 826 827 aw_root->awar(AWAR_DBB_BROWSE)->write_string(""); 828 aw_root->awar(AWAR_DBB_PATH)->write_string(fullpath); 829 } 830 else { 831 info += GBS_global_string("Node type | data [type=%s]\n", GB_get_type_name(gb_selected_node)); 832 info += GBS_global_string("Data size | %li\n", GB_read_count(gb_selected_node)); 833 info += GBS_global_string("Memory | %li\n", GB_read_memuse(gb_selected_node)); 834 } 835 836 info += GBS_global_string("Security | read=%i write=%i delete=%i\n", 837 GB_read_security_read(gb_selected_node), 838 GB_read_security_write(gb_selected_node), 839 GB_read_security_delete(gb_selected_node)); 840 841 char *callback_info = GB_get_callback_info(gb_selected_node); 842 if (callback_info) { 843 info = info+"Callbacks |\n"+callback_info+'\n'; 844 free(callback_info); 845 } 846 847 if (type != GB_DB) { 848 MemDump dump = make_userdefined_MemDump(aw_root); 849 char *content = get_dbentry_content(gb_selected_node, GB_read_type(gb_selected_node), false, dump); 850 info = info+"Content |\n"+content+'\n'; 851 free(content); 852 } 853 } 854 855 aw_root->awar(AWAR_DBB_INFO)->write_string(info.c_str()); 856 857 free(fullpath); 858 avoid_recursion = false; 859 } 860 } 861 862 free(path); 863 } 864 free(child); 865 } 866 791 867 static void path_changed_cb(AW_root *aw_root) { 792 868 static bool avoid_recursion = false; … … 812 888 } 813 889 814 add_to_history(aw_root, path); 890 if (found) { 891 add_to_history(aw_root, goto_child ? GBS_global_string("%s/%s", path, goto_child) : path); 892 } 815 893 browser->set_path(path); 816 894 free(path); … … 899 977 browse_id = aws->create_selection_list(AWAR_DBB_BROWSE); 900 978 update_browser_selection_list(aw_root, (AW_CL)aws, (AW_CL)browse_id); 979 980 aws->at("infoopt"); 981 aws->label("ASCII"); aws->create_toggle (AWAR_DUMP_ASCII); 982 aws->label("Hex"); aws->create_toggle (AWAR_DUMP_HEX); 983 aws->label("Sep?"); aws->create_toggle (AWAR_DUMP_SPACE); 984 aws->label("Width"); aws->create_input_field(AWAR_DUMP_WIDTH, 3); 985 aws->label("Block"); aws->create_input_field(AWAR_DUMP_BLOCK, 3); 901 986 902 987 aws->at("info"); -
branches/dev_elmar/AWT/AWT_input_mask.cxx
r7669 r8224 16 16 17 17 #include <arbdbt.h> 18 #include <arb_file.h> 18 19 #include <awt_www.hxx> 19 20 #include <aw_edit.hxx> … … 927 928 if (local) { 928 929 static char *local_mask_dir; 929 if (!local_mask_dir) local_mask_dir = AW_unfold_path("HOME", ".arb_prop/inputMasks");930 if (!local_mask_dir) local_mask_dir = strdup(GB_path_in_arbprop("inputMasks")); 930 931 return local_mask_dir; 931 932 } -
branches/dev_elmar/AWT/AWT_macro.cxx
r7625 r8224 15 15 16 16 #include <arbdb.h> 17 #include <arb_file.h> 17 18 18 19 #include <aw_window.hxx> -
branches/dev_elmar/AWT/AWT_sel_boxes.cxx
r7945 r8224 18 18 #include <aw_msg.hxx> 19 19 #include <aw_root.hxx> 20 #include <aw_edit.hxx> 20 21 21 22 #include <ad_config.h> … … 24 25 #include <arb_strbuf.h> 25 26 #include <arb_strarray.h> 27 #include <arb_file.h> 26 28 27 29 #include <list> … … 203 205 204 206 205 207 static void arb_tcp_dat_changed_cb(const char * /* path */, bool fileChanged, bool /* editorTerminated */) { 208 if (fileChanged) { 209 awt_refresh_all_pt_server_selection_lists(); 210 } 211 } 212 213 void awt_edit_arbtcpdat_cb(AW_window *aww, AW_CL cl_gb_main) { 214 GBDATA *gb_main = (GBDATA*)cl_gb_main; 215 char *filename = GB_arbtcpdat_path(); 216 217 AW_edit(filename, arb_tcp_dat_changed_cb, aww, gb_main); 218 free(filename); 219 } 206 220 207 221 static char *readable_pt_servername(int index, int maxlength) { -
branches/dev_elmar/AWT/Makefile
r7945 r8224 80 80 AWT_canio.o: $(ARBHOME)/INCLUDE/arb_defs.h 81 81 AWT_canio.o: $(ARBHOME)/INCLUDE/arb_error.h 82 AWT_canio.o: $(ARBHOME)/INCLUDE/arb_file.h 82 83 AWT_canio.o: $(ARBHOME)/INCLUDE/arb_msg.h 83 84 AWT_canio.o: $(ARBHOME)/INCLUDE/arb_progress.h … … 153 154 154 155 AWT_db_browser.o: awt.hxx 156 AWT_db_browser.o: awt_hexdump.hxx 155 157 AWT_db_browser.o: $(ARBHOME)/INCLUDE/ad_prot.h 156 AWT_db_browser.o: $(ARBHOME)/INCLUDE/ad_t_prot.h157 AWT_db_browser.o: $(ARBHOME)/INCLUDE/AliView.hxx158 AWT_db_browser.o: $(ARBHOME)/INCLUDE/AP_sequence.hxx159 AWT_db_browser.o: $(ARBHOME)/INCLUDE/AP_Tree.hxx160 158 AWT_db_browser.o: $(ARBHOME)/INCLUDE/arb_assert.h 161 159 AWT_db_browser.o: $(ARBHOME)/INCLUDE/arb_core.h … … 163 161 AWT_db_browser.o: $(ARBHOME)/INCLUDE/arb_msg.h 164 162 AWT_db_browser.o: $(ARBHOME)/INCLUDE/arb_str.h 163 AWT_db_browser.o: $(ARBHOME)/INCLUDE/arb_strbuf.h 165 164 AWT_db_browser.o: $(ARBHOME)/INCLUDE/arb_string.h 166 AWT_db_browser.o: $(ARBHOME)/INCLUDE/ARB_Tree.hxx167 165 AWT_db_browser.o: $(ARBHOME)/INCLUDE/arbdb.h 168 166 AWT_db_browser.o: $(ARBHOME)/INCLUDE/arbdb_base.h 169 AWT_db_browser.o: $(ARBHOME)/INCLUDE/arbdbt.h170 167 AWT_db_browser.o: $(ARBHOME)/INCLUDE/arbtools.h 171 168 AWT_db_browser.o: $(ARBHOME)/INCLUDE/attributes.h 172 169 AWT_db_browser.o: $(ARBHOME)/INCLUDE/aw_awar.hxx 173 170 AWT_db_browser.o: $(ARBHOME)/INCLUDE/aw_base.hxx 174 AWT_db_browser.o: $(ARBHOME)/INCLUDE/aw_color_groups.hxx175 171 AWT_db_browser.o: $(ARBHOME)/INCLUDE/aw_keysym.hxx 176 172 AWT_db_browser.o: $(ARBHOME)/INCLUDE/aw_msg.hxx … … 178 174 AWT_db_browser.o: $(ARBHOME)/INCLUDE/aw_window.hxx 179 175 AWT_db_browser.o: $(ARBHOME)/INCLUDE/cb.h 180 AWT_db_browser.o: $(ARBHOME)/INCLUDE/downcast.h181 176 AWT_db_browser.o: $(ARBHOME)/INCLUDE/dupstr.h 182 177 AWT_db_browser.o: $(ARBHOME)/INCLUDE/smartptr.h 183 178 AWT_db_browser.o: $(ARBHOME)/INCLUDE/test_global.h 179 180 AWT_hexdump.o: awt.hxx 181 AWT_hexdump.o: awt_hexdump.hxx 182 AWT_hexdump.o: $(ARBHOME)/INCLUDE/arb_assert.h 183 AWT_hexdump.o: $(ARBHOME)/INCLUDE/arb_core.h 184 AWT_hexdump.o: $(ARBHOME)/INCLUDE/arb_error.h 185 AWT_hexdump.o: $(ARBHOME)/INCLUDE/arb_strbuf.h 186 AWT_hexdump.o: $(ARBHOME)/INCLUDE/arbdb_base.h 187 AWT_hexdump.o: $(ARBHOME)/INCLUDE/arbtools.h 188 AWT_hexdump.o: $(ARBHOME)/INCLUDE/attributes.h 189 AWT_hexdump.o: $(ARBHOME)/INCLUDE/aw_base.hxx 190 AWT_hexdump.o: $(ARBHOME)/INCLUDE/aw_root.hxx 191 AWT_hexdump.o: $(ARBHOME)/INCLUDE/cb.h 192 AWT_hexdump.o: $(ARBHOME)/INCLUDE/dupstr.h 193 AWT_hexdump.o: $(ARBHOME)/INCLUDE/smartptr.h 194 AWT_hexdump.o: $(ARBHOME)/INCLUDE/test_global.h 195 AWT_hexdump.o: $(ARBHOME)/INCLUDE/test_unit.h 184 196 185 197 AWT_hotkeys.o: awt_hotkeys.hxx … … 195 207 AWT_input_mask.o: $(ARBHOME)/INCLUDE/arb_core.h 196 208 AWT_input_mask.o: $(ARBHOME)/INCLUDE/arb_error.h 209 AWT_input_mask.o: $(ARBHOME)/INCLUDE/arb_file.h 197 210 AWT_input_mask.o: $(ARBHOME)/INCLUDE/arb_msg.h 198 211 AWT_input_mask.o: $(ARBHOME)/INCLUDE/arb_string.h … … 220 233 AWT_macro.o: $(ARBHOME)/INCLUDE/arb_core.h 221 234 AWT_macro.o: $(ARBHOME)/INCLUDE/arb_error.h 235 AWT_macro.o: $(ARBHOME)/INCLUDE/arb_file.h 222 236 AWT_macro.o: $(ARBHOME)/INCLUDE/arb_msg.h 223 237 AWT_macro.o: $(ARBHOME)/INCLUDE/arb_string.h … … 264 278 AWT_sel_boxes.o: $(ARBHOME)/INCLUDE/arb_core.h 265 279 AWT_sel_boxes.o: $(ARBHOME)/INCLUDE/arb_error.h 280 AWT_sel_boxes.o: $(ARBHOME)/INCLUDE/arb_file.h 266 281 AWT_sel_boxes.o: $(ARBHOME)/INCLUDE/arb_msg.h 267 282 AWT_sel_boxes.o: $(ARBHOME)/INCLUDE/arb_strarray.h … … 277 292 AWT_sel_boxes.o: $(ARBHOME)/INCLUDE/aw_awars.hxx 278 293 AWT_sel_boxes.o: $(ARBHOME)/INCLUDE/aw_base.hxx 294 AWT_sel_boxes.o: $(ARBHOME)/INCLUDE/aw_edit.hxx 279 295 AWT_sel_boxes.o: $(ARBHOME)/INCLUDE/aw_file.hxx 280 296 AWT_sel_boxes.o: $(ARBHOME)/INCLUDE/aw_keysym.hxx -
branches/dev_elmar/AWT/awt_sel_boxes.hxx
r7945 r8224 32 32 void awt_create_selection_list_on_pt_servers(AW_window *aws, const char *varname, bool popup); 33 33 void awt_refresh_all_pt_server_selection_lists(); 34 void awt_edit_arbtcpdat_cb(AW_window *aww, AW_CL cl_gb_main); 34 35 35 36 void awt_create_selection_list_on_tables(GBDATA *gb_main, AW_window *aws, const char *varname); -
branches/dev_elmar/AWTC/AWTC_next_neighbours.cxx
r7415 r8224 161 161 ff_assert(!com && !link); 162 162 163 if (arb_look_and_start_server(AISC_MAGIC_NUMBER, servername , gb_main)) {163 if (arb_look_and_start_server(AISC_MAGIC_NUMBER, servername)) { 164 164 error = "Cannot contact PT server"; 165 165 } -
branches/dev_elmar/AWTI/AWTI_export.cxx
r7945 r8224 22 22 #include <arbdbt.h> 23 23 #include <arb_str.h> 24 #include <arb_file.h> 24 25 25 26 #define AWAR_EXPORT_FILE "tmp/export_db/file" -
branches/dev_elmar/AWTI/AWTI_import.cxx
r7945 r8224 26 26 #include <arb_progress.h> 27 27 #include <arb_strbuf.h> 28 #include <arb_file.h> 28 29 29 30 #include <climits> … … 397 398 arb_progress::show_comment(GBS_global_string("exec '%s'", awtcig.ifo2->system)); 398 399 399 error = GB _system(sys);400 error = GBK_system(sys); 400 401 if (!error) origin_file_name = mid_file_name; 401 402 … … 425 426 arb_progress::show_comment(GBS_global_string("Converting File %s", awtcig.ifo->system)); 426 427 427 error = GB _system(sys);428 error = GBK_system(sys); 428 429 if (!error) origin_file_name = dest_file_name; 429 430 -
branches/dev_elmar/AWTI/Makefile
r7945 r8224 39 39 AWTI_export.o: $(ARBHOME)/INCLUDE/arb_core.h 40 40 AWTI_export.o: $(ARBHOME)/INCLUDE/arb_error.h 41 AWTI_export.o: $(ARBHOME)/INCLUDE/arb_file.h 41 42 AWTI_export.o: $(ARBHOME)/INCLUDE/arb_msg.h 42 43 AWTI_export.o: $(ARBHOME)/INCLUDE/arb_progress.h … … 72 73 AWTI_import.o: $(ARBHOME)/INCLUDE/arb_core.h 73 74 AWTI_import.o: $(ARBHOME)/INCLUDE/arb_error.h 75 AWTI_import.o: $(ARBHOME)/INCLUDE/arb_file.h 74 76 AWTI_import.o: $(ARBHOME)/INCLUDE/arb_msg.h 75 77 AWTI_import.o: $(ARBHOME)/INCLUDE/arb_progress.h -
branches/dev_elmar/CONVERTALN/Makefile
r7945 r8224 108 108 fconv.o: $(ARBHOME)/INCLUDE/arb_defs.h 109 109 fconv.o: $(ARBHOME)/INCLUDE/arb_error.h 110 fconv.o: $(ARBHOME)/INCLUDE/arb_file.h 110 111 fconv.o: $(ARBHOME)/INCLUDE/arb_msg.h 111 112 fconv.o: $(ARBHOME)/INCLUDE/arb_string.h -
branches/dev_elmar/CONVERTALN/fconv.cxx
r7945 r8224 59 59 #ifdef UNIT_TESTS 60 60 #include <arbdbt.h> // before test_unit.h! 61 #include <arb_file.h> 61 62 #include <test_unit.h> 63 62 64 63 65 #define TEST_THROW // comment out to temp. disable intentional throws -
branches/dev_elmar/CORE/Makefile
r7945 r8224 1 1 2 .SUFFIXES: .o .cxx .depend .h .genh 2 .SUFFIXES: .o .cxx .depend .h .genh 3 3 4 4 OBJECTS=$(subst .cxx,.o,$(wildcard *.cxx)) 5 6 GENERATED_HEADERS= \ 7 arb_msg.h \ 8 arb_string.h \ 9 arb_signal.h \ 10 arb_file.h \ 5 11 6 12 $(MAIN): $(OBJECTS) … … 11 17 $(CPPLIB) $(cflags) -c $< $(AINCLUDES) $(POST_COMPILE) 12 18 13 proto: 14 ../AISC_MKPTPS/aisc_mkpt -P -G -A -w arb_msg.h arb_msg.cxx > arb_msg.genh15 ../AISC_MKPTPS/aisc_mkpt -P -G -A -w arb_string.h arb_string.cxx > arb_string.genh 16 ../AISC_MKPTPS/aisc_mkpt -P -G -A -w arb_signal.h arb_signal.cxx > arb_signal.genh17 ../SOURCE_TOOLS/mv_if_diff arb_msg.genh arb_msg.h18 ../SOURCE_TOOLS/mv_if_diff arb_string.genh arb_string.h 19 ../SOURCE_TOOLS/mv_if_diff arb_signal.genh arb_signal.h 19 .cxx.genh: 20 ../AISC_MKPTPS/aisc_mkpt -P -G -A -w $(subst .genh,.h,$@) $< > $@ 21 22 %.genheader: %.genh 23 ../SOURCE_TOOLS/mv_if_diff $< $(subst .genheader,.h,$@) 24 25 proto: $(subst .h,.genheader,$(GENERATED_HEADERS)) 20 26 21 27 clean: … … 48 54 arb_cs.o: $(ARBHOME)/INCLUDE/smartptr.h 49 55 arb_cs.o: $(ARBHOME)/INCLUDE/test_global.h 56 57 arb_file.o: arb_core.h 58 arb_file.o: arb_file.h 59 arb_file.o: arb_msg.h 60 arb_file.o: $(ARBHOME)/INCLUDE/attributes.h 61 arb_file.o: $(ARBHOME)/INCLUDE/dupstr.h 50 62 51 63 arb_handlers.o: arb_core.h … … 122 134 arb_string.o: arb_string.h 123 135 arb_string.o: $(ARBHOME)/INCLUDE/arb_assert.h 136 arb_string.o: $(ARBHOME)/INCLUDE/arbtools.h 124 137 arb_string.o: $(ARBHOME)/INCLUDE/attributes.h 125 138 arb_string.o: $(ARBHOME)/INCLUDE/dupstr.h 126 139 arb_string.o: $(ARBHOME)/INCLUDE/test_global.h 140 arb_string.o: $(ARBHOME)/INCLUDE/test_unit.h -
branches/dev_elmar/CORE/arb_core.h
r7084 r8224 39 39 void GBK_terminate(const char *error); 40 40 41 GB_ERROR GBK_system(const char *system_command); 42 41 43 #else 42 44 #error arb_core.h included twice -
branches/dev_elmar/CORE/arb_msg.cxx
r7945 r8224 23 23 // AISC_MKPT_PROMOTE:#include "arb_core.h" 24 24 // AISC_MKPT_PROMOTE:#endif 25 // AISC_MKPT_PROMOTE: 26 // AISC_MKPT_PROMOTE:// return error and ensure none is exported 27 // AISC_MKPT_PROMOTE:#define RETURN_ERROR(err) arb_assert(!GB_have_error()); return (err) 25 28 26 29 … … 495 498 } 496 499 500 #if defined(WARN_TODO) 501 #warning search for '\b(system)\b\s*\(' and use GBK_system instead 502 #endif 503 GB_ERROR GBK_system(const char *system_command) { 504 // goes to header: __ATTR__USERESULT 505 fprintf(stderr, "[Action: '%s']\n", system_command); 506 int res = system(system_command); 507 GB_ERROR error = NULL; 508 if (res) { 509 error = GBS_global_string("System call failed (result=%i)\n" 510 "System call was '%s'\n" 511 "(Note: console window may contain additional information)", res, system_command); 512 } 513 return error; 514 } 515 -
branches/dev_elmar/CORE/arb_msg.h
r7945 r8224 20 20 #include "arb_core.h" 21 21 #endif 22 23 // return error and ensure none is exported 24 #define RETURN_ERROR(err) arb_assert(!GB_have_error()); return (err) 22 25 23 26 const char *GBS_global_string_to_buffer(char *buffer, size_t bufsize, const char *templat, ...) __ATTR__FORMAT(3); … … 50 53 void GB_informationf(const char *templat, ...) __ATTR__FORMAT(1); 51 54 void GBS_reuse_buffer(const char *global_buffer); 55 GB_ERROR GBK_system(const char *system_command) __ATTR__USERESULT; 52 56 53 57 #else -
branches/dev_elmar/CORE/arb_sort.cxx
- Property svn:mergeinfo changed from /trunk/CORE/arb_sort.cxx:7771-7998 to /trunk/CORE/arb_sort.cxx:7771-8223
-
branches/dev_elmar/CORE/arb_strarray.cxx
- Property svn:mergeinfo changed from /trunk/CORE/arb_strarray.cxx:7771-7998 to /trunk/CORE/arb_strarray.cxx:7771-8223
-
branches/dev_elmar/CORE/arb_strbuf.cxx
r7667 r8224 13 13 14 14 void GBS_strstruct::vnprintf(size_t maxlen, const char *templat, va_list& parg) { 15 ensure_mem(maxlen );15 ensure_mem(maxlen+1); 16 16 17 17 char *buffer = data+pos; … … 19 19 20 20 #ifdef LINUX 21 printed = vsnprintf(buffer, maxlen , templat, parg);21 printed = vsnprintf(buffer, maxlen+1, templat, parg); 22 22 #else 23 23 printed = vsprintf(buffer, templat, parg); -
branches/dev_elmar/CORE/arb_string.cxx
r7314 r8224 69 69 70 70 71 72 71 // -------------------------------------------------------------------------------- 72 73 74 #ifdef UNIT_TESTS 75 76 #include <string> 77 #include <climits> 78 79 #ifndef TEST_UNIT_H 80 #include <test_unit.h> 81 #endif 82 83 using namespace std; 84 85 // ---------------------------------------------- 86 // some tests for unit-test-code itself 87 88 #define TEST_ASSERT_HEAPCOPY_EQUAL(copy,expected) do { \ 89 char *theCopy = (copy); \ 90 TEST_ASSERT_EQUAL(theCopy, expected); \ 91 free(theCopy); \ 92 } while(0) 93 94 void TEST_arbtest_strf() { 95 // tests string formatter from test_unit.h 96 using namespace arb_test; 97 TEST_ASSERT_HEAPCOPY_EQUAL(StaticCode::strf("<%i>", 7), "<7>"); 98 TEST_ASSERT_HEAPCOPY_EQUAL(StaticCode::strf("<%0*i>", 3, 7), "<007>"); 99 } 100 101 void TEST_arbtest_readable() { 102 using namespace arb_test; 103 104 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy('x')), "'x'"); 105 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy(static_cast<unsigned char>('x'))), "'x'"); 106 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy(static_cast<signed char>('x'))), "'x'"); 107 108 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy(true)), "true"); 109 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy(false)), "false"); 110 111 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy(1)), "1"); 112 TEST_ASSERT_HEAPCOPY_EQUAL(val2hex(make_copy(2)), "0x2"); 113 114 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy(3L)), "3"); 115 TEST_ASSERT_HEAPCOPY_EQUAL(val2hex(make_copy(4L)), "0x4"); 116 117 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy(5U)), "5"); 118 TEST_ASSERT_HEAPCOPY_EQUAL(val2hex(make_copy(6U)), "0x6"); 119 120 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy("some\ntext\twhich\"special\\chars")), "\"some\\ntext\\twhich\\\"special\\\\chars\""); 121 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy("a\1\2\x1a\x7e\x7f\x80\xfe\xff")), "\"a\\1\\2\\x1a~\\x7f\\x80\\xfe\\xff\""); 122 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy((const char *)NULL)), "(null)"); 123 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy((const unsigned char *)NULL)), "(null)"); 124 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy((const signed char *)NULL)), "(null)"); 125 126 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy(1.7)), "1.700000"); 127 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy(177.0e20)), "17699999999999998951424.000000"); 128 TEST_ASSERT_HEAPCOPY_EQUAL(val2readable(make_copy(177.0e20F)), "17699999967695435988992.000000"); 129 } 130 131 void TEST_arbtest_copyable() { 132 using namespace arb_test; 133 134 int i = 7; 135 const char *s = "servas"; 136 137 TEST_ASSERT(make_copy(i) == make_copy(7)); 138 139 TEST_ASSERT(strcmp(make_copy(s), make_copy("servas")) == 0); 140 } 141 142 #define TEST_DESCRIPTIONS(d, tt, tf, ft, ff) do { \ 143 TEST_ASSERT_EQUAL((d).make(true, true), (tt)); \ 144 TEST_ASSERT_EQUAL((d).make(true, false), (tf)); \ 145 TEST_ASSERT_EQUAL((d).make(false, true), (ft)); \ 146 TEST_ASSERT_EQUAL((d).make(false, false), (ff)); \ 147 } while(0) 148 149 #define TEST_SIMPLE_DESCRIPTIONS(d, ae, nae) TEST_DESCRIPTIONS(d, ae, nae, nae, ae) 150 151 void TEST_arbtest_predicate_description() { 152 TEST_SIMPLE_DESCRIPTIONS(predicate_description("similar"), "is similar", "isnt similar"); 153 TEST_SIMPLE_DESCRIPTIONS(predicate_description("repairs"), "repairs", "doesnt repair"); 154 155 TEST_DESCRIPTIONS(predicate_description("equals", "differs"), 156 "equals", "doesnt equal", 157 "doesnt differ", "differs"); 158 159 TEST_DESCRIPTIONS(predicate_description("less_than", "more_than"), 160 "is less_than", "isnt less_than", 161 "isnt more_than", "is more_than"); 162 } 163 164 void TEST_arbtest_expectations() { 165 // used to TDD expectations 166 using namespace arb_test; 167 168 string apple = "Apfel"; 169 string pear = "Birne"; 170 string boskop = apple; 171 string pomegranate = "Granatapfel"; 172 173 TEST_EXPECT(that(apple).equals("Apfel")); 174 175 TEST_EXPECT(that(apple).differs(pear)); 176 TEST_EXPECT(that(apple).equals(boskop)); 177 TEST_EXPECT(wrong(that(pomegranate).equals(apple))); 178 179 match_expectation ff1 = that(1.0).equals(2-1); 180 match_expectation ff2 = that(boskop).equals(apple); 181 match_expectation ff3 = that(apple).equals(apple); 182 183 match_expectation nf1 = that(apple).equals(pear); 184 match_expectation nf2 = that(pomegranate).equals(apple); 185 match_expectation nf3 = that(apple).differs(boskop); 186 187 match_expectation a1 = all().of(ff1); 188 match_expectation a2 = all().of(ff1, ff2); 189 match_expectation a3 = all().of(ff1, ff2, ff3); 190 191 TEST_EXPECT(a1); 192 TEST_EXPECT(a2); 193 TEST_EXPECT(a3); 194 195 match_expectation n1 = none().of(ff1); 196 match_expectation n2 = none().of(ff1, ff2); 197 match_expectation n3 = none().of(ff1, ff2, ff3); 198 199 TEST_EXPECT(wrong(none().of(that(boskop).equals(apple)))); 200 TEST_EXPECT(wrong(n1)); 201 TEST_EXPECT(wrong(n2)); 202 TEST_EXPECT(wrong(n3)); 203 204 TEST_EXPECT(atleast(1).of(a1)); 205 TEST_EXPECT(atleast(1).of(a1, n1)); 206 TEST_EXPECT(atleast(1).of(n2, a1, n1)); 207 208 TEST_EXPECT(wrong(atleast(2).of(a1, n1, n2))); 209 TEST_EXPECT(wrong(atleast(2).of(a1, n1))); 210 TEST_EXPECT(wrong(atleast(2).of(a1))); // impossible 211 212 TEST_EXPECT(atmost(2).of(a1)); 213 TEST_EXPECT(atmost(2).of(a1, a2)); 214 TEST_EXPECT(atmost(2).of(a1, a2, n1)); 215 TEST_EXPECT(atmost(2).of(a1, n1, n2)); 216 TEST_EXPECT(atmost(2).of(n1, n2)); 217 TEST_EXPECT(wrong(atmost(2).of(a1, a2, a3))); 218 219 TEST_EXPECT(exacly(1).of(ff1, nf1, nf2)); 220 TEST_EXPECT(wrong(exacly(1).of(nf1, nf2))); 221 TEST_EXPECT(wrong(exacly(1).of(nf1, nf2, nf3))); 222 TEST_EXPECT(wrong(exacly(1).of(ff1, ff2, nf2))); 223 TEST_EXPECT(wrong(exacly(1).of(ff1, ff2, ff3))); 224 225 } 226 227 void TEST_replace_old_TEST_ASSERTS_by_expectations() { 228 // test various string-types are matchable (w/o casts) 229 { 230 const char *car_ccp = "Alfa"; 231 char *car_cp = strdup("Alfa"); 232 string car_str("Alfa"); 233 234 TEST_ASSERT_EQUAL(car_ccp, "Alfa"); 235 TEST_ASSERT_EQUAL(car_cp, "Alfa"); 236 TEST_ASSERT_EQUAL(car_str, "Alfa"); 237 238 TEST_ASSERT_EQUAL("Alfa", car_ccp); 239 TEST_ASSERT_EQUAL("Alfa", car_cp); 240 TEST_ASSERT_EQUAL("Alfa", car_str); 241 242 TEST_ASSERT_EQUAL(car_cp, car_ccp); 243 TEST_ASSERT_EQUAL(car_cp, car_str); 244 TEST_ASSERT_EQUAL(car_ccp, car_cp); 245 TEST_ASSERT_EQUAL(car_ccp, car_str); 246 TEST_ASSERT_EQUAL(car_str, car_cp); 247 TEST_ASSERT_EQUAL(car_str, car_ccp); 248 249 char *null = NULL; 250 TEST_ASSERT_NULL(NULL); 251 TEST_ASSERT_NULL(null); 252 253 TEST_ASSERT_CONTAINS(car_ccp, "lf"); 254 TEST_ASSERT_CONTAINS(car_cp, "fa"); 255 TEST_ASSERT_CONTAINS(car_str, "Al"); 256 257 free(car_cp); 258 } 259 260 // test various numeric types are matchable 261 262 { 263 short unsigned su = 7; 264 short s = -su; 265 266 unsigned iu = su; 267 int i = -iu; 268 269 long unsigned lu = (long unsigned)INT_MAX+3; 270 long l = -lu; 271 272 float f = s; 273 double d = i; 274 275 TEST_ASSERT_EQUAL(s, -7); 276 TEST_ASSERT_EQUAL(i, -7); 277 278 TEST_ASSERT_EQUAL(su, 7); TEST_ASSERT_EQUAL(iu, 7); 279 TEST_ASSERT_EQUAL(su, 7U); TEST_ASSERT_EQUAL(iu, 7U); 280 TEST_ASSERT_EQUAL(su, 7L); TEST_ASSERT_EQUAL(iu, 7L); 281 282 TEST_ASSERT_EQUAL(s, -su); TEST_ASSERT_EQUAL(s, -iu); 283 TEST_ASSERT_EQUAL(i, -iu); TEST_ASSERT_EQUAL(i, -su); 284 TEST_ASSERT_EQUAL(l, -lu); 285 286 TEST_ASSERT_EQUAL(f, d); 287 TEST_ASSERT_EQUAL(d, f); 288 } 289 290 TEST_ASSERT_ZERO(7-7); 291 } 292 293 // --- simulate user_type (which may be defined anywhere) --- 294 class user_type { 295 int x, y; 296 public: 297 user_type(int X, int Y) : x(X), y(Y) {} 298 299 int get_x() const { return x; } 300 int get_y() const { return y; } 301 302 user_type flipped() const { return user_type(y,x); } 303 304 int quadrant() const { 305 if (x == 0 || y == 0) return 0; // on axis 306 if (y>0) return x<0 ? 2 : 1; 307 return x<0 ? 3 : 4; 308 } 309 }; 310 // --- end of user_type --- 311 312 // helpers needed for tests: 313 inline bool operator == (const user_type& u1, const user_type& u2) { return u1.get_x() == u2.get_x() && u1.get_y() == u2.get_y(); } 314 inline char *val2readable(const user_type& u) { return arb_test::StaticCode::strf("user_type(%i,%i)", u.get_x(), u.get_y()); } 315 inline bool in_same_quadrant(const user_type& u1, const user_type& u2) { return u1.quadrant() == u2.quadrant(); } 316 317 void TEST_user_type_with_expectations() { 318 user_type ut1(3, 4); 319 user_type ut12(4, 4); 320 user_type ut2(-4, 4); 321 user_type ut3(-4, -8); 322 user_type ut4(4, -8); 323 324 TEST_EXPECT(that(ut1).differs(ut12)); 325 TEST_EXPECT(that(ut12).equals(ut12.flipped())); 326 TEST_EXPECT(that(ut1).differs(ut1.flipped())); 327 328 TEST_EXPECT(that(ut1).is(in_same_quadrant, ut12)); 329 TEST_EXPECT(none().of(that(ut1).is(in_same_quadrant, ut2), 330 that(ut2).is(in_same_quadrant, ut3), 331 that(ut3).is(in_same_quadrant, ut4))); 332 } 333 334 void TEST_similarity() { 335 double d1 = 0.7531; 336 double epsilon = 0.00001; 337 double d2 = d1-epsilon*0.6; 338 double d3 = d1+epsilon*0.6; 339 340 TEST_EXPECT(that(d1).is(epsilon_similar(epsilon), d2)); 341 TEST_EXPECT(that(d1).is(epsilon_similar(epsilon), d3)); 342 TEST_EXPECT(that(d2).is_not(epsilon_similar(epsilon), d3)); 343 344 TEST_ASSERT_SIMILAR(d1, d2, epsilon); 345 TEST_ASSERT_SIMILAR(d1, d3, epsilon); 346 } 347 348 void TEST_less_equal() { 349 int x = 7; 350 int y = 8; 351 int z = 9; 352 353 // less/more etc 354 355 TEST_EXPECT(that(x).less_than(y)); 356 TEST_EXPECT(that(x).less_or_equal(y)); 357 TEST_EXPECT(that(x).less_or_equal(x)); 358 359 TEST_EXPECT(that(y).more_than(x)); 360 TEST_EXPECT(that(y).more_or_equal(x)); 361 TEST_EXPECT(that(y).more_or_equal(y)); 362 363 TEST_ASSERT_LOWER_EQUAL(x, y); 364 TEST_ASSERT_LOWER_EQUAL(x, x); 365 TEST_ASSERT_LOWER(x, y); 366 TEST_ASSERT_IN_RANGE(y, x, z); 367 } 368 369 #endif // UNIT_TESTS 370 371 // -------------------------------------------------------------------------------- 372 373 -
branches/dev_elmar/DBSERVER/Makefile
r7183 r8224 33 33 db_server.o: $(ARBHOME)/INCLUDE/arb_core.h 34 34 db_server.o: $(ARBHOME)/INCLUDE/arb_error.h 35 db_server.o: $(ARBHOME)/INCLUDE/arb_file.h 35 36 db_server.o: $(ARBHOME)/INCLUDE/arb_msg.h 36 37 db_server.o: $(ARBHOME)/INCLUDE/arb_string.h … … 43 44 db_server.o: $(ARBHOME)/INCLUDE/smartptr.h 44 45 db_server.o: $(ARBHOME)/INCLUDE/test_global.h 46 db_server.o: $(ARBHOME)/INCLUDE/test_unit.h 47 db_server.o: $(ARBHOME)/INCLUDE/ut_valgrinded.h -
branches/dev_elmar/DBSERVER/db_server.cxx
r7945 r8224 2 2 // // 3 3 // File : db_server.cxx // 4 // Purpose : //4 // Purpose : CL ARB database server // 5 5 // // 6 6 // Institute of Microbiology (Technical University Munich) // … … 11 11 #include <arbdb.h> 12 12 #include <servercntrl.h> 13 #include <ut_valgrinded.h> 14 #include <arb_file.h> 13 15 14 16 #define TIMEOUT 1000*60*2 // save every 2 minutes 15 17 #define LOOPS 30 // wait 30*TIMEOUT (1 hour) till shutdown 16 18 17 int main(int argc, char **argv) 18 { 19 arb_params *params; 20 GBDATA *gb_extern; 21 GBDATA *gb_main; 22 GB_ERROR error; 23 int timer; 24 int last_update = 0; 25 int clock; 26 27 if (argc <= 1 || strcmp(argv[1], "--help") == 0) { 28 printf("Syntax of the arb_db_server:\n"); 29 printf(" arb_db_server [-D]database [-Tsocketid]\n"); 30 return -1; 31 } 32 33 params = arb_trace_argv(&argc, argv); 34 if (!params->tcp) { 35 static char arg[] = ":"; 36 params->tcp = arg; 37 } 38 39 if (argc==2) { 40 params->db_server = (char *)strdup(argv[1]); 41 argc--; 42 } 43 44 // 45 46 gb_extern = GB_open(params->tcp, "rwc"); 19 inline GBDATA *dbserver_container(GBDATA *gb_main) { 20 return GB_search(gb_main, "/tmp/dbserver", GB_CREATE_CONTAINER); 21 } 22 inline GBDATA *dbserver_entry(GBDATA *gb_main, const char *entry) { 23 GBDATA *gb_entry = GB_searchOrCreate_string(dbserver_container(gb_main), entry, "<undefined>"); 24 if (gb_entry) { 25 GBDATA *gb_brother = GB_nextEntry(gb_entry); 26 arb_assert(!gb_brother); 27 } 28 return gb_entry; 29 } 30 31 inline GBDATA *get_command_entry(GBDATA *gb_main) { return dbserver_entry(gb_main, "cmd"); } 32 inline GBDATA *get_param_entry(GBDATA *gb_main) { return dbserver_entry(gb_main, "param"); } 33 inline GBDATA *get_result_entry(GBDATA *gb_main) { return dbserver_entry(gb_main, "result"); } 34 35 inline GB_ERROR init_data(GBDATA *gb_main) { 36 GB_ERROR error = NULL; 37 38 if (!get_command_entry(gb_main) || !get_param_entry(gb_main) || !get_result_entry(gb_main)) { 39 error = GB_await_error(); 40 } 41 42 return error; 43 } 44 45 inline bool served(GBDATA *gb_main) { 46 GB_begin_transaction(gb_main); 47 GB_commit_transaction(gb_main); 48 return GBCMS_accept_calls(gb_main, false); 49 } 50 51 static bool do_shutdown = false; 52 static bool command_triggered = false; 53 54 static const char *savemode = "b"; 55 56 static void command_cb(GBDATA *, int*, GB_CB_TYPE ) { 57 command_triggered = true; 58 } 59 60 static void react_to_command(GBDATA *gb_main) { 61 static bool in_reaction = false; 62 63 if (!in_reaction) { 64 in_reaction = true; 65 66 command_triggered = false; 67 68 GB_ERROR error = NULL; 69 70 GB_begin_transaction(gb_main); 71 GBDATA *gb_cmd_entry = get_command_entry(gb_main); 72 GB_commit_transaction(gb_main); 73 74 char *command; 75 { 76 GB_transaction ta(gb_main); 77 78 command = GB_read_string(gb_cmd_entry); 79 if (command[0]) { 80 error = GB_write_string(gb_cmd_entry, ""); 81 if (!error) error = GB_write_string(get_result_entry(gb_main), "busy"); 82 } 83 } 84 85 if (command[0]) { 86 if (strcmp(command, "shutdown") == 0) do_shutdown = true; 87 else if (strcmp(command, "ping") == 0) {} // ping is a noop 88 else if (strcmp(command, "save") == 0) { 89 fprintf(stdout, "arb_db_server: save requested (savemode is \"%s\")\n", savemode); 90 91 char *param = NULL; 92 { 93 GB_transaction ta(gb_main); 94 GBDATA *gb_param = get_param_entry(gb_main); 95 if (!gb_param) error = GB_await_error(); 96 else { 97 param = GB_read_string(gb_param); 98 if (!param) error = GB_await_error(); 99 else error = GB_write_string(gb_param, ""); 100 } 101 } 102 103 if (!error) { 104 if (param[0]) error = GB_save(gb_main, param, savemode); 105 else error = "No savename specified"; 106 } 107 108 printf("arb_db_server: save returns '%s'\n", error); 109 110 free(param); 111 } 112 else { 113 error = GBS_global_string("Unknown command '%s'", command); 114 } 115 } 116 { 117 GB_transaction ta(gb_main); 118 119 GB_ERROR err2 = GB_write_string(get_result_entry(gb_main), error ? error : "ok"); 120 if (!error && err2) error = GBS_global_string("could not write result (reason: %s)", err2); 121 if (error) fprintf(stderr, "arb_db_server: failed to react to command '%s' (reason: %s)\n", command, error); 122 } 123 free(command); 124 in_reaction = false; 125 } 126 } 127 128 static GB_ERROR server_main_loop(GBDATA *gb_main) { 129 GB_ERROR error = NULL; 130 { 131 GB_transaction ta(gb_main); 132 133 GBDATA *cmd_entry = get_command_entry(gb_main); 134 error = GB_add_callback(cmd_entry, GB_CB_CHANGED, command_cb, NULL); 135 } 136 137 while (!error) { 138 served(gb_main); 139 if (command_triggered) { 140 react_to_command(gb_main); 141 } 142 if (do_shutdown) { 143 int clients; 144 do { 145 clients = GB_read_clients(gb_main); 146 if (clients>0) { 147 fprintf(stdout, "arb_db_server: shutdown requested (waiting for %i clients)\n", clients); 148 served(gb_main); 149 } 150 } 151 while (clients>0); 152 fputs("arb_db_server: all clients left, performing shutdown\n", stdout); 153 break; 154 } 155 } 156 return error; 157 } 158 159 static GB_ERROR check_socket_available(const arb_params& params) { 160 GBDATA *gb_extern = GB_open(params.tcp, "rwc"); 47 161 if (gb_extern) { 48 162 GB_close(gb_extern); 49 return -1; 50 } 51 printf("Loading '%s'...\n", params->db_server); 52 gb_main = GB_open(params->db_server, "rw"); 53 if (!gb_main) { 54 printf("Error: File %s not found\n", params->db_server); 55 return -1; 56 } 57 error = GBCMS_open(params->tcp, TIMEOUT, gb_main); 163 return GBS_global_string("socket '%s' already in use", params.tcp); 164 } 165 GB_clear_error(); 166 return NULL; 167 } 168 169 static GB_ERROR run_server(const arb_params& params) { 170 GB_shell shell; 171 GB_ERROR error = check_socket_available(params); 172 if (!error) { 173 printf("Loading '%s'...\n", params.default_file); 174 GBDATA *gb_main = GB_open(params.default_file, "rw"); 175 if (!gb_main) error = GBS_global_string("Can't open DB '%s' (reason: %s)", params.default_file, GB_await_error()); 176 else { 177 error = GBCMS_open(params.tcp, TIMEOUT, gb_main); 178 if (error) error = GBS_global_string("Error starting server: %s", error); 179 } 180 181 if (!error) { 182 GB_transaction ta(gb_main); 183 error = init_data(gb_main); 184 } 185 if (!error) { 186 error = server_main_loop(gb_main); 187 fprintf(stderr, "server_main_loop returns with '%s'\n", error); 188 } 189 190 if (gb_main) { 191 GBCMS_shutdown(gb_main); 192 GB_close(gb_main); 193 } 194 } 195 return error; 196 } 197 198 static GB_ERROR run_command(const arb_params& params, const char *command) { 199 GB_ERROR error = NULL; 200 GB_shell shell; 201 GBDATA *gb_main = GB_open(params.tcp, "rw"); 202 if (!gb_main) error = GB_await_error(); 203 else { 204 { 205 GB_transaction ta(gb_main); 206 207 GBDATA *gb_cmd_entry = get_command_entry(gb_main); 208 error = gb_cmd_entry ? GB_write_string(gb_cmd_entry, command) : GB_await_error(); 209 210 if (!error) { 211 if (strcmp(command, "save") == 0) { 212 GBDATA *gb_param = get_param_entry(gb_main); 213 if (!gb_param) error = GB_await_error(); 214 else error = GB_write_string(gb_param, params.default_file); // send save-name 215 } 216 } 217 } 218 219 if (!error) { 220 GB_transaction ta(gb_main); 221 222 GBDATA *gb_result_entry = get_result_entry(gb_main); 223 if (!gb_result_entry) error = GB_await_error(); 224 else { 225 const char *result = GB_read_char_pntr(gb_result_entry); 226 227 if (strcmp(result, "ok") != 0) { 228 error = GBS_global_string("Error from server: %s", result); 229 } 230 } 231 } 232 233 GB_close(gb_main); 234 } 235 return error; 236 } 237 238 static void show_help() { 239 fputs("arb_db_server 2.0 -- ARB-database server\n", stdout); 240 fputs("options:\n", stdout); 241 fputs(" -h show this help\n", stdout); 242 fputs(" -A use ASCII-DB-version\n", stdout); 243 fputs(" -Ccmd execute command 'cmd' on running server\n", stdout); 244 fputs(" known command are:\n", stdout); 245 fputs(" ping test if server is up (crash or failure if not)\n", stdout); 246 fputs(" save save the database (use -d to change name)\n", stdout); 247 fputs(" shutdown shutdown running arb_db_server\n", stdout); 248 arb_print_server_params(); 249 } 250 251 int main(int argc, char **argv) { 252 arb_params *params = arb_trace_argv(&argc, argv); 253 254 bool help = false; 255 const char *cmd = NULL; // run server command 256 257 GB_ERROR error = NULL; 258 while (argc>1 && !error) { 259 const char *arg = argv[1]; 260 if (arg[0] == '-') { 261 char sw_char = arg[1]; 262 switch (sw_char) { 263 case 'h': help = true; break; 264 case 'C': cmd = arg+2; break; 265 case 'A': savemode = "a"; break; 266 267 default: 268 error = GBS_global_string("Unknown switch '-%c'", sw_char); 269 break; 270 } 271 } 272 else { 273 error = GBS_global_string("Unknown argument '%s'", arg); 274 } 275 argc--; argv++; 276 } 277 278 if (!error) { 279 if (help) show_help(); 280 else if (cmd) error = run_command(*params, cmd); 281 else error = run_server(*params); 282 } 283 58 284 if (error) { 59 printf("Cannot start your arb_db_server: %s\n", error); 60 return (-1); 61 } 62 63 printf("Database is saved after every transaction (one . one save)\n"); 64 65 for (timer = LOOPS; timer>0; timer--) { // the server ends 66 GB_begin_transaction(gb_main); 67 clock = GB_read_clock(gb_main); 68 if (GB_read_clients(gb_main) >0) { 69 timer = LOOPS; 70 } 71 GB_commit_transaction(gb_main); 72 if (clock>last_update) { 73 last_update = clock; 74 printf("."); fflush(stdout); 75 GB_save(gb_main, 0, "b"); 76 timer = LOOPS; 77 } 78 GBCMS_accept_calls(gb_main, false); 79 } 80 return (0); 81 } 82 285 fprintf(stderr, "Error in arb_db_server: %s\n", error); 286 return EXIT_FAILURE; 287 } 288 return EXIT_SUCCESS; 289 } 290 291 // -------------------------------------------------------------------------------- 292 293 #ifdef UNIT_TESTS 294 #ifndef TEST_UNIT_H 295 #include <test_unit.h> 296 #endif 297 298 #include <unistd.h> 299 #include <sys/wait.h> 300 301 inline GB_ERROR valgrinded_system(const char *cmdline) { 302 char *cmddup = strdup(cmdline); 303 make_valgrinded_call(cmddup); 304 305 GB_ERROR error = GBK_system(cmddup); 306 free(cmddup); 307 return error; 308 } 309 310 #define RUN_TOOL(cmdline) valgrinded_system(cmdline) 311 #define TEST_RUN_TOOL(cmdline) TEST_ASSERT_NO_ERROR(RUN_TOOL(cmdline)) 312 #define TEST_RUN_TOOL_FAILS(cmdline) TEST_ASSERT_ERROR(RUN_TOOL(cmdline)) 313 314 inline bool server_is_down(const char *tcp) { 315 char *ping_cmd = strdup(GBS_global_string("arb_db_server -T%s -Cping", tcp)); 316 GB_ERROR error = GBK_system(ping_cmd); // causes a crash in called command (as long as server is not up) 317 free(ping_cmd); 318 return error; 319 } 320 321 static int entry_changed_cb_called = 0; 322 static void entry_changed_cb(GBDATA *, int*, GB_CB_TYPE) { 323 entry_changed_cb_called++; 324 } 325 326 void TEST_SLOW_dbserver() { 327 // MISSING_TEST(TEST_dbserver); 328 TEST_RUN_TOOL("arb_db_server -h"); 329 TEST_RUN_TOOL_FAILS("arb_db_server -X"); 330 TEST_RUN_TOOL_FAILS("arb_db_server brzl"); 331 332 char *sock = strdup(GB_path_in_ARBHOME("UNIT_TESTER/sockets/dbserver.socket")); 333 char *tcp = GBS_global_string_copy(":%s", sock); 334 char *db = strdup(GB_path_in_ARBHOME("UNIT_TESTER/run/TEST_loadsave.arb")); 335 336 char *shutdown_cmd = strdup(GBS_global_string("arb_db_server -T%s -Cshutdown", tcp)); 337 338 // #define DEBUG_SERVER // uncomment when debugging server manually 339 340 #if !defined(DEBUG_SERVER) 341 TEST_ASSERT(server_is_down(tcp)); 342 #endif 343 344 pid_t child_pid = fork(); 345 if (child_pid) { // parent ("the client") 346 bool down = true; 347 int max_wait = 2000/50; 348 while (down) { 349 GB_usleep(25*1000); 350 down = server_is_down(tcp); 351 TEST_ASSERT(max_wait-->0); 352 } 353 // ok - server is up 354 355 { 356 char *bad_cmd = strdup(GBS_global_string("arb_db_server -T%s -Cbad", tcp)); 357 TEST_RUN_TOOL_FAILS(bad_cmd); 358 free(bad_cmd); 359 } 360 361 { // now directly connect to server 362 GB_shell shell; 363 GB_ERROR error = NULL; 364 GBDATA *gb_main1 = GB_open(tcp, "rw"); // first client 365 if (!gb_main1) error = GB_await_error(); 366 else { 367 GBDATA *gb_main2 = GB_open(tcp, "rw"); // second client 368 if (!gb_main2) error = GB_await_error(); 369 else { 370 // test existing entries 371 { 372 GB_transaction ta(gb_main1); 373 GBDATA *gb_ecoli = GB_search(gb_main1, "/extended_data/extended/ali_16s/data", GB_FIND); 374 375 TEST_ASSERT(gb_ecoli); 376 377 const char *ecoli = GB_read_char_pntr(gb_ecoli); 378 if (!ecoli) error = GB_await_error(); 379 else TEST_ASSERT_EQUAL(GBS_checksum(ecoli, 0, NULL), 0x3558760cU); 380 } 381 { 382 GB_transaction ta(gb_main2); 383 GBDATA *gb_alitype = GB_search(gb_main2, "/presets/alignment/alignment_type", GB_FIND); 384 385 TEST_ASSERT(gb_alitype); 386 387 const char *alitype = GB_read_char_pntr(gb_alitype); 388 if (!alitype) error = GB_await_error(); 389 else TEST_ASSERT_EQUAL(alitype, "rna"); 390 } 391 392 // test value written in client1 is changed in client2 393 const char *test_entry = "/tmp/TEST_SLOW_dbserver"; 394 const char *test_content = "hello world!"; 395 396 GBDATA *gb_entry1; 397 GBDATA *gb_entry2; 398 399 if (!error) { 400 GB_transaction ta(gb_main1); 401 402 gb_entry1 = GB_search(gb_main1, test_entry, GB_STRING); 403 if (!gb_entry1) error = GB_await_error(); 404 else error = GB_write_string(gb_entry1, test_content); 405 } 406 407 if (!error) { // test value arrived in other client 408 GB_transaction ta(gb_main2); 409 410 gb_entry2 = GB_search(gb_main2, test_entry, GB_STRING); 411 if (!gb_entry2) error = GB_await_error(); 412 else { 413 const char *read_content = GB_read_char_pntr(gb_entry2); 414 if (!read_content) { 415 error = GB_await_error(); 416 } 417 else { 418 TEST_ASSERT_EQUAL(read_content, test_content); 419 } 420 } 421 } 422 423 // test change-callback gets triggered 424 if (!error) { 425 426 TEST_ASSERT_EQUAL(entry_changed_cb_called, 0); 427 { 428 GB_transaction ta(gb_entry1); 429 error = GB_add_callback(gb_entry1, GB_CB_CHANGED, entry_changed_cb, NULL); 430 } 431 TEST_ASSERT_EQUAL(entry_changed_cb_called, 0); 432 { 433 GB_transaction ta(gb_entry2); 434 GB_touch(gb_entry2); 435 } 436 TEST_ASSERT_EQUAL(entry_changed_cb_called, 0); // client1 did not transact yet 437 delete new GB_transaction(gb_main1); 438 TEST_ASSERT_EQUAL(entry_changed_cb_called, 1); 439 } 440 441 GB_close(gb_main2); 442 } 443 GB_close(gb_main1); 444 } 445 446 TEST_ASSERT_NO_ERROR(error); 447 } 448 449 // test remote save 450 { 451 char *savename = strdup(GB_path_in_ARBHOME("UNIT_TESTER/run/TEST_arbdbserver_save.arb")); 452 char *expected = strdup(GB_path_in_ARBHOME("UNIT_TESTER/run/TEST_arbdbserver_save_expected.arb")); 453 char *save_cmd = strdup(GBS_global_string("arb_db_server -T%s -Csave -d%s", tcp, savename)); 454 char *bad_savecmd = strdup(GBS_global_string("arb_db_server -T%s -Csave", tcp)); 455 456 TEST_RUN_TOOL(save_cmd); 457 TEST_ASSERT(GB_is_regularfile(savename)); 458 459 // #define TEST_AUTO_UPDATE 460 #if defined(TEST_AUTO_UPDATE) 461 TEST_COPY_FILE(savename, expected); 462 #else // !defined(TEST_AUTO_UPDATE) 463 TEST_ASSERT_FILES_EQUAL(savename, expected); 464 #endif 465 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink(savename)); 466 467 TEST_RUN_TOOL_FAILS(bad_savecmd); 468 469 free(bad_savecmd); 470 free(save_cmd); 471 free(expected); 472 free(savename); 473 } 474 475 // stop the server 476 TEST_RUN_TOOL(shutdown_cmd); 477 while (child_pid != wait(NULL)) {} // wait for child to finish = wait for server to terminate 478 } 479 else { // child ("the server") 480 #if !defined(DEBUG_SERVER) 481 GB_usleep(100*1000); 482 TEST_RUN_TOOL(GBS_global_string("arb_db_server -T%s -d%s -A", tcp, db)); // start the server (in ASCII-mode) 483 #endif 484 exit(EXIT_SUCCESS); 485 } 486 487 TEST_ASSERT(server_is_down(tcp)); 488 489 #define socket_disappeared(sock) (GB_time_of_file(sock) == 0) 490 491 TEST_ASSERT(socket_disappeared(sock)); 492 493 free(shutdown_cmd); 494 free(db); 495 free(tcp); 496 free(sock); 497 } 498 499 #endif // UNIT_TESTS 500 501 // -------------------------------------------------------------------------------- -
branches/dev_elmar/DIST/DI_main.cxx
r7190 r8224 54 54 55 55 GB_shell shell; 56 AW_root *aw_root = AWT_create_root(" .arb_prop/dist.arb", "ARB_DIST");56 AW_root *aw_root = AWT_create_root("dist.arb", "ARB_DIST"); 57 57 58 58 { -
branches/dev_elmar/DIST/DI_matr.cxx
r7945 r8224 298 298 if (!gb_species) { 299 299 if (show_warnings) { 300 aw_message(GB _export_errorf("Species '%s' found in tree '%s' but NOT in database.",301 species_in_sort_tree[i], sort_tree_name));300 aw_message(GBS_global_string("Species '%s' found in tree '%s' but NOT in database.", 301 species_in_sort_tree[i], sort_tree_name)); 302 302 } 303 303 unknown_species_in_tree++; … … 340 340 341 341 if (unknown_species_in_tree && show_warnings) { 342 aw_message(GB _export_errorf("We found %i species in tree '%s' which are not in database.\n"343 "This does not affect the current calculation, but you should think about it.",344 unknown_species_in_tree, sort_tree_name));342 aw_message(GBS_global_string("We found %i species in tree '%s' which are not in database.\n" 343 "This does not affect the current calculation, but you should think about it.", 344 unknown_species_in_tree, sort_tree_name)); 345 345 } 346 346 … … 1462 1462 1463 1463 aws->create_menu("Properties", "P", AWM_ALL); 1464 aws->insert_menu_topic("frame_props", "Frame ...", "F", "props_frame.hlp", AWM_ALL, AW_POPUP, (AW_CL)AW_preset_window,0);1465 aws->insert_menu_topic("save_props", "Save Properties ( in ~/.arb_prop/dist.arb)", "S", "savedef.hlp", AWM_ALL,(AW_CB)AW_save_properties, 0, 0);1464 aws->insert_menu_topic("frame_props", "Frame ...", "F", "props_frame.hlp", AWM_ALL, AW_POPUP,(AW_CL)AW_preset_window, 0); 1465 aws->insert_menu_topic("save_props", "Save Properties (dist.arb)", "S", "savedef.hlp", AWM_ALL, (AW_CB)AW_save_properties, 0, 0); 1466 1466 1467 1467 aws->insert_help_topic("help ...", "h", "dist.hlp", AWM_ALL, (AW_CB)AW_POPUP_HELP, (AW_CL)"dist.hlp", 0); -
branches/dev_elmar/DIST/Makefile
r7945 r8224 10 10 DI_main.o \ 11 11 DI_matr.o \ 12 DI_mldist.o \13 12 DI_protdist.o \ 14 13 DI_save_matr.o \ … … 237 236 DI_matr.o: $(ARBHOME)/INCLUDE/test_global.h 238 237 239 DI_mldist.o: di_matr.hxx240 DI_mldist.o: di_mldist.hxx241 DI_mldist.o: $(ARBHOME)/INCLUDE/ad_prot.h242 DI_mldist.o: $(ARBHOME)/INCLUDE/ad_t_prot.h243 DI_mldist.o: $(ARBHOME)/INCLUDE/AliView.hxx244 DI_mldist.o: $(ARBHOME)/INCLUDE/AP_matrix.hxx245 DI_mldist.o: $(ARBHOME)/INCLUDE/AP_pro_a_nucs.hxx246 DI_mldist.o: $(ARBHOME)/INCLUDE/AP_seq_simple_pro.hxx247 DI_mldist.o: $(ARBHOME)/INCLUDE/AP_sequence.hxx248 DI_mldist.o: $(ARBHOME)/INCLUDE/AP_Tree.hxx249 DI_mldist.o: $(ARBHOME)/INCLUDE/arb_assert.h250 DI_mldist.o: $(ARBHOME)/INCLUDE/arb_core.h251 DI_mldist.o: $(ARBHOME)/INCLUDE/arb_error.h252 DI_mldist.o: $(ARBHOME)/INCLUDE/arb_msg.h253 DI_mldist.o: $(ARBHOME)/INCLUDE/arb_progress.h254 DI_mldist.o: $(ARBHOME)/INCLUDE/arb_string.h255 DI_mldist.o: $(ARBHOME)/INCLUDE/ARB_Tree.hxx256 DI_mldist.o: $(ARBHOME)/INCLUDE/arbdb.h257 DI_mldist.o: $(ARBHOME)/INCLUDE/arbdb_base.h258 DI_mldist.o: $(ARBHOME)/INCLUDE/arbdbt.h259 DI_mldist.o: $(ARBHOME)/INCLUDE/arbtools.h260 DI_mldist.o: $(ARBHOME)/INCLUDE/attributes.h261 DI_mldist.o: $(ARBHOME)/INCLUDE/aw_base.hxx262 DI_mldist.o: $(ARBHOME)/INCLUDE/aw_color_groups.hxx263 DI_mldist.o: $(ARBHOME)/INCLUDE/aw_msg.hxx264 DI_mldist.o: $(ARBHOME)/INCLUDE/downcast.h265 DI_mldist.o: $(ARBHOME)/INCLUDE/dupstr.h266 DI_mldist.o: $(ARBHOME)/INCLUDE/smartptr.h267 DI_mldist.o: $(ARBHOME)/INCLUDE/test_global.h268 269 238 DI_protdist.o: di_matr.hxx 270 239 DI_protdist.o: di_protdist.hxx -
branches/dev_elmar/EDIT4/ED4_main.cxx
r7945 r8224 464 464 465 465 const char *ED4_propertyName(int mode) { 466 // mode == 0 -> alignment specific (e.g. " .arb_prop/edit4_ali_16s.arb")467 // mode == 1 -> alignment-type specific (e.g. " .arb_prop/edit4_rna.arb")468 // mode == 2 -> unspecific (normal) (always " .arb_prop/edit4.arb")466 // mode == 0 -> alignment specific (e.g. "edit4_ali_16s.arb") 467 // mode == 1 -> alignment-type specific (e.g. "edit4_rna.arb") 468 // mode == 2 -> unspecific (normal) (always "edit4.arb") 469 469 // 470 470 // Note : result is only valid until next call … … 472 472 e4_assert(mode >= 0 && mode <= 2); 473 473 474 if (mode == 2) return " .arb_prop/edit4.arb";474 if (mode == 2) return "edit4.arb"; 475 475 476 476 static char *ali_name = 0; … … 485 485 } 486 486 487 sprintf(result, " .arb_prop/edit4_%s.arb", mode == 0 ? ali_name : ali_type);487 sprintf(result, "edit4_%s.arb", mode == 0 ? ali_name : ali_type); 488 488 489 489 return result; -
branches/dev_elmar/EDIT4/ED4_root.cxx
r7945 r8224 37 37 #include <aw_advice.hxx> 38 38 #include <arb_version.h> 39 #include <arb_file.h> 39 40 #include <arbdbt.h> 40 41 … … 1587 1588 int default_mode = -1; 1588 1589 for (int mode = 0; mode <= 2; ++mode) { 1589 if ( 0 == strcmp(AW_root::property_DB_fullname(ED4_propertyName(mode)), db_name)) {1590 if (strcmp(GB_path_in_arbprop(ED4_propertyName(mode)), db_name) == 0) { 1590 1591 default_mode = mode; 1591 1592 break; … … 1594 1595 e4_assert(default_mode != -1); 1595 1596 1596 const char *entry = GBS_global_string("Save loaded Properties ( ~/%s)", db_name);1597 const char *entry = GBS_global_string("Save loaded Properties (%s)", ED4_propertyName(default_mode)); 1597 1598 awmm->insert_menu_topic("save_loaded_props", entry, "l", "e4_defaults.hlp", AWM_ALL, ED4_save_properties, (AW_CL)default_mode, 0); 1598 1599 SEP________________________SEP; … … 1601 1602 char hotkey[] = "x"; 1602 1603 hotkey[0] = "Pta"[mode]; 1603 entry = GBS_global_string("Save %sProperties ( ~/%s)", entry_type[mode], ED4_propertyName(mode));1604 entry = GBS_global_string("Save %sProperties (%s)", entry_type[mode], ED4_propertyName(mode)); 1604 1605 awmm->insert_menu_topic(tag[mode], entry, hotkey, "e4_defaults.hlp", AWM_ALL, ED4_save_properties, (AW_CL)mode, 0); 1605 1606 } … … 1898 1899 1899 1900 for (int mode = 0; !propname && mode <= 2; ++mode) { // search for properties-database 1900 const char *fullprop = AW_root::property_DB_fullname(ED4_propertyName(mode));1901 const char *fullprop = GB_path_in_arbprop(ED4_propertyName(mode)); 1901 1902 if (mode == 2 || GB_is_regularfile(fullprop)) { 1902 1903 freedup(propname, fullprop); -
branches/dev_elmar/EDIT4/ED4_search.cxx
r7945 r8224 809 809 // awars to save/load search parameters: 810 810 { 811 char *dir = GBS_global_string_copy("%s/.arb_prop/search_settings", GB_getenvHOME());811 char *dir = strdup(GB_path_in_arbprop("search_settings")); 812 812 AW_create_fileselection_awars(root, ED4_SEARCH_SAVE_BASE, dir, ".asp", "noname.asp"); 813 813 root->awar(ED4_SEARCH_SAVE_BASE"/directory")->write_string(dir); -
branches/dev_elmar/EDIT4/Makefile
r7945 r8224 678 678 ED4_root.o: $(ARBHOME)/INCLUDE/arb_core.h 679 679 ED4_root.o: $(ARBHOME)/INCLUDE/arb_error.h 680 ED4_root.o: $(ARBHOME)/INCLUDE/arb_file.h 680 681 ED4_root.o: $(ARBHOME)/INCLUDE/arb_msg.h 681 682 ED4_root.o: $(ARBHOME)/INCLUDE/arb_progress.h -
branches/dev_elmar/EDIT4/graph_aligner_gui.cxx
r7944 r8224 185 185 186 186 // start pt server if necessary 187 gb_error = arb_look_and_start_server(AISC_MAGIC_NUMBER, ptnam.str().c_str() , GLOBAL_gb_main);187 gb_error = arb_look_and_start_server(AISC_MAGIC_NUMBER, ptnam.str().c_str()); 188 188 if (gb_error) { 189 189 std::stringstream tmp; -
branches/dev_elmar/GDE/Makefile
r7428 r8224 3 3 CLUSTAL/CLUSTAL.dummy \ 4 4 SUPPORT/SUPPORT.dummy \ 5 MOLPHY/MOLPHY.dummy \6 5 AxML/AxML.dummy \ 7 6 RAxML/RAxML.dummy \ … … 54 53 endif 55 54 56 proto: MOLPHY/MOLPHY.proto57 58 55 depends: $(ARCHS:.dummy=.depend) 59 56 -
branches/dev_elmar/GDEHELP/ARB_GDEmenus.source
r7492 r8224 51 51 menumeta:X 52 52 #include <fastdnaml.genmenu> 53 #include <molphy.genmenu>54 53 55 54 menu:Phylogeny max. Likelyhood -
branches/dev_elmar/GDEHELP/Makefile.helpfiles
r7409 r8224 36 36 37 37 $(GENHELPDEST)/dnaml.help: $(AXML_HELP) $(FASTDNAML_DOC) 38 ./genhelptree.sh $@ "$(subst .help,,$(notdir $@))" $(HEADER) $^39 40 PROTML=$(GDE)/MOLPHY/doc41 PROTML_DOC_NAMES=protml protml_cli42 PROTML_DOCS=$(addsuffix .doc,$(addprefix $(PROTML)/,$(PROTML_DOC_NAMES)))43 44 $(GENHELPDEST)/protml.help: $(PROTML_DOCS)45 38 ./genhelptree.sh $@ "$(subst .help,,$(notdir $@))" $(HEADER) $^ 46 39 -
branches/dev_elmar/GENOM/EXP_main.cxx
r7945 r8224 114 114 } 115 115 116 static void EXP_run_pgt(AW_window *aww, AW_CL cl_gb_main, AW_CL) {117 AW_system(aww, (GBDATA*)cl_gb_main,"arb_pgt &", 0);116 static void EXP_run_pgt(AW_window *aww, AW_CL, AW_CL) { 117 AW_system(aww, "arb_pgt &", 0); 118 118 } 119 119 … … 137 137 138 138 awm->insert_separator(); 139 AWMIMT("pgt", "Proteom Genome Toolkit (PGT)", "P", "pgt.hlp", AWM_ALL, EXP_run_pgt, (AW_CL)gb_main, 0);139 AWMIMT("pgt", "Proteom Genome Toolkit (PGT)", "P", "pgt.hlp", AWM_ALL, EXP_run_pgt, 0, 0); 140 140 } 141 141 if (submenu) awm->close_sub_menu(); -
branches/dev_elmar/GENOM/GEN_map.cxx
r7945 r8224 1626 1626 insert_menu_topic("gene_options", "Options", "O", "gene_options.hlp", AWM_ALL, AW_POPUP, (AW_CL)GEN_create_options_window, 0); 1627 1627 insert_menu_topic("gene_nds", "NDS ( Select Gene Information ) ...", "N", "props_nds.hlp", AWM_ALL, AW_POPUP, (AW_CL)GEN_open_nds_window, (AW_CL)gb_main); 1628 insert_menu_topic("gene_save_props", "Save Defaults ( in ~/.arb_prop/ntree.arb)", "D", "savedef.hlp", AWM_ALL, (AW_CB) AW_save_properties, 0, 0);1628 insert_menu_topic("gene_save_props", "Save Defaults (ntree.arb)", "D", "savedef.hlp", AWM_ALL, (AW_CB) AW_save_properties, 0, 0); 1629 1629 1630 1630 // --------------------- -
branches/dev_elmar/MERGE/MG_main.cxx
r7621 r8224 19 19 #include <aw_file.hxx> 20 20 #include <aw_msg.hxx> 21 #include <aw_root.hxx> 22 21 23 #include <arb_progress.h> 22 #include <aw_root.hxx> 23 24 #include <arb_file.h> 24 25 25 26 GBDATA *GLOBAL_gb_merge = NULL; … … 240 241 } 241 242 242 awm->insert_menu_topic("save_props", "Save properties ( to ~/.arb_prop/ntree.arb)", "p", "savedef.hlp", AWM_ALL,(AW_CB)AW_save_properties, 0, 0);243 awm->insert_menu_topic("save_props", "Save properties (ntree.arb)", "p", "savedef.hlp", AWM_ALL, (AW_CB)AW_save_properties, 0, 0); 243 244 244 245 awm->button_length(30); … … 325 326 #endif 326 327 progress.subtitle("DATABASE I"); 327 GLOBAL_gb_merge = GBT_open(merge, "rw" , "$(ARBHOME)/lib/pts/*");328 GLOBAL_gb_merge = GBT_open(merge, "rw"); 328 329 if (!GLOBAL_gb_merge) error = GB_await_error(); 329 330 else { … … 349 350 350 351 if (!error) { 351 GLOBAL_gb_dest = GBT_open(main, open_mode , "$(ARBHOME)/lib/pts/*");352 GLOBAL_gb_dest = GBT_open(main, open_mode); 352 353 if (!GLOBAL_gb_dest) error = GB_await_error(); 353 354 #if defined(DEBUG) -
branches/dev_elmar/MERGE/Makefile
r7945 r8224 213 213 MG_main.o: $(ARBHOME)/INCLUDE/arb_core.h 214 214 MG_main.o: $(ARBHOME)/INCLUDE/arb_error.h 215 MG_main.o: $(ARBHOME)/INCLUDE/arb_file.h 215 216 MG_main.o: $(ARBHOME)/INCLUDE/arb_msg.h 216 217 MG_main.o: $(ARBHOME)/INCLUDE/arb_progress.h -
branches/dev_elmar/MULTI_PROBE/MP_noclass.cxx
r7945 r8224 932 932 const char *MP_probe_pt_look_for_server() { 933 933 const char *server_tag = GBS_ptserver_tag(mp_gl_awars.ptserver); 934 GB_ERROR error = arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag , 0);934 GB_ERROR error = arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag); 935 935 936 936 if (error) { -
branches/dev_elmar/Makefile
r7984 r8224 1039 1039 SERVERCNTRL/SERVERCNTRL.a \ 1040 1040 SL/HELIX/HELIX.a \ 1041 SL/PTCLEAN/PTCLEAN.a \ 1041 1042 1042 1043 ARCHS_PROBE_LINK = \ … … 1229 1230 SL/NEIGHBOURJOIN/NEIGHBOURJOIN.dummy: links_non_perl 1230 1231 SL/PRONUC/PRONUC.dummy: links_non_perl 1232 SL/PTCLEAN/PTCLEAN.dummy: links_non_perl link_db 1231 1233 SL/SEQUENCE/SEQUENCE.dummy: links_non_perl 1232 1234 SL/TRANSLATE/TRANSLATE.dummy: links_non_perl … … 1452 1454 $(ARCHS_PT_SERVER:.a=.proto) \ 1453 1455 SERVERCNTRL/SERVERCNTRL.proto \ 1454 GDE/GDE.proto \1455 1456 SL/SL.proto \ 1456 1457 … … 1837 1838 ALIV3/ALIV3.test \ 1838 1839 ARB_GDE/ARB_GDE.test \ 1839 AWT/AWT.test \1840 1840 CONSENSUS_TREE/CONSENSUS_TREE.test \ 1841 DBSERVER/DBSERVER.test \1842 1841 DIST/DIST.test \ 1843 1842 EISPACK/EISPACK.test \ … … 1852 1851 PHYLO/PHYLO.test \ 1853 1852 PRIMER_DESIGN/PRIMER_DESIGN.test \ 1854 PROBE/PROBE.test \1855 1853 PROBE_DESIGN/PROBE_DESIGN.test \ 1856 1854 ptpan/PROBE.test \ … … 1904 1902 1905 1903 UNITS_TESTED = \ 1904 DBSERVER/DBSERVER.test \ 1906 1905 GENOM_IMPORT/GENOM_IMPORT.test \ 1906 AWT/AWT.test \ 1907 1907 CORE/CORE.test \ 1908 1908 SL/TREEDISP/TREEDISP.test \ … … 1919 1919 CONVERTALN/CONVERTALN.test \ 1920 1920 SL/SEQIO/SEQIO.test \ 1921 SL/PTCLEAN/PTCLEAN.test \ 1922 PROBE/PROBE.test \ 1921 1923 1922 1924 TESTED_UNITS_MANUAL = \ -
branches/dev_elmar/NALIGNER/ali_other_stuff.hxx
r6381 r8224 12 12 #define ALI_OTHER_STUFF_HXX 13 13 14 #ifndef PT_COM_H 14 15 #include <PT_com.h> 15 16 #endif 17 #ifndef ATTRIBUTES_H 18 #include <attributes.h> 19 #endif 20 #ifndef SERVER_H 16 21 extern "C" { 17 22 #include <server.h> 18 23 } 19 24 #endif 25 #ifndef ARBDBT_H 20 26 #include <arbdbt.h> 27 #endif 28 #ifndef SERVERCNTRL_H 21 29 #include <servercntrl.h> 30 #endif 22 31 23 32 #else -
branches/dev_elmar/NALIGNER/ali_pt.cxx
r7945 r8224 96 96 97 97 98 int ALI_PT::open(char *servername , GBDATA *gb_main)99 { 100 if (arb_look_and_start_server(AISC_MAGIC_NUMBER, servername , gb_main)) {98 int ALI_PT::open(char *servername) 99 { 100 if (arb_look_and_start_server(AISC_MAGIC_NUMBER, servername)) { 101 101 ali_message ("Cannot contact Probe bank server"); 102 102 return -1; … … 152 152 153 153 ali_message("Connecting to PT server"); 154 if (open(context->servername , context->gb_main) != 0) {154 if (open(context->servername) != 0) { 155 155 ali_fatal_error("Can't connect to PT server"); 156 156 } -
branches/dev_elmar/NALIGNER/ali_pt.hxx
r7945 r8224 78 78 char *get_family_member(char *specified_family, unsigned long number); 79 79 char *get_extension_member(char *specified_family, unsigned long number); 80 int open(char *servername , GBDATA *gb_main);80 int open(char *servername); 81 81 void close(); 82 82 -
branches/dev_elmar/NAMES/Makefile
r7945 r8224 36 36 names.o: $(ARBHOME)/INCLUDE/arb_core.h 37 37 names.o: $(ARBHOME)/INCLUDE/arb_error.h 38 names.o: $(ARBHOME)/INCLUDE/arb_file.h 38 39 names.o: $(ARBHOME)/INCLUDE/arb_msg.h 39 40 names.o: $(ARBHOME)/INCLUDE/arb_string.h -
branches/dev_elmar/NAMES/names.cxx
r7945 r8224 14 14 15 15 #include <arbdb.h> 16 #include <arb_file.h> 16 17 #include <names_prototypes.h> 17 18 #include <server.h> -
branches/dev_elmar/NAMES_COM/names_extern.c
r7415 r8224 4 4 5 5 struct sigcontext; 6 #include <attributes.h> 6 7 #include "C/server.h" 7 8 -
branches/dev_elmar/NTREE/ColumnStat_2_gnuplot.cxx
r7945 r8224 20 20 #include <aw_root.hxx> 21 21 #include <arbdbt.h> 22 #include <arb_file.h> 22 23 23 24 #include <unistd.h> -
branches/dev_elmar/NTREE/Makefile
r7945 r8224 203 203 ad_trees.o: $(ARBHOME)/INCLUDE/arb_core.h 204 204 ad_trees.o: $(ARBHOME)/INCLUDE/arb_error.h 205 ad_trees.o: $(ARBHOME)/INCLUDE/arb_file.h 205 206 ad_trees.o: $(ARBHOME)/INCLUDE/arb_msg.h 206 207 ad_trees.o: $(ARBHOME)/INCLUDE/arb_strbuf.h … … 348 349 ColumnStat_2_gnuplot.o: $(ARBHOME)/INCLUDE/arb_core.h 349 350 ColumnStat_2_gnuplot.o: $(ARBHOME)/INCLUDE/arb_error.h 351 ColumnStat_2_gnuplot.o: $(ARBHOME)/INCLUDE/arb_file.h 350 352 ColumnStat_2_gnuplot.o: $(ARBHOME)/INCLUDE/arb_msg.h 351 353 ColumnStat_2_gnuplot.o: $(ARBHOME)/INCLUDE/arb_string.h … … 511 513 NT_extern.o: $(ARBHOME)/INCLUDE/arb_core.h 512 514 NT_extern.o: $(ARBHOME)/INCLUDE/arb_error.h 515 NT_extern.o: $(ARBHOME)/INCLUDE/arb_file.h 513 516 NT_extern.o: $(ARBHOME)/INCLUDE/arb_msg.h 514 517 NT_extern.o: $(ARBHOME)/INCLUDE/arb_progress.h … … 667 670 NT_main.o: $(ARBHOME)/INCLUDE/arb_core.h 668 671 NT_main.o: $(ARBHOME)/INCLUDE/arb_error.h 672 NT_main.o: $(ARBHOME)/INCLUDE/arb_file.h 669 673 NT_main.o: $(ARBHOME)/INCLUDE/arb_msg.h 670 674 NT_main.o: $(ARBHOME)/INCLUDE/arb_progress.h -
branches/dev_elmar/NTREE/NT_cb.cxx
r7945 r8224 119 119 120 120 void NT_system_cb(AW_window *aww, AW_CL cl_command, AW_CL cl_auto_help_file) { 121 AW_system(aww, GLOBAL_gb_main,(const char *)cl_command, (const char *)cl_auto_help_file);121 AW_system(aww, (const char *)cl_command, (const char *)cl_auto_help_file); 122 122 } 123 123 -
branches/dev_elmar/NTREE/NT_edconf.cxx
r7945 r8224 642 642 #define CONFNAME "default_configuration" 643 643 644 void nt_start_editor_on_configuration(AW_window *aww) {644 static void nt_start_editor_on_configuration(AW_window *aww) { 645 645 aww->hide(); 646 char *cn = aww->get_root()->awar(AWAR_CONFIGURATION)->read_string(); 647 char *com = (char *)GBS_global_string("arb_edit4 -c '%s' &", cn); 648 GBCMC_system(GLOBAL_gb_main, com); 649 delete cn; 646 647 const char *cn = aww->get_root()->awar(AWAR_CONFIGURATION)->read_char_pntr(); 648 const char *com = GBS_global_string("arb_edit4 -c '%s' &", cn); 649 650 aw_message_if(GBK_system(com)); 650 651 } 651 652 … … 673 674 void NT_start_editor_on_tree(AW_window *, AW_CL cl_use_species_aside, AW_CL) { 674 675 GB_ERROR error = nt_create_configuration(0, nt_get_current_tree_root(), CONFNAME, (int)cl_use_species_aside); 675 if (!error) { 676 int res = GBCMC_system(GLOBAL_gb_main, "arb_edit4 -c "CONFNAME" &"); 677 if (res != 0) error = GB_await_error(); 678 } 676 if (!error) error = GBK_system("arb_edit4 -c " CONFNAME " &"); 679 677 aw_message_if(error); 680 678 } -
branches/dev_elmar/NTREE/NT_extern.cxx
r7945 r8224 52 52 #include <arb_strbuf.h> 53 53 #include <arb_strarray.h> 54 #include <arb_file.h> 54 55 55 56 #include <arb_version.h> … … 677 678 nt_assert(GB_is_privatefile(mail_file, false)); 678 679 679 error = GB _system(command);680 error = GBK_system(command); 680 681 GB_unlink_or_warn(mail_file, &error); 681 682 … … 1571 1572 AWMIMT("!toggle_focus", "Toggle focus follows mouse", "f", 0, AWM_ALL, NT_toggle_focus_policy, 0, 0); 1572 1573 SEP________________________SEP(); 1573 AWMIMT("save_props", "Save properties ( in ~/.arb_prop/ntree.arb)", "S", "savedef.hlp", AWM_ALL, (AW_CB) AW_save_properties, 0, 0);1574 AWMIMT("save_props", "Save properties (ntree.arb)", "S", "savedef.hlp", AWM_ALL, (AW_CB) AW_save_properties, 0, 0); 1574 1575 } 1575 1576 } -
branches/dev_elmar/NTREE/NT_main.cxx
r7945 r8224 25 25 #include <aw_file.hxx> 26 26 #include <aw_msg.hxx> 27 #include <arb_progress.h>28 27 #include <aw_root.hxx> 29 28 30 29 #include <arbdbt.h> 31 30 #include <adGene.h> 31 32 32 #include <arb_version.h> 33 #include <arb_progress.h> 34 #include <arb_file.h> 33 35 34 36 using namespace std; … … 203 205 static ARB_ERROR load_and_startup_main_window(AW_root *aw_root, const char *autorun_macro) { 204 206 char *db_server = aw_root->awar(AWAR_DB_PATH)->read_string(); 205 GLOBAL_gb_main = GBT_open(db_server, "rw" , "$(ARBHOME)/lib/pts/*");207 GLOBAL_gb_main = GBT_open(db_server, "rw"); 206 208 207 209 ARB_ERROR error; … … 514 516 515 517 int main(int argc, char **argv) { 516 unsigned long mtime = GB_time_of_file("$(ARBHOME)/lib/message");517 unsigned long rtime = GB_time_of_file("$(HOME)/.arb_prop/msgtime");518 if (mtime > rtime) {519 AW_edit("${ARBHOME}/lib/message");520 system("touch ${HOME}/.arb_prop/msgtime");521 }522 518 aw_initstatus(); 523 519 GB_set_verbose(); 524 520 525 521 GB_shell shell; 526 AW_root *aw_root = AWT_create_root(" .arb_prop/ntree.arb", "ARB_NT");522 AW_root *aw_root = AWT_create_root("ntree.arb", "ARB_NT"); 527 523 528 524 GLOBAL_NT.awr = aw_root; 525 526 { 527 char *message = strdup(GB_path_in_ARBLIB("message")); 528 char *stamp = strdup(GB_path_in_arbprop("msgtime")); 529 if (GB_time_of_file(message)>GB_time_of_file(stamp)) { 530 AW_edit(message); 531 system(GBS_global_string("touch %s", stamp)); 532 } 533 free(stamp); 534 free(message); 535 } 529 536 530 537 // create some early awars … … 559 566 if (mode == EXPORT) { 560 567 MG_create_all_awars(aw_root, AW_ROOT_DEFAULT, ":", "noname.arb"); 561 GLOBAL_gb_merge = GBT_open(":", "rw" , 0);568 GLOBAL_gb_merge = GBT_open(":", "rw"); 562 569 if (!GLOBAL_gb_merge) { 563 570 error = GB_await_error(); … … 568 575 #endif // DEBUG 569 576 570 GLOBAL_gb_dest = GBT_open("noname.arb", "cw" , 0);577 GLOBAL_gb_dest = GBT_open("noname.arb", "cw"); 571 578 #if defined(DEBUG) 572 579 AWT_announce_db_to_browser(GLOBAL_gb_dest, "New database (noname.arb)"); -
branches/dev_elmar/NTREE/ad_ext.cxx
r7945 r8224 176 176 else { 177 177 GB_clear_error(); 178 type = GBT_read_string(gb_ali, "_TYPE"); 179 if (!type) error = GB_await_error(); 178 type = GBT_read_string(gb_ali, "_TYPE"); 179 if (!type) { 180 if (GB_have_error()) { 181 error = GB_await_error(); 182 } 183 else { 184 type = strdup(""); 185 } 186 } 180 187 } 181 188 } -
branches/dev_elmar/NTREE/ad_trees.cxx
r7945 r8224 23 23 #include <arbdbt.h> 24 24 #include <arb_strbuf.h> 25 #include <arb_file.h> 25 26 26 27 #define nt_assert(bed) arb_assert(bed) -
branches/dev_elmar/PARSIMONY/PARS_main.cxx
r7945 r8224 1389 1389 awm->create_menu("Properties", "r", AWM_ALL); 1390 1390 { 1391 awm->insert_menu_topic("props_menu", "Menu: Colors and Fonts ...", "M", "props_frame.hlp", AWM_ALL, AW_POPUP, (AW_CL)AW_preset_window,0);1392 awm->insert_menu_topic("props_tree", "Tree: Colors and Fonts ...", "C", "pars_props_data.hlp", AWM_ALL, AW_POPUP, (AW_CL)AW_create_gc_window,(AW_CL)aw_gc_manager);1393 awm->insert_menu_topic("props_tree2", "Tree: Settings ...", "T", "nt_tree_settings.hlp", AWM_ALL, AW_POPUP, (AW_CL)NT_create_tree_setting,(AW_CL)ntw);1394 awm->insert_menu_topic("props_kl", "KERN. LIN ...", "K", "kernlin.hlp", AWM_ALL, AW_POPUP,(AW_CL)create_kernighan_window, 0);1395 awm->insert_menu_topic("save_props", "Save Defaults ( in ~/.arb_prop/pars.arb)", "D", "savedef.hlp", AWM_ALL, (AW_CB)AW_save_properties,0, 0);1391 awm->insert_menu_topic("props_menu", "Menu: Colors and Fonts ...", "M", "props_frame.hlp", AWM_ALL, AW_POPUP,(AW_CL)AW_preset_window, 0); 1392 awm->insert_menu_topic("props_tree", "Tree: Colors and Fonts ...", "C", "pars_props_data.hlp", AWM_ALL, AW_POPUP,(AW_CL)AW_create_gc_window, (AW_CL)aw_gc_manager); 1393 awm->insert_menu_topic("props_tree2", "Tree: Settings ...", "T", "nt_tree_settings.hlp", AWM_ALL, AW_POPUP,(AW_CL)NT_create_tree_setting, (AW_CL)ntw); 1394 awm->insert_menu_topic("props_kl", "KERN. LIN ...", "K", "kernlin.hlp", AWM_ALL, AW_POPUP,(AW_CL)create_kernighan_window, 0); 1395 awm->insert_menu_topic("save_props", "Save Defaults (pars.arb)", "D", "savedef.hlp", AWM_ALL, (AW_CB)AW_save_properties, 0, 0); 1396 1396 } 1397 1397 awm->button_length(5); … … 1665 1665 1666 1666 GB_shell shell; 1667 AW_root *aw_root = AWT_create_root(" .arb_prop/pars.arb", "ARB_PARS");1667 AW_root *aw_root = AWT_create_root("pars.arb", "ARB_PARS"); 1668 1668 AD_map_viewer_aw_root = aw_root; 1669 1669 … … 1706 1706 } 1707 1707 1708 GLOBAL_gb_main = GBT_open(db_server, "rw" , 0);1708 GLOBAL_gb_main = GBT_open(db_server, "rw"); 1709 1709 if (!GLOBAL_gb_main) aw_popup_exit(GB_await_error()); // exits 1710 1710 -
branches/dev_elmar/PGT/arb_interface.cxx
r7190 r8224 76 76 77 77 /**************************************************************************** 78 * ESTABLISH A CONNECTION TO THE ARB CONFIGURATION 79 ****************************************************************************/ 80 int CONFIG_connect() 81 { 82 global_gbConfig= NULL; // ABFRAGE !!! 83 global_CONFIG_available= false; 84 85 // GET ARB HOME 86 const char *home= GB_getenvHOME(); 87 char *buffer= (char *)malloc(1025 * sizeof(char)); 88 sprintf(buffer,"%s/%s", home, PGT_CONFIG_FILE); 89 90 // OPEN CONFIG FILE 91 global_gbConfig= GB_open(buffer, "rwc"); 92 if(!global_gbConfig) 93 { 94 free(buffer); 95 return 0; 96 } 97 98 // DISABLE TRANSACTIONS 99 GB_no_transaction(global_gbConfig); 100 101 global_CONFIG_available= true; 102 103 free(buffer); 104 return 1; 78 * ESTABLISH A CONNECTION TO THE ARB CONFIGURATION 79 ****************************************************************************/ 80 void CONFIG_connect() { 81 char *config = strdup(GB_path_in_arbprop(PGT_CONFIG_NAME)); 82 global_gbConfig = GB_open(config, "rwc"); // OPEN CONFIG FILE 83 free(config); 84 85 if (global_gbConfig) GB_no_transaction(global_gbConfig); // DISABLE TRANSACTIONS 86 global_CONFIG_available = global_gbConfig; 105 87 } 106 88 … … 109 91 * CLOSE THE ARB CONFIGURATION 110 92 ****************************************************************************/ 111 int CONFIG_disconnect() 112 { 113 if(global_gbConfig) 114 { 115 // GET ARB HOME 116 const char *home= GB_getenvHOME(); 117 char *buffer= (char *)malloc(1025 * sizeof(char)); 118 sprintf(buffer,"%s/%s", home, PGT_CONFIG_FILE); 119 120 GB_save(global_gbConfig, buffer, "a"); 121 93 void CONFIG_disconnect() { 94 if (global_gbConfig) { 95 GB_save_in_arbprop(global_gbConfig, PGT_CONFIG_NAME, "a"); 122 96 GB_close(global_gbConfig); 123 124 free(buffer); 125 } 126 127 global_CONFIG_available= false; 128 global_gbConfig= NULL; 129 130 return 1; 97 } 98 global_CONFIG_available = false; 99 global_gbConfig = NULL; 131 100 } 132 101 -
branches/dev_elmar/PGT/arb_interface.hxx
r7190 r8224 28 28 #define AWAR_ORGANISM_NAME "tmp/focus/organism_name" 29 29 30 // PATH TOTHE PGT CONFIG FILE31 #define PGT_CONFIG_ FILE ".arb_prop/pgt.arb"30 // NAME OF THE PGT CONFIG FILE 31 #define PGT_CONFIG_NAME "pgt.arb" 32 32 33 33 // CONFIG DATABASE ENTRIES … … 56 56 int ARB_disconnect(); 57 57 58 intCONFIG_connect();59 intCONFIG_disconnect();58 void CONFIG_connect(); 59 void CONFIG_disconnect(); 60 60 61 61 bool ARB_begin_transaction(); -
branches/dev_elmar/PHYLO/PH_display.cxx
r7661 r8224 209 209 210 210 if (!device) return; 211 if (!markerline) return;212 211 213 212 GB_transaction dummy(PHDATA::ROOT->gb_main); -
branches/dev_elmar/PHYLO/PH_main.cxx
r7945 r8224 474 474 // Properties menu 475 475 awm->create_menu("Properties", "P"); 476 awm->insert_menu_topic("props_menu", "Menu: Colors and Fonts ...", "M", "props_frame.hlp", AWM_ALL, AW_POPUP, (AW_CL)AW_preset_window,0);477 awm->insert_menu_topic("props_data", "Data: Colors and Fonts ...", "D", "ph_props_data.hlp", AWM_ALL, AW_POPUP,(AW_CL)AW_create_gc_window, (AW_CL)gcmiddle);478 awm->insert_menu_topic("save_props", "Save Properties ( in ~/.arb_prop/phylo.arb)", "S", "savedef.hlp", AWM_ALL, (AW_CB)AW_save_properties,0, 0);476 awm->insert_menu_topic("props_menu", "Menu: Colors and Fonts ...", "M", "props_frame.hlp", AWM_ALL, AW_POPUP,(AW_CL)AW_preset_window, 0); 477 awm->insert_menu_topic("props_data", "Data: Colors and Fonts ...", "D", "ph_props_data.hlp", AWM_ALL, AW_POPUP,(AW_CL)AW_create_gc_window, (AW_CL)gcmiddle); 478 awm->insert_menu_topic("save_props", "Save Properties (phylo.arb)", "S", "savedef.hlp", AWM_ALL, (AW_CB)AW_save_properties, 0, 0); 479 479 480 480 … … 549 549 550 550 GB_shell shell; 551 AW_root *aw_root = AWT_create_root(" .arb_prop/phylo.arb", "ARB_PHYLO");551 AW_root *aw_root = AWT_create_root("phylo.arb", "ARB_PHYLO"); 552 552 PH_root *ph_root = new PH_root; 553 553 GB_ERROR error = ph_root->open(db_server); -
branches/dev_elmar/PROBE/Makefile
r7945 r8224 27 27 28 28 proto: 29 ../AISC_MKPTPS/aisc_mkpt - G -E -z -A -w pt_prototypes.h $(OBJECTS:.o=.cxx) probe_tree.h >pt_prototypes.h.tmp29 ../AISC_MKPTPS/aisc_mkpt -P -G -E -z -A -w pt_prototypes.h $(OBJECTS:.o=.cxx) probe_tree.h >pt_prototypes.h.tmp 30 30 ../SOURCE_TOOLS/mv_if_diff pt_prototypes.h.tmp pt_prototypes.h 31 31 … … 57 57 PT_buildtree.o: $(ARBHOME)/INCLUDE/arb_assert.h 58 58 PT_buildtree.o: $(ARBHOME)/INCLUDE/arb_core.h 59 PT_buildtree.o: $(ARBHOME)/INCLUDE/arb_defs.h 59 60 PT_buildtree.o: $(ARBHOME)/INCLUDE/arb_error.h 61 PT_buildtree.o: $(ARBHOME)/INCLUDE/arb_file.h 60 62 PT_buildtree.o: $(ARBHOME)/INCLUDE/arb_msg.h 61 63 PT_buildtree.o: $(ARBHOME)/INCLUDE/arb_progress.h … … 73 75 PT_buildtree.o: $(ARBHOME)/INCLUDE/static_assert.h 74 76 PT_buildtree.o: $(ARBHOME)/INCLUDE/test_global.h 77 PT_buildtree.o: $(ARBHOME)/INCLUDE/test_unit.h 75 78 76 79 PT_debug.o: probe.h … … 202 205 PT_main.o: $(ARBHOME)/INCLUDE/arb_assert.h 203 206 PT_main.o: $(ARBHOME)/INCLUDE/arb_core.h 207 PT_main.o: $(ARBHOME)/INCLUDE/arb_defs.h 204 208 PT_main.o: $(ARBHOME)/INCLUDE/arb_error.h 209 PT_main.o: $(ARBHOME)/INCLUDE/arb_file.h 205 210 PT_main.o: $(ARBHOME)/INCLUDE/arb_msg.h 206 211 PT_main.o: $(ARBHOME)/INCLUDE/arb_string.h … … 218 223 PT_main.o: $(ARBHOME)/INCLUDE/PT_server.h 219 224 PT_main.o: $(ARBHOME)/INCLUDE/PT_server_prototypes.h 225 PT_main.o: $(ARBHOME)/INCLUDE/ptclean.h 220 226 PT_main.o: $(ARBHOME)/INCLUDE/server.h 221 227 PT_main.o: $(ARBHOME)/INCLUDE/servercntrl.h … … 287 293 PT_prefixtree.o: $(ARBHOME)/INCLUDE/arb_core.h 288 294 PT_prefixtree.o: $(ARBHOME)/INCLUDE/arb_error.h 295 PT_prefixtree.o: $(ARBHOME)/INCLUDE/arb_file.h 289 296 PT_prefixtree.o: $(ARBHOME)/INCLUDE/arb_msg.h 290 297 PT_prefixtree.o: $(ARBHOME)/INCLUDE/arb_string.h -
branches/dev_elmar/PROBE/PT_buildtree.cxx
r7945 r8224 13 13 #include "probe_tree.h" 14 14 #include "pt_prototypes.h" 15 #include <arb_defs.h> 16 #include <arb_file.h> 15 17 16 18 #include <arb_progress.h> … … 18 20 #include <unistd.h> 19 21 20 POS_TREE *build_pos_tree (POS_TREE *pt, int anfangs_pos, int apos, int RNS_nr, unsigned int end) 21 { 22 static POS_TREE *pthelp, *pt_next; 23 unsigned int i, j; 24 int height = 0, anfangs_apos_ref, anfangs_rpos_ref, RNS_nr_ref; 25 pthelp = pt; 26 i = anfangs_pos; 27 while (PT_read_type(pthelp) == PT_NT_NODE) { // now we got an inner node 28 if ((pt_next = PT_read_son_stage_1(psg.ptmain, pthelp, (PT_BASES)psg.data[RNS_nr].data[i])) == NULL) { 29 // there is no son of that type -> simply add the new son to that path // 30 if (pthelp == pt) { // now we create a new root structure (size will change) 31 PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr].data[i], anfangs_pos, apos, RNS_nr); 32 return pthelp; // return the new root 33 } 34 else { 35 PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr].data[i], anfangs_pos, apos, RNS_nr); 36 return pt; // return the old root 37 } 22 // AISC_MKPT_PROMOTE: class DataLoc; 23 24 static POS_TREE *build_pos_tree(POS_TREE *const root, const DataLoc& loc) { 25 POS_TREE *at = root; 26 int height = 0; 27 28 while (PT_read_type(at) == PT_NT_NODE) { // now we got an inner node 29 POS_TREE *pt_next = PT_read_son_stage_1(at, loc[height]); 30 if (!pt_next) { // there is no son of that type -> simply add the new son to that path // 31 bool atRoot = (at == root); 32 PT_create_leaf(&at, loc[height], loc); 33 return atRoot ? at : root; // inside tree return old root, otherwise new root has been created 38 34 } 39 35 else { // go down the tree 40 pthelp= pt_next;36 at = pt_next; 41 37 height++; 42 i++; 43 if (i >= end) { // end of sequence reached -> change node to chain and add 44 // should never be reached, because of the terminal symbol 45 // of each sequence 46 if (PT_read_type(pthelp) == PT_NT_CHAIN) 47 pthelp = PT_add_to_chain(psg.ptmain, pthelp, RNS_nr, apos, anfangs_pos); 38 39 if (loc.is_shorther_than(height)) { 40 // end of sequence reached -> change node to chain and add 41 // should never be reached, because of the terminal symbol of each sequence (@@@ this IS reached - even with unittestdb) 42 if (PT_read_type(at) == PT_NT_CHAIN) { 43 PT_add_to_chain(at, loc); 44 } 48 45 // if type == node then forget it 49 return pt; 50 } 51 } 52 } 53 // type == leaf or chain 54 if (PT_read_type(pthelp) == PT_NT_CHAIN) { // old chain reached 55 pthelp = PT_add_to_chain(psg.ptmain, pthelp, RNS_nr, apos, anfangs_pos); 56 return pt; 57 } 58 anfangs_rpos_ref = PT_read_rpos(psg.ptmain, pthelp); // change leave to node and create two sons 59 anfangs_apos_ref = PT_read_apos(psg.ptmain, pthelp); 60 RNS_nr_ref = PT_read_name(psg.ptmain, pthelp); 61 j = anfangs_rpos_ref + height; 62 63 while (psg.data[RNS_nr].data[i] == psg.data[RNS_nr_ref].data[j]) { // creates nodes until sequences are different 64 // type != nt_node 65 if (PT_read_type(pthelp) == PT_NT_CHAIN) { // break 66 pthelp = PT_add_to_chain(psg.ptmain, pthelp, RNS_nr, apos, anfangs_pos); 67 return pt; 46 return root; 47 } 48 } 49 } 50 51 // type == leaf or chain 52 if (PT_read_type(at) == PT_NT_CHAIN) { // old chain reached 53 PT_add_to_chain(at, loc); 54 return root; 55 } 56 57 // change leave to node and create two sons 58 59 const DataLoc loc_ref(at); 60 61 while (loc[height] == loc_ref[height]) { // creates nodes until sequences are different 62 // type != nt_node 63 if (PT_read_type(at) == PT_NT_CHAIN) { 64 PT_add_to_chain(at, loc); 65 return root; 68 66 } 69 67 if (height >= PT_POS_TREE_HEIGHT) { 70 if (PT_read_type(pthelp) == PT_NT_LEAF) { 71 pthelp = PT_leaf_to_chain(psg.ptmain, pthelp); 72 } 73 pthelp = PT_add_to_chain(psg.ptmain, pthelp, RNS_nr, apos, anfangs_pos); 74 return pt; 75 } 76 if (((i + 1) >= end) && (j + 1 >= (unsigned)(psg.data[RNS_nr_ref].size))) { // end of both sequences 77 return pt; 78 } 79 pthelp = PT_change_leaf_to_node(psg.ptmain, pthelp); // change tip to node and append two new leafs 80 if (i + 1 >= end) { // end of source sequence reached 81 pthelp = PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr_ref].data[j], 82 anfangs_rpos_ref, anfangs_apos_ref, RNS_nr_ref); 83 return pt; 84 } 85 if (j + 1 >= (unsigned)(psg.data[RNS_nr_ref].size)) { // end of reference sequence 86 pthelp = PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr].data[i], anfangs_pos, apos, RNS_nr); 87 return pt; 88 } 89 pthelp = PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr].data[i], anfangs_rpos_ref, anfangs_apos_ref, RNS_nr_ref); 90 // dummy leaf just to create a new node; may become a chain 91 i++; 92 j++; 68 if (PT_read_type(at) == PT_NT_LEAF) { 69 at = PT_leaf_to_chain(at); 70 } 71 PT_add_to_chain(at, loc); 72 return root; 73 } 74 75 bool loc_done = loc.is_shorther_than(height+1); 76 bool ref_done = loc_ref.is_shorther_than(height+1); 77 78 if (ref_done && loc_done) return root; // end of both sequences 79 80 at = PT_change_leaf_to_node(at); // change tip to node and append two new leafs 81 if (loc_done) { // end of source sequence reached 82 PT_create_leaf(&at, loc_ref[height], loc_ref); 83 return root; 84 } 85 if (ref_done) { // end of reference sequence 86 PT_create_leaf(&at, loc[height], loc); 87 return root; 88 } 89 at = PT_create_leaf(&at, loc[height], loc_ref); // dummy leaf just to create a new node; may become a chain 93 90 height++; 94 91 } 92 93 94 95 95 if (height >= PT_POS_TREE_HEIGHT) { 96 if (PT_read_type( pthelp) == PT_NT_LEAF)97 pthelp = PT_leaf_to_chain(psg.ptmain, pthelp);98 pthelp = PT_add_to_chain(psg.ptmain, pthelp, RNS_nr, apos, anfangs_pos);99 return pt;100 }101 if (PT_read_type(pthelp) == PT_NT_CHAIN) {102 pthelp = PT_add_to_chain(psg.ptmain, pthelp, RNS_nr, apos, anfangs_pos);96 if (PT_read_type(at) == PT_NT_LEAF) at = PT_leaf_to_chain(at); 97 PT_add_to_chain(at, loc); 98 return root; 99 } 100 if (PT_read_type(at) == PT_NT_CHAIN) { 101 // not covered by test - but looks similar to case in top-loop 102 PT_add_to_chain(at, loc); 103 103 } 104 104 else { 105 pthelp = PT_change_leaf_to_node(psg.ptmain, pthelp); // Blatt loeschen 106 PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr].data[i], anfangs_pos, apos, RNS_nr); // zwei neue Blaetter 107 PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr_ref].data[j], anfangs_rpos_ref, anfangs_apos_ref, RNS_nr_ref); 108 } 109 return pt; 110 } 105 at = PT_change_leaf_to_node(at); // delete leaf 106 PT_create_leaf(&at, loc[height], loc); // two new leafs 107 PT_create_leaf(&at, loc_ref[height], loc_ref); 108 } 109 return root; 110 } 111 111 112 112 113 inline void get_abs_align_pos(char *seq, int &pos) … … 147 148 } 148 149 149 long PTD_save_partial_tree(FILE *out, P TM2 *ptmain, POS_TREE * node, char *partstring, int partsize, long pos, long *ppos, ARB_ERROR& error) {150 long PTD_save_partial_tree(FILE *out, POS_TREE * node, char *partstring, int partsize, long pos, long *ppos, ARB_ERROR& error) { 150 151 if (partsize) { 151 POS_TREE *son = PT_read_son( ptmain,node, (PT_BASES)partstring[0]);152 POS_TREE *son = PT_read_son(node, (PT_BASES)partstring[0]); 152 153 if (son) { 153 pos = PTD_save_partial_tree(out, ptmain,son, partstring+1, partsize-1, pos, ppos, error);154 pos = PTD_save_partial_tree(out, son, partstring+1, partsize-1, pos, ppos, error); 154 155 } 155 156 } 156 157 else { 157 PTD_clear_fathers( ptmain,node);158 PTD_clear_fathers(node); 158 159 long r_pos; 159 160 int blocked; … … 165 166 fflush(stdout); 166 167 #endif 167 r_pos = PTD_write_leafs_to_disk(out, ptmain,node, pos, ppos, &blocked, error);168 r_pos = PTD_write_leafs_to_disk(out, node, pos, ppos, &blocked, error); 168 169 if (r_pos > pos) pos = r_pos; 169 170 } … … 221 222 psg.ptmain->stage1 = 1; // enter stage 1 222 223 223 pt = PT_create_leaf( psg.ptmain, NULL, PT_N, 0, 0, 0); // create main node224 pt = PT_change_leaf_to_node(p sg.ptmain, pt);224 pt = PT_create_leaf(NULL, PT_N, DataLoc(0, 0, 0)); // create main node 225 pt = PT_change_leaf_to_node(pt); 225 226 psg.stat.cut_offs = 0; // statistic information 226 227 GB_begin_transaction(psg.gb_main); … … 267 268 268 269 int abs_align_pos = psize-1; 269 for (int j = psg.data[i]. size- 1; j >= 0; j--, abs_align_pos--) {270 for (int j = psg.data[i].get_size() - 1; j >= 0; j--, abs_align_pos--) { 270 271 get_abs_align_pos(align_abs, abs_align_pos); // may result in neg. abs_align_pos (seems to happen if sequences are short < 214bp ) 271 272 if (abs_align_pos < 0) break; // -> in this case abort 272 273 273 if (partsize && (*partstring != psg.data[i]. data[j] || strncmp(partstring, psg.data[i].data+j, partsize))) continue;274 if (ptd_string_shorter_than(psg.data[i]. data+j, 9)) continue;275 276 pt = build_pos_tree(pt, j, abs_align_pos, i, psg.data[i].size);274 if (partsize && (*partstring != psg.data[i].get_data()[j] || strncmp(partstring, psg.data[i].get_data()+j, partsize))) continue; 275 if (ptd_string_shorter_than(psg.data[i].get_data()+j, 9)) continue; 276 277 pt = build_pos_tree(pt, DataLoc(i, abs_align_pos, j)); 277 278 } 278 279 free(align_abs); … … 280 281 ++data_progress; 281 282 } 282 pos = PTD_save_partial_tree(out, p sg.ptmain, pt, partstring, partsize, pos, &last_obj, error);283 pos = PTD_save_partial_tree(out, pt, partstring, partsize, pos, &last_obj, error); 283 284 if (error) break; 284 285 … … 292 293 if (!error) { 293 294 if (partsize) { 294 pos = PTD_save_partial_tree(out, p sg.ptmain, pt, NULL, 0, pos, &last_obj, error);295 pos = PTD_save_partial_tree(out, pt, NULL, 0, pos, &last_obj, error); 295 296 #ifdef PTM_DEBUG 296 297 PTM_debug_mem(); … … 377 378 } 378 379 else { 379 error = PTD_read_leafs_from_disk(tname, psg.ptmain,&psg.pt);380 error = PTD_read_leafs_from_disk(tname, &psg.pt); 380 381 fclose(in); 381 382 } … … 385 386 } 386 387 388 // -------------------------------------------------------------------------------- 389 390 #ifdef UNIT_TESTS 391 #ifndef TEST_UNIT_H 392 #include <test_unit.h> 393 #endif 394 395 int main(int argc, const char*argv[]); 396 void NOTEST_SLOW_maybe_build_tree() { 397 // does only test sth if DB is present. 398 399 const char *dbarg = "-D" "extra_pt_src.arb"; 400 const char *testDB = dbarg+2; 401 const char *resultPT = "extra_pt_src.arb.pt"; 402 const char *expectedPT = "extra_pt_src.arb_expected.pt"; 403 bool exists = GB_is_regularfile(testDB); 404 405 if (exists) { 406 const char *argv[] = { 407 "fake_pt_server", 408 "-build", 409 dbarg, 410 }; 411 412 #if 1 413 // build 414 int res = main(ARRAY_ELEMS(argv), argv); 415 TEST_ASSERT_EQUAL(res, EXIT_SUCCESS); 416 #endif 417 418 // #define TEST_AUTO_UPDATE 419 #if defined(TEST_AUTO_UPDATE) 420 TEST_COPY_FILE(resultPT, expectedPT); 421 #else // !defined(TEST_AUTO_UPDATE) 422 TEST_ASSERT_FILES_EQUAL(resultPT, expectedPT); 423 #endif 424 } 425 } 426 427 #endif // UNIT_TESTS 428 429 // -------------------------------------------------------------------------------- -
branches/dev_elmar/PROBE/PT_debug.cxx
r7945 r8224 47 47 basecnt = 0; 48 48 for (i=PT_QU; i<PT_B_MAX; i++) { 49 if ((pt_help = PT_read_son(p sg.ptmain, pt, (PT_BASES)i)))49 if ((pt_help = PT_read_son(pt, (PT_BASES)i))) 50 50 { 51 51 basecnt++; … … 61 61 ptds->chains[height]++; 62 62 psg.height = 0; 63 PT_forwhole_chain(p sg.ptmain, pt, PT_chain_count());63 PT_forwhole_chain(pt, PT_chain_count()); 64 64 if (psg.height >= DEBUG_MAX_CHAIN_SIZE) psg.height = DEBUG_MAX_CHAIN_SIZE; 65 65 ptds->chainsizes[psg.height][height]++; … … 68 68 if (ptds->chaincount<20) { 69 69 printf("\n\n\n\n"); 70 PT_forwhole_chain(p sg.ptmain, pt, PTD_chain_print());70 PT_forwhole_chain(pt, PTD_chain_print()); 71 71 } 72 72 break; … … 140 140 struct probe_input_data& data = psg.data[leaf.name]; 141 141 142 PT_BASES b = (PT_BASES)data. data[leaf.rpos];143 144 printf("%s[%c] %s apos=%i rpos=%i\n", prefix, PT_BASES_2_char(b), data. name, leaf.apos, leaf.rpos);142 PT_BASES b = (PT_BASES)data.get_data()[leaf.rpos]; 143 144 printf("%s[%c] %s apos=%i rpos=%i\n", prefix, PT_BASES_2_char(b), data.get_name(), leaf.apos, leaf.rpos); 145 145 return 0; 146 146 } … … 152 152 switch (PT_read_type(pt)) { 153 153 case PT_NT_NODE: 154 for (int i = PT_ N; i<PT_B_MAX; i++) {154 for (int i = PT_QU; i<PT_B_MAX; i++) { 155 155 PT_BASES b = PT_BASES(i); 156 POS_TREE *son = PT_read_son(p sg.ptmain, pt, b);156 POS_TREE *son = PT_read_son(pt, b); 157 157 if (son) { 158 char *subPrefix = GBS_global_string_copy("%s%c", prefix, PT_BASES_2_char(b));158 char *subPrefix = GBS_global_string_copy("%s%c", prefix, b == PT_QU ? '.' : PT_BASES_2_char(b)); 159 159 PT_dump_POS_TREE_recursive(son, subPrefix); 160 160 free(subPrefix); … … 163 163 break; 164 164 case PT_NT_LEAF: { 165 PT_dump_leaf dump_leaf(prefix); 166 dump_leaf(DataLoc(psg.ptmain, pt)); 167 break; 168 } 169 case PT_NT_CHAIN: 170 PT_forwhole_chain(psg.ptmain, pt, PT_dump_leaf(prefix)); 171 break; 165 char *subPrefix = GBS_global_string_copy("{l} %s", prefix); 166 PT_dump_leaf dump_leaf(subPrefix); 167 dump_leaf(DataLoc(pt)); 168 free(subPrefix); 169 break; 170 } 171 case PT_NT_CHAIN: { 172 char *subPrefix = GBS_global_string_copy("{c} %s", prefix); 173 PT_forwhole_chain(pt, PT_dump_leaf(subPrefix)); 174 free(subPrefix); 175 break; 176 } 172 177 default: 173 178 printf("%s [unhandled]\n", prefix); … … 183 188 // Debug function for all stages 184 189 #if defined(DEBUG) 185 long i;186 PTM2 *ptmain = psg.ptmain;187 190 if (!node) printf("Zero node\n"); 188 PT_READ_PNTR(&node->data, i); 189 printf("node father 0x%lx\n", i); 191 192 { 193 long i; 194 PT_READ_PNTR(&node->data, i); 195 printf("node father 0x%lx\n", i); 196 } 197 190 198 switch (PT_read_type(node)) { 191 case PT_NT_LEAF: 192 printf("leaf %i:%i,%i\n", PT_read_name(ptmain, node), 193 PT_read_rpos(ptmain, node), PT_read_apos(ptmain, node)); 194 break; 199 case PT_NT_LEAF: { 200 DataLoc loc(node); 201 printf("leaf %i:%i,%i\n", loc.name, loc.rpos, loc.apos); 202 break; 203 } 195 204 case PT_NT_NODE: 196 for ( i = 0; i < PT_B_MAX; i++) {197 printf("%6li:0x%p\n", i, PT_read_son( ptmain,node, (PT_BASES)i));205 for (long i = 0; i < PT_B_MAX; i++) { 206 printf("%6li:0x%p\n", i, PT_read_son(node, (PT_BASES)i)); 198 207 } 199 208 break; 200 209 case PT_NT_CHAIN: 201 210 printf("chain:\n"); 202 PT_forwhole_chain( ptmain,node, PTD_chain_print());211 PT_forwhole_chain(node, PTD_chain_print()); 203 212 break; 204 213 case PT_NT_SAVED: -
branches/dev_elmar/PROBE/PT_etc.cxx
r7999 r8224 72 72 } 73 73 74 const char *virt_name(PT_probematch *ml) 74 const char *virt_name(PT_probematch *ml) 75 75 { 76 76 // get the name with a virtual function 77 77 if (gene_flag) { 78 const gene_struct *gs = get_gene_struct_by_internal_gene_name(psg.data[ml->name]. name);78 const gene_struct *gs = get_gene_struct_by_internal_gene_name(psg.data[ml->name].get_name()); 79 79 return gs ? gs->get_arb_species_name() : "<cantResolveName>"; 80 80 } 81 81 else { 82 pt_assert(psg.data[ml->name]. name);83 return psg.data[ml->name]. name;84 } 85 } 86 87 const char *virt_fullname(PT_probematch * ml) 82 pt_assert(psg.data[ml->name].get_name()); 83 return psg.data[ml->name].get_name(); 84 } 85 } 86 87 const char *virt_fullname(PT_probematch * ml) 88 88 { 89 89 if (gene_flag) { 90 const gene_struct *gs = get_gene_struct_by_internal_gene_name(psg.data[ml->name]. name);90 const gene_struct *gs = get_gene_struct_by_internal_gene_name(psg.data[ml->name].get_name()); 91 91 return gs ? gs->get_arb_gene_name() : "<cantResolveGeneFullname>"; 92 92 } 93 93 else { 94 return psg.data[ml->name]. fullname ? psg.data[ml->name].fullname: "<undefinedFullname>";94 return psg.data[ml->name].get_fullname() ? psg.data[ml->name].get_fullname() : "<undefinedFullname>"; 95 95 } 96 96 } … … 163 163 // clear 'is_group' 164 164 for (int i = 0; i < psg.data_count; i++) { 165 psg.data[i]. is_group = 0; // Note: probes are designed for species with is_group == 1165 psg.data[i].set_group_state(0); // Note: probes are designed for species with is_group == 1 166 166 } 167 167 locs->group_count = 0; … … 212 212 const char *checksum = get_list_part(checksums, coff); 213 213 // if sequence checksum changed since pt server was updated -> not found 214 found = atol(checksum) == psg.data[idx]. checksum;214 found = atol(checksum) == psg.data[idx].get_checksum(); 215 215 } 216 216 else { … … 219 219 220 220 if (found) { 221 psg.data[idx]. is_group = 1; // mark221 psg.data[idx].set_group_state(1); // mark 222 222 locs->group_count++; 223 223 } -
branches/dev_elmar/PROBE/PT_family.cxx
r7945 r8224 22 22 inline void aisc_link(dll_public *dll, PT_family_list *family) { aisc_link(reinterpret_cast<dllpublic_ext*>(dll), reinterpret_cast<dllheader_ext*>(family)); } 23 23 24 25 class HitCounter { 26 int count; // Counter for matches 27 double rel_count; // match_count / (seq_len - probe_len + 1) 28 29 public: 30 HitCounter() : count(0), rel_count(0.0) {} 31 32 void inc() { count++; } 33 void calc_rel_match(int max_poss_matches) { 34 rel_count = max_poss_matches>0 ? double(count)/max_poss_matches : 0; 35 } 36 37 bool less_abs(const HitCounter& other) const { return count < other.count; } 38 bool less_rel(const HitCounter& other) const { return rel_count < other.rel_count; } 39 40 int get_match_count() const { return count; } 41 const double& get_rel_match_count() const { return rel_count; } 42 }; 43 44 class FamilyStat : virtual Noncopyable { 45 size_t size; 46 HitCounter *famstat; 47 48 public: 49 FamilyStat(size_t size_) : size(size_), famstat(new HitCounter[size]) { } 50 ~FamilyStat() { delete [] famstat; } 51 52 void calc_rel_matches(int probe_len, int sequence_length) { 53 for (size_t i = 0; i < size; i++) { 54 int max_poss_matches = std::min(psg.data[i].get_size(), sequence_length) - probe_len + 1; 55 famstat[i].calc_rel_match(max_poss_matches); 56 } 57 } 58 59 const HitCounter& hits(size_t idx) const { pt_assert(idx<size); return famstat[idx]; } 60 61 void count_match(size_t idx) { famstat[idx].inc(); } 62 63 bool less_abs(int a, int b) const { return famstat[a].less_abs(famstat[b]); } 64 bool less_rel(int a, int b) const { return famstat[a].less_rel(famstat[b]); } 65 }; 66 24 67 class ProbeTraversal { 25 68 static Range range; 26 69 27 static void count_match(const DataLoc& match) {28 if (range.contains(match)) {29 ++psg.data[match.name].stat.match_count;30 }31 }32 33 // ----------------------------------------34 35 70 const char *probe; 36 71 int height; 37 72 int needed_positions; 38 73 int accept_mismatches; 74 75 FamilyStat& fam_stat; 76 77 void count_match(const DataLoc& match) const { 78 if (range.contains(match)) { 79 fam_stat.count_match(match.name); 80 } 81 } 39 82 40 83 bool at_end() const { return *probe == PT_QU; } … … 55 98 56 99 void match_rest_and_mark(const DataLoc& loc) { 57 do match_one_char(psg.data[loc.name]. data[loc.rpos+height]); while (match_possible());100 do match_one_char(psg.data[loc.name].get_data()[loc.rpos+height]); while (match_possible()); 58 101 if (did_match()) count_match(loc); 59 102 } … … 69 112 range = Range(-1, -1, -1); 70 113 } 71 72 ProbeTraversal(const char *probe_, int needed_positions_, int accept_mismatches_ )114 115 ProbeTraversal(const char *probe_, int needed_positions_, int accept_mismatches_, FamilyStat& fam_stat_) 73 116 : probe(probe_), 74 117 height(0), 75 118 needed_positions(needed_positions_), 76 accept_mismatches(accept_mismatches_) 119 accept_mismatches(accept_mismatches_), 120 fam_stat(fam_stat_) 77 121 { } 78 122 … … 100 144 if (PT_read_type(pt) == PT_NT_NODE) { 101 145 for (int base = PT_N; base < PT_B_MAX; base++) { 102 POS_TREE *pt_son = PT_read_son(p sg.ptmain, pt, (PT_BASES)base);146 POS_TREE *pt_son = PT_read_son(pt, (PT_BASES)base); 103 147 if (pt_son && !at_end()) { 104 148 ProbeTraversal sub(*this); … … 112 156 } 113 157 else { 114 PT_withall_tips(p sg.ptmain, pt, *this); // calls operator()158 PT_withall_tips(pt, *this); // calls operator() 115 159 } 116 160 } … … 123 167 if (PT_read_type(pt) == PT_NT_NODE) { 124 168 for (int base = PT_N; base < PT_B_MAX; base++) { 125 POS_TREE *pt_son = PT_read_son(p sg.ptmain, pt, (PT_BASES)base);169 POS_TREE *pt_son = PT_read_son(pt, (PT_BASES)base); 126 170 if (pt_son) mark_all(pt_son); 127 171 } 128 172 } 129 173 else { 130 PT_withall_tips(psg.ptmain, pt, *this); // calls operator() 131 } 132 } 133 134 135 static void clear_statistic() { 136 //! Clear all information in psg.data[i].stat 137 138 for (int i = 0; i < psg.data_count; i++) { 139 memset((char *) &psg.data[i].stat, 0, sizeof(probe_statistic)); 140 } 141 } 142 143 144 145 static void make_match_statistic(int probe_len, int sequence_length) { 146 //! Calculate the statistic information for the family 147 148 // compute statistic for all species in family 149 for (int i = 0; i < psg.data_count; i++) { 150 int all_len = std::min(psg.data[i].size, sequence_length) - probe_len + 1; 151 if (all_len <= 0) { 152 psg.data[i].stat.rel_match_count = 0; 153 } 154 else { 155 psg.data[i].stat.rel_match_count = psg.data[i].stat.match_count / (double) (all_len); 156 } 174 PT_withall_tips(pt, *this); // calls operator() 157 175 } 158 176 } 159 177 160 178 struct cmp_probe_abs { 161 bool operator()(const struct probe_input_data* a, const struct probe_input_data* b) {162 return b->stat.match_count < a->stat.match_count;163 }179 const FamilyStat& fam_stat; 180 cmp_probe_abs(const FamilyStat& fam_stat_) : fam_stat(fam_stat_) {} 181 bool operator()(int a, int b) { return fam_stat.less_abs(b, a); } 164 182 }; 165 183 166 184 struct cmp_probe_rel { 167 bool operator()(const struct probe_input_data* a, const struct probe_input_data* b) {168 return b->stat.rel_match_count < a->stat.rel_match_count;169 }170 }; 171 172 static int make_PT_family_list(PT_family *ffinder ) {185 const FamilyStat& fam_stat; 186 cmp_probe_rel(const FamilyStat& fam_stat_) : fam_stat(fam_stat_) {} 187 bool operator()(int a, int b) { return fam_stat.less_rel(b, a); } 188 }; 189 190 static int make_PT_family_list(PT_family *ffinder, const FamilyStat& famStat) { 173 191 //! Make sorted list of family members 174 192 193 // destroy old list 194 while (ffinder->fl) destroy_PT_family_list(ffinder->fl); 195 175 196 // Sort the data 176 std::vector<struct probe_input_data*> my_list; 177 my_list.resize(psg.data_count); 178 179 for (int i = 0; i < psg.data_count; i++) { 180 my_list[i] = &psg.data[i]; 181 } 197 std::vector<int> sorted; 198 sorted.resize(psg.data_count); 199 200 for (int i = 0; i < psg.data_count; i++) sorted[i] = i; 182 201 183 202 bool sort_all = ffinder->sort_max == 0 || ffinder->sort_max >= psg.data_count; … … 185 204 if (ffinder->sort_type == 0) { 186 205 if (sort_all) { 187 std::sort( my_list.begin(), my_list.end(), cmp_probe_abs());206 std::sort(sorted.begin(), sorted.end(), cmp_probe_abs(famStat)); 188 207 } 189 208 else { 190 std::partial_sort( my_list.begin(), my_list.begin() + ffinder->sort_max, my_list.begin() + psg.data_count, cmp_probe_abs());209 std::partial_sort(sorted.begin(), sorted.begin() + ffinder->sort_max, sorted.begin() + psg.data_count, cmp_probe_abs(famStat)); 191 210 } 192 211 } 193 212 else { 194 213 if (sort_all) { 195 std::sort( my_list.begin(), my_list.begin() + psg.data_count, cmp_probe_rel());214 std::sort(sorted.begin(), sorted.begin() + psg.data_count, cmp_probe_rel(famStat)); 196 215 } 197 216 else { 198 std::partial_sort(my_list.begin(), my_list.begin() + ffinder->sort_max, my_list.begin() + psg.data_count, cmp_probe_rel()); 199 } 200 } 201 202 // destroy old list 203 while (ffinder->fl) destroy_PT_family_list(ffinder->fl); 217 std::partial_sort(sorted.begin(), sorted.begin() + ffinder->sort_max, sorted.begin() + psg.data_count, cmp_probe_rel(famStat)); 218 } 219 } 204 220 205 221 // build new list … … 208 224 int end = (sort_all) ? psg.data_count : ffinder->sort_max; 209 225 for (int i = 0; i < end; i++) { 210 if (my_list[i]->stat.match_count != 0) { 226 probe_input_data& pid = psg.data[sorted[i]]; 227 const HitCounter& ps = famStat.hits(sorted[i]); 228 229 if (ps.get_match_count() != 0) { 211 230 PT_family_list *fl = create_PT_family_list(); 212 231 213 fl->name = strdup( my_list[i]->name);214 fl->matches = my_list[i]->stat.match_count;215 fl->rel_matches = my_list[i]->stat.rel_match_count;232 fl->name = strdup(pid.get_name()); 233 fl->matches = ps.get_match_count(); 234 fl->rel_matches = ps.get_rel_match_count(); 216 235 217 236 aisc_link(&ffinder->pfl, fl); … … 263 282 int sequence_len = probe_compress_sequence(sequence, species->size); 264 283 265 clear_statistic();266 267 284 // if find_type > 0 -> search only probes starting with 'A' (quick but less accurate) 268 285 char last_first_c = ffinder->find_type ? PT_A : PT_T; … … 270 287 ProbeTraversal::restrictMatchesToRegion(ffinder->range_start, ffinder->range_end, probe_len); 271 288 289 FamilyStat famStat(psg.data_count); 290 272 291 // Note: code depends on order of ../AWTC/awtc_next_neighbours.hxx@FF_complement_dep 273 292 for (int cmode = 1; cmode <= 8; cmode *= 2) { … … 290 309 for (char *probe = sequence; probe < last_probe; ++probe) { 291 310 if (probe_is_ok(probe, probe_len, first_c, second_c)) { 292 ProbeTraversal(probe, probe_len, mismatch_nr ).mark_matching(psg.pt);311 ProbeTraversal(probe, probe_len, mismatch_nr, famStat).mark_matching(psg.pt); 293 312 } 294 313 } … … 298 317 } 299 318 300 make_match_statistic(ffinder->pr_len, sequence_len);301 make_PT_family_list(ffinder );319 famStat.calc_rel_matches(ffinder->pr_len, sequence_len); 320 make_PT_family_list(ffinder, famStat); 302 321 303 322 ProbeTraversal::unrestrictMatchesToRegion(); -
branches/dev_elmar/PROBE/PT_findEx.cxx
r7415 r8224 21 21 case PT_NT_NODE: { 22 22 for (int i=PT_A; i<PT_B_MAX; ++i) { 23 POS_TREE *son = PT_read_son( psg.ptmain,node, PT_BASES(i));23 POS_TREE *son = PT_read_son(node, PT_BASES(i)); 24 24 if (son) { 25 25 probe[0] = PT_BASES(i); // write leftmost probe into result … … 37 37 case PT_NT_LEAF: { 38 38 // here the probe-tree is cut off, because only one species matches 39 int pos = PT_read_rpos(psg.ptmain, node) + height; 40 int name = PT_read_name(psg.ptmain, node); 41 if (pos + restlen >= psg.data[name].size) 39 DataLoc loc(node); 40 int pos = loc.rpos + height; 41 int name = loc.name; 42 43 if (pos + restlen >= psg.data[name].get_size()) 42 44 break; // at end-of-sequence -> no probe with wanted length here 43 45 44 46 pt_assert(probe[restlen] == 0); 45 const char *seq_data = psg.data[name]. data;47 const char *seq_data = psg.data[name].get_data(); 46 48 for (int r = 0; r<restlen; ++r) { 47 49 int data = seq_data[pos+r]; … … 70 72 switch (PT_read_type(node)) { 71 73 case PT_NT_NODE: { 72 POS_TREE *son = PT_read_son( psg.ptmain,node, PT_BASES(probe[0]));74 POS_TREE *son = PT_read_son(node, PT_BASES(probe[0])); 73 75 bool found = (son != 0) && findNextProbe(son, probe+1, restlen-1, height+1); 74 76 … … 77 79 if (!found) { 78 80 for (int i=probe[0]+1; !found && i<PT_B_MAX; ++i) { 79 son = PT_read_son( psg.ptmain,node, PT_BASES(i));81 son = PT_read_son(node, PT_BASES(i)); 80 82 if (son) { 81 83 probe[0] = PT_BASES(i); // change probe -
branches/dev_elmar/PROBE/PT_io.cxx
r7946 r8224 16 16 #include <BI_basepos.hxx> 17 17 #include <arb_progress.h> 18 19 #include <sys/stat.h>20 18 21 19 int compress_data(char *probestring) { … … 73 71 } 74 72 75 ARB_ERROR probe_read_data_base(const char *name ) { // goes to header: __ATTR__USERESULT73 ARB_ERROR probe_read_data_base(const char *name, bool readOnly) { // goes to header: __ATTR__USERESULT 76 74 ARB_ERROR error; 77 75 GB_set_verbose(); … … 79 77 psg.gb_shell = new GB_shell; 80 78 81 GBDATA *gb_main = GB_open(name, "r");79 GBDATA *gb_main = GB_open(name, readOnly ? "r" : "rw"); 82 80 if (!gb_main) error = GB_await_error(); 83 81 else { … … 197 195 } 198 196 199 char *probe_ read_alignment(int j, int *psize){197 char *probe_input_data::read_alignment(int *psize) const { 200 198 char *buffer = 0; 201 GBDATA *gb_species = psg.data[j].gbd;199 GBDATA *gb_species = get_gbdata(); 202 200 GB_transaction ta(gb_species); 203 201 GBDATA *gb_ali = GB_entry(gb_species, psg.alignment_name); … … 210 208 } 211 209 212 /** Cache: 213 * Instead of extracting the pure sequence data and checksum from the arb 214 * database each time the pt server loads, cache this data in a separate 215 * file to regain near instant pt server startup time. 216 * 217 * The format of the file is as follows: 218 * uint32: magic 219 * uint32: version 220 * uint32: number of sequences c 221 * uint32[c]: lengths of sequences 222 * uint32[c]: checksums 223 * char[]: sequences 224 */ 225 static const uint cache_magic = 0x97CAC11E; 226 static const uint cache_version = 1; 227 228 static char* cache_mkfilename(const char *arbfile) { 229 const char* const suffix = ".ptc"; 230 char *cname = (char*)calloc(sizeof(char),strlen(arbfile)+strlen(suffix)+1); 231 sprintf(cname, "%s%s", arbfile, suffix); 232 return cname; 233 } 234 235 static int cache_load(const char* filename, const uint count) { 236 char *cname = cache_mkfilename(filename); 237 238 // get stats for arb-file 239 struct stat s_arb, s_ptc; 240 if (stat(filename,&s_arb)) { 241 perror("Unable to stat arb file! Utterly weird, I just opened it..."); 242 exit(1); 243 } 244 245 // get stats for cache-file 246 if (stat(cname, &s_ptc)) { 247 printf("Couldn't find cache file.\n"); 248 return 1; 249 } 250 251 // check that cache file is newer than arb file 252 if (s_arb.st_mtime > s_ptc.st_mtime) { 253 printf("Cachefile older than ARB file.\n"); 254 return 1; 255 } 256 257 printf("Loading data from cache:\n"); 258 259 FILE *fp = fopen(cname, "r"); 260 if (!fp) { 261 perror("Unable to open cache file."); 262 return 1; 263 } 264 free(cname); 265 266 uint rval; 267 fread(&rval, sizeof(int), 1, fp); 268 if (rval != cache_magic) { 269 printf("Cache file not a cache file!?!\n"); 270 return 1; 271 } 272 273 fread(&rval, sizeof(int), 1, fp); 274 if (rval != cache_version) { 275 printf("Cache file has wrong version"); 276 return 1; 277 } 278 279 fread(&rval, sizeof(int), 1, fp); 280 if (rval != count) { 281 printf("Unable to load cache: wrong number of sequences!\n"); 282 return 1; 283 } 284 285 int *sizes = (int*)calloc(sizeof(int), count); 286 if (fread(sizes, sizeof(int), count, fp) != count) { 287 printf("Cache file too short!"); 288 return 1; 289 } 290 291 uint *checksums = (uint*)calloc(sizeof(uint), count); 292 if (fread(checksums, sizeof(uint), count, fp) != count) { 293 printf("Cache file too short!"); 294 return 1; 295 } 296 297 ulong datasize = 0; 298 for (uint i=0; i<count; i++) { 299 psg.data[i].size = sizes[i]; 300 datasize += sizes[i]; 301 psg.data[i].checksum = checksums[i]; 302 } 303 304 free(sizes); 305 free(checksums); 306 307 char *data = (char*)calloc(sizeof(char), datasize); 308 if (fread(data, sizeof(char), datasize, fp) != datasize) { 309 printf("Cache file too short!"); 310 return 1; 311 } 312 313 for (uint i=0; i<count; i++) { 314 psg.data[i].data = data; 315 data += psg.data[i].size; 316 } 317 318 printf("done\n"); 319 320 return 0; 321 } 322 323 void cache_save(const char *filename, int count) { 324 char *cname = cache_mkfilename(filename); 325 FILE *fp = fopen(cname, "w+"); 326 if (!fp) { 327 perror("Unable to open cache file! Not saving cache."); 328 return; 329 } 330 free(cname); 331 332 printf("PT-cache: writing cache file...\n"); 333 334 fwrite(&cache_magic, sizeof(uint), 1, fp); 335 fwrite(&cache_version, sizeof(uint), 1, fp); 336 fwrite(&count, sizeof(count), 1, fp); 337 338 339 int *sizes = (int*)calloc(sizeof(int), count); 340 uint *checksums = (uint*)calloc(sizeof(uint), count); 341 for (int i=0; i<count; i++) { 342 sizes[i]=psg.data[i].size; 343 checksums[i]=psg.data[i].checksum; 344 } 345 fwrite(sizes, sizeof(int), count, fp); 346 fwrite(checksums, sizeof(uint), count, fp); 347 free(sizes); 348 free(checksums); 349 350 for (int i=0; i<count; i++) { 351 fwrite(psg.data[i].data, sizeof(char), psg.data[i].size, fp); 352 } 353 354 fclose(fp); 355 356 printf("done\n"); 357 } 358 359 void probe_read_alignments(const char* filename) { 210 char *probe_read_alignment(int j, int *psize) { 211 return psg.data[j].read_alignment(psize); 212 } 213 214 GB_ERROR probe_input_data::init(GBDATA *gb_species) { 215 GB_ERROR error = NULL; 216 GBDATA *gb_ali = GB_entry(gb_species, psg.alignment_name); 217 GBDATA *gb_data = gb_ali ? GB_entry(gb_ali, "data") : NULL; 218 219 if (!gb_data) { 220 error = GBS_global_string("Species '%s' has no data in '%s'\n", GBT_read_name(gb_species), psg.alignment_name); 221 } 222 else { 223 int hsize; 224 char *sdata = probe_read_string_append_point(gb_data, &hsize); 225 226 if (!sdata) { 227 error = GBS_global_string("Could not read data in '%s' for species '%s'\n(Reason: %s)\n", 228 psg.alignment_name, GBT_read_name(gb_species), GB_await_error()); 229 } 230 else { 231 name = strdup(GBT_read_name(gb_species)); 232 233 fullname = GBT_read_string(gb_species, "full_name"); 234 if (!fullname) fullname = strdup(""); 235 236 gbd = gb_species; 237 238 set_checksum(GB_checksum(sdata, hsize, 1, ".-")); 239 int csize = probe_compress_sequence(sdata, hsize); 240 241 set_data(GB_memdup(sdata, csize), csize); 242 free(sdata); 243 } 244 } 245 246 return error; 247 } 248 249 void probe_read_alignments(const char* /*filename*/) { 360 250 // reads sequence data into psg.data 361 251 … … 379 269 int icount = GB_number_of_subentries(psg.gb_species_data); 380 270 381 psg.data = (probe_input_data *)calloc(sizeof(probe_input_data), icount);271 psg.data = new probe_input_data[icount]; 382 272 psg.data_count = 0; 383 273 … … 388 278 arb_progress progress("Preparing sequence data", icount); 389 279 int count = 0; 390 int recache = cache_load(filename, icount);391 280 392 281 for (GBDATA *gb_species = GBT_first_species_rel_species_data(psg.gb_species_data); … … 396 285 probe_input_data& pid = psg.data[count]; 397 286 398 pid.name = strdup(GBT_read_name(gb_species)); 399 pid.fullname = GBT_read_string(gb_species, "full_name"); 400 401 if (!pid.fullname) pid.fullname = strdup(""); 402 403 pid.is_group = 1; 404 pid.gbd = gb_species; 405 406 GBDATA *gb_ali = GB_entry(gb_species, psg.alignment_name); 407 GBDATA *gb_data = gb_ali ? GB_entry(gb_ali, "data") : NULL; 408 if (!gb_data) { 409 fprintf(stderr, "Species '%s' has no data in '%s'\n", pid.name, psg.alignment_name); 287 GB_ERROR error = pid.init(gb_species); 288 if (error) { 289 fputs(error, stderr); 290 fputc('\n', stderr); 410 291 data_missing++; 411 292 } 412 else if (recache) { 413 int hsize; 414 char *data = probe_read_string_append_point(gb_data, &hsize); 415 416 if (!data) { 417 GB_ERROR error = GB_await_error(); 418 fprintf(stderr, "Could not read data in '%s' for species '%s'\n(Reason: %s)\n", 419 psg.alignment_name, pid.name, error); 420 data_missing++; 421 } 422 else { 423 if (recache) { 424 pid.checksum = GB_checksum(data, hsize, 1, ".-"); 425 int size = probe_compress_sequence(data, hsize); 426 427 pid.data = GB_memdup(data, size); 428 pid.size = size; 429 430 free(data); 431 count++; 432 } 433 } 434 435 } else { 293 else { 436 294 count++; 437 295 } … … 443 301 psg.data_count = count; 444 302 GB_commit_transaction(psg.gb_main); 445 if (recache && data_missing == 0)446 cache_save(filename, count);447 303 } 448 304 … … 456 312 } 457 313 fflush(stdout); 458 459 314 } 460 315 … … 463 318 psg.namehash = GBS_create_hash(psg.data_count, GB_MIND_CASE); 464 319 for (i=0; i<psg.data_count; i++) { 465 GBS_write_hash(psg.namehash, psg.data[i]. name, i+1);320 GBS_write_hash(psg.namehash, psg.data[i].get_name(), i+1); 466 321 } 467 322 unsigned int max_size; 468 323 max_size = 0; 469 324 for (i = 0; i < psg.data_count; i++) { // get max sequence len 470 max_size = std::max(max_size, (unsigned)(psg.data[i]. size));471 psg.char_count += psg.data[i]. size;325 max_size = std::max(max_size, (unsigned)(psg.data[i].get_size())); 326 psg.char_count += psg.data[i].get_size(); 472 327 } 473 328 psg.max_size = max_size; -
branches/dev_elmar/PROBE/PT_main.cxx
r7946 r8224 16 16 17 17 #include <arbdbt.h> 18 #include <arb_file.h> 19 #include <arb_defs.h> 18 20 #include <servercntrl.h> 19 21 #include <server.h> … … 21 23 #include <struct_man.h> 22 24 #include <ut_valgrinded.h> 25 #include <ptclean.h> 23 26 24 27 #include <unistd.h> … … 42 45 43 46 ARB_ERROR pt_init_main_struct(PT_main *, const char *filename) { // __ATTR__USERESULT 44 ARB_ERROR error = probe_read_data_base(filename );47 ARB_ERROR error = probe_read_data_base(filename, true); 45 48 if (!error) { 46 49 GB_begin_transaction(psg.gb_main); … … 67 70 // shutdown server 68 71 aisc_server_shutdown(psg.com_so); 69 PT_exit( EXIT_SUCCESS); // never returns70 return 0;72 PT_exit(); 73 exit(EXIT_SUCCESS); 71 74 } 72 75 … … 98 101 if (psg_initialized) { 99 102 if (psg.gb_main) { 100 int count = GB_number_of_subentries(psg.gb_species_data); 101 for (int i = 0; i < count; ++i) { 102 free(psg.data[i].data); 103 free(psg.data[i].name); 104 free(psg.data[i].fullname); 105 } 106 free(psg.data); 103 delete [] psg.data; 107 104 108 105 GB_close(psg.gb_main); … … 131 128 } 132 129 133 void PT_exit( int exitcode) { // goes to header: __ATTR__NORETURN130 void PT_exit() { 134 131 // unique exit point to ensure cleanup 135 132 if (aisc_main) destroy_PT_main(aisc_main); 136 133 if (psg_initialized) PT_exit_psg(); 137 134 PTM_finally_free_all_mem(); 138 exit(exitcode);139 135 } 140 136 … … 220 216 const char *map_str = GB_read_char_pntr(map_ptr_str); 221 217 222 parse_names_into_gene_struct(map_str, all_gene_structs);218 error = parse_names_into_gene_struct(map_str, all_gene_structs).deliver(); 223 219 224 220 // build indices : … … 309 305 if (update_reason) { 310 306 printf("- updating postree (Reason: %s)", update_reason); 311 char *build_cmd = GBS_global_string_copy("%s -build -D%s", exename, arbdb_name); 312 make_valgrinded_call(build_cmd); 313 error = GB_system(build_cmd); 314 free(build_cmd); 307 308 const char *build_step[] = { 309 "build_clean", 310 "build_map", 311 "build", 312 }; 313 314 for (size_t s = 0; !error && s<ARRAY_ELEMS(build_step); s++) { 315 if (s == 1 && !GB_supports_mapfile()) continue; // skip useless step 316 317 char *build_cmd = GBS_global_string_copy("%s -%s -D%s", exename, build_step[s], arbdb_name); 318 make_valgrinded_call(build_cmd); 319 error = GBK_system(build_cmd); 320 free(build_cmd); 321 } 322 315 323 if (error) error = GBS_global_string("Failed to update postree (Reason: %s)", error.deliver()); 316 324 } … … 364 372 char *pt_name = GBS_global_string_copy("%s.pt", params->db_server); 365 373 366 if (strcmp(command, "-build") == 0) { // build command 374 if (strcmp(command, "-build_clean") == 0) { // cleanup source DB 375 error = probe_read_data_base(params->db_server, false); 376 if (!error) { 377 pt_assert(psg.gb_main); 378 error = prepare_ptserver_database(psg.gb_main, PTSERVER); 379 if (!error) { 380 const char *mode = "bf"; // save PT-server database withOUT! Fastload file 381 error = GB_save_as(psg.gb_main, params->db_server, mode); 382 } 383 } 384 } 385 else if (strcmp(command, "-build_map") == 0) { // create a clean mapfile for source DB 386 if (GB_supports_mapfile()) { 387 error = probe_read_data_base(params->db_server, false); 388 if (!error) { 389 pt_assert(psg.gb_main); 390 const char *mode = "bfm"; // save PT-server database with Fastload file 391 error = GB_save_as(psg.gb_main, params->db_server, mode); 392 } 393 } 394 else { 395 error = "Invalid invocation of -build_map (your ARB version does not support mapfiles)"; 396 } 397 } 398 else if (strcmp(command, "-build") == 0) { // build command 367 399 error = pt_init_main_struct(aisc_main, params->db_server); 368 400 if (error) error = GBS_global_string("Gave up (Reason: %s)", error.deliver()); … … 477 509 478 510 free_arb_params(params); 479 PT_exit(exitcode); 480 } 511 PT_exit(); 512 return exitcode; 513 } -
branches/dev_elmar/PROBE/PT_match.cxx
r7999 r8224 67 67 pos = matchLoc.rpos+psg.height; 68 68 height = psg.height; 69 while ((base=probe[height]) && (ref = psg.data[matchLoc.name]. data[pos])) {69 while ((base=probe[height]) && (ref = psg.data[matchLoc.name].get_data()[pos])) { 70 70 if (ref == PT_N || base == PT_N) { 71 71 // @@@ Warning: dupped code also counts PT_QU as mismatch! … … 124 124 int base; 125 125 int error; 126 int name, pos, rpos;127 126 PT_probematch *ml; 128 127 … … 135 134 } 136 135 if (PT_read_type(pt) == PT_NT_LEAF) { 137 name = PT_read_name(psg.ptmain, pt); 138 pos = PT_read_apos(psg.ptmain, pt); 139 rpos = PT_read_rpos(psg.ptmain, pt); 136 DataLoc loc(pt); 140 137 141 138 // @@@ dupped code from PT_store_match_in::operator() 142 139 ml = create_PT_probematch(); 143 140 144 ml->name = name;145 ml->b_pos = pos;141 ml->name = loc.name; 142 ml->b_pos = loc.apos; 146 143 ml->g_pos = -1; 147 ml->rpos = rpos;144 ml->rpos = loc.rpos; 148 145 ml->mismatches = psg.mismatches; 149 146 ml->wmismatches = psg.wmismatches; … … 158 155 if (PT_read_type(pt) == PT_NT_CHAIN) { 159 156 psg.probe = 0; 160 if (PT_forwhole_chain(p sg.ptmain, pt, PT_store_match_in(locs))) {157 if (PT_forwhole_chain(pt, PT_store_match_in(locs))) { 161 158 error = 1; 162 159 return 1; … … 165 162 else { 166 163 for (base = PT_QU; base< PT_B_MAX; base++) { 167 error = read_names_and_pos(locs, PT_read_son(p sg.ptmain, pt, (PT_BASES)base));164 error = read_names_and_pos(locs, PT_read_son(pt, (PT_BASES)base)); 168 165 if (error) return error; 169 166 } … … 197 194 if (PT_read_type(pt) == PT_NT_NODE && probe[height]) { 198 195 for (i=PT_N; i<PT_B_MAX; i++) { 199 if ((pthelp = PT_read_son(p sg.ptmain, pt, (PT_BASES)i))) {196 if ((pthelp = PT_read_son(pt, (PT_BASES)i))) { 200 197 new_N_mis = N_mismatches; 201 198 base = probe[height]; … … 232 229 // @@@ code here is duplicate of code in PT_store_match_in::operator() 233 230 234 pos = PT_read_rpos(psg.ptmain, pt) + height; 235 name = PT_read_name(psg.ptmain, pt); 231 DataLoc loc(pt); 232 pos = loc.rpos + height; 233 name = loc.name; 236 234 237 235 // @@@ recursive use of strlen with constant result (argh!) 238 if (pos + (int)(strlen(probe+height)) >= psg.data[name]. size) // end of sequence236 if (pos + (int)(strlen(probe+height)) >= psg.data[name].get_size()) // end of sequence 239 237 return 0; 240 238 241 239 while ((base = probe[height])) { 242 i = psg.data[name]. data[pos];240 i = psg.data[name].get_data()[pos]; 243 241 if (i == PT_N || base == PT_N || i == PT_QU || base == PT_QU) { 244 242 psg.N_mismatches = psg.N_mismatches + 1; … … 260 258 psg.probe = probe; 261 259 psg.height = height; 262 PT_forwhole_chain(p sg.ptmain, pt, PT_store_match_in(locs)); // @@@ why ignore result260 PT_forwhole_chain(pt, PT_store_match_in(locs)); // @@@ why ignore result 263 261 return 0; 264 262 } … … 444 442 pt_build_pos_to_weight((PT_MATCH_TYPE)locs->sort_by, probestring); 445 443 446 if (psg.deep >= 0) { 447 get_info_about_probe(locs, probestring, psg.pt, 0, 0.0, 0, 0); 448 } 449 else { 450 ptnd_new_match(locs, probestring); 451 } 444 pt_assert(psg.deep >= 0); // deep < 0 was used till [8011] to trigger "new match" (feature unused) 445 get_info_about_probe(locs, probestring, psg.pt, 0, 0.0, 0, 0); 446 452 447 if (locs->pm_reversed) { 453 448 psg.reversed = 1; 454 rev_pro = reverse_probe(probestring, 0);449 rev_pro = reverse_probe(probestring, 0); 455 450 complement_probe(rev_pro, 0); 456 451 freeset(locs->pm_csequence, psg.main_probe = strdup(rev_pro)); 457 if (psg.deep >= 0) { 458 get_info_about_probe(locs, rev_pro, psg.pt, 0, 0.0, 0, 0); 459 } 460 else { 461 ptnd_new_match(locs, rev_pro); 462 } 452 453 get_info_about_probe(locs, rev_pro, psg.pt, 0, 0.0, 0, 0); 463 454 free(rev_pro); 464 455 } … … 564 555 pr_pos--, al_pos--) 565 556 { 566 if (!psg.data[ml->name]. data[al_pos]) break;567 ref[pr_pos] = psg.data[ml->name]. data[al_pos];557 if (!psg.data[ml->name].get_data()[al_pos]) break; 558 ref[pr_pos] = psg.data[ml->name].get_data()[al_pos]; 568 559 } 569 560 ref[9] = '-'; … … 572 563 573 564 for (int pr_pos = 0, al_pos = ml->rpos; 574 pr_pos < pr_len && al_pos < psg.data[ml->name]. size;565 pr_pos < pr_len && al_pos < psg.data[ml->name].get_size(); 575 566 pr_pos++, al_pos++) 576 567 { 577 568 int a = ml->sequence[pr_pos]; 578 int b = psg.data[ml->name]. data[al_pos];569 int b = psg.data[ml->name].get_data()[al_pos]; 579 570 if (a == b) { 580 571 ref[pr_pos+10] = '='; … … 593 584 594 585 for (int pr_pos = 0, al_pos = ml->rpos+pr_len; 595 pr_pos < 9 && al_pos < psg.data[ml->name]. size;586 pr_pos < 9 && al_pos < psg.data[ml->name].get_size(); 596 587 pr_pos++, al_pos++) 597 588 { 598 ref[pr_pos+11+pr_len] = psg.data[ml->name]. data[al_pos];589 ref[pr_pos+11+pr_len] = psg.data[ml->name].get_data()[al_pos]; 599 590 } 600 591 ref[10+pr_len] = '-'; … … 605 596 606 597 const char* get_match_acc(PT_probematch *ml) { 598 /* 607 599 GB_transaction trans(psg.gb_main); 608 600 GBDATA *gbd = GB_entry(psg.data[ml->name].gbd, "acc"); … … 610 602 return GB_read_char_pntr(gbd); 611 603 } 604 */ 612 605 return 0; 613 606 } 614 607 int get_match_start(PT_probematch *ml) { 608 /* 615 609 GB_transaction trans(psg.gb_main); 616 610 GBDATA *gbd = GB_entry(psg.data[ml->name].gbd, "start"); … … 618 612 return GB_read_int(gbd); 619 613 } 614 */ 620 615 return 0; 621 616 } 622 617 int get_match_stop(PT_probematch *ml) { 618 /* 623 619 GB_transaction trans(psg.gb_main); 624 620 GBDATA *gbd = GB_entry(psg.data[ml->name].gbd, "stop"); … … 626 622 return GB_read_int(gbd); 627 623 } 624 */ 628 625 return 0; 629 626 } … … 709 706 710 707 for (; ml; ml = ml->next) { 711 probe_input_data& pid = psg.data[ml->name]; 712 GBDATA *gb_pos = GB_entry(pid.gbd, "abspos"); 713 714 if (gb_pos) { 715 long gene_pos = GB_read_int(gb_pos); 716 ml->g_pos = ml->b_pos; 717 ml->b_pos += gene_pos; 708 long gene_pos = psg.data[ml->name].get_abspos(); 709 if (gene_pos >= 0) { 710 ml->g_pos = ml->b_pos; 711 ml->b_pos += gene_pos; 718 712 } 719 713 else { 720 714 fprintf(stderr, "Error in gene-pt-server: gene w/o position info\n"); 721 pt_assert( gb_pos);715 pt_assert(0); 722 716 } 723 717 } … … 821 815 for (i = 0; i < psg.data_count; i++) 822 816 { 823 GBS_strcat(memfile, psg.data[i]. name);817 GBS_strcat(memfile, psg.data[i].get_name()); 824 818 GBS_chrcat(memfile, (char)1); 825 819 } -
branches/dev_elmar/PROBE/PT_new_design.cxx
r7945 r8224 54 54 } 55 55 } 56 struct ptnd_loop_com { 56 57 static struct ptnd_loop_com { 57 58 PT_pdc *pdc; 58 59 PT_local *locs; 59 60 PT_probeparts *parts; 60 61 int mishits; 61 int new_match; // match or design the probe: 1 match 0 design62 62 double sum_bonds; // sum of bond of longest non mismatch string 63 63 double dt; // sum of mismatches … … 193 193 // count all mishits for a probe 194 194 195 // @@@ dupped code is in ptnd_count_mishits and ptnd_count_mishits2196 195 char *probe = psg.probe; 197 196 psg.abs_pos.announce(probeLoc.apos); … … 199 198 const probe_input_data& pid = psg.data[probeLoc.name]; 200 199 201 if (pid.is_group) return 0; // don't count group or neverminds 202 if (probe) { 203 int rpos = probeLoc.rpos + psg.height; 204 while (*probe && pid.data[rpos]) { 205 if (pid.data[rpos] != *(probe)) return 0; 206 probe++; 207 rpos++; 208 } 209 } 210 ptnd.mishits++; 200 if (pid.outside_group()) { 201 if (probe) { 202 int rpos = probeLoc.rpos + psg.height; 203 while (*probe && pid.get_data()[rpos]) { 204 if (pid.get_data()[rpos] != *(probe)) return 0; 205 probe++; 206 rpos++; 207 } 208 } 209 ptnd.mishits++; 210 } 211 211 return 0; 212 212 } … … 215 215 static int ptnd_count_mishits2(POS_TREE *pt) { 216 216 //! go down the tree to chains and leafs; count the species that are in the non member group 217 int base;218 int name;219 int mishits = 0;220 221 217 if (pt == NULL) 222 218 return 0; 219 223 220 if (PT_read_type(pt) == PT_NT_LEAF) { 224 name = PT_read_name(psg.ptmain, pt); 225 int apos = PT_read_apos(psg.ptmain, pt); 226 227 // @@@ dupped code from ptnd_chain_count_mishits::operator(): 228 psg.abs_pos.announce(apos); 229 if (!psg.data[name].is_group) return 1; 230 return 0; 231 } 232 else if (PT_read_type(pt) == PT_NT_CHAIN) { 221 DataLoc loc(pt); 222 psg.abs_pos.announce(loc.apos); 223 return psg.data[loc.name].outside_group(); 224 } 225 226 if (PT_read_type(pt) == PT_NT_CHAIN) { 233 227 psg.probe = 0; 234 228 ptnd.mishits = 0; 235 PT_forwhole_chain(p sg.ptmain, pt, ptnd_chain_count_mishits());229 PT_forwhole_chain(pt, ptnd_chain_count_mishits()); 236 230 return ptnd.mishits; 237 231 } 238 else {239 for (base = PT_QU; base< PT_B_MAX; base++) {240 mishits += ptnd_count_mishits2(PT_read_son(psg.ptmain, pt, (PT_BASES)base));241 }242 return mishits;243 }232 233 int mishits = 0; 234 for (int base = PT_QU; base< PT_B_MAX; base++) { 235 mishits += ptnd_count_mishits2(PT_read_son(pt, (PT_BASES)base)); 236 } 237 return mishits; 244 238 } 245 239 … … 409 403 static int ptnd_count_mishits(char *probe, POS_TREE *pt, int height) { 410 404 //! search down the tree to find matching species for the given probe 411 int name;412 405 int i; 413 406 POS_TREE *pthelp; 414 int pos;415 407 int mishits; 416 408 … … 420 412 for (i=PT_A; i<PT_B_MAX; i++) { 421 413 if (i != *probe) continue; 422 if ((pthelp = PT_read_son(p sg.ptmain, pt, (PT_BASES)i)))414 if ((pthelp = PT_read_son(pt, (PT_BASES)i))) 423 415 mishits += ptnd_count_mishits(probe+1, pthelp, height+1); 424 416 } … … 427 419 if (*probe) { 428 420 if (PT_read_type(pt) == PT_NT_LEAF) { 429 pos = PT_read_rpos(psg.ptmain, pt) + height; 430 name = PT_read_name(psg.ptmain, pt); 431 432 // @@@ dupped code from ptnd_chain_count_mishits::operator() 433 if (pos + (int)(strlen(probe)) >= psg.data[name].size) // after end 421 const DataLoc loc(pt); 422 int pos = loc.rpos+height; 423 424 if (pos + (int)(strlen(probe)) >= psg.data[loc.name].get_size()) // after end 434 425 return 0; 435 426 436 427 while (*probe) { 437 if (psg.data[ name].data[pos++] != *(probe++))428 if (psg.data[loc.name].get_data()[pos++] != *(probe++)) 438 429 return 0; 439 430 } … … 443 434 psg.height = height; 444 435 ptnd.mishits = 0; 445 PT_forwhole_chain(p sg.ptmain, pt, ptnd_chain_count_mishits());436 PT_forwhole_chain(pt, ptnd_chain_count_mishits()); 446 437 return ptnd.mishits; 447 438 } … … 482 473 } 483 474 484 static void ptnd_check_bonds(PT_pdc *pdc , int match) {475 static void ptnd_check_bonds(PT_pdc *pdc) { 485 476 /*! check the average bond size. 486 477 * … … 501 492 tprobe->sum_bonds = sbond; 502 493 } 503 match = match;504 494 } 505 495 … … 628 618 } 629 619 630 static void ptnd_check_part_inc_dt(PT_pdc *pdc, PT_probeparts *parts, 631 const DataLoc& matchLoc, 632 double dt, double sum_bonds) 633 { 620 static void ptnd_check_part_inc_dt(PT_pdc *pdc, PT_probeparts *parts, const DataLoc& matchLoc, double dt, double sum_bonds) { 634 621 //! test the probe parts, search the longest non mismatch string 635 622 … … 649 636 while (start>=0) { 650 637 if (pos<0) break; // out of sight 651 h = ptnd_check_split(ptnd.pdc, probe, start, psg.data[matchLoc.name]. data[pos]);638 h = ptnd_check_split(ptnd.pdc, probe, start, psg.data[matchLoc.name].get_data()[pos]); 652 639 if (h>0.0 && !split) return; // there is a longer part matching this 653 640 dt -= h; … … 664 651 if (pos >= PERC_SIZE) return; // out of observation 665 652 tprobe->perc[pos] ++; 666 if (ptnd.new_match) { // save the result in probematch667 PT_probematch *match;668 if (psg.data[matchLoc.name].match) {669 if (psg.data[matchLoc.name].match->dt < ndt) return;670 // there is a better hit for that sequence671 match = psg.data[matchLoc.name].match;672 }673 else {674 match = create_PT_probematch();675 aisc_link(&ptnd.locs->ppm, match);676 psg.data[matchLoc.name].match = match;677 }678 match->name = matchLoc.name;679 match->b_pos = matchLoc.apos - parts->start; // that's not correct !!!680 match->rpos = matchLoc.rpos-parts->start;681 match->N_mismatches = -1; // there are no mismatches in this mode682 match->mismatches = -1;683 match->wmismatches = dt; // only weighted mismatches (maybe)684 match->dt = ndt;685 match->sequence = psg.main_probe;686 match->reversed = psg.reversed;687 }688 653 } 689 654 static int ptnd_check_inc_mode(PT_pdc *pdc, PT_probeparts *parts, double dt, double sum_bonds) … … 705 670 706 671 int operator() (const DataLoc& partLoc) { 707 char *probe = psg.probe; 708 int height = psg.height; 709 double sbond = ptnd.sum_bonds; 710 double dt = ptnd.dt; 711 double h = 1.0; 712 int pos; 713 int base; 714 715 if (!ptnd.new_match && psg.data[partLoc.name].is_group) return 0; // don't count group or neverminds 716 if (probe) { 717 pos = partLoc.rpos+psg.height; 718 while (probe[height] && (base = psg.data[partLoc.name].data[pos])) { 719 if (!split && (h = ptnd_check_split(ptnd.pdc, probe, height, base) < 0.0)) { 720 dt -= h; 721 split = 1; 672 if (psg.data[partLoc.name].outside_group()) { 673 char *probe = psg.probe; 674 int height = psg.height; 675 double sbond = ptnd.sum_bonds; 676 double dt = ptnd.dt; 677 double h = 1.0; 678 int pos; 679 int base; 680 681 if (probe) { 682 pos = partLoc.rpos+psg.height; 683 while (probe[height] && (base = psg.data[partLoc.name].get_data()[pos])) { 684 if (!split && (h = ptnd_check_split(ptnd.pdc, probe, height, base) < 0.0)) { 685 dt -= h; 686 split = 1; 687 } 688 else { 689 dt += h; 690 sbond += ptnd_check_max_bond(ptnd.pdc, probe[height]) - h; 691 } 692 height++; pos++; 722 693 } 723 else { 724 dt += h; 725 sbond += ptnd_check_max_bond(ptnd.pdc, probe[height]) - h; 726 } 727 height++; pos++; 728 } 729 } 730 ptnd_check_part_inc_dt(ptnd.pdc, ptnd.parts, partLoc, dt, sbond); 694 } 695 ptnd_check_part_inc_dt(ptnd.pdc, ptnd.parts, partLoc, dt, sbond); 696 } 731 697 return 0; 732 698 } … … 739 705 740 706 int base; 741 int name, apos, rpos;742 743 707 if (pt == NULL) 744 708 return; 745 709 if (PT_read_type(pt) == PT_NT_LEAF) { 746 710 // @@@ dupped code is in ptnd_chain_check_part::operator() 747 name = PT_read_name(psg.ptmain, pt); 748 if (!ptnd.new_match && psg.data[name].is_group) return; 749 rpos = PT_read_rpos(psg.ptmain, pt); 750 apos = PT_read_apos(psg.ptmain, pt); 751 ptnd_check_part_inc_dt(ptnd.pdc, ptnd.parts, DataLoc(name, apos, rpos), dt, sum_bonds); 711 DataLoc loc(pt); 712 if (psg.data[loc.name].outside_group()) { 713 ptnd_check_part_inc_dt(ptnd.pdc, ptnd.parts, loc, dt, sum_bonds); 714 } 752 715 } 753 716 else if (PT_read_type(pt) == PT_NT_CHAIN) { … … 755 718 ptnd.dt = dt; 756 719 ptnd.sum_bonds = sum_bonds; 757 PT_forwhole_chain(p sg.ptmain, pt, ptnd_chain_check_part(0));720 PT_forwhole_chain(pt, ptnd_chain_check_part(0)); 758 721 } 759 722 else { 760 723 for (base = PT_QU; base< PT_B_MAX; base++) { 761 ptnd_check_part_all(PT_read_son(p sg.ptmain, pt, (PT_BASES)base), dt, sum_bonds);724 ptnd_check_part_all(PT_read_son(pt, (PT_BASES)base), dt, sum_bonds); 762 725 } 763 726 } … … 765 728 static void ptnd_check_part(char *probe, POS_TREE *pt, int height, double dt, double sum_bonds, int split) { 766 729 //! search down the tree to find matching species for the given probe 767 int name;730 int pos; 768 731 int i; 769 732 POS_TREE *pthelp; 770 int rpos, apos, pos;771 733 double ndt, nsum_bonds, h; 772 734 int nsplit; … … 778 740 if (split && ptnd_check_inc_mode(ptnd.pdc, ptnd.parts, dt, sum_bonds)) return; 779 741 for (i=PT_A; i<PT_B_MAX; i++) { 780 if ((pthelp = PT_read_son(p sg.ptmain, pt, (PT_BASES)i)))742 if ((pthelp = PT_read_son(pt, (PT_BASES)i))) 781 743 { 782 744 nsplit = split; … … 810 772 if (PT_read_type(pt) == PT_NT_LEAF) { 811 773 // @@@ dupped code is in ptnd_chain_check_part::operator() 812 name = PT_read_name(psg.ptmain, pt); 813 if (!ptnd.new_match && psg.data[name].is_group) return; 814 rpos = PT_read_rpos(psg.ptmain, pt); 815 apos = PT_read_apos(psg.ptmain, pt); 816 pos = rpos + height; 817 if (pos + (int)(strlen(probe+height)) >= psg.data[name].size) // after end 818 return; 819 while (probe[height] && (ref = psg.data[name].data[pos])) { 820 if (split) { 821 h = ptnd_check_split(ptnd.pdc, probe, height, ref); 822 if (h<0.0) dt -= h; else dt += h; 823 } else if ((h = ptnd_check_split(ptnd.pdc, probe, height, 824 ref)) < 0.0) { 825 dt -= h; 826 split = 1; 774 const DataLoc loc(pt); 775 if (psg.data[loc.name].outside_group()) { 776 pos = loc.rpos + height; 777 if (pos + (int)(strlen(probe+height)) >= psg.data[loc.name].get_size()) // after end 778 return; 779 while (probe[height] && (ref = psg.data[loc.name].get_data()[pos])) { 780 if (split) { 781 h = ptnd_check_split(ptnd.pdc, probe, height, ref); 782 if (h<0.0) dt -= h; else dt += h; 783 } 784 else if ((h = ptnd_check_split(ptnd.pdc, probe, height, ref)) < 0.0) { 785 dt -= h; 786 split = 1; 787 } 788 else { 789 dt += h; 790 sum_bonds += ptnd_check_max_bond(ptnd.pdc, probe[height]) - h; 791 } 792 height++; pos++; 827 793 } 828 else { 829 dt += h; 830 sum_bonds += ptnd_check_max_bond(ptnd.pdc, probe[height]) - h; 831 } 832 height++; pos++; 833 } 834 ptnd_check_part_inc_dt(ptnd.pdc, ptnd.parts, DataLoc(name, apos, rpos), dt, sum_bonds); 794 ptnd_check_part_inc_dt(ptnd.pdc, ptnd.parts, loc, dt, sum_bonds); 795 } 835 796 return; 836 797 } … … 840 801 ptnd.dt = dt; 841 802 ptnd.sum_bonds = sum_bonds; 842 PT_forwhole_chain(p sg.ptmain, pt, ptnd_chain_check_part(split));803 PT_forwhole_chain(pt, ptnd_chain_check_part(split)); 843 804 return; 844 805 } … … 895 856 } 896 857 897 inline void PT_incr_hash(GB_HASH *hash, c har *sequence, int len) {858 inline void PT_incr_hash(GB_HASH *hash, const char *sequence, int len) { 898 859 char c = sequence[len]; 899 sequence[len] = 0;860 const_cast<char*>(sequence)[len] = 0; 900 861 901 862 pt_assert(strlen(sequence) == (size_t)len); … … 903 864 GBS_incr_hash(hash, sequence); 904 865 905 sequence[len] = c;906 } 907 908 static void ptnd_add_sequence_to_hash(PT_pdc *pdc, GB_HASH *hash, c har *sequence, int seq_len, int probe_len, char *prefix, int prefix_len) {866 const_cast<char*>(sequence)[len] = c; 867 } 868 869 static void ptnd_add_sequence_to_hash(PT_pdc *pdc, GB_HASH *hash, const char *sequence, int seq_len, int probe_len, char *prefix, int prefix_len) { 909 870 int pos; 910 871 if (*prefix) { // partition search, else very large hash tables (>60 mbytes) … … 946 907 int used_idx = 0; 947 908 for (int name = 0; name < psg.data_count; name++) { 948 if (psg.data[name].i s_group == 1) {909 if (psg.data[name].inside_group()) { 949 910 group_idx[used_idx++] = name; // store marked group indices 950 unsigned long size = psg.data[name]. size;911 unsigned long size = psg.data[name].get_size(); 951 912 datasize += size; 952 913 if (datasize<size) datasize = ULONG_MAX; // avoid overflow! … … 1002 963 for (int g = 0; g<group_count; ++g) { 1003 964 int name = group_idx[g]; 1004 long possible_tprobes = psg.data[name]. size-pdc->probelen+1;965 long possible_tprobes = psg.data[name].get_size()-pdc->probelen+1; 1005 966 GB_HASH *hash_one = GBS_create_hash(possible_tprobes*hash_multiply, GB_MIND_CASE); // count tprobe occurrences for one group/sequence 1006 ptnd_add_sequence_to_hash(pdc, hash_one, psg.data[name]. data, psg.data[name].size, pdc->probelen, partstring, partsize);967 ptnd_add_sequence_to_hash(pdc, hash_one, psg.data[name].get_data(), psg.data[name].get_size(), pdc->probelen, partstring, partsize); 1007 968 GBS_hash_do_loop(hash_one, ptnd_collect_hash, hash_outer); // merge hash_one into hash 1008 969 #if defined(DEBUG) … … 1049 1010 // IDP probe design 1050 1011 1051 PT_local *locs = (PT_local*)pdc->mh.parent->parent;1052 ptnd.new_match = 0; 1053 ptnd.locs = locs;1054 ptnd.pdc = pdc;1012 PT_local *locs = (PT_local*)pdc->mh.parent->parent; 1013 1014 ptnd.locs = locs; 1015 ptnd.pdc = pdc; 1055 1016 1056 1017 const char *error; … … 1083 1044 ptnd_first_check(pdc); 1084 1045 ptnd_check_position(pdc); 1085 ptnd_check_bonds(pdc , ptnd.new_match);1046 ptnd_check_bonds(pdc); 1086 1047 ptnd_cp_tprobe_2_probepart(pdc); 1087 1048 ptnd_duplicate_probepart(pdc); … … 1097 1058 } 1098 1059 1099 void ptnd_new_match(PT_local * locs, char *probestring)1100 {1101 PT_pdc *pdc = locs->pdc;1102 PT_tprobes *tprobe;1103 1104 ptnd.locs = locs;1105 ptnd.pdc = pdc;1106 ptnd.new_match = 1;1107 1108 if (!pdc) return; // no config1109 1110 tprobe = create_PT_tprobes();1111 tprobe->sequence = strdup(probestring);1112 1113 aisc_link(&pdc->ptprobes, tprobe);1114 ptnd_check_bonds(pdc, ptnd.new_match);1115 ptnd_cp_tprobe_2_probepart(pdc);1116 ptnd_duplicate_probepart(pdc);1117 ptnd_sort_parts(pdc);1118 ptnd_remove_duplicated_probepart(pdc);1119 ptnd_check_probepart(pdc);1120 1121 while (pdc->parts) destroy_PT_probeparts(pdc->parts);1122 while ((tprobe = pdc->tprobes)) destroy_PT_tprobes(tprobe);1123 } -
branches/dev_elmar/PROBE/PT_prefixtree.cxx
r7945 r8224 12 12 #include "probe_tree.h" 13 13 #include "pt_prototypes.h" 14 15 #include <arb_file.h> 14 16 15 17 #include <sys/types.h> … … 204 206 } 205 207 206 POS_TREE *PT_add_to_chain(PTM2 *ptmain, POS_TREE *node, int name, int apos, int rpos) // stage1 207 { // insert at the beginning of list 208 static char buffer[100]; 208 POS_TREE *PT_add_to_chain(POS_TREE *node, const DataLoc& loc) { // stage1 209 // insert at the beginning of list 210 211 char *data = (&node->data) + psg.ptmain->mode; 212 data += (node->flags&1) ? 4 : 2; 213 209 214 unsigned long old_first; 210 char *data;211 int mainapos; // TODO: mainapos isn't used212 data = (&node->data) + ptmain->mode;213 if (node->flags&1) {214 PT_READ_INT(data, mainapos);215 data += 4;216 }217 else {218 PT_READ_SHORT(data, mainapos);219 data += 2;220 }221 215 PT_READ_PNTR(data, old_first); // create a new list element 222 char *p; 223 p = buffer; 216 217 static char buffer[100]; 218 char *p = buffer; 219 224 220 PT_WRITE_PNTR(p, old_first); 225 221 p += sizeof(PT_PNTR); 226 PT_WRITE_NAT(p, name); 227 PT_WRITE_NAT(p, rpos); 228 PT_WRITE_NAT(p, apos); 222 223 PT_WRITE_NAT(p, loc.name); 224 PT_WRITE_NAT(p, loc.rpos); 225 PT_WRITE_NAT(p, loc.apos); 226 229 227 int size = p - buffer; 230 p = (char *)PTM_get_mem(size);228 p = (char *)PTM_get_mem(size); 231 229 memcpy(p, buffer, size); 232 230 PT_WRITE_PNTR(data, p); … … 235 233 } 236 234 237 238 POS_TREE *PT_change_leaf_to_node(PTM2 * /* ptmain */, POS_TREE *node) // stage 1 239 { 235 POS_TREE *PT_change_leaf_to_node(POS_TREE *node) { // stage 1 236 if (PT_GET_TYPE(node) != PT_NT_LEAF) PT_CORE; 237 240 238 long i; 241 POS_TREE *father, *new_elem;242 if (PT_GET_TYPE(node) != PT_NT_LEAF) PT_CORE;243 239 PT_READ_PNTR((&node->data), i); 244 father=(POS_TREE *)i; 245 new_elem = (POS_TREE *)PTM_get_mem(PT_EMPTY_NODE_SIZE); 240 241 POS_TREE *father = (POS_TREE *)i; 242 POS_TREE *new_elem = (POS_TREE *)PTM_get_mem(PT_EMPTY_NODE_SIZE); 246 243 if (father) PT_change_father(father, node, new_elem); 247 244 PTM_free_mem((char *)node, PT_LEAF_SIZE(node)); 248 245 PT_SET_TYPE(new_elem, PT_NT_NODE, 0); 249 246 PT_WRITE_PNTR((&(new_elem->data)), (long)father); 247 250 248 return new_elem; 251 249 } 252 250 253 POS_TREE *PT_leaf_to_chain(PTM2 *ptmain, POS_TREE *node) // stage 1 254 { 251 POS_TREE *PT_leaf_to_chain(POS_TREE *node) { // stage 1 252 if (PT_GET_TYPE(node) != PT_NT_LEAF) PT_CORE; 253 255 254 long i; 256 int apos, rpos, name;257 POS_TREE *father, *new_elem;258 int chain_size;259 char *data;260 if (PT_GET_TYPE(node) != PT_NT_LEAF) PT_CORE;261 255 PT_READ_PNTR((&node->data), i); 262 father=(POS_TREE *)i; 263 name = PT_read_name(ptmain, node); // backup name,264 apos = PT_read_apos(ptmain, node); // apos,265 rpos = PT_read_rpos(ptmain, node); // rpos 266 chain_size= PT_EMPTY_CHAIN_SIZE;267 if ( apos>PT_SHORT_SIZE) chain_size+=2;268 269 new_elem = (POS_TREE *)PTM_get_mem(chain_size);256 257 POS_TREE *father = (POS_TREE *)i; 258 const DataLoc loc(node); 259 260 int chain_size = PT_EMPTY_CHAIN_SIZE; 261 if (loc.apos>PT_SHORT_SIZE) chain_size += 2; 262 263 POS_TREE *new_elem = (POS_TREE *)PTM_get_mem(chain_size); 270 264 PT_change_father(father, node, new_elem); 271 265 PTM_free_mem((char *)node, PT_LEAF_SIZE(node)); 272 266 PT_SET_TYPE(new_elem, PT_NT_CHAIN, 0); 273 PT_WRITE_PNTR((&new_elem->data), (long)father); // father 274 data = (&new_elem->data)+sizeof(PT_PNTR); 275 if (apos>PT_SHORT_SIZE) { // mainapos 276 PT_WRITE_INT(data, apos); // . 277 data+=4; new_elem->flags|=1; // . 278 } 279 else { // . 280 PT_WRITE_SHORT(data, apos); // . 281 data+=2; // . 282 } 283 PT_WRITE_PNTR(data, NULL); // first element 284 PT_add_to_chain(ptmain, new_elem, name, apos, rpos); 267 PT_WRITE_PNTR((&new_elem->data), (long)father); 268 269 char *data = (&new_elem->data)+sizeof(PT_PNTR); 270 if (loc.apos>PT_SHORT_SIZE) { 271 PT_WRITE_INT(data, loc.apos); 272 data+=4; 273 new_elem->flags|=1; 274 } 275 else { 276 PT_WRITE_SHORT(data, loc.apos); 277 data+=2; 278 } 279 PT_WRITE_PNTR(data, NULL); 280 PT_add_to_chain(new_elem, loc); 281 285 282 return new_elem; 286 283 } 287 284 288 POS_TREE * 289 PT_create_leaf(PTM2 *ptmain, POS_TREE ** pfather, PT_BASES base, int rpos, int apos, int name) // stage 1 290 { 291 POS_TREE *father, *node, *new_elemfather; 292 int base2; 293 int leafsize; 294 char *dest; 285 POS_TREE *PT_create_leaf(POS_TREE ** pfather, PT_BASES base, const DataLoc& loc) { // stage 1 286 POS_TREE *father, *node, *new_elemfather; 287 int base2; 288 int leafsize; 289 char *dest; 295 290 leafsize = PT_EMPTY_LEAF_SIZE; 296 if (rpos>PT_SHORT_SIZE) leafsize+=2; 297 if (apos>PT_SHORT_SIZE) leafsize+=2; 298 if (name>PT_SHORT_SIZE) leafsize+=2; 299 node = (POS_TREE *) PTM_get_mem(leafsize); 291 292 if (loc.rpos>PT_SHORT_SIZE) leafsize += 2; 293 if (loc.apos>PT_SHORT_SIZE) leafsize += 2; 294 if (loc.name>PT_SHORT_SIZE) leafsize += 2; 295 node = (POS_TREE *) PTM_get_mem(leafsize); 300 296 if (base >= PT_B_MAX) 301 *(int *) 0 = 0;297 *(int *) 0 = 0; 302 298 if (pfather) { 303 299 int oldfathersize; … … 341 337 PT_SET_TYPE(node, PT_NT_LEAF, 0); 342 338 dest = (&node->data) + sizeof(PT_PNTR); 343 if ( name>PT_SHORT_SIZE) {344 PT_WRITE_INT(dest, name);339 if (loc.name>PT_SHORT_SIZE) { 340 PT_WRITE_INT(dest, loc.name); 345 341 node->flags |= 1; 346 342 dest += 4; 347 343 } 348 344 else { 349 PT_WRITE_SHORT(dest, name);345 PT_WRITE_SHORT(dest, loc.name); 350 346 dest += 2; 351 347 } 352 if ( rpos>PT_SHORT_SIZE) {353 PT_WRITE_INT(dest, rpos);348 if (loc.rpos>PT_SHORT_SIZE) { 349 PT_WRITE_INT(dest, loc.rpos); 354 350 node->flags |= 2; 355 351 dest += 4; 356 352 } 357 353 else { 358 PT_WRITE_SHORT(dest, rpos);354 PT_WRITE_SHORT(dest, loc.rpos); 359 355 dest += 2; 360 356 } 361 if ( apos>PT_SHORT_SIZE) {362 PT_WRITE_INT(dest, apos);357 if (loc.apos>PT_SHORT_SIZE) { 358 PT_WRITE_INT(dest, loc.apos); 363 359 node->flags |= 4; 364 360 dest += 4; 365 361 } 366 362 else { 367 PT_WRITE_SHORT(dest, apos);363 PT_WRITE_SHORT(dest, loc.apos); 368 364 dest += 2; 369 365 } 370 366 if (base == PT_QU) 371 return PT_leaf_to_chain( ptmain,node);367 return PT_leaf_to_chain(node); 372 368 return node; 373 369 } 374 375 370 376 371 // ------------------------------------ 377 372 // functions for stage 1: save 378 373 379 void PTD_clear_fathers(PTM2 *ptmain, POS_TREE * node) // stage 1 380 { 381 POS_TREE *sons; 382 int i; 383 PT_NODE_TYPE type = PT_read_type(node); 384 if (type == PT_NT_SAVED) return; 385 PT_WRITE_PNTR((&node->data), NULL); 386 if (type == PT_NT_NODE) { 387 for (i = PT_QU; i < PT_B_MAX; i++) { 388 sons = PT_read_son(ptmain, node, (PT_BASES)i); 389 if (sons) 390 PTD_clear_fathers(ptmain, sons); 374 void PTD_clear_fathers(POS_TREE * node) { // stage 1 375 PT_NODE_TYPE type = PT_read_type(node); 376 if (type != PT_NT_SAVED) { 377 PT_WRITE_PNTR((&node->data), NULL); 378 if (type == PT_NT_NODE) { 379 for (int i = PT_QU; i < PT_B_MAX; i++) { 380 POS_TREE *sons = PT_read_son(node, (PT_BASES)i); 381 if (sons) PTD_clear_fathers(sons); 382 } 391 383 } 392 384 } … … 445 437 } 446 438 447 long PTD_write_tip_to_disk(FILE * out, P TM2 * /* ptmain */, POS_TREE * node, long pos)439 long PTD_write_tip_to_disk(FILE * out, POS_TREE * node, long pos) 448 440 { 449 441 int size, cnt; … … 490 482 } 491 483 492 ARB_ERROR ptd_write_chain_entries(FILE * out, long *ppos, PTM2 * /* ptmain */,char ** entry_tab, int n_entries, int mainapos) { // __ATTR__USERESULT484 ARB_ERROR ptd_write_chain_entries(FILE * out, long *ppos, char ** entry_tab, int n_entries, int mainapos) { // __ATTR__USERESULT 493 485 ARB_ERROR error; 494 486 int lastname = 0; … … 530 522 531 523 532 long PTD_write_chain_to_disk(FILE * out, P TM2 *ptmain, POS_TREE * node, long pos, ARB_ERROR& error) {524 long PTD_write_chain_to_disk(FILE * out, POS_TREE * node, long pos, ARB_ERROR& error) { 533 525 char *data; 534 526 long oldpos = pos; … … 536 528 pos++; 537 529 int mainapos; 538 data = (&node->data) + p tmain->mode;530 data = (&node->data) + psg.ptmain->mode; 539 531 540 532 if (node->flags&1) { … … 556 548 char **entry_tab = (char **)GB_calloc(sizeof(char *), n_entries); 557 549 ptd_set_chain_references((char *)first_entry, entry_tab); 558 error = ptd_write_chain_entries(out, &pos, ptmain,entry_tab, n_entries, mainapos);550 error = ptd_write_chain_entries(out, &pos, entry_tab, n_entries, mainapos); 559 551 free(entry_tab); 560 552 } … … 593 585 } 594 586 595 long PTD_write_node_to_disk(FILE * out, P TM2 *ptmain, POS_TREE * node, long *r_poss, long pos) {587 long PTD_write_node_to_disk(FILE * out, POS_TREE * node, long *r_poss, long pos) { 596 588 int i, size; // Save node after all descendends are already saved 597 589 POS_TREE *sons; … … 606 598 607 599 for (i = PT_QU; i < PT_B_MAX; i++) { // free all sons 608 sons = PT_read_son( ptmain,node, (PT_BASES)i);600 sons = PT_read_son(node, (PT_BASES)i); 609 601 if (sons) { 610 602 int memsize; … … 759 751 } 760 752 761 long PTD_write_leafs_to_disk(FILE * out, P TM2 *ptmain, POS_TREE * node, long pos, long *pnodepos, int *pblock, ARB_ERROR& error) {753 long PTD_write_leafs_to_disk(FILE * out, POS_TREE * node, long pos, long *pnodepos, int *pblock, ARB_ERROR& error) { 762 754 // returns new pos when son is written 0 otherwise 763 755 // pnodepos is set to last object … … 778 770 else if (type == PT_NT_LEAF) { 779 771 *pnodepos = pos; 780 pos = PTD_write_tip_to_disk(out, ptmain,node, pos);772 pos = PTD_write_tip_to_disk(out, node, pos); 781 773 } 782 774 else if (type == PT_NT_CHAIN) { 783 775 *pnodepos = pos; 784 pos = PTD_write_chain_to_disk(out, ptmain,node, pos, error);776 pos = PTD_write_chain_to_disk(out, node, pos, error); 785 777 } 786 778 else if (type == PT_NT_NODE) { … … 788 780 o_pos = pos; 789 781 for (i = PT_QU; i < PT_B_MAX && !error; i++) { // save all sons 790 sons = PT_read_son( ptmain,node, (PT_BASES)i);782 sons = PT_read_son(node, (PT_BASES)i); 791 783 r_poss[i] = 0; 792 784 if (sons) { 793 r_pos = PTD_write_leafs_to_disk(out, ptmain,sons, pos, &(r_poss[i]), &(block[0]), error);785 r_pos = PTD_write_leafs_to_disk(out, sons, pos, &(r_poss[i]), &(block[0]), error); 794 786 if (r_pos>pos) { // really saved ???? 795 787 son_size[i] = r_pos-pos; … … 813 805 else { // now i can write my data 814 806 *pnodepos = pos; 815 if (!error) pos = PTD_write_node_to_disk(out, ptmain,node, r_poss, pos);807 if (!error) pos = PTD_write_node_to_disk(out, node, r_poss, pos); 816 808 } 817 809 } … … 824 816 825 817 826 ARB_ERROR PTD_read_leafs_from_disk(const char *fname, P TM2 *ptmain, POS_TREE **pnode) { // __ATTR__USERESULT818 ARB_ERROR PTD_read_leafs_from_disk(const char *fname, POS_TREE **pnode) { // __ATTR__USERESULT 827 819 GB_ERROR error = NULL; 828 820 char *buffer = GB_map_file(fname, 0); … … 892 884 pt_assert(i >= 0); 893 885 894 *pnode = (POS_TREE *)(i+buffer); 895 ptmain->mode = 0; 896 ptmain->data_start = buffer; 886 *pnode = (POS_TREE *)(i+buffer); 887 888 psg.ptmain->mode = 0; 889 psg.ptmain->data_start = buffer; 897 890 } 898 891 } -
branches/dev_elmar/PROBE/needs_libs
r6865 r8224 4 4 SERVERCNTRL/SERVERCNTRL.a 5 5 SL/HELIX/HELIX.a 6 SL/PTCLEAN/PTCLEAN.a 6 7 -
branches/dev_elmar/PROBE/probe.h
r7999 r8224 50 50 #define FINDANSWER 52 // private msg type: find result answer 51 51 52 extern int gene_flag; // if 'gene_flag' == 1 -> we are a gene pt server 52 53 extern ULONG physical_memory; 53 54 struct Hs_struct; … … 100 101 // Probe search 101 102 102 struct probe_statistic { 103 int match_count; // Counter for matches 104 double rel_match_count; // match_count / (seq_len - probe_len + 1) 105 }; 106 107 struct probe_input_data { // every taxa's own data 108 char *data; // sequence 109 long checksum; 110 int size; 103 class probe_input_data : virtual Noncopyable { // every taxa's own data 104 105 char *data; // sequence 106 long checksum; // checksum of sequence 107 int size; 108 111 109 char *name; 112 110 char *fullname; 113 111 GBDATA *gbd; 114 112 115 // probe design 116 int is_group; // -1: nevermind, 0: no group, 1: group 117 118 // probe design (match) 119 PT_probematch *match; // best hit for PT_new_design 120 121 // find family 122 probe_statistic stat; 123 124 int next; 113 bool group; // probe_design: whether species is in group 114 115 // obsolete methods below @@@ remove them 116 GBDATA *get_gbdata() const { return gbd; } 117 void set_data(char *assign, int size_) { pt_assert(!data); data = assign; size = size_; } 118 void set_checksum(long cs) { checksum = cs; } 119 120 public: 121 122 probe_input_data() 123 : data(0), 124 checksum(0), 125 size(0), 126 name(0), 127 fullname(0), 128 gbd(0), 129 group(false) 130 {} 131 ~probe_input_data() { 132 free(data); 133 free(name); 134 free(fullname); 135 } 136 137 GB_ERROR init(GBDATA *gbd_); 138 139 const char *get_data() const { return data; } 140 char *read_alignment(int *psize) const; 141 142 const char *get_name() const { return name; } 143 const char *get_fullname() const { return fullname; } 144 long get_checksum() const { return checksum; } 145 int get_size() const { return size; } 146 147 bool inside_group() const { return group; } 148 bool outside_group() const { return !group; } 149 150 void set_group_state(bool isGroupMember) { group = isGroupMember; } 151 152 long get_abspos() const { 153 pt_assert(gene_flag); // only legal in gene-ptserver 154 GBDATA *gb_pos = GB_entry(get_gbdata(), "abspos"); 155 if (gb_pos) return GB_read_int(gb_pos); 156 return -1; 157 } 158 159 private: 125 160 }; 126 161 … … 198 233 GB_HASH *namehash; // name to int 199 234 235 int data_count; 200 236 struct probe_input_data *data; // the internal database 201 237 … … 203 239 BI_ecoli_ref *bi_ecoli; 204 240 205 int data_count;206 241 int max_size; // maximum sequence len 207 242 long char_count; // number of all 'acgtuACGTU' … … 284 319 }; 285 320 286 extern int gene_flag; // if 'gene_flag' == 1 -> we are a gene pt server287 288 321 struct ltByArbName { 289 322 bool operator()(const gene_struct *gs1, const gene_struct *gs2) const { … … 313 346 #error probe.h included twice 314 347 #endif 348 349 -
branches/dev_elmar/PROBE/probe_tree.h
r7945 r8224 411 411 // calculate the index of the pointer in a node 412 412 413 inline POS_TREE *PT_read_son(P TM2 *ptmain, POS_TREE *node, PT_BASES base)413 inline POS_TREE *PT_read_son(POS_TREE *node, PT_BASES base) 414 414 { 415 long i; 416 UINT sec; 417 UINT offset; 415 long i; 416 UINT sec; 417 UINT offset; 418 PTM2 *ptmain = psg.ptmain; 418 419 if (ptmain->stage3) { // stage 3 no father 419 420 if (node->flags & IS_SINGLE_BRANCH_NODE) { … … 503 504 } 504 505 505 inline POS_TREE *PT_read_son_stage_1(PTM2 *ptmain, POS_TREE *node, PT_BASES base) 506 { 507 long i; 506 inline POS_TREE *PT_read_son_stage_1(POS_TREE *node, PT_BASES base) { 508 507 if (!((1<<base) & node->flags)) return NULL; // bit not set 509 508 base = (PT_BASES)PT_count_bits[base][node->flags]; 510 PT_READ_PNTR((&node->data)+sizeof(PT_PNTR)*base+ptmain->mode, i); 511 return (POS_TREE *)(i+ptmain->data_start); // ptmain->data_start == 0x00 in stage 1 509 long i; 510 PT_READ_PNTR((&node->data)+sizeof(PT_PNTR)*base+psg.ptmain->mode, i); 511 return (POS_TREE *)(i+psg.ptmain->data_start); // psg.ptmain->data_start == 0x00 in stage 1 512 512 } 513 513 … … 517 517 } 518 518 519 inline int PT_read_name(PTM2 *ptmain, POS_TREE *node)520 {521 int i;522 if (node->flags&1) {523 PT_READ_INT((&node->data)+ptmain->mode, i);524 }525 else {526 PT_READ_SHORT((&node->data)+ptmain->mode, i);527 }528 pt_assert(i >= 0);529 return i;530 }531 532 inline int PT_read_rpos(PTM2 *ptmain, POS_TREE *node)533 {534 int i;535 char *data = (&node->data)+2+ptmain->mode;536 if (node->flags&1) data+=2;537 if (node->flags&2) {538 PT_READ_INT(data, i);539 }540 else {541 PT_READ_SHORT(data, i);542 }543 pt_assert(i >= 0);544 return i;545 }546 547 inline int PT_read_apos(PTM2 *ptmain, POS_TREE *node)548 {549 int i;550 char *data = (&node->data)+ptmain->mode+4; // father 4 name 2 rpos 2551 if (node->flags&1) data+=2;552 if (node->flags&2) data+=2;553 if (node->flags&4) {554 PT_READ_INT(data, i);555 }556 else {557 PT_READ_SHORT(data, i);558 }559 pt_assert(i >= 0);560 return i;561 }562 563 519 struct DataLoc { 564 int name; 520 int name; // index into psg.data[], aka as species id 565 521 int apos; 566 int rpos; 522 int rpos; // position in data 567 523 568 524 void init(const char ** data, int pos) { 569 525 *data = PT_READ_CHAIN_ENTRY(*data, pos, &name, &apos, &rpos); 570 526 } 571 void init(PTM2 *ptmain, POS_TREE *pt) { 572 pt_assert(PT_read_type(pt) == PT_NT_LEAF); 573 574 name = PT_read_name(ptmain, pt); 575 apos = PT_read_apos(ptmain, pt); 576 rpos = PT_read_rpos(ptmain, pt); 527 void init(POS_TREE *node) { 528 pt_assert(PT_read_type(node) == PT_NT_LEAF); 529 char *data = (&node->data)+psg.ptmain->mode; 530 if (node->flags&1) { PT_READ_INT(data, name); data += 4; } else { PT_READ_SHORT(data, name); data += 2; } 531 if (node->flags&2) { PT_READ_INT(data, rpos); data += 4; } else { PT_READ_SHORT(data, rpos); data += 2; } 532 if (node->flags&4) { PT_READ_INT(data, apos); data += 4; } else { PT_READ_SHORT(data, apos); data += 2; } 533 534 pt_assert(name >= 0); 535 pt_assert(apos >= 0); 536 pt_assert(rpos >= 0); 577 537 } 578 538 579 539 DataLoc(int name_, int apos_, int rpos_) : name(name_), apos(apos_), rpos(rpos_) {} 580 DataLoc(const char ** data, int pos) { 581 name = 0; 582 init(data, pos); 583 } 584 DataLoc(PTM2 *ptmain, POS_TREE *pt) { 585 init(ptmain, pt); 586 } 540 DataLoc(POS_TREE *pt) { init(pt); } 541 DataLoc(const char ** data, int pos) { name = 0; init(data, pos); } 542 543 const probe_input_data& get_pid() const { pt_assert(name >= 0 && name<psg.data_count); return psg.data[name]; } 544 const char *get_data() const { return get_pid().get_data(); } 545 PT_BASES operator[](int offset) const { return PT_BASES(get_data()[rpos+offset]); } 546 547 int restlength() const { return get_pid().get_size()-rpos; } 548 bool is_shorther_than(int offset) const { return offset >= restlength(); } 587 549 588 550 #if defined(DEBUG) 589 551 void dump(FILE *fp) const { 590 fprintf(fp, " apos=%6i rpos=%6i name=%6i='%s'\n", apos, rpos, name, psg.data[name]. name);552 fprintf(fp, " apos=%6i rpos=%6i name=%6i='%s'\n", apos, rpos, name, psg.data[name].get_name()); 591 553 fflush(fp); 592 554 } … … 595 557 596 558 template<typename T> 597 int PT_forwhole_chain(P TM2 *ptmain, POS_TREE *node, T func) {559 int PT_forwhole_chain(POS_TREE *node, T func) { 598 560 pt_assert(PT_read_type(node) == PT_NT_CHAIN); 599 561 600 const char *data = (&node->data) + p tmain->mode;562 const char *data = (&node->data) + psg.ptmain->mode; 601 563 int pos; 602 564 … … 621 583 622 584 template<typename T> 623 int PT_withall_tips(P TM2 *ptmain, POS_TREE *node, T func) {585 int PT_withall_tips(POS_TREE *node, T func) { 624 586 // like PT_forwhole_chain, but also can handle leafs 625 587 PT_NODE_TYPE type = PT_read_type(node); 626 588 if (type == PT_NT_LEAF) { 627 return func(DataLoc( ptmain,node));589 return func(DataLoc(node)); 628 590 } 629 591 630 592 pt_assert(type == PT_NT_CHAIN); 631 return PT_forwhole_chain( ptmain,node, func);593 return PT_forwhole_chain(node, func); 632 594 } 633 595 -
branches/dev_elmar/PROBE/pt_prototypes.h
r7999 r8224 13 13 14 14 /* PT_buildtree.cxx */ 15 POS_TREE *build_pos_tree(POS_TREE *pt, int anfangs_pos, int apos, int RNS_nr, unsigned int end); 16 long PTD_save_partial_tree(FILE *out, PTM2 *ptmain, POS_TREE *node, char *partstring, int partsize, long pos, long *ppos, ARB_ERROR &error); 15 16 class DataLoc; 17 18 long PTD_save_partial_tree(FILE *out, POS_TREE *node, char *partstring, int partsize, long pos, long *ppos, ARB_ERROR &error); 17 19 ARB_ERROR enter_stage_1_build_tree(PT_main *, char *tname) __ATTR__USERESULT; 18 20 ARB_ERROR enter_stage_3_load_tree(PT_main *, const char *tname) __ATTR__USERESULT; … … 40 42 int compress_data(char *probestring); 41 43 void PT_base_2_string(char *id_string, long len); 42 ARB_ERROR probe_read_data_base(const char *name ) __ATTR__USERESULT;44 ARB_ERROR probe_read_data_base(const char *name, bool readOnly) __ATTR__USERESULT; 43 45 int probe_compress_sequence(char *seq, int seqsize); 44 46 char *probe_read_alignment(int j, int *psize); … … 54 56 void PT_init_psg(void); 55 57 void PT_exit_psg(void); 56 void PT_exit( int exitcode) __ATTR__NORETURN;58 void PT_exit(void); 57 59 GB_ERROR PT_init_map(void) __ATTR__USERESULT; 58 60 … … 77 79 char *get_design_hinfo(PT_tprobes *tprobe); 78 80 int PT_start_design(PT_pdc *pdc, int dummy_1x); 79 void ptnd_new_match(PT_local *locs, char *probestring);80 81 81 82 /* PT_prefixtree.cxx */ … … 89 90 PTM2 *PT_init(void); 90 91 void PT_change_father(POS_TREE *father, POS_TREE *source, POS_TREE *dest); 91 POS_TREE *PT_add_to_chain(P TM2 *ptmain, POS_TREE *node, int name, int apos, int rpos);92 POS_TREE *PT_change_leaf_to_node(P TM2 *, POS_TREE *node);93 POS_TREE *PT_leaf_to_chain(P TM2 *ptmain, POS_TREE *node);94 POS_TREE *PT_create_leaf(P TM2 *ptmain, POS_TREE **pfather, PT_BASES base, int rpos, int apos, int name);95 void PTD_clear_fathers(P TM2 *ptmain, POS_TREE *node);92 POS_TREE *PT_add_to_chain(POS_TREE *node, const DataLoc &loc); 93 POS_TREE *PT_change_leaf_to_node(POS_TREE *node); 94 POS_TREE *PT_leaf_to_chain(POS_TREE *node); 95 POS_TREE *PT_create_leaf(POS_TREE **pfather, PT_BASES base, const DataLoc &loc); 96 void PTD_clear_fathers(POS_TREE *node); 96 97 void PTD_put_longlong(FILE *out, ULONG i); 97 98 void PTD_put_int(FILE *out, ULONG i); 98 99 void PTD_put_short(FILE *out, ULONG i); 99 100 void PTD_set_object_to_saved_status(POS_TREE *node, long pos, int size); 100 long PTD_write_tip_to_disk(FILE *out, P TM2 *, POS_TREE *node, long pos);101 long PTD_write_tip_to_disk(FILE *out, POS_TREE *node, long pos); 101 102 int ptd_count_chain_entries(char *entry); 102 103 void ptd_set_chain_references(char *entry, char **entry_tab); 103 ARB_ERROR ptd_write_chain_entries(FILE *out, long *ppos, PTM2 *,char **entry_tab, int n_entries, int mainapos) __ATTR__USERESULT;104 long PTD_write_chain_to_disk(FILE *out, P TM2 *ptmain, POS_TREE *node, long pos, ARB_ERROR &error);104 ARB_ERROR ptd_write_chain_entries(FILE *out, long *ppos, char **entry_tab, int n_entries, int mainapos) __ATTR__USERESULT; 105 long PTD_write_chain_to_disk(FILE *out, POS_TREE *node, long pos, ARB_ERROR &error); 105 106 void PTD_debug_nodes(void); 106 long PTD_write_node_to_disk(FILE *out, P TM2 *ptmain, POS_TREE *node, long *r_poss, long pos);107 long PTD_write_leafs_to_disk(FILE *out, P TM2 *ptmain, POS_TREE *node, long pos, long *pnodepos, int *pblock, ARB_ERROR &error);108 ARB_ERROR PTD_read_leafs_from_disk(const char *fname, P TM2 *ptmain, POS_TREE **pnode) __ATTR__USERESULT;107 long PTD_write_node_to_disk(FILE *out, POS_TREE *node, long *r_poss, long pos); 108 long PTD_write_leafs_to_disk(FILE *out, POS_TREE *node, long pos, long *pnodepos, int *pblock, ARB_ERROR &error); 109 ARB_ERROR PTD_read_leafs_from_disk(const char *fname, POS_TREE **pnode) __ATTR__USERESULT; 109 110 110 111 /* PT_debug.cxx */ … … 114 115 115 116 /* probe_tree.h */ 116 template <typename T >int PT_forwhole_chain(P TM2 *ptmain, POS_TREE *node, T func);117 template <typename T >int PT_withall_tips(P TM2 *ptmain, POS_TREE *node, T func);117 template <typename T >int PT_forwhole_chain(POS_TREE *node, T func); 118 template <typename T >int PT_withall_tips(POS_TREE *node, T func); 118 119 119 120 #else -
branches/dev_elmar/PROBE_COM/PT_extern.c
r7415 r8224 3 3 #include <cstring> 4 4 #include "PT_server.h" 5 #include <attributes.h> 5 6 #include "C/server.h" 6 7 #include <aisc_server_proto.h> -
branches/dev_elmar/PROBE_DESIGN/Makefile
r7945 r8224 40 40 probe_design.o: $(ARBHOME)/INCLUDE/arb_core.h 41 41 probe_design.o: $(ARBHOME)/INCLUDE/arb_error.h 42 probe_design.o: $(ARBHOME)/INCLUDE/arb_file.h 42 43 probe_design.o: $(ARBHOME)/INCLUDE/arb_msg.h 43 44 probe_design.o: $(ARBHOME)/INCLUDE/arb_progress.h … … 56 57 probe_design.o: $(ARBHOME)/INCLUDE/aw_color_groups.hxx 57 58 probe_design.o: $(ARBHOME)/INCLUDE/aw_device.hxx 58 probe_design.o: $(ARBHOME)/INCLUDE/aw_edit.hxx59 59 probe_design.o: $(ARBHOME)/INCLUDE/aw_keysym.hxx 60 60 probe_design.o: $(ARBHOME)/INCLUDE/aw_msg.hxx -
branches/dev_elmar/PROBE_DESIGN/probe_design.cxx
r7999 r8224 26 26 #include <aw_awars.hxx> 27 27 #include <aw_preset.hxx> 28 #include <aw_edit.hxx>29 28 #include <aw_select.hxx> 30 29 #include <aw_msg.hxx> … … 33 32 #include <adGene.h> 34 33 #include <arb_strbuf.h> 34 #include <arb_file.h> 35 35 36 36 // general awars … … 237 237 } 238 238 239 static const char *PD_probe_pt_look_for_server(AW_root *root, GB DATA *gb_main, GB_ERROR& error) {239 static const char *PD_probe_pt_look_for_server(AW_root *root, GB_ERROR& error) { 240 240 // return PT server info string (see GBS_read_arb_tcp for details) 241 241 // or NULL (in this case 'error' is set) … … 244 244 const char *server_tag = GBS_ptserver_tag(root->awar(AWAR_PT_SERVER)->read_int()); 245 245 246 error = arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag , gb_main);246 error = arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag); 247 247 if (!error) { 248 248 result = GBS_read_arb_tcp(server_tag); … … 419 419 420 420 { 421 const char *servername = PD_probe_pt_look_for_server(root, gb_main,error);421 const char *servername = PD_probe_pt_look_for_server(root, error); 422 422 if (servername) { 423 423 pd_gl.link = aisc_open(servername, &pd_gl.com, AISC_MAGIC_NUMBER); … … 683 683 684 684 if (!error) { 685 const char *servername = PD_probe_pt_look_for_server(root, gb_main,error);685 const char *servername = PD_probe_pt_look_for_server(root, error); 686 686 687 687 if (!error) { … … 1656 1656 } 1657 1657 1658 static void pd_start_pt_server(AW_window *aww , AW_CL cl_gb_main) {1658 static void pd_start_pt_server(AW_window *aww) { 1659 1659 const char *server_tag = GBS_ptserver_tag(aww->get_root()->awar(AWAR_PROBE_ADMIN_PT_SERVER)->read_int()); 1660 1660 arb_progress progress("Connecting PT-server"); 1661 GB_ERROR error = arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag , (GBDATA*)cl_gb_main);1661 GB_ERROR error = arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag); 1662 1662 if (error) aw_message(error); 1663 1663 } … … 1816 1816 if (!error) { 1817 1817 progress.subtitle("Start PT-server (builds in background)"); 1818 error = arb_start_server(server_tag, gb_main,1);1818 error = arb_start_server(server_tag, 1); 1819 1819 } 1820 1820 } 1821 1821 if (error) aw_message(error); 1822 }1823 1824 static void arb_tcp_dat_changed_cb(const char * /* path */, bool fileChanged, bool /* editorTerminated */) {1825 #if defined(DEBUG) && 01826 printf("File '%s': changed=%i editorTerminated=%i\n", path, int(fileChanged), int(editorTerminated));1827 #endif // DEBUG1828 if (fileChanged) {1829 awt_refresh_all_pt_server_selection_lists();1830 }1831 }1832 1833 static void pd_edit_arb_tcp(AW_window *aww, AW_CL cl_gb_main) {1834 GBDATA *gb_main = (GBDATA*)cl_gb_main;1835 char *filename = GBS_find_lib_file("arb_tcp.dat", "", true);1836 1837 AW_edit(filename, arb_tcp_dat_changed_cb, aww, gb_main);1838 free(filename);1839 1822 } 1840 1823 … … 1868 1851 1869 1852 aws->at("start"); 1870 aws->callback(pd_start_pt_server , (AW_CL)gb_main);1853 aws->callback(pd_start_pt_server); 1871 1854 aws->create_button("START_SERVER", "Start server"); 1872 1855 … … 1884 1867 1885 1868 aws->at("edit"); 1886 aws->callback( pd_edit_arb_tcp, (AW_CL)gb_main);1869 aws->callback(awt_edit_arbtcpdat_cb, (AW_CL)gb_main); 1887 1870 aws->create_button("CREATE_TEMPLATE", "Configure"); 1888 1871 -
branches/dev_elmar/RNA3D/RNA3D_StructureData.cxx
r7272 r8224 36 36 37 37 static char *find_data_file(const char *name) { 38 char *fname = GB S_find_lib_file(name, "rna3d/", false);38 char *fname = GB_lib_file(false, "rna3d/", name); 39 39 if (!fname) throw string("file not found: ")+name; 40 40 return fname; -
branches/dev_elmar/RNA3D/RNA3D_Textures.cxx
r6678 r8224 46 46 } 47 47 48 char *fname = GB S_find_lib_file(imageName, "rna3d/images/", false);48 char *fname = GB_lib_file(false, "rna3d/images/", imageName); 49 49 if (!fname) { 50 50 throw string("File not found: ")+imageName; -
branches/dev_elmar/SECEDIT/Makefile
r7945 r8224 252 252 SEC_main.o: $(ARBHOME)/INCLUDE/arb_core.h 253 253 SEC_main.o: $(ARBHOME)/INCLUDE/arb_error.h 254 SEC_main.o: $(ARBHOME)/INCLUDE/arb_file.h 254 255 SEC_main.o: $(ARBHOME)/INCLUDE/arb_msg.h 255 256 SEC_main.o: $(ARBHOME)/INCLUDE/arb_string.h -
branches/dev_elmar/SECEDIT/SEC_db.cxx
r7337 r8224 372 372 373 373 { 374 char *dir = GBS_global_string_copy("%s/.arb_prop/secondary_structure", GB_getenvHOME());374 char *dir = strdup(GB_path_in_arbprop("secondary_structure")); 375 375 AW_create_fileselection_awars(aw_root, AWAR_SECEDIT_SAVEDIR, dir, ".ass", "noname.ass"); 376 376 free(dir); -
branches/dev_elmar/SECEDIT/SEC_main.cxx
r7945 r8224 22 22 #include <aw_msg.hxx> 23 23 #include <aw_root.hxx> 24 25 #include <arb_file.h> 24 26 25 27 #ifndef sec_assert // happens in NDEBUG mode -
branches/dev_elmar/SERVERCNTRL/Makefile
r7945 r8224 39 39 servercntrl.o: $(ARBHOME)/INCLUDE/arb_core.h 40 40 servercntrl.o: $(ARBHOME)/INCLUDE/arb_error.h 41 servercntrl.o: $(ARBHOME)/INCLUDE/arb_file.h 41 42 servercntrl.o: $(ARBHOME)/INCLUDE/arb_msg.h 42 43 servercntrl.o: $(ARBHOME)/INCLUDE/arb_string.h -
branches/dev_elmar/SERVERCNTRL/servercntrl.cxx
r7945 r8224 13 13 #include <client_privat.h> 14 14 #include <client.h> 15 15 16 #include <arbdb.h> 17 #include <arb_file.h> 16 18 #include <ut_valgrinded.h> 17 19 … … 84 86 } 85 87 86 GB_ERROR arb_start_server(const char *arb_tcp_env, GBDATA *gbmain,int do_sleep)88 GB_ERROR arb_start_server(const char *arb_tcp_env, int do_sleep) 87 89 { 88 90 const char *tcp_id; … … 153 155 154 156 if (!error) { 155 #if defined(DEBUG) 156 printf("Starting server (cmd='%s')\n", command); 157 #endif // DEBUG 158 if (!gbmain || GBCMC_system(gbmain, command)) system(command); 157 error = GBK_system(command); 159 158 if (do_sleep) sleep(delay); 160 159 } … … 166 165 } 167 166 168 static GB_ERROR arb_wait_for_server(const char *arb_tcp_env, GBDATA *gbmain,const char *tcp_id, int magic_number, struct gl_struct *serverctrl, int wait) {167 static GB_ERROR arb_wait_for_server(const char *arb_tcp_env, const char *tcp_id, int magic_number, struct gl_struct *serverctrl, int wait) { 169 168 serverctrl->link = aisc_open(tcp_id, &(serverctrl->com), magic_number); 170 169 if (!serverctrl->link) { // no server running -> start one 171 GB_ERROR error = arb_start_server(arb_tcp_env, gbmain,0);170 GB_ERROR error = arb_start_server(arb_tcp_env, 0); 172 171 if (error) return error; 173 172 … … 185 184 } 186 185 187 GB_ERROR arb_look_and_start_server(long magic_number, const char *arb_tcp_env , GBDATA *gbmain) {186 GB_ERROR arb_look_and_start_server(long magic_number, const char *arb_tcp_env) { 188 187 GB_ERROR error = 0; 189 188 const char *tcp_id = GBS_read_arb_tcp(arb_tcp_env); … … 244 243 245 244 if (!error) { 246 error = arb_wait_for_server(arb_tcp_env, gbmain,tcp_id, magic_number, &glservercntrl, 20);245 error = arb_wait_for_server(arb_tcp_env, tcp_id, magic_number, &glservercntrl, 20); 247 246 248 247 if (!error) { -
branches/dev_elmar/SERVERCNTRL/servercntrl.h
r6656 r8224 32 32 33 33 char *prefixSSH(const char *host, const char *command, int async); 34 GB_ERROR arb_start_server(const char *arb_tcp_env, GBDATA *gbmain,int do_sleep);35 GB_ERROR arb_look_and_start_server(long magic_number, const char *arb_tcp_env , GBDATA *gbmain);34 GB_ERROR arb_start_server(const char *arb_tcp_env, int do_sleep); 35 GB_ERROR arb_look_and_start_server(long magic_number, const char *arb_tcp_env); 36 36 GB_ERROR arb_look_and_kill_server(int magic_number, const char *arb_tcp_env); 37 37 void arb_print_server_params(void); -
branches/dev_elmar/SH/README
r7488 r8224 29 29 arb_phyml wrapper for phyml 30 30 arb_proml wrapper for proml 31 arb_protml wrapper for protml32 31 arb_protpars wrapper for protpars 33 32 arb_raxml wrapper for raxml -
branches/dev_elmar/SH/arb_installubuntu4arb.sh
r7489 r8224 4 4 # 5 5 # Tested with: 6 # * Ubuntu 8.10 (Intrepid Ibex)6 # * Ubuntu 10.04 (Lucid Lynx) 7 7 # 8 8 # [ May as well work with other ubuntu flavors or debian. -
branches/dev_elmar/SL/AW_NAME/AW_names_admin.cxx
r7945 r8224 17 17 #include <aw_msg.hxx> 18 18 #include <aw_root.hxx> 19 #include <awt_sel_boxes.hxx> 20 21 #include <arb_file.h> 19 22 20 23 static char *namesFilename(AW_CL cl_gb_main) { … … 50 53 " %s", 51 54 path, newpath, path); 52 GB_ERROR error = GB _system(command);55 GB_ERROR error = GBK_system(command); 53 56 if (error) aw_message(error); 54 57 … … 65 68 else AW_advice("Calling 'Species/Generate New Names' is highly recommended", AW_ADVICE_TOGGLE|AW_ADVICE_HELP, 0, "namesadmin.hlp"); 66 69 } 67 68 static void edit_arb_tcp(AW_window *aww, AW_CL cl_gb_main) {69 GBDATA *gb_main = (GBDATA*)cl_gb_main;70 char *filename = GBS_find_lib_file("arb_tcp.dat", "", true);71 72 AW_edit(filename, NULL, aww, gb_main);73 free(filename);74 }75 76 70 77 71 void AW_create_namesadmin_awars(AW_root *awr, GBDATA *gb_main) { … … 115 109 116 110 aws->at("config"); 117 aws->callback( edit_arb_tcp, cl_gb_main);111 aws->callback(awt_edit_arbtcpdat_cb, cl_gb_main); 118 112 aws->create_button("CREATE_TEMPLATE", "Configure arb_tcp.dat"); 119 113 -
branches/dev_elmar/SL/AW_NAME/AW_rename.cxx
r7945 r8224 208 208 const char *server_id = GBS_nameserver_tag(add_field); 209 209 210 err = arb_look_and_start_server(AISC_MAGIC_NUMBER, server_id , gb_main);210 err = arb_look_and_start_server(AISC_MAGIC_NUMBER, server_id); 211 211 212 212 if (!err) { -
branches/dev_elmar/SL/AW_NAME/Makefile
r7945 r8224 45 45 AW_names_admin.o: $(ARBHOME)/INCLUDE/arb_core.h 46 46 AW_names_admin.o: $(ARBHOME)/INCLUDE/arb_error.h 47 AW_names_admin.o: $(ARBHOME)/INCLUDE/arb_file.h 47 48 AW_names_admin.o: $(ARBHOME)/INCLUDE/arb_msg.h 48 49 AW_names_admin.o: $(ARBHOME)/INCLUDE/arb_string.h … … 60 61 AW_names_admin.o: $(ARBHOME)/INCLUDE/aw_root.hxx 61 62 AW_names_admin.o: $(ARBHOME)/INCLUDE/aw_window.hxx 63 AW_names_admin.o: $(ARBHOME)/INCLUDE/awt_sel_boxes.hxx 62 64 AW_names_admin.o: $(ARBHOME)/INCLUDE/cb.h 63 65 AW_names_admin.o: $(ARBHOME)/INCLUDE/dupstr.h -
branches/dev_elmar/SL/DB_QUERY/db_query.cxx
- Property svn:mergeinfo changed from /trunk/SL/DB_QUERY/db_query.cxx:7771-7998 to /trunk/SL/DB_QUERY/db_query.cxx:7771-8223
-
branches/dev_elmar/SL/DB_QUERY/db_query.h
- Property svn:mergeinfo changed from /trunk/SL/DB_QUERY/db_query.h:7771-7998 to /trunk/SL/DB_QUERY/db_query.h:7771-8223
-
branches/dev_elmar/SL/DB_QUERY/db_query_local.h
- Property svn:mergeinfo changed from /trunk/SL/DB_QUERY/db_query_local.h:7771-7998 to /trunk/SL/DB_QUERY/db_query_local.h:7771-8223
-
branches/dev_elmar/SL/DB_UI/ui_species.cxx
- Property svn:mergeinfo changed from /trunk/SL/DB_UI/ui_species.cxx:7771-7998 to /trunk/SL/DB_UI/ui_species.cxx:7771-8223
-
branches/dev_elmar/SL/ITEMS/changekey.cxx
- Property svn:mergeinfo changed from /trunk/SL/ITEMS/changekey.cxx:7771-7998 to /trunk/SL/ITEMS/changekey.cxx:7771-8223
-
branches/dev_elmar/SL/ITEMS/item_sel_list.cxx
- Property svn:mergeinfo changed from /trunk/SL/ITEMS/item_sel_list.cxx:7771-7998 to /trunk/SL/ITEMS/item_sel_list.cxx:7771-8223
-
branches/dev_elmar/SL/ITEMS/item_sel_list.h
- Property svn:mergeinfo changed from /trunk/SL/ITEMS/item_sel_list.h:7771-7998 to /trunk/SL/ITEMS/item_sel_list.h:7771-8223
-
branches/dev_elmar/SL/ITEMS/items.h
- Property svn:mergeinfo changed from /trunk/SL/ITEMS/items.h:7771-7998 to /trunk/SL/ITEMS/items.h:7771-8223
-
branches/dev_elmar/SL/ITEMS/species.cxx
- Property svn:mergeinfo changed from /trunk/SL/ITEMS/species.cxx:7771-7998 to /trunk/SL/ITEMS/species.cxx:7771-8223
-
branches/dev_elmar/SL/Makefile
r7945 r8224 1 1 2 2 ARCHS_ALL = \ 3 PTCLEAN/PTCLEAN.dummy \ 3 4 ALIVIEW/ALIVIEW.dummy \ 4 5 AP_TREE/AP_TREE.dummy \ -
branches/dev_elmar/SL/NDS/nds.cxx
- Property svn:mergeinfo changed from /trunk/SL/NDS/nds.cxx:7771-7998 to /trunk/SL/NDS/nds.cxx:7771-8223
-
branches/dev_elmar/SL/NDS/nds.h
- Property svn:mergeinfo changed from /trunk/SL/NDS/nds.h:7771-7998 to /trunk/SL/NDS/nds.h:7771-8223
-
branches/dev_elmar/SL/PRONUC/Makefile
r7423 r8224 79 79 iupac.o: $(ARBHOME)/INCLUDE/arb_core.h 80 80 iupac.o: $(ARBHOME)/INCLUDE/arbdb_base.h 81 iupac.o: $(ARBHOME)/INCLUDE/arbtools.h 81 82 iupac.o: $(ARBHOME)/INCLUDE/dupstr.h 82 83 iupac.o: $(ARBHOME)/INCLUDE/test_global.h -
branches/dev_elmar/SL/REFENTRIES/refentries.cxx
- Property svn:mergeinfo changed from /trunk/SL/REFENTRIES/refentries.cxx:7771-7998 to /trunk/SL/REFENTRIES/refentries.cxx:7771-8223
-
branches/dev_elmar/SL/REFENTRIES/refentries.h
- Property svn:mergeinfo changed from /trunk/SL/REFENTRIES/refentries.h:7771-7998 to /trunk/SL/REFENTRIES/refentries.h:7771-8223
-
branches/dev_elmar/SL/SEQIO/Makefile
r7945 r8224 46 46 seq_export.o: $(ARBHOME)/INCLUDE/arb_core.h 47 47 seq_export.o: $(ARBHOME)/INCLUDE/arb_error.h 48 seq_export.o: $(ARBHOME)/INCLUDE/arb_file.h 48 49 seq_export.o: $(ARBHOME)/INCLUDE/arb_msg.h 49 50 seq_export.o: $(ARBHOME)/INCLUDE/arb_progress.h -
branches/dev_elmar/SL/SEQIO/seq_export.cxx
r7945 r8224 14 14 #include <arbdbt.h> 15 15 #include <arb_strarray.h> 16 #include <arb_file.h> 16 17 #include <xml.hxx> 17 18 #include <arb_progress.h> … … 560 561 561 562 GB_informationf("exec '%s'", efo.system); 562 error = GB _system(sys);563 error = GBK_system(sys); 563 564 564 565 GB_unlink_or_warn(intermediate_export, &error); -
branches/dev_elmar/SOURCE_TOOLS/arb_valgrind
r7945 r8224 18 18 echo ' -q quiet' 19 19 echo ' -L <file> log stdout to <file> (does not work with -D)' 20 echo ' -E <file> log stderr to <file> (does not work with -D)' 21 echo ' Default is to collect output and print in after valgrind terminates' 20 22 echo ' -D run gdb on error' 21 23 echo ' -e return exitcode 1 on valgrind-errors' … … 63 65 QUIET='' 64 66 LOG_STDOUT='' 67 LOG_STDERR='' 65 68 ERROR_EXITCODE='' 66 69 … … 120 123 if [ "$1" = "-L" ] ; then 121 124 LOG_STDOUT=$2 125 shift 2 126 SCAN_ARGS=1 127 fi 128 if [ "$1" = "-E" ] ; then 129 LOG_STDERR=$2 122 130 shift 2 123 131 SCAN_ARGS=1 … … 162 170 echo "VG_CMD='$VG_CMD $@'" 163 171 if [ "$ATTACH" = "" ]; then 172 POSTDUMP_STDOUT=0 173 POSTDUMP_STDERR=0 164 174 if [ -z "$LOG_STDOUT" ]; then 165 175 LOG_STDOUT=/tmp/arb_valgrind_$USER_$$.stdout 166 fi 167 $VG_CMD --log-fd=3 "$@" 3>&1 >$LOG_STDOUT 2>&1 | $DIR/valgrind2grep $CALLERS "$FILTER" $SUPPX 176 POSTDUMP_STDOUT=1 177 fi 178 if [ -z "$LOG_STDERR" ]; then 179 LOG_STDERR=/tmp/arb_valgrind_$USER_$$.stderr 180 POSTDUMP_STDERR=1 181 fi 182 $VG_CMD --log-fd=3 "$@" 3>&1 >$LOG_STDOUT 2>$LOG_STDERR | $DIR/valgrind2grep $CALLERS "$FILTER" $SUPPX 168 183 EXITCODE=${PIPESTATUS[0]} 184 185 if [ "$POSTDUMP_STDOUT" = "1" ]; then 186 echo "-------------------- [stdout of '$@' ]" 187 cat $LOG_STDOUT 188 rm $LOG_STDOUT 189 fi 190 if [ "$POSTDUMP_STDERR" = "1" ]; then 191 echo "-------------------- [stderr of '$@' ]" 192 cat $LOG_STDERR 193 rm $LOG_STDERR 194 fi 195 if [ "$POSTDUMP_STDOUT" = "1" -o "$POSTDUMP_STDERR" = "1" ]; then 196 echo "-------------------- [end of output]" 197 fi 169 198 else 170 199 $VG_CMD "$@" -
branches/dev_elmar/SOURCE_TOOLS/dep.4dummy
r7945 r8224 24 24 PHYLO/PHYLO.dummy: AWT/AWT.dummy SL/MATRIX/MATRIX.dummy 25 25 PRIMER_DESIGN/PRIMER_DESIGN.dummy: AWT/AWT.dummy 26 PROBE/PROBE.dummy: PROBE_COM/PROBE_COM.dummy SERVERCNTRL/SERVERCNTRL.dummy SL/HELIX/HELIX.dummy 26 PROBE/PROBE.dummy: PROBE_COM/PROBE_COM.dummy SERVERCNTRL/SERVERCNTRL.dummy SL/HELIX/HELIX.dummy SL/PTCLEAN/PTCLEAN.dummy 27 27 PROBE_DESIGN/PROBE_DESIGN.dummy: SERVERCNTRL/SERVERCNTRL.dummy SL/TREEDISP/TREEDISP.dummy 28 28 RNA3D/RNA3D.dummy: AWT/AWT.dummy GL/glAW/glAW.dummy GL/glpng/glpng.dummy SL/HELIX/HELIX.dummy … … 48 48 SL/NEIGHBOURJOIN/NEIGHBOURJOIN.dummy: ARBDB/ARBDB.dummy 49 49 SL/PRONUC/PRONUC.dummy: ARBDB/ARBDB.dummy 50 SL/PTCLEAN/PTCLEAN.dummy: ARBDB/ARBDB.dummy 50 51 SL/REFENTRIES/REFENTRIES.dummy: WINDOW/WINDOW.dummy 51 52 SL/REGEXPR/REGEXPR.dummy: ARBDB/ARBDB.dummy -
branches/dev_elmar/SOURCE_TOOLS/dep.alltargets
r7945 r8224 48 48 SL/NEIGHBOURJOIN/NEIGHBOURJOIN.a 49 49 SL/PRONUC/PRONUC.a 50 SL/PTCLEAN/PTCLEAN.a 50 51 SL/REFENTRIES/REFENTRIES.a 51 52 SL/REGEXPR/REGEXPR.a -
branches/dev_elmar/SOURCE_TOOLS/dep.libtargets
r7945 r8224 48 48 SL/NEIGHBOURJOIN/NEIGHBOURJOIN.a 49 49 SL/PRONUC/PRONUC.a 50 SL/PTCLEAN/PTCLEAN.a 50 51 SL/REFENTRIES/REFENTRIES.a 51 52 SL/REGEXPR/REGEXPR.a -
branches/dev_elmar/SOURCE_TOOLS/generate_all_links.sh
r7945 r8224 229 229 symlink_file ../CORE/arb_core.h INCLUDE/arb_core.h && 230 230 symlink_file ../CORE/arb_cs.h INCLUDE/arb_cs.h && 231 symlink_file ../CORE/arb_file.h INCLUDE/arb_file.h && 231 232 symlink_file ../CORE/arb_msg.h INCLUDE/arb_msg.h && 232 233 symlink_file ../CORE/arb_signal.h INCLUDE/arb_signal.h && … … 278 279 symlink_file ../SL/PRONUC/AP_pro_a_nucs.hxx INCLUDE/AP_pro_a_nucs.hxx && 279 280 symlink_file ../SL/PRONUC/iupac.h INCLUDE/iupac.h && 281 symlink_file ../SL/PTCLEAN/ptclean.h INCLUDE/ptclean.h && 280 282 symlink_file ../SL/REFENTRIES/refentries.h INCLUDE/refentries.h && 281 283 symlink_file ../SL/REGEXPR/RegExpr.hxx INCLUDE/RegExpr.hxx && -
branches/dev_elmar/SOURCE_TOOLS/postcompile.pl
r7945 r8224 41 41 qr/^base\sclass\s.*has\sa\snon-virtual\sdestructor/, 42 42 qr/\sshould\sbe\sinitialized\sin\sthe\smember\sinitialization\slist/, 43 43 qr/boost::icl::(insert|add)_iterator<ContainerT>.*should\sreturn/, # filter boost-iterator postfix operators warnings 44 44 qr/^\s\sbut\sdoes\snot\soverride/, # belongs to reg_Weffpp_copyable 45 45 qr/^\s\sor\s'operator=/, # belongs to reg_Weffpp_copyable … … 50 50 51 51 # regexps for files: 52 my $reg_user_include = qr/^\/usr\/include\//; 52 my $reg_user_include = qr/^\/usr\/include\//; 53 my $reg_HEADERLIBS_include = qr/\/HEADERLIBS\//; 53 54 54 55 my $stop_after_first_error = 0; … … 217 218 } 218 219 220 sub is_system_or_builtin($) { 221 my ($file) = @_; 222 return (($file =~ $reg_user_include) or ($file eq '<built-in>') or ($file =~ $reg_HEADERLIBS_include)); 223 } 224 225 sub suppress_shadow_warning_for($) { 226 my ($file) = @_; 227 return is_system_or_builtin($file); 228 } 229 219 230 sub parse_input(\@) { 220 231 my ($out_r) = @_; … … 243 254 $_ = suppress($_,@warnout); 244 255 } 256 elsif (suppress_shadow_warning_for($file)) { 257 $_ = suppress($_,@warnout); 258 # $location_info = undef; 259 } 245 260 } 246 261 elsif ($warn_text =~ $reg_shadow_location) { 247 262 if (not defined $shadow_warning) { warning('no shadow_warning seen',@warnout); } 248 263 else { 249 if ( $file =~ $reg_user_include or $file eq '<built-in>') {264 if (suppress_shadow_warning_for($file)) { 250 265 # don't warn about /usr/include or <built-in> shadowing 251 266 $_ = suppress($_,@warnout); -
branches/dev_elmar/SOURCE_TOOLS/tabBrake.pl
r7945 r8224 67 67 'GDE/PHYML', 68 68 'GDE/RAxML', 69 'GDE/MOLPHY',70 69 'GDE/SUPPORT', 71 70 'GDE/PHYLIP', -
branches/dev_elmar/SOURCE_TOOLS/valgrind2grep
r7408 r8224 108 108 chomp; 109 109 addFileIndex($_,$_); 110 # $fileIndex{$_} = $_;111 110 if (/\/([^\/]+)\/([^\/]+)$/) { 112 111 my $last_dir = $1; … … 115 114 addFileIndex($fname,$_); 116 115 addFileIndex($last_dir.'/'.$fname,$_); 117 # $fileIndex{$fname} = $_;118 # $fileIndex{$last_dir.'/'.$fname} = $_;119 116 } 120 117 elsif (/\/([^\/]+)$/) { 121 118 my $fname = $1; 122 119 addFileIndex($fname,$_); 123 # $fileIndex{$fname} = $_;124 120 } 125 121 else { … … 130 126 close(SOURCELIST); 131 127 128 sub parentDir($) { 129 my ($dirOrFile) = @_; 130 if ($dirOrFile =~ /\/[^\/]+$/o) { return $`; } 131 return undef; 132 } 133 132 134 sub makeTargetAbsolute($$) { 133 135 my ($abslink,$reltarget) = @_; 134 if ($abslink =~ /\/[^\/]+$/o) {135 my $absdir = $`;136 while ($reltarget =~ /^ ..\//o) {136 my $absdir = parentDir($abslink); 137 if (defined $absdir) { 138 while ($reltarget =~ /^\.\.\//o) { 137 139 $reltarget = $'; 138 if ($absdir =~ /\/[^\/]+$/o) { 139 $absdir = $`; 140 my $absparent = parentDir($absdir); 141 if (defined $absparent) { 142 $absdir = $absparent; 140 143 } 141 144 else { … … 143 146 } 144 147 } 145 # print "absdir='$absdir' reltarget='$reltarget'\n"; 146 return $absdir.'/'.$reltarget; 148 149 my $result = $absdir.'/'.$reltarget; 150 return $result; 147 151 } 148 152 else { -
branches/dev_elmar/STAT/ST_quality.cxx
r7945 r8224 220 220 free(blownUp_report); 221 221 } 222 if (report == ST_QUALITY_REPORT_TEMP) GB_set_temporary(gb_report);222 if (report == ST_QUALITY_REPORT_TEMP) error = GB_set_temporary(gb_report); 223 223 224 224 delete [] report_str; -
branches/dev_elmar/TEMPLATES/attributes.h
r7945 r8224 101 101 102 102 // ------------------------------------------------------------ 103 // casting result to void does not help when a function is 104 // declared with __ATTR__USERESULT. Use 105 106 #ifdef __cplusplus 107 template <typename T> void IGNORE_RESULT(const T&) {} 108 #endif 109 110 // ------------------------------------------------------------ 103 111 // helper macros to declare attributed function prototype and 104 112 // start function definition in one line (static or inline functions only) -
branches/dev_elmar/TEMPLATES/ut_valgrinded.h
r7945 r8224 23 23 #endif 24 24 25 26 #define UTVG_ANY_SYSCALL "any.syscall" 25 #define UTVG_CALL_SEEN "flag.valgrind.callseen" 27 26 28 27 namespace utvg { … … 42 41 const char *path = flag_name(name); 43 42 struct stat stt; 44 43 45 44 return stat(path, &stt) == 0 && S_ISREG(stt.st_mode); 45 } 46 inline void raise_flag(const char *name) { 47 const char *path = flag_name(name); 48 FILE *fp = fopen(path, "w"); 49 arb_assert(fp); 50 fclose(fp); 46 51 } 47 52 … … 60 65 }; 61 66 62 inline void touch(const char *file) {63 FILE *out = fopen(file, "w");64 fclose(out);67 inline const valgrind_info& get_valgrind_info() { 68 static valgrind_info vinfo; 69 return vinfo; 65 70 } 66 71 }; … … 68 73 inline void make_valgrinded_call(char *&command) { 69 74 using namespace utvg; 70 static valgrind_info valgrind;75 const valgrind_info& valgrind = get_valgrind_info(); 71 76 if (valgrind.wanted) { 72 77 // #define VALGRIND_ONLY_SOME … … 84 89 freeset(command, valgrinded_command); 85 90 86 touch(flag_name(UTVG_ANY_SYSCALL));91 utvg::raise_flag(UTVG_CALL_SEEN); 87 92 } 88 93 } 94 95 inline bool will_valgrind_calls() { return utvg::get_valgrind_info().wanted; } 96 inline bool seen_valgrinded_call() { return utvg::flag_exists(UTVG_CALL_SEEN); } 89 97 90 98 #else 91 99 92 100 #define make_valgrinded_call(command) 101 inline bool will_valgrind_calls() { return false; } 102 inline bool seen_valgrinded_call() { return false; } 93 103 94 104 #endif -
branches/dev_elmar/TOOLS/Makefile
r7945 r8224 295 295 arb_replace.o: $(ARBHOME)/INCLUDE/arb_core.h 296 296 arb_replace.o: $(ARBHOME)/INCLUDE/arb_error.h 297 arb_replace.o: $(ARBHOME)/INCLUDE/arb_file.h 297 298 arb_replace.o: $(ARBHOME)/INCLUDE/arb_msg.h 298 299 arb_replace.o: $(ARBHOME)/INCLUDE/arb_strbuf.h … … 312 313 arb_test.o: $(ARBHOME)/INCLUDE/arb_defs.h 313 314 arb_test.o: $(ARBHOME)/INCLUDE/arb_error.h 315 arb_test.o: $(ARBHOME)/INCLUDE/arb_file.h 314 316 arb_test.o: $(ARBHOME)/INCLUDE/arb_msg.h 315 317 arb_test.o: $(ARBHOME)/INCLUDE/arb_string.h -
branches/dev_elmar/TOOLS/arb_2_ascii.cxx
r7945 r8224 59 59 else { 60 60 error = GB_save(gb_main, out, saveflags); 61 GB_close(gb_main); 61 62 } 62 63 GB_close(gb_main);64 63 } 65 64 -
branches/dev_elmar/TOOLS/arb_2_bin.cxx
r7190 r8224 66 66 printf("Reading database...\n"); 67 67 GB_shell shell; 68 GBDATA *gb_main = GBT_open(in, rtype , 0);68 GBDATA *gb_main = GBT_open(in, rtype); 69 69 if (!gb_main) { 70 70 error = GB_await_error(); -
branches/dev_elmar/TOOLS/arb_export_rates.cxx
r7945 r8224 77 77 if (!error) { 78 78 GB_shell shell; 79 GBDATA *gb_main = GBT_open(dbname, "r" , 0);79 GBDATA *gb_main = GBT_open(dbname, "r"); 80 80 if (!gb_main) { 81 81 error = GB_await_error(); -
branches/dev_elmar/TOOLS/arb_export_tree.cxx
r7945 r8224 59 59 60 60 GB_shell shell; 61 GBDATA *gb_main = GBT_open(db_name, "r" , 0);61 GBDATA *gb_main = GBT_open(db_name, "r"); 62 62 63 63 if (!gb_main) error = GB_await_error(); -
branches/dev_elmar/TOOLS/arb_notify.cxx
r6381 r8224 23 23 if (!progname || progname[0] == 0) progname = "arb_notify"; 24 24 25 GB_shell shell; 25 26 GBDATA *gb_main = GB_open(":", "r"); 26 27 if (!gb_main) { -
branches/dev_elmar/TOOLS/arb_perf_test.cxx
r7945 r8224 148 148 else { 149 149 char *in = argv[1]; 150 gb_main = GBT_open(in, "rw" , 0);150 gb_main = GBT_open(in, "rw"); 151 151 152 152 if (!gb_main) { -
branches/dev_elmar/TOOLS/arb_probe.cxx
r7999 r8224 79 79 const char *server_tag = GBS_ptserver_tag(P.SERVERID); 80 80 81 error = arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag , 0);81 error = arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag); 82 82 if (error) return NULL; 83 83 … … 319 319 320 320 #ifdef UNIT_TESTS 321 const int minServerID = TEST_ SERVER_ID;321 const int minServerID = TEST_GENESERVER_ID; 322 322 #else // !UNIT_TESTS 323 323 const int minServerID = 0; … … 326 326 P.SERVERID = getInt("serverid", 0, minServerID, 100, "Server Id, look into $ARBHOME/lib/arb_tcp.dat"); 327 327 #ifdef UNIT_TESTS 328 if (P.SERVERID<0) { arb_assert(P.SERVERID == TEST_SERVER_ID ); }328 if (P.SERVERID<0) { arb_assert(P.SERVERID == TEST_SERVER_ID || P.SERVERID == TEST_GENESERVER_ID); } 329 329 #endif 330 330 … … 455 455 #endif 456 456 457 static void test_setup() { 458 static bool setup = false; 459 if (!setup) { 460 TEST_SETUP_GLOBAL_ENVIRONMENT("ptserver"); // first call will recreate the test pt-server 461 setup = true; 462 } 457 static int test_setup(bool use_gene_ptserver) { 458 static bool setup[2] = { false, false }; 459 if (!setup[use_gene_ptserver]) { 460 TEST_SETUP_GLOBAL_ENVIRONMENT(use_gene_ptserver ? "ptserver_gene" : "ptserver"); // first call will recreate the test pt-server 461 setup[use_gene_ptserver] = true; 462 } 463 return use_gene_ptserver ? TEST_GENESERVER_ID : TEST_SERVER_ID; 464 } 465 466 // ---------------------------------- 467 // test probe design / match 468 469 #define TEST_PART1(fake_argc,fake_argv) \ 470 int serverid = test_setup(use_gene_ptserver); \ 471 TEST_ASSERT_EQUAL(true, parseCommandLine(fake_argc, fake_argv)); \ 472 TEST_ASSERT((serverid == TEST_SERVER_ID)||(serverid == TEST_GENESERVER_ID)); \ 473 P.SERVERID = serverid; \ 474 ARB_ERROR error; \ 475 char *answer = execute(error); \ 476 TEST_ASSERT_NO_ERROR(error.deliver()) 477 478 479 #define TEST_ARB_PROBE(fake_argc,fake_argv,expected) do { \ 480 TEST_PART1(fake_argc,fake_argv); \ 481 TEST_ASSERT_EQUAL(answer, expected); \ 482 free(answer); \ 483 } while(0) 484 485 #define TEST_ARB_PROBE__BROKEN(fake_argc,fake_argv,expected) do { \ 486 TEST_PART1(fake_argc,fake_argv); \ 487 TEST_ASSERT_EQUAL__BROKEN(answer, expected); \ 488 free(answer); \ 489 } while(0) 490 491 #define TEST_ARB_PROBE_FILT(fake_argc,fake_argv,filter,expected) do { \ 492 TEST_PART1(fake_argc,fake_argv); \ 493 char *filtered = filter(answer); \ 494 TEST_ASSERT_EQUAL(filtered, expected); \ 495 free(filtered); \ 496 free(answer); \ 497 } while(0) 498 499 typedef const char *CCP; 500 501 void TEST_SLOW_match_geneprobe() { 502 bool use_gene_ptserver = true; 503 { 504 const char *arguments[] = { 505 "prgnamefake", 506 "matchsequence=NNUCNN", 507 "matchacceptN=4", 508 "matchlimitN=5", 509 }; 510 CCP expectd = " organism genename------- mis N_mis wmis pos gpos rev 'NNUCNN'\1" 511 "genome2\1" " genome2 gene3 0 4 0.0 2 1 0 .........-UU==GG-UUGAUC\1" 512 "genome2\1" " genome2 joined1 0 4 0.0 2 1 0 .........-UU==GG-UUGAUCCUG\1" 513 "genome2\1" " genome2 gene2 0 4 0.0 10 4 0 ......GUU-GA==CU-GCCA\1" 514 "genome2\1" " genome2 intergene_19_65 0 4 0.0 31 12 0 GGUUACUGC-AU==GG-UGUUCGCCU\1" 515 "genome1\1" " genome1 intergene_17_65 0 4 0.0 31 14 0 GGUUACUGC-UA==GG-UGUUCGCCU\1" 516 "genome2\1" " genome2 intergene_19_65 0 4 0.0 38 19 0 GCAUUCGGU-GU==GC-CUAAGCACU\1" 517 "genome1\1" " genome1 intergene_17_65 0 4 0.0 38 21 0 GCUAUCGGU-GU==GC-CUAAGCCAU\1" 518 "genome1\1" " genome1 intergene_17_65 0 4 0.0 56 39 0 AGCCAUGCG-AG==AU-AUGUA\1" ""; 519 520 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); 521 } 522 { 523 const char *arguments[] = { 524 "prgnamefake", 525 "matchsequence=NGGUUN", 526 "matchacceptN=2", 527 "matchlimitN=3", 528 }; 529 CCP expectd = " organism genename------- mis N_mis wmis pos gpos rev 'NGGUUN'\1" 530 "genome1\1" " genome1 joined1 0 2 0.0 5 2 0 ........C-U====G-AUCCUGC\1" 531 "genome2\1" " genome2 intergene_19_65 0 2 0.0 21 2 0 ........G-A====A-CUGCAUUCG\1" 532 "genome1\1" " genome1 intergene_17_65 0 2 0.0 21 4 0 ......CAG-A====A-CUGCUAUCG\1" 533 "genome2\1" " genome2 gene3 0 2 0.0 5 4 0 ......UUU-C====G-AUC\1" 534 "genome2\1" " genome2 joined1 0 2 0.0 5 4 0 ......UUU-C====G-AUCCUGCCA\1" ""; 535 536 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); 537 } 538 539 { 540 const char *arguments[] = { 541 "prgnamefake", 542 "matchsequence=UGAUCCU", // exists in data 543 }; 544 CCP expectd = " organism genename mis N_mis wmis pos gpos rev 'UGAUCCU'\1" 545 "genome1\1" " genome1 gene2 0 0 0.0 9 1 0 .........-=======-GC\1" 546 "genome2\1" " genome2 gene2 0 0 0.0 9 3 0 .......GU-=======-GCCA\1" ""; 547 548 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); // @@@ defect: probe exists as well in 'joined1' (of both genomes) 549 } 550 { 551 const char *arguments[] = { 552 "prgnamefake", 553 "matchsequence=GAUCCU", 554 }; 555 CCP expectd = " organism genename mis N_mis wmis pos gpos rev 'GAUCCU'\1" 556 "genome2\1" " genome2 gene2 0 0 0.0 10 4 0 ......GUU-======-GCCA\1" ""; 557 558 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); // @@@ defect: probe is part of above probe, but reports less hits 559 } 560 { 561 const char *arguments[] = { 562 "prgnamefake", 563 "matchsequence=UUUCGG", // exists only in genome2 564 }; 565 CCP expectd = " organism genename mis N_mis wmis pos gpos rev 'UUUCGG'\1" 566 "genome2\1" " genome2 gene3 0 0 0.0 2 1 0 .........-======-UUGAUC\1" 567 "genome2\1" " genome2 joined1 0 0 0.0 2 1 0 .........-======-UUGAUCCUG\1" ""; 568 569 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); // @@@ defect: also exists in genome2/gene1 570 } 571 { 572 const char *arguments[] = { 573 "prgnamefake", 574 "matchsequence=AUCCUG", 575 }; 576 CCP expectd = " organism genename mis N_mis wmis pos gpos rev 'AUCCUG'\1" 577 "genome2\1" " genome2 gene2 0 0 0.0 11 5 0 .....GUUG-======-CCA\1" ""; 578 579 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); // @@@ defect: exists in 'gene2' and 'joined1' of both genomes 580 } 581 { 582 const char *arguments[] = { 583 "prgnamefake", 584 "matchsequence=UUGAUCCUGC", 585 }; 586 CCP expectd = " organism genename mis N_mis wmis pos gpos rev 'UUGAUCCUGC'\1" 587 "genome2\1" " genome2 gene2 0 0 0.0 8 2 0 ........G-==========-CA\1" 588 "genome1\1" " genome1 joined1 0 0 0.0 8 5 0 .....CUGG-==========-\1" ""; 589 590 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); // @@@ defect: also exists in 'genome2/joined1' 591 } 592 } 593 594 void TEST_SLOW_match_probe() { 595 bool use_gene_ptserver = false; 596 { 597 const char *arguments[] = { 598 "prgnamefake", 599 "matchsequence=UAUCGGAGAGUUUGA", 600 }; 601 CCP expected = " name---- fullname mis N_mis wmis pos ecoli rev 'UAUCGGAGAGUUUGA'\1" 602 "BcSSSS00\1" " BcSSSS00 0 0 0.0 3 2 0 .......UU-===============-UCAAGUCGA\1"; 603 604 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expected); 605 } 606 607 // ---------------------------------------------------------------------------- 608 // match with old(=default) N-mismatch-behavior (accepting 1 N-match) 609 610 { 611 const char *arguments[] = { 612 "prgnamefake", 613 "matchsequence=CANCUCCUUUC", // contains 1 N 614 NULL // matchmismatches 615 }; 616 617 CCP expectd0 = " name---- fullname mis N_mis wmis pos ecoli rev 'CANCUCCUUUC'\1" 618 "BcSSSS00\1" " BcSSSS00 0 1 0.0 176 162 0 CGGCUGGAU-==C========-U\1" ""; // only N-mismatch accepted 619 620 CCP expectd1 = " name---- fullname mis N_mis wmis pos ecoli rev 'CANCUCCUUUC'\1" 621 "BcSSSS00\1" " BcSSSS00 0 1 0.0 176 162 0 CGGCUGGAU-==C========-U\1" 622 "PbcAcet2\1" " PbcAcet2 0 2 0.0 176 162 0 CGGCUGGAU-==C=======N-N\1" 623 "ClfPerfr\1" " ClfPerfr 1 1 0.0 176 162 0 AGAUUAAUA-=CC========-U\1"; 624 625 CCP expectd2 = " name---- fullname mis N_mis wmis pos ecoli rev 'CANCUCCUUUC'\1" 626 "BcSSSS00\1" " BcSSSS00 0 1 0.0 176 162 0 CGGCUGGAU-==C========-U\1" 627 "PbcAcet2\1" " PbcAcet2 0 2 0.0 176 162 0 CGGCUGGAU-==C=======N-N\1" 628 "DlcTolu2\1" " DlcTolu2 0 3 0.0 176 162 0 CGGCUGGAU-==C======NN-N\1" 629 "ClfPerfr\1" " ClfPerfr 1 1 0.0 176 162 0 AGAUUAAUA-=CC========-U\1"; 630 631 arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 632 arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1); 633 arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2); 634 } 635 { 636 const char *arguments[] = { 637 "prgnamefake", 638 "matchsequence=UCACCUCCUUUC", // contains no N 639 NULL // matchmismatches 640 }; 641 642 CCP expectd0 = " name---- fullname mis N_mis wmis pos ecoli rev 'UCACCUCCUUUC'\1" 643 "BcSSSS00\1" " BcSSSS00 0 0 0.0 175 161 0 GCGGCUGGA-============-U\1" 644 "PbcAcet2\1" " PbcAcet2 0 1 0.0 175 161 0 GCGGCUGGA-===========N-N\1"; 645 646 CCP expectd1 = " name---- fullname mis N_mis wmis pos ecoli rev 'UCACCUCCUUUC'\1" 647 "BcSSSS00\1" " BcSSSS00 0 0 0.0 175 161 0 GCGGCUGGA-============-U\1" 648 "PbcAcet2\1" " PbcAcet2 0 1 0.0 175 161 0 GCGGCUGGA-===========N-N\1" 649 "DlcTolu2\1" " DlcTolu2 0 2 0.0 175 161 0 GCGGCUGGA-==========NN-N\1" ""; 650 651 CCP expectd2 = " name---- fullname mis N_mis wmis pos ecoli rev 'UCACCUCCUUUC'\1" 652 "BcSSSS00\1" " BcSSSS00 0 0 0.0 175 161 0 GCGGCUGGA-============-U\1" 653 "PbcAcet2\1" " PbcAcet2 0 1 0.0 175 161 0 GCGGCUGGA-===========N-N\1" 654 "DlcTolu2\1" " DlcTolu2 0 2 0.0 175 161 0 GCGGCUGGA-==========NN-N\1" 655 "ClfPerfr\1" " ClfPerfr 2 0 0.0 175 161 0 AAGAUUAAU-A=C=========-U\1" ""; 656 657 arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 658 arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1); 659 arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2); 660 } 661 662 // ---------------------------------------------- 663 // do not accept any N-matches as match 664 665 { 666 const char *arguments[] = { 667 "prgnamefake", 668 "matchsequence=CANCUCCUUUC", // contains 1 N 669 NULL, // matchmismatches 670 "matchacceptN=0", 671 }; 672 673 CCP expectd0 = ""; // nothing matches 674 675 CCP expectd1 = " name---- fullname mis N_mis wmis pos ecoli rev 'CANCUCCUUUC'\1" 676 "BcSSSS00\1" " BcSSSS00 0 1 0.0 176 162 0 CGGCUGGAU-==C========-U\1" ""; 677 678 CCP expectd2 = " name---- fullname mis N_mis wmis pos ecoli rev 'CANCUCCUUUC'\1" 679 "BcSSSS00\1" " BcSSSS00 0 1 0.0 176 162 0 CGGCUGGAU-==C========-U\1" 680 "PbcAcet2\1" " PbcAcet2 0 2 0.0 176 162 0 CGGCUGGAU-==C=======N-N\1" 681 "ClfPerfr\1" " ClfPerfr 1 1 0.0 176 162 0 AGAUUAAUA-=CC========-U\1" ""; 682 683 arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 684 arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1); 685 arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2); 686 } 687 { 688 const char *arguments[] = { 689 "prgnamefake", 690 "matchsequence=UCACCUCCUUUC", // contains no N 691 NULL, // matchmismatches 692 "matchacceptN=0", 693 }; 694 695 CCP expectd0 = " name---- fullname mis N_mis wmis pos ecoli rev 'UCACCUCCUUUC'\1" 696 "BcSSSS00\1" " BcSSSS00 0 0 0.0 175 161 0 GCGGCUGGA-============-U\1" ""; 697 698 CCP expectd1 = " name---- fullname mis N_mis wmis pos ecoli rev 'UCACCUCCUUUC'\1" 699 "BcSSSS00\1" " BcSSSS00 0 0 0.0 175 161 0 GCGGCUGGA-============-U\1" 700 "PbcAcet2\1" " PbcAcet2 0 1 0.0 175 161 0 GCGGCUGGA-===========N-N\1" ""; 701 702 CCP expectd2 = " name---- fullname mis N_mis wmis pos ecoli rev 'UCACCUCCUUUC'\1" 703 "BcSSSS00\1" " BcSSSS00 0 0 0.0 175 161 0 GCGGCUGGA-============-U\1" 704 "PbcAcet2\1" " PbcAcet2 0 1 0.0 175 161 0 GCGGCUGGA-===========N-N\1" 705 "DlcTolu2\1" " DlcTolu2 0 2 0.0 175 161 0 GCGGCUGGA-==========NN-N\1" 706 "ClfPerfr\1" " ClfPerfr 2 0 0.0 175 161 0 AAGAUUAAU-A=C=========-U\1" ""; 707 708 arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 709 arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1); 710 arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2); 711 } 712 713 // ---------------------------------- 714 // accept several N-matches 715 716 { 717 const char *arguments[] = { 718 "prgnamefake", 719 "matchsequence=CANCUCCUUNC", // contains 2 N 720 NULL, // matchmismatches 721 "matchacceptN=2", 722 "matchlimitN=4", 723 }; 724 725 CCP expectd0 = " name---- fullname mis N_mis wmis pos ecoli rev 'CANCUCCUUNC'\1" 726 "BcSSSS00\1" " BcSSSS00 0 2 0.0 176 162 0 CGGCUGGAU-==C======U=-U\1" ""; 727 728 CCP expectd1 = " name---- fullname mis N_mis wmis pos ecoli rev 'CANCUCCUUNC'\1" 729 "BcSSSS00\1" " BcSSSS00 0 2 0.0 176 162 0 CGGCUGGAU-==C======U=-U\1" 730 "DlcTolu2\1" " DlcTolu2 0 3 0.0 176 162 0 CGGCUGGAU-==C=======N-N\1" 731 "PbcAcet2\1" " PbcAcet2 0 3 0.0 176 162 0 CGGCUGGAU-==C======UN-N\1" 732 "ClfPerfr\1" " ClfPerfr 1 2 0.0 176 162 0 AGAUUAAUA-=CC======U=-U\1" ""; 733 734 CCP expectd2 = " name---- fullname mis N_mis wmis pos ecoli rev 'CANCUCCUUNC'\1" 735 "BcSSSS00\1" " BcSSSS00 0 2 0.0 176 162 0 CGGCUGGAU-==C======U=-U\1" 736 "DlcTolu2\1" " DlcTolu2 0 3 0.0 176 162 0 CGGCUGGAU-==C=======N-N\1" 737 "PbcAcet2\1" " PbcAcet2 0 3 0.0 176 162 0 CGGCUGGAU-==C======UN-N\1" 738 "ClfPerfr\1" " ClfPerfr 1 2 0.0 176 162 0 AGAUUAAUA-=CC======U=-U\1" ""; 739 740 arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 741 arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1); 742 arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2); 743 } 744 745 // -------------------------- 746 // truncate results 747 748 { 749 const char *arguments[] = { 750 "prgnamefake", 751 "matchsequence=CANCNCNNUNC", // contains 5N 752 NULL, // matchmismatches 753 "matchacceptN=5", 754 "matchlimitN=7", 755 "matchmaxresults=5", 756 }; 757 758 CCP expectd0 = " name---- fullname mis N_mis wmis pos ecoli rev 'CANCNCNNUNC'\1" 759 "BcSSSS00\1" " BcSSSS00 0 5 0.0 176 162 0 CGGCUGGAU-==C=U=CU=U=-U\1" ""; 760 761 CCP expectd1 = " name---- fullname mis N_mis wmis pos ecoli rev 'CANCNCNNUNC'\1" 762 "BcSSSS00\1" " BcSSSS00 0 5 0.0 176 162 0 CGGCUGGAU-==C=U=CU=U=-U\1" 763 "DlcTolu2\1" " DlcTolu2 0 6 0.0 176 162 0 CGGCUGGAU-==C=U=CU==N-N\1" 764 "PbcAcet2\1" " PbcAcet2 0 6 0.0 176 162 0 CGGCUGGAU-==C=U=CU=UN-N\1" 765 "LgtLytic\1" " LgtLytic 1 5 0.0 31 26 0 GUCGAACGG-==G=A=AG=CU-AGCUUGCUA\1" 766 "ClfPerfr\1" " ClfPerfr 1 5 0.0 111 99 0 CGGCUGGAU-==U=AUAA=G=-AGCGAUUGG\1"; // one hit is truncated here 767 768 CCP expectd2 = " name---- fullname mis N_mis wmis pos ecoli rev 'CANCNCNNUNC'\1" 769 "VbrFurni\1" " VbrFurni 2 5 0.0 40 35 0 CGGCAGCGA-==A=AUUGAA=-CUUCGGGGG\1" 770 "HllHalod\1" " HllHalod 2 5 0.0 45 40 0 AAACGAUGG-A=G=UUGC=U=-CAGGCGUCG\1" 771 "VblVulni\1" " VblVulni 2 5 0.0 49 44 0 AGCACAGAG-A=A=UUGU=U=-UCGGGUGGC\1" 772 "LgtLytic\1" " LgtLytic 2 5 0.0 101 89 0 GGGGAAACU-==AGCUAA=A=-CGCAUAAUC\1" 773 "ClfPerfr\1" " ClfPerfr 2 5 0.0 172 158 0 AGGAAGAUU-A=UAC=CC=C=-UUUCU\1"; // many hits are truncated here 774 775 arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 776 arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1); 777 arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2); 778 } 779 } 780 781 static char *extract_locations(const char *probe_design_result) { 782 const char *Target = strstr(probe_design_result, "\nTarget"); 783 if (Target) { 784 const char *designed = strchr(Target+7, '\n'); 785 if (designed) { 786 ++designed; 787 char *result = strdup(""); 788 789 while (designed) { 790 const char *eol = strchr(designed, '\n'); 791 const char *space1 = strchr(designed, ' '); if (!space1) break; // 1st space between probe and len 792 const char *nonspace = space1+strspn(space1, " "); if (!nonspace) break; 793 const char *space2 = strchr(nonspace, ' '); if (!space2) break; // 1st space between len and "X=" 794 const char *nonspace2 = space2+strspn(space2, " "); if (!nonspace2) break; 795 const char *space3 = strchr(nonspace2, ' '); if (!space3) break; // 1st space between "X=" and abs 796 const char *nonspace3 = space3+strspn(space3, " "); if (!nonspace3) break; 797 const char *space4 = strchr(nonspace3, ' '); if (!space4) break; // 1st space between abs and rest 798 799 char *abs = GB_strpartdup(nonspace3, space4-1); 800 801 freeset(result, GBS_global_string_copy("%s%c%c%s", result, space2[1], space2[2], abs)); 802 free(abs); 803 804 designed = eol ? eol+1 : NULL; 805 } 806 807 return result; 808 } 809 } 810 return strdup("can't extract"); 811 } 812 813 void TEST_SLOW_design_probe() { 814 bool use_gene_ptserver = false; 815 const char *arguments[] = { 816 "prgnamefake", 817 "designnames=ClnCorin#CltBotul#CPPParap#ClfPerfr", 818 "designmintargets=100", 819 }; 820 const char *expected = 821 "Probe design Parameters:\n" 822 "Length of probe 18\n" 823 "Temperature [ 0.0 -400.0]\n" 824 "GC-Content [30.0 -80.0]\n" 825 "E.Coli Position [any]\n" 826 "Max Non Group Hits 0\n" 827 "Min Group Hits 100%\n" 828 "Target le apos ecol grps G+C 4GC+2AT Probe sequence | Decrease T by n*.3C -> probe matches n non group species\n" 829 "CGAAAGGAAGAUUAAUAC 18 A= 94 82 4 33.3 48.0 GUAUUAAUCUUCCUUUCG | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n" 830 "GAAAGGAAGAUUAAUACC 18 A+ 1 83 4 33.3 48.0 GGUAUUAAUCUUCCUUUC | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n" 831 "UCAAGUCGAGCGAUGAAG 18 B= 18 17 4 50.0 54.0 CUUCAUCGCUCGACUUGA | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n" 832 "AUCAAGUCGAGCGAUGAA 18 B- 1 16 4 44.4 52.0 UUCAUCGCUCGACUUGAU | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3,\n"; 833 834 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expected); 835 836 // ------------------------------------------------------ 837 // design MANY probes to test location specifier 838 839 { 840 char *positions = extract_locations(expected); 841 TEST_ASSERT_EQUAL(positions, "A=94A+1B=18B-1"); 842 free(positions); 843 } 844 845 const char *arguments_loc[] = { 846 "prgnamefake", 847 // "designnames=Stsssola#Stsssola", // @@@ crashes the ptserver 848 "designnames=CPPParap#PsAAAA00", 849 "designmintargets=50", // hit at least 1 of the 2 targets 850 "designmingc=0", "designmaxgc=100", // allow all GCs 851 "designmishit=99999", // allow enough outgroup hits 852 "designmaxhits=99999", // do not limit results 853 "designprobelength=3", 854 }; 855 856 const char *expected_loc = 857 "A=96B=141C=20D=107B+1E=110F=84G=9H=150I=145C+1D+1J=17K=122L=72C-1M=33N=114E+1O=163" 858 "P=24E+2F+1Q=138R=54O+1S=49A-1T=87G+1J-1N-1U=79F+2U-1V=129I+2H-2C+2W=12D-1D+2C-2R+1" 859 "P-1J-2O+2V-2X=92W+2W+1Y=125Z=176D-2H+1a=104H-1L+1"; 860 861 TEST_ARB_PROBE_FILT(ARRAY_ELEMS(arguments_loc), arguments_loc, extract_locations, expected_loc); 862 } 863 864 void TEST_SLOW_match_designed_probe() { 865 bool use_gene_ptserver = false; 866 const char *arguments[] = { 867 "prgnamefake", 868 "matchsequence=UCAAGUCGAGCGAUGAAG", 869 }; 870 CCP expected = " name---- fullname mis N_mis wmis pos ecoli rev 'UCAAGUCGAGCGAUGAAG'\1" 871 "ClnCorin\1" " ClnCorin 0 0 0.0 18 17 0 .GAGUUUGA-==================-UUCCUUCGG\1" 872 "CltBotul\1" " CltBotul 0 0 0.0 18 17 0 ........A-==================-CUUCUUCGG\1" 873 "CPPParap\1" " CPPParap 0 0 0.0 18 17 0 AGAGUUUGA-==================-UUCCUUCGG\1" 874 "ClfPerfr\1" " ClfPerfr 0 0 0.0 18 17 0 AGAGUUUGA-==================-UUUCCUUCG\1"; 875 876 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expected); 463 877 } 464 878 465 879 void TEST_SLOW_variable_defaults_in_server() { 466 test_setup( );880 test_setup(false); 467 881 468 882 const char *server_tag = GBS_ptserver_tag(TEST_SERVER_ID); 469 TEST_ASSERT_NO_ERROR(arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag , 0));883 TEST_ASSERT_NO_ERROR(arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag)); 470 884 471 885 const char *servername = GBS_read_arb_tcp(server_tag);; … … 521 935 } 522 936 523 // ----------------------------------524 // test probe design / match525 526 #define TEST_PART1(fake_argc,fake_argv) \527 test_setup(); \528 TEST_ASSERT_EQUAL(true, parseCommandLine(fake_argc, fake_argv)); \529 P.SERVERID = TEST_SERVER_ID; \530 ARB_ERROR error; \531 char *answer = execute(error); \532 TEST_ASSERT_NO_ERROR(error.deliver()); \533 534 535 #define TEST_ARB_PROBE(fake_argc,fake_argv,expected) do { \536 TEST_PART1(fake_argc,fake_argv); \537 TEST_ASSERT_EQUAL(answer, expected); \538 free(answer); \539 } while(0)540 541 #define TEST_ARB_PROBE__BROKEN(fake_argc,fake_argv,expected) do { \542 TEST_PART1(fake_argc,fake_argv); \543 TEST_ASSERT_EQUAL__BROKEN(answer, expected); \544 free(answer); \545 } while(0)546 547 #define TEST_ARB_PROBE_FILT(fake_argc,fake_argv,filter,expected) do { \548 TEST_PART1(fake_argc,fake_argv); \549 char *filtered = filter(answer); \550 TEST_ASSERT_EQUAL(filtered, expected); \551 free(filtered); \552 free(answer); \553 } while(0)554 555 void TEST_SLOW_match_probe() {556 typedef const char *CCP;557 {558 const char *arguments[] = {559 "fake", // "program"-name560 "matchsequence=UAUCGGAGAGUUUGA",561 };562 CCP expected = " name---- fullname mis N_mis wmis pos rev 'UAUCGGAGAGUUUGA'\1"563 "BcSSSS00\1" " BcSSSS00 0 0 0.0 3 0 .......UU-===============-UCAAGUCGA\1";564 565 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expected);566 }567 568 // ----------------------------------------------------------------------------569 // match with old(=default) N-mismatch-behavior (accepting 1 N-match)570 571 {572 const char *arguments[] = {573 "fake", // "program"-name574 "matchsequence=CANCUCCUUUC", // contains 1 N575 NULL // matchmismatches576 };577 578 CCP expectd0 = " name---- fullname mis N_mis wmis pos rev 'CANCUCCUUUC'\1"579 "BcSSSS00\1" " BcSSSS00 0 1 0.0 176 0 CGGCUGGAU-==C========-U\1"; // only N-mismatch accepted580 581 CCP expectd1 = " name---- fullname mis N_mis wmis pos rev 'CANCUCCUUUC'\1"582 "BcSSSS00\1" " BcSSSS00 0 1 0.0 176 0 CGGCUGGAU-==C========-U\1"583 "PbcAcet2\1" " PbcAcet2 0 2 0.0 176 0 CGGCUGGAU-==C=======N-N\1"584 "ClfPerfr\1" " ClfPerfr 1 1 0.0 176 0 AGAUUAAUA-=CC========-U\1";585 586 CCP expectd2 = " name---- fullname mis N_mis wmis pos rev 'CANCUCCUUUC'\1"587 "BcSSSS00\1" " BcSSSS00 0 1 0.0 176 0 CGGCUGGAU-==C========-U\1"588 "PbcAcet2\1" " PbcAcet2 0 2 0.0 176 0 CGGCUGGAU-==C=======N-N\1"589 "DlcTolu2\1" " DlcTolu2 0 3 0.0 176 0 CGGCUGGAU-==C======NN-N\1"590 "ClfPerfr\1" " ClfPerfr 1 1 0.0 176 0 AGAUUAAUA-=CC========-U\1";591 592 arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0);593 arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1);594 arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2);595 }596 {597 const char *arguments[] = {598 "fake", // "program"-name599 "matchsequence=UCACCUCCUUUC", // contains no N600 NULL // matchmismatches601 };602 603 CCP expectd0 = " name---- fullname mis N_mis wmis pos rev 'UCACCUCCUUUC'\1"604 "BcSSSS00\1" " BcSSSS00 0 0 0.0 175 0 GCGGCUGGA-============-U\1"605 "PbcAcet2\1" " PbcAcet2 0 1 0.0 175 0 GCGGCUGGA-===========N-N\1" "";606 607 CCP expectd1 = " name---- fullname mis N_mis wmis pos rev 'UCACCUCCUUUC'\1"608 "BcSSSS00\1" " BcSSSS00 0 0 0.0 175 0 GCGGCUGGA-============-U\1"609 "PbcAcet2\1" " PbcAcet2 0 1 0.0 175 0 GCGGCUGGA-===========N-N\1"610 "DlcTolu2\1" " DlcTolu2 0 2 0.0 175 0 GCGGCUGGA-==========NN-N\1" "";611 612 CCP expectd2 = " name---- fullname mis N_mis wmis pos rev 'UCACCUCCUUUC'\1"613 "BcSSSS00\1" " BcSSSS00 0 0 0.0 175 0 GCGGCUGGA-============-U\1"614 "PbcAcet2\1" " PbcAcet2 0 1 0.0 175 0 GCGGCUGGA-===========N-N\1"615 "DlcTolu2\1" " DlcTolu2 0 2 0.0 175 0 GCGGCUGGA-==========NN-N\1"616 "ClfPerfr\1" " ClfPerfr 2 0 0.0 175 0 AAGAUUAAU-A=C=========-U\1" "";617 618 arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0);619 arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1);620 arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2);621 }622 623 // ----------------------------------------------624 // do not accept any N-matches as match625 626 {627 const char *arguments[] = {628 "fake", // "program"-name629 "matchsequence=CANCUCCUUUC", // contains 1 N630 NULL, // matchmismatches631 "matchacceptN=0",632 };633 634 CCP expectd0 = ""; // nothing matches635 636 CCP expectd1 = " name---- fullname mis N_mis wmis pos rev 'CANCUCCUUUC'\1"637 "BcSSSS00\1" " BcSSSS00 0 1 0.0 176 0 CGGCUGGAU-==C========-U\1" "";638 639 CCP expectd2 = " name---- fullname mis N_mis wmis pos rev 'CANCUCCUUUC'\1"640 "BcSSSS00\1" " BcSSSS00 0 1 0.0 176 0 CGGCUGGAU-==C========-U\1"641 "PbcAcet2\1" " PbcAcet2 0 2 0.0 176 0 CGGCUGGAU-==C=======N-N\1"642 "ClfPerfr\1" " ClfPerfr 1 1 0.0 176 0 AGAUUAAUA-=CC========-U\1" "";643 644 arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0);645 arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1);646 arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2);647 }648 {649 const char *arguments[] = {650 "fake", // "program"-name651 "matchsequence=UCACCUCCUUUC", // contains no N652 NULL, // matchmismatches653 "matchacceptN=0",654 };655 656 CCP expectd0 = " name---- fullname mis N_mis wmis pos rev 'UCACCUCCUUUC'\1"657 "BcSSSS00\1" " BcSSSS00 0 0 0.0 175 0 GCGGCUGGA-============-U\1" "";658 659 CCP expectd1 = " name---- fullname mis N_mis wmis pos rev 'UCACCUCCUUUC'\1"660 "BcSSSS00\1" " BcSSSS00 0 0 0.0 175 0 GCGGCUGGA-============-U\1"661 "PbcAcet2\1" " PbcAcet2 0 1 0.0 175 0 GCGGCUGGA-===========N-N\1" "";662 663 CCP expectd2 = " name---- fullname mis N_mis wmis pos rev 'UCACCUCCUUUC'\1"664 "BcSSSS00\1" " BcSSSS00 0 0 0.0 175 0 GCGGCUGGA-============-U\1"665 "PbcAcet2\1" " PbcAcet2 0 1 0.0 175 0 GCGGCUGGA-===========N-N\1"666 "DlcTolu2\1" " DlcTolu2 0 2 0.0 175 0 GCGGCUGGA-==========NN-N\1"667 "ClfPerfr\1" " ClfPerfr 2 0 0.0 175 0 AAGAUUAAU-A=C=========-U\1" "";668 669 arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0);670 arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1);671 arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2);672 }673 674 // ----------------------------------675 // accept several N-matches676 677 {678 const char *arguments[] = {679 "fake", // "program"-name680 "matchsequence=CANCUCCUUNC", // contains 2 N681 NULL, // matchmismatches682 "matchacceptN=2",683 "matchlimitN=4",684 };685 686 CCP expectd0 = " name---- fullname mis N_mis wmis pos rev 'CANCUCCUUNC'\1"687 "BcSSSS00\1" " BcSSSS00 0 2 0.0 176 0 CGGCUGGAU-==C======U=-U\1" "";688 689 CCP expectd1 = " name---- fullname mis N_mis wmis pos rev 'CANCUCCUUNC'\1"690 "BcSSSS00\1" " BcSSSS00 0 2 0.0 176 0 CGGCUGGAU-==C======U=-U\1"691 "DlcTolu2\1" " DlcTolu2 0 3 0.0 176 0 CGGCUGGAU-==C=======N-N\1"692 "PbcAcet2\1" " PbcAcet2 0 3 0.0 176 0 CGGCUGGAU-==C======UN-N\1"693 "ClfPerfr\1" " ClfPerfr 1 2 0.0 176 0 AGAUUAAUA-=CC======U=-U\1" "";694 695 CCP expectd2 = " name---- fullname mis N_mis wmis pos rev 'CANCUCCUUNC'\1"696 "BcSSSS00\1" " BcSSSS00 0 2 0.0 176 0 CGGCUGGAU-==C======U=-U\1"697 "DlcTolu2\1" " DlcTolu2 0 3 0.0 176 0 CGGCUGGAU-==C=======N-N\1"698 "PbcAcet2\1" " PbcAcet2 0 3 0.0 176 0 CGGCUGGAU-==C======UN-N\1"699 "ClfPerfr\1" " ClfPerfr 1 2 0.0 176 0 AGAUUAAUA-=CC======U=-U\1" "";700 701 arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0);702 arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1);703 arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2);704 }705 706 // --------------------------707 // truncate results708 709 {710 const char *arguments[] = {711 "fake", // "program"-name712 "matchsequence=CANCNCNNUNC", // contains 5N713 NULL, // matchmismatches714 "matchacceptN=5",715 "matchlimitN=7",716 "matchmaxresults=5",717 };718 719 CCP expectd0 = " name---- fullname mis N_mis wmis pos rev 'CANCNCNNUNC'\1"720 "BcSSSS00\1" " BcSSSS00 0 5 0.0 176 0 CGGCUGGAU-==C=U=CU=U=-U\1" "";721 722 CCP expectd1 = " name---- fullname mis N_mis wmis pos rev 'CANCNCNNUNC'\1"723 "BcSSSS00\1" " BcSSSS00 0 5 0.0 176 0 CGGCUGGAU-==C=U=CU=U=-U\1"724 "DlcTolu2\1" " DlcTolu2 0 6 0.0 176 0 CGGCUGGAU-==C=U=CU==N-N\1"725 "PbcAcet2\1" " PbcAcet2 0 6 0.0 176 0 CGGCUGGAU-==C=U=CU=UN-N\1"726 "LgtLytic\1" " LgtLytic 1 5 0.0 31 0 GUCGAACGG-==G=A=AG=CU-AGCUUGCUA\1"727 "ClfPerfr\1" " ClfPerfr 1 5 0.0 111 0 CGGCUGGAU-==U=AUAA=G=-AGCGAUUGG\1"; // one hit is truncated here728 729 CCP expectd2 = " name---- fullname mis N_mis wmis pos rev 'CANCNCNNUNC'\1"730 "VbrFurni\1" " VbrFurni 2 5 0.0 40 0 CGGCAGCGA-==A=AUUGAA=-CUUCGGGGG\1"731 "HllHalod\1" " HllHalod 2 5 0.0 45 0 AAACGAUGG-A=G=UUGC=U=-CAGGCGUCG\1"732 "VblVulni\1" " VblVulni 2 5 0.0 49 0 AGCACAGAG-A=A=UUGU=U=-UCGGGUGGC\1"733 "LgtLytic\1" " LgtLytic 2 5 0.0 101 0 GGGGAAACU-==AGCUAA=A=-CGCAUAAUC\1"734 "ClfPerfr\1" " ClfPerfr 2 5 0.0 172 0 AGGAAGAUU-A=UAC=CC=C=-UUUCU\1" ""; // many hits are truncated here735 736 arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0);737 arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1);738 arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2);739 }740 }741 742 static char *extract_locations(const char *probe_design_result) {743 const char *Target = strstr(probe_design_result, "\nTarget");744 if (Target) {745 const char *designed = strchr(Target+7, '\n');746 if (designed) {747 ++designed;748 char *result = strdup("");749 750 while (designed) {751 const char *eol = strchr(designed, '\n');752 const char *space1 = strchr(designed, ' '); if (!space1) break; // 1st space between probe and len753 const char *nonspace = space1+strspn(space1, " "); if (!nonspace) break;754 const char *space2 = strchr(nonspace, ' '); if (!space2) break; // 1st space between len and "X="755 const char *nonspace2 = space2+strspn(space2, " "); if (!nonspace2) break;756 const char *space3 = strchr(nonspace2, ' '); if (!space3) break; // 1st space between "X=" and abs757 const char *nonspace3 = space3+strspn(space3, " "); if (!nonspace3) break;758 const char *space4 = strchr(nonspace3, ' '); if (!space4) break; // 1st space between abs and rest759 760 char *abs = GB_strpartdup(nonspace3, space4-1);761 762 freeset(result, GBS_global_string_copy("%s%c%c%s", result, space2[1], space2[2], abs));763 free(abs);764 765 designed = eol ? eol+1 : NULL;766 }767 768 return result;769 }770 }771 return strdup("can't extract");772 }773 774 void TEST_SLOW_design_probe() {775 const char *arguments[] = {776 "fake", // "program"-name777 "designnames=ClnCorin#CltBotul#CPPParap#ClfPerfr",778 "designmintargets=100",779 };780 const char *expected =781 "Probe design Parameters:\n"782 "Length of probe 18\n"783 "Temperature [ 0.0 -400.0]\n"784 "GC-Content [30.0 -80.0]\n"785 "E.Coli Position [any]\n"786 "Max Non Group Hits 0\n"787 "Min Group Hits 100%\n"788 "Target le apos ecol grps G+C 4GC+2AT Probe sequence | Decrease T by n*.3C -> probe matches n non group species\n"789 "CGAAAGGAAGAUUAAUAC 18 A= 94 94 4 33.3 48.0 GUAUUAAUCUUCCUUUCG | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"790 "GAAAGGAAGAUUAAUACC 18 A+ 1 95 4 33.3 48.0 GGUAUUAAUCUUCCUUUC | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"791 "UCAAGUCGAGCGAUGAAG 18 B= 18 18 4 50.0 54.0 CUUCAUCGCUCGACUUGA | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"792 "AUCAAGUCGAGCGAUGAA 18 B- 1 17 4 44.4 52.0 UUCAUCGCUCGACUUGAU | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3,\n";793 794 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expected);795 796 // ------------------------------------------------------797 // design MANY probes to test location specifier798 799 {800 char *positions = extract_locations(expected);801 TEST_ASSERT_EQUAL(positions, "A=94A+1B=18B-1");802 free(positions);803 }804 805 const char *arguments_loc[] = {806 "fake", // "program"-name807 // "designnames=Stsssola#Stsssola", // @@@ crashes the ptserver808 "designnames=CPPParap#PsAAAA00",809 "designmintargets=50", // hit at least 1 of the 2 targets810 "designmingc=0", "designmaxgc=100", // allow all GCs811 "designmishit=99999", // allow enough outgroup hits812 "designmaxhits=99999", // do not limit results813 "designprobelength=3",814 };815 816 const char *expected_loc =817 "A=96B=141C=20D=107B+1E=110F=84G=9H=150I=145C+1D+1J=17K=122L=72C-1M=33N=114E+1O=163"818 "P=24E+2F+1Q=138R=54O+1S=49A-1T=87G+1J-1N-1U=79F+2U-1V=129I+2H-2C+2W=12D-1D+2C-2R+1"819 "P-1J-2O+2V-2X=92W+2W+1Y=125Z=176D-2H+1a=104H-1L+1";820 821 TEST_ARB_PROBE_FILT(ARRAY_ELEMS(arguments_loc), arguments_loc, extract_locations, expected_loc);822 }823 824 void TEST_SLOW_match_designed_probe() {825 const char *arguments[] = {826 "fake", // "program"-name827 "matchsequence=UCAAGUCGAGCGAUGAAG",828 };829 const char *expected =830 " name---- fullname mis N_mis wmis pos rev 'UCAAGUCGAGCGAUGAAG'\1"831 "ClnCorin\1" " ClnCorin 0 0 0.0 18 0 .GAGUUUGA-==================-UUCCUUCGG\1"832 "CltBotul\1" " CltBotul 0 0 0.0 18 0 ........A-==================-CUUCUUCGG\1"833 "CPPParap\1" " CPPParap 0 0 0.0 18 0 AGAGUUUGA-==================-UUCCUUCGG\1"834 "ClfPerfr\1" " ClfPerfr 0 0 0.0 18 0 AGAGUUUGA-==================-UUUCCUUCG\1";835 836 TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expected);837 }838 839 840 937 #endif -
branches/dev_elmar/TOOLS/arb_replace.cxx
r7314 r8224 10 10 11 11 #include <arb_strbuf.h> 12 #include <arb_file.h> 12 13 #include <arbdb.h> 13 14 -
branches/dev_elmar/TOOLS/arb_test.cxx
r7945 r8224 12 12 #include <arbdbt.h> 13 13 #include <arb_defs.h> 14 #include <unistd.h> 14 15 15 16 int main(int, char **) { … … 21 22 22 23 #ifdef UNIT_TESTS 24 #include <arb_file.h> 23 25 #include <test_unit.h> 24 26 #include <ut_valgrinded.h> … … 27 29 28 30 31 inline void make_valgrinded_call_from_pipe(char *&command) { 32 using namespace utvg; 33 static valgrind_info valgrind; 34 if (valgrind.wanted) { 35 char *pipeSym = strchr(command, '|'); 36 if (pipeSym) { 37 char *left = GB_strpartdup(command, pipeSym-1); 38 char *right = strdup(pipeSym+1); 39 40 make_valgrinded_call(left); 41 make_valgrinded_call_from_pipe(right); 42 43 freeset(command, GBS_global_string_copy("%s | %s", left, right)); 44 45 free(right); 46 free(left); 47 } 48 else { 49 make_valgrinded_call(command); 50 } 51 } 52 } 53 29 54 inline GB_ERROR valgrinded_system(const char *cmdline) { 30 char *cmddup = strdup(cmdline); 31 make_valgrinded_call(cmddup); 32 GB_ERROR error = GB_system(cmddup); 55 char *cmddup = strdup(cmdline); 56 make_valgrinded_call_from_pipe(cmddup); 57 58 GB_ERROR error = GBK_system(cmddup); 33 59 free(cmddup); 34 60 return error; … … 36 62 37 63 #define RUN_TOOL(cmdline) valgrinded_system(cmdline) 38 #define RUN_TOOL_NEVER_VALGRIND(cmdline) GB _system(cmdline)64 #define RUN_TOOL_NEVER_VALGRIND(cmdline) GBK_system(cmdline) 39 65 40 66 #define TEST_RUN_TOOL(cmdline) TEST_ASSERT_NO_ERROR(RUN_TOOL(cmdline)) … … 55 81 // test conversion (bin->ascii->bin) via stream (this tests 'arb_repair') 56 82 TEST_RUN_TOOL(GBS_global_string("arb_2_ascii %s - | arb_2_bin - %s", binary, binary_2ND)); 83 57 84 // TEST_ASSERT_FILES_EQUAL(binary, binary_2ND); // can't compare binary files (they contain undefined bytes) 85 86 // instead convert back to ascii and compare result with original 58 87 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink(ascii)); 59 88 TEST_RUN_TOOL(GBS_global_string("arb_2_ascii %s %s", binary_2ND, ascii)); 60 89 TEST_ASSERT_FILES_EQUAL(ascii, ascii_ORG); 61 90 62 91 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink(ascii)); 63 92 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink(binary)); … … 65 94 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink("ascii2bin.ARF")); 66 95 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink("ascii2bin2.ARF")); 67 }68 69 void TEST_SLOW_arb_gene_probe() {70 const char *genome = "tools/gene_probe.arb";71 const char *out = "tools/gene_probe_out.arb";72 const char *expected = "tools/gene_probe_expected.arb";73 74 TEST_RUN_TOOL(GBS_global_string("arb_gene_probe %s %s", genome, out));75 TEST_ASSERT_FILES_EQUAL(out, expected);76 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink(out));77 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink("tools/gene_probe_out.ARM"));78 96 } 79 97 … … 180 198 181 199 void TEST_arb_replace() { 182 const char *infile = "tools/ gene_probe.arb";200 const char *infile = "tools/arb_replace.in"; 183 201 const char *file1 = "tools/arb_replace_1.out"; 184 202 const char *file2 = "tools/arb_replace_2.out"; … … 221 239 char *cmd = GBS_global_string_copy("bash -c '%s >stdout.log 2>stderr.log'", escaped); 222 240 223 appendError(GB _system(cmd));241 appendError(GBK_system(cmd)); 224 242 free(cmd); 225 243 free(escaped); … … 298 316 " matchsequence=UAUCGGAGAGUUUGA", 299 317 300 " name---- fullname mis N_mis wmis pos rev 'UAUCGGAGAGUUUGA'" 301 "BcSSSS00" 302 " BcSSSS00 0 0 0.0 3 0 .......UU-===============-UCAAGUCGA" 303 ); 318 /* ---- */ " name---- fullname mis N_mis wmis pos ecoli rev 'UAUCGGAGAGUUUGA'\1" 319 "BcSSSS00\1" " BcSSSS00 0 0 0.0 3 2 0 .......UU-===============-UCAAGUCGA\1" 320 ); 304 321 305 322 TEST_STDOUT_EQUALS("arb_probe" … … 316 333 "Min Group Hits 100%\n" 317 334 "Target le apos ecol grps G+C 4GC+2AT Probe sequence | Decrease T by n*.3C -> probe matches n non group species\n" 318 "CGAAAGGAAGAUUAAUAC 18 A= 94 944 33.3 48.0 GUAUUAAUCUUCCUUUCG | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"319 "GAAAGGAAGAUUAAUACC 18 A+ 1 954 33.3 48.0 GGUAUUAAUCUUCCUUUC | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"320 "UCAAGUCGAGCGAUGAAG 18 B= 18 1 84 50.0 54.0 CUUCAUCGCUCGACUUGA | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"321 "AUCAAGUCGAGCGAUGAA 18 B- 1 1 74 44.4 52.0 UUCAUCGCUCGACUUGAU | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3,\n"335 "CGAAAGGAAGAUUAAUAC 18 A= 94 82 4 33.3 48.0 GUAUUAAUCUUCCUUUCG | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n" 336 "GAAAGGAAGAUUAAUACC 18 A+ 1 83 4 33.3 48.0 GGUAUUAAUCUUCCUUUC | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n" 337 "UCAAGUCGAGCGAUGAAG 18 B= 18 17 4 50.0 54.0 CUUCAUCGCUCGACUUGA | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n" 338 "AUCAAGUCGAGCGAUGAA 18 B- 1 16 4 44.4 52.0 UUCAUCGCUCGACUUGAU | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3,\n" 322 339 ); 323 340 } … … 371 388 } 372 389 390 static char *notification_result = NULL; 391 static void test_notification_cb(const char *message, void *cd) { 392 const char *cds = (const char *)cd; 393 notification_result = GBS_global_string_copy("message='%s' cd='%s'", message, cds); 394 } 395 396 #define INIT_NOTIFICATION \ 397 GB_shell shell; \ 398 GBDATA *gb_main = GBT_open("nosuch.arb", "crw"); \ 399 const char *cd = "some argument"; \ 400 char *cmd = GB_generate_notification(gb_main, test_notification_cb, "the note", (void*)cd) 401 402 #define EXIT_NOTIFICATION \ 403 GB_close(gb_main); \ 404 free(cmd) 405 406 #define TEST_DBSERVER_OPEN(gbmain) TEST_ASSERT_NO_ERROR(GBCMS_open(":", 0, gbmain)) 407 #define TEST_DBSERVER_SERVE_UNTIL(gbmain, cond) do { \ 408 bool success = GBCMS_accept_calls(gb_main, false); \ 409 while (success) success = GBCMS_accept_calls(gb_main, true); \ 410 GB_usleep(10000); \ 411 } while(!(cond)) 412 413 #define TEST_DBSERVER_CLOSE(gbmain) GBCMS_shutdown(gb_main) 414 415 void TEST_close_with_pending_notification() { 416 INIT_NOTIFICATION; 417 EXIT_NOTIFICATION; 418 } 419 void TEST_close_after_pending_notification_removed() { 420 INIT_NOTIFICATION; 421 TEST_ASSERT_NO_ERROR(GB_remove_last_notification(gb_main)); 422 EXIT_NOTIFICATION; 423 } 424 void TEST_arb_notify() { 425 INIT_NOTIFICATION; 426 427 TEST_DBSERVER_OPEN(gb_main); 428 429 TEST_ASSERT_NULL(notification_result); 430 TEST_ASSERT_NO_ERROR(GBK_system(GBS_global_string("%s &", cmd))); // async call to arb_notify 431 432 TEST_DBSERVER_SERVE_UNTIL(gb_main, notification_result); 433 TEST_DBSERVER_CLOSE(gb_main); 434 435 TEST_ASSERT_EQUAL(notification_result, "message='the note' cd='some argument'"); 436 freenull(notification_result); 437 438 EXIT_NOTIFICATION; 439 } 440 373 441 #endif // UNIT_TESTS 374 442 -
branches/dev_elmar/UNIT_TESTER/Makefile
r7945 r8224 64 64 TestEnvironment.o: $(ARBHOME)/INCLUDE/arb_defs.h 65 65 TestEnvironment.o: $(ARBHOME)/INCLUDE/arb_error.h 66 TestEnvironment.o: $(ARBHOME)/INCLUDE/arb_file.h 66 67 TestEnvironment.o: $(ARBHOME)/INCLUDE/arb_msg.h 67 68 TestEnvironment.o: $(ARBHOME)/INCLUDE/arb_str.h -
branches/dev_elmar/UNIT_TESTER/Makefile.suite
r7945 r8224 12 12 PATCHNAMESUFFIX:= 13 13 14 VALGRIND_INTERNAL=$(findstring B,$(VALGRIND))$(findstring A,$(VALGRIND)) 15 VALGRIND_EXTERNAL=$(findstring E,$(VALGRIND)) 16 VALGRIND_ANY=$(VALGRIND_INTERNAL)$(VALGRIND_EXTERNAL) 17 14 18 # -------------------- build patch name 15 19 … … 17 21 PATCHNAMESUFFIX:=$(PATCHNAMESUFFIX)__only_$(RESTRICT_LIB) 18 22 endif 23 19 24 ifneq ($(RESTRICT_MODULE),'.') 20 25 PATCHNAMESUFFIX:=$(PATCHNAMESUFFIX)__notAllFiles 21 26 endif 27 22 28 SKIPPED_SLOW:=$(shell (test -f skipslow.stamp && ls -1 skipslow.stamp)) 23 29 ifneq ('$(SKIPPED_SLOW)','') 24 30 PATCHNAMESUFFIX:=$(PATCHNAMESUFFIX)__SLOW_skipped 25 31 endif 32 33 ifneq ('$(VALGRIND_ANY)','') 34 PATCHNAMESUFFIX:=$(PATCHNAMESUFFIX)__valgrinded_$(VALGRIND_ANY) 35 endif 36 26 37 PATCHNAMESUFFIX:=$(subst :,_,$(PATCHNAMESUFFIX)) 27 38 28 39 # -------------------- targets 29 40 30 VALGRIND_EXTERNAL=$(findstring E,$(VALGRIND))31 32 41 cleanup_environment: 33 ./test_environment clean 42 ./test_environment clean || echo "Failed to clean environment (maybe some setup/cleanup crashed?)" 34 43 ifeq ($(VALGRIND_EXTERNAL),E) 35 44 ./valgrind/arb_valgrind_logged WAIT -
branches/dev_elmar/UNIT_TESTER/README.txt
r7945 r8224 157 157 stored inside $ARBHOME/patches.arb/ 158 158 159 After DELETE_PATCHES_AFTERseconds the patch will be deleted automatically160 (see Makefile.setup.local) .159 After PATCHES_KEEP_HOURS seconds the patch will be deleted automatically 160 (see Makefile.setup.local), considering at least PATCHES_MIN_KEPT patches remain. 161 161 162 162 8. Building tests -
branches/dev_elmar/UNIT_TESTER/TestEnvironment.cxx
r7945 r8224 14 14 #include <arb_defs.h> 15 15 #include <arb_str.h> 16 #include <arb_file.h> 16 17 #include <arbdb.h> 17 18 #include <PT_com.h> … … 27 28 28 29 #include <sys/stat.h> 30 #include <sys/time.h> 29 31 30 32 … … 39 41 enum Mode { UNKNOWN, SETUP, CLEAN }; 40 42 static const char *mode_command[] = { NULL, "setup", "clean" }; // same order as in enum Mode 41 42 typedef GB_ERROR Error; 43 static Mode other_mode[] = { UNKNOWN, CLEAN, SETUP }; 44 45 typedef SmartCharPtr Error; 43 46 44 47 static const char *upcase(const char *str) { … … 63 66 } 64 67 68 #if defined(DEBUG) 69 // #define DUMP_MUTEX_ACCESS 70 #endif 71 72 65 73 class Mutex : virtual Noncopyable { 66 74 string name; … … 68 76 69 77 bool mutexdir_exists() const { return GB_is_directory(mutexdir.c_str()); } 78 79 static const char *now() { 80 static char buf[100]; 81 timeval t; 82 gettimeofday(&t, NULL); 83 sprintf(buf, "%li.%li", t.tv_sec, t.tv_usec); 84 return buf; 85 } 70 86 71 87 static set<string> known_mutexes; … … 83 99 arb_assert(maxwait>0); 84 100 101 test_data().entered_mutex_loop = true; // avoid race-condition 85 102 while (!gotMutex) { 86 103 if (mutexdir_exists()) { 87 104 if (wait>maxwait && mutexdir_exists()) { 88 GBK_terminatef(" Failed to get mutex for more than %i seconds", maxwait);89 } 90 printf(" mutex '%s' exists.. sleeping\n", name.c_str());105 GBK_terminatef("[%s] Failed to get mutex for more than %i seconds", now(), maxwait); 106 } 107 printf("[%s] mutex '%s' exists.. sleeping\n", now(), name.c_str()); 91 108 sleep(1); 92 109 wait++; … … 95 112 int res = mkdir(mutexdir.c_str(), S_IRWXU); 96 113 if (res == 0) { 97 printf("allocated mutex '%s'\n", name.c_str()); 114 #if defined(DUMP_MUTEX_ACCESS) 115 printf("[%s] allocated mutex '%s'\n", now(), name.c_str()); 116 #endif 98 117 gotMutex = true; 99 118 } 100 119 else { 101 120 wait = 0; // reset timeout 102 printf(" lost race for mutex '%s'\n", name.c_str());121 printf("[%s] lost race for mutex '%s'\n", now(), name.c_str()); 103 122 } 104 123 } … … 108 127 ~Mutex() { 109 128 if (!mutexdir_exists()) { 110 printf(" Strange - mutex '%s' has vanished\n", name.c_str());129 printf("[%s] Strange - mutex '%s' has vanished\n", now(), name.c_str()); 111 130 } 112 131 else { 113 132 if (rmdir(mutexdir.c_str()) != 0) { 114 133 const char *error = GB_IO_error("remove", mutexdir.c_str()); 115 GBK_terminatef(" Failed to release mutex dir (%s)", error);134 GBK_terminatef("[%s] Failed to release mutex dir (%s)", now(), error); 116 135 } 117 136 else { 118 printf("released mutex '%s'\n", mutexdir.c_str()); 137 #if defined(DUMP_MUTEX_ACCESS) 138 printf("[%s] released mutex '%s'\n", now(), mutexdir.c_str()); 139 #endif 119 140 } 120 141 } … … 162 183 if (!fp) { 163 184 GB_ERROR error = GB_IO_error("creating flag", flagfile); 164 StaticCode::errorf(__FILE__, __LINE__, "%s\n", error);185 HERE.errorf(true, "%s\n", error); 165 186 } 166 187 fclose(fp); … … 176 197 if (res != 0) { 177 198 GB_ERROR error = GB_IO_error("unlinking", flagfile); 178 StaticCode::errorf(__FILE__, __LINE__, "%s\n", error);199 HERE.errorf(true, "%s\n", error); 179 200 } 180 201 env_assert(!flagFileExists()); … … 209 230 PersistantFlag& operator = (bool b) { 210 231 if (b != bool(*this)) { 232 StaticCode::printf("Changing flag '%s' to %i\n", name.c_str(), int(b)); 211 233 value = b; 212 234 updateFlagFile(); … … 270 292 // ptserver 271 293 272 static void test_ptserver_activate(bool start ) {273 const char *server_tag = GBS_ptserver_tag( TEST_SERVER_ID);294 static void test_ptserver_activate(bool start, int serverid) { 295 const char *server_tag = GBS_ptserver_tag(serverid); 274 296 if (start) { 275 TEST_ASSERT_NO_ERROR(arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag , 0));297 TEST_ASSERT_NO_ERROR(arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag)); 276 298 } 277 299 else { // stop … … 288 310 // TEST_SETUP_GLOBAL_ENVIRONMENT("ptserver"); 289 311 312 Error error; 290 313 switch (mode) { 291 314 case SETUP: { 292 test_ptserver_activate(false );// first kill pt-server (otherwise we may test an outdated pt-server)293 TEST_ASSERT_NO_ERROR(GB _system("touchTEST_pt.arb")); // force rebuild294 test_ptserver_activate(true );315 test_ptserver_activate(false, TEST_SERVER_ID); // first kill pt-server (otherwise we may test an outdated pt-server) 316 TEST_ASSERT_NO_ERROR(GBK_system("cp TEST_pt_src.arb TEST_pt.arb")); // force rebuild 317 test_ptserver_activate(true, TEST_SERVER_ID); 295 318 TEST_ASSERT_FILES_EQUAL("TEST_pt.arb.pt.expected", "TEST_pt.arb.pt"); 296 319 TEST_ASSERT(GB_time_of_file("TEST_pt.arb.pt") >= GB_time_of_file("TEST_pt.arb")); … … 298 321 } 299 322 case CLEAN: { 300 test_ptserver_activate(false );323 test_ptserver_activate(false, TEST_SERVER_ID); 301 324 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(unlink("TEST_pt.arb.pt")); 302 325 break; … … 307 330 } 308 331 309 return NULL; 332 return error; 333 } 334 335 static Error ptserver_gene(Mode mode) { 336 // test-gene-ptserver is restarted and rebuild. 337 // This is done only once in the complete test suite. 338 // 339 // every unit-test using the test-gene-ptserver should simply call 340 // TEST_SETUP_GLOBAL_ENVIRONMENT("ptserver_gene"); 341 342 // #define TEST_AUTO_UPDATE 343 344 Error error; 345 switch (mode) { 346 case SETUP: { 347 test_ptserver_activate(false, TEST_GENESERVER_ID); // first kill pt-server (otherwise we may test an outdated pt-server) 348 TEST_ASSERT_NO_ERROR(GBK_system("arb_gene_probe TEST_gpt_src.arb TEST_gpt.arb")); // prepare gene-ptserver-db (forcing rebuild) 349 350 #if defined(TEST_AUTO_UPDATE) 351 TEST_COPY_FILE("TEST_gpt.arb", "TEST_gpt.arb.expected"); 352 #else // !defined(TEST_AUTO_UPDATE) 353 TEST_ASSERT_FILES_EQUAL("TEST_gpt.arb.expected", "TEST_gpt.arb"); 354 #endif 355 356 test_ptserver_activate(true, TEST_GENESERVER_ID); 357 358 #if defined(TEST_AUTO_UPDATE) 359 TEST_COPY_FILE("TEST_gpt.arb.pt", "TEST_gpt.arb.pt.expected"); 360 #else // !defined(TEST_AUTO_UPDATE) 361 TEST_ASSERT_FILES_EQUAL("TEST_gpt.arb.pt.expected", "TEST_gpt.arb.pt"); 362 #endif 363 364 TEST_ASSERT(GB_time_of_file("TEST_gpt.arb.pt") >= GB_time_of_file("TEST_gpt.arb")); 365 break; 366 } 367 case CLEAN: { 368 test_ptserver_activate(false, TEST_GENESERVER_ID); 369 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(unlink("TEST_gpt.arb.pt")); 370 break; 371 } 372 case UNKNOWN: 373 env_assert(0); 374 break; 375 } 376 377 #undef TEST_AUTO_UPDATE 378 379 return error; 310 380 } 311 381 … … 314 384 typedef Error (*Environment_cb)(Mode mode); 315 385 316 static Environment_cb wrapped_cb = NULL; 317 static Mode wrapped_mode = UNKNOWN; 318 static const char *wrapped_error = NULL; 386 static Environment_cb wrapped_cb = NULL; 387 static Mode wrapped_mode = UNKNOWN; 388 static SmartCharPtr wrapped_error; 389 319 390 void wrapped() { wrapped_error = wrapped_cb(wrapped_mode); } 320 321 static LazyPersistantFlag any_setup(ANY_SETUP, true);322 391 323 392 class FunInfo { … … 325 394 string name; 326 395 LazyPersistantFlag is_setup; 396 LazyPersistantFlag changing; // some process is currently setting up/cleaning the environment 397 398 void all_get_lazy_again() { 399 changing.get_lazy_again(); 400 is_setup.get_lazy_again(); 401 } 327 402 328 403 Error set_to(Mode mode) { 329 404 StaticCode::printf("[%s environment '%s' START]\n", mode_command[mode], get_name()); 330 405 331 any_setup = true; 332 333 wrapped_cb = cb; 334 wrapped_mode = mode; 335 wrapped_error = NULL; 406 wrapped_cb = cb; 407 wrapped_mode = mode; 408 wrapped_error.SetNull(); 336 409 337 410 chdir(runDir()); 338 411 339 long duration;340 UnitTestResult guard_says = execute_guarded(wrapped, &duration, MAX_EXEC_MS_ENV, false);341 const char *error = NULL;412 long duration; 413 UnitTestResult guard_says = execute_guarded(wrapped, &duration, MAX_EXEC_MS_ENV, false); 414 Error error; 342 415 343 416 switch (guard_says) { 344 417 case TEST_OK: 345 if (wrapped_error ) {346 error = GBS_global_string ("returns error: %s",wrapped_error);418 if (wrapped_error.isSet()) { 419 error = GBS_global_string_copy("returns error: %s", &*wrapped_error); 347 420 } 348 421 break; … … 354 427 : "has been interrupted (might be a deaklock)"; 355 428 356 error = GBS_global_string ("%s%s",357 what_happened,358 wrapped_error ? GBS_global_string(" (wrapped_error='%s')",wrapped_error) : "");429 error = GBS_global_string_copy("%s%s", 430 what_happened, 431 wrapped_error.isSet() ? GBS_global_string(" (wrapped_error='%s')", &*wrapped_error) : ""); 359 432 break; 360 433 } 361 434 } 362 if (error ) {363 error = GBS_global_string ("%s(%s) %s", name.c_str(), upcase(mode_command[mode]),error);435 if (error.isSet()) { 436 error = GBS_global_string_copy("%s(%s) %s", name.c_str(), upcase(mode_command[mode]), &*error); 364 437 } 365 438 else { 439 Mutex m(FLAG_MUTEX); 440 441 env_assert(changing); 366 442 is_setup = (mode == SETUP); 367 443 #if defined(SIMULATE_ENVSETUP_TIMEOUT) … … 377 453 } 378 454 #endif 455 changing = false; 456 all_get_lazy_again(); 379 457 } 380 458 … … 388 466 : cb(cb_), 389 467 name(name_), 390 is_setup(name_) 468 is_setup(name_), 469 changing(GBS_global_string("changing_%s", name_)) 391 470 {} 392 471 393 Error switch_to(Mode mode) { 394 Error error = NULL;472 Error switch_to(Mode mode) { // @@@ need to return allocated msg (it gets overwritten) 473 Error error; 395 474 bool want_setup = (mode == SETUP); 396 if (is_setup == want_setup) { 397 StaticCode::printf("[environment '%s' already was %s]\n", get_name(), mode_command[mode]); 398 } 399 else { 400 error = set_to(mode); 401 } 402 403 is_setup.get_lazy_again(); 475 476 bool perform_change = false; 477 bool wait_for_change = false; 478 { 479 Mutex m(FLAG_MUTEX); 480 481 if (changing) { // somebody is changing the environment state 482 if (is_setup == want_setup) { // wanted state was reached, but somebody is altering it 483 error = GBS_global_string_copy("[environment '%s' was %s, but somebody is changing it to %s]", 484 get_name(), mode_command[mode], mode_command[other_mode[mode]]); 485 } 486 else { // the somebody is changing to my wanted state 487 wait_for_change = true; 488 } 489 } 490 else { 491 if (is_setup == want_setup) { 492 StaticCode::printf("[environment '%s' already was %s]\n", get_name(), mode_command[mode]); 493 } 494 else { 495 changing = perform_change = true; 496 } 497 } 498 499 all_get_lazy_again(); 500 } 501 502 env_assert(!(perform_change && wait_for_change)); 503 504 if (perform_change) set_to(mode); 505 506 if (wait_for_change) { 507 bool reached = false; 508 while (!reached) { 509 StaticCode::printf("[waiting until environment '%s' reaches '%s']\n", get_name(), mode_command[mode]); 510 sleep(1); 511 { 512 Mutex m(FLAG_MUTEX); 513 if (!changing && is_setup == want_setup) reached = true; 514 all_get_lazy_again(); 515 } 516 } 517 StaticCode::printf("[environment '%s' has reached '%s']\n", get_name(), mode_command[mode]); 518 } 404 519 405 520 return error; … … 414 529 static FunInfo modules[] = { 415 530 FUNINFO(ptserver), 531 FUNINFO(ptserver_gene), 416 532 }; 417 533 … … 428 544 429 545 static Error set_all_modules_to(Mode mode) { 430 Error error = NULL; 431 432 for (size_t e = 0; !error && e<MODULES; ++e) error = modules[e].switch_to(mode); 433 434 435 546 Error error; 547 for (size_t e = 0; error.isNull() && e<MODULES; ++e) { 548 error = modules[e].switch_to(mode); 549 } 436 550 return error; 437 551 } … … 460 574 461 575 int main(int argc, char* argv[]) { 462 Error error = NULL; 463 if (argc<2 || argc>3) error = "Wrong number of arguments"; 576 Error error; 577 bool showUsage = true; 578 579 if (argc<2 || argc>3) error = strdup("Wrong number of arguments"); 464 580 else { 465 581 const char *modearg = argv[1]; … … 471 587 472 588 if (mode == UNKNOWN) { 473 error = GBS_global_string ("unknown argument '%s' (known modes are: %s)", modearg, known_modes(' '));589 error = GBS_global_string_copy("unknown argument '%s' (known modes are: %s)", modearg, known_modes(' ')); 474 590 } 475 591 else { 476 592 if (argc == 2) { 477 Mutex m(FLAG_MUTEX); 478 479 error = set_all_modules_to(mode); 480 if (mode == CLEAN) any_setup = false; // reset during final environment cleanup 481 any_setup.get_lazy_again(); 593 error = set_all_modules_to(mode); 594 showUsage = false; 482 595 } 483 596 else { … … 486 599 487 600 if (!module) { 488 error = GBS_global_string ("unknown argument '%s' (known modules are: %s)", modulearg, known_modules(' '));601 error = GBS_global_string_copy("unknown argument '%s' (known modules are: %s)", modulearg, known_modules(' ')); 489 602 } 490 603 else { 491 Mutex m(FLAG_MUTEX); 492 error = module->switch_to(mode); 493 any_setup.get_lazy_again(); 494 } 495 } 496 } 497 } 498 499 if (error) { 604 error = module->switch_to(mode); 605 showUsage = false; 606 } 607 } 608 } 609 } 610 611 if (error.isSet()) { 500 612 const char *exename = argv[0]; 501 StaticCode::printf(" %s: %s\n", exename,error);502 StaticCode::printf("Usage: %s [%s] [%s]\n", exename, known_modes('|'), known_modules('|'));613 StaticCode::printf("Error in %s: %s\n", exename, &*error); 614 if (showUsage) StaticCode::printf("Usage: %s [%s] [%s]\n", exename, known_modes('|'), known_modules('|')); 503 615 return EXIT_FAILURE; 504 616 } -
branches/dev_elmar/UNIT_TESTER/UnitTester.cxx
r7623 r8224 38 38 39 39 struct Globals : virtual Noncopyable { 40 bool inside_test; 41 bool running_on_valgrind; 42 char *runDir; 43 pid_t pid; 40 bool inside_test; 41 bool running_on_valgrind; 42 char *runDir; 43 pid_t pid; 44 const char *libname; 44 45 45 46 Globals() … … 212 213 } 213 214 214 // set by TestEnvironment.cxx@ANY_SETUP 215 static const char * const any_setup_flag = "../" FLAGS_DIR "/" ANY_SETUP "." FLAGS_EXT; 216 217 static bool been_inside_environment() { 218 struct stat stt; 219 return stat(any_setup_flag, &stt) == 0 && S_ISREG(stt.st_mode); 220 // dups GB_is_regularfile("any_setup") 221 } 222 static void reset_been_inside_environment() { 223 if (been_inside_environment()) { 224 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(unlink(any_setup_flag)); 225 } 226 } 227 228 static bool did_valgrinded_syscall() { 229 return utvg::flag_exists(UTVG_ANY_SYSCALL); 230 } 231 static void reset_did_valgrinded_syscall() { 232 if (did_valgrinded_syscall()) { 233 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(unlink(utvg::flag_name(UTVG_ANY_SYSCALL))); 234 } 235 } 236 237 void sleepms(long ms) { 215 class Flag { 216 string flagname; 217 218 public: 219 Flag(const string& flagname_) : flagname(flagname_) {} 220 221 bool is_up() const { struct stat stt; return stat(flagname.c_str(), &stt) == 0 && S_ISREG(stt.st_mode); } 222 void raise() { 223 fprintf(stderr, "Raising flag '%s'\n", flagname.c_str()); fflush(stderr); 224 ut_assert(!is_up()); 225 FILE *fp = fopen(flagname.c_str(), "w"); 226 fclose(fp); 227 } 228 void lower() { 229 fprintf(stderr, "Lowering flag '%s'\n", flagname.c_str()); fflush(stderr); 230 ut_assert(is_up()); 231 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(unlink(flagname.c_str())); 232 } 233 234 void lower_if_up() { if (is_up()) lower(); } 235 }; 236 237 inline Flag getLocalFlag(const char *flagname) { 238 string localname = string(GLOBAL.runDir)+"/../flags/"+flagname+'.'+GLOBAL.libname; 239 return Flag(localname.c_str()); 240 } 241 242 static bool flag_callback(arb_test::FlagAction action, const char *name) { 243 using namespace arb_test; 244 245 Flag flag = getLocalFlag(name); 246 bool result = true; 247 248 switch (action) { 249 case FLAG_RAISE: 250 flag.raise(); 251 break; 252 case FLAG_IS_RAISED: 253 result = flag.is_up(); 254 break; 255 } 256 257 return result; 258 } 259 260 inline bool been_inside_environment() { 261 return getLocalFlag(ANY_SETUP).is_up() || arb_test::test_data().entered_mutex_loop; 262 } 263 inline bool did_valgrinded_syscall() { 264 return seen_valgrinded_call(); 265 } 266 inline void reset_test_local_flags() { 267 getLocalFlag(ANY_SETUP).lower_if_up(); 268 } 269 270 inline void sleepms(long ms) { 238 271 int seconds = ms/1000; 239 272 long rest_ms = ms - seconds*1000; … … 256 289 257 290 if (did_valgrinded_syscall()) { 258 fprintf(stderr, "[valgrinded system call detected. Added %li ms tolerance]\n", MAX_EXEC_MS_VGSYS); 291 const long additional = max_allowed_duration_ms*3 + MAX_EXEC_MS_VGSYS; 292 fprintf(stderr, "[external calls are running valgrinded. Added %li ms tolerance]\n", additional); 259 293 fflush(stderr); 260 sleepms( MAX_EXEC_MS_VGSYS);261 max_allowed_duration_ms += MAX_EXEC_MS_VGSYS;262 } 263 294 sleepms(additional); 295 max_allowed_duration_ms += additional; 296 } 297 264 298 const long aBIT = 50*1000; // µs 265 299 … … 353 387 UnitTest_function fun = test.fun; 354 388 355 reset_been_inside_environment(); 356 reset_did_valgrinded_syscall(); 357 389 reset_test_local_flags(); 390 358 391 bool marked_as_slow = strlen(test.name) >= 10 && memcmp(test.name, "TEST_SLOW_", 10) == 0; 359 392 long duration_usec; … … 431 464 432 465 TEST_ASSERT_ZERO_OR_SHOW_ERRNO(chdir("run")); 433 GLOBAL.runDir = getcwd(0, PATH_MAX); 466 GLOBAL.runDir = getcwd(0, PATH_MAX); 467 GLOBAL.libname = libname; 434 468 435 469 size_t tests = 0; … … 438 472 { 439 473 arb_test::GlobalTestData& global = arb_test::test_data(); 440 474 475 global.init(flag_callback); 441 476 global.show_warnings = (warn_level != 0); 442 477 -
branches/dev_elmar/UNIT_TESTER/UnitTester.hxx
r7945 r8224 45 45 const long MAX_EXEC_MS_SLOW = 20 * SECONDS; // same for slow tests 46 46 const long MAX_EXEC_MS_ENV = 30 * SECONDS; // same for environment setup/cleanup 47 const long MAX_EXEC_MS_VGSYS = 40 * SECONDS; // same for valgrinded system calls (especially pt_server)47 const long MAX_EXEC_MS_VGSYS = 60 * SECONDS; // same for valgrinded system calls (especially pt_server) 48 48 49 49 const long WARN_SLOW_ABOVE_MS = 1 * SECONDS; // when too warn about slow test … … 52 52 #define FLAGS_EXT "flag" 53 53 54 #define ANY_SETUP "any_setup"55 56 54 #else 57 55 #error UnitTester.hxx included twice -
branches/dev_elmar/UNIT_TESTER/reporter.pl
r7945 r8224 99 99 if (/^UnitTester:/) { 100 100 if (/tests=([0-9]+)/) { $tests_this += $1; $seenSummary=1; } 101 if (/skipped=([0-9]+)/) { $skipped_this += $1; }101 if (/skipped=([0-9]+)/) { $skipped_this += $1; $dump_log = 1; } 102 102 103 103 if (/passed=([0-9]+)/) { $passed += $1; } -
branches/dev_elmar/UNIT_TESTER/run
-
Property
svn:ignore set
to
TEST_gpt.ARM
TEST_gpt.arb
TEST_pt.arb
*.ARF
TEST_pt.ARM
-
Property
svn:ignore set
to
-
branches/dev_elmar/UNIT_TESTER/test_global.h
r7623 r8224 72 72 }; 73 73 74 enum FlagAction { 75 FLAG_RAISE, 76 FLAG_IS_RAISED, 77 }; 78 74 79 class GlobalTestData { 80 typedef bool (*FlagCallback)(FlagAction action, const char *name); 81 82 FlagCallback flag_cb; 83 75 84 GlobalTestData() 76 : annotation(NULL), 85 : flag_cb(NULL), 86 annotation(NULL), 77 87 show_warnings(true), 78 88 assertion_failed(false), … … 85 95 GlobalTestData(const GlobalTestData&); // do not synthesize 86 96 GlobalTestData& operator=(const GlobalTestData&); // do not synthesize 87 97 88 98 static GlobalTestData *instance(bool erase) { 89 99 static GlobalTestData *data = 0; // singleton … … 113 123 bool assertion_failed; 114 124 bool running_test; 125 bool entered_mutex_loop; // helper to avoid race-condition 115 126 116 127 // counters 117 128 size_t warnings; 129 130 void raiseLocalFlag(const char *name) const { 131 if (flag_cb) { 132 flag_cb(FLAG_RAISE, name); 133 } 134 else { 135 fputs("cannot raise local flag (called from outside test-code?)\n", stderr); 136 } 137 } 138 void init(FlagCallback fc) { flag_cb = fc; } 118 139 119 140 bool not_covered_by_test() const { return !running_test; } -
branches/dev_elmar/UNIT_TESTER/test_unit.h
r7945 r8224 16 16 #include <arb_assert.h> 17 17 #endif 18 #ifndef ARBTOOLS_H 19 #include <arbtools.h> 20 #endif 18 21 #ifndef _GLIBCXX_CSTDARG 19 22 #include <cstdarg> … … 25 28 #include <errno.h> 26 29 #endif 30 #ifndef DUPSTR_H 31 #include <dupstr.h> 32 #endif 33 34 #if defined(_GLIBCXX_STRING) 35 #define TESTS_KNOW_STRING 36 #endif 37 27 38 28 39 #define ENABLE_CRASH_TESTS // comment out this line to get rid of provoked SEGVs (e.g. while debugging test-code) 29 // #define TRACE_IS_EQUAL // print calls to numerical is_equal()30 40 31 41 /* Note: … … 36 46 * test is known to fail, but cannot be fixed atm for some reason 37 47 * 48 * Recommended test-assertion is TEST_EXPECT(that(..).xxx()) 49 * see examples in test-unit-tests in ../CORE/arb_string.cxx@UNIT_TESTS 38 50 */ 39 51 40 52 #define TEST_ASSERT(cond) test_assert(cond, false) 41 53 54 #define ANY_SETUP "any_env_setup" 55 42 56 namespace arb_test { 43 57 44 class StaticCode { 45 static void vcompiler_msg(const char *filename, int lineno, const char *message_type, const char *format, va_list parg) __attribute__((format(__printf__, 4, 0))) { 46 fprintf(stderr, "%s:%i: ", filename, lineno); 58 // ------------- 59 // str 60 61 class str { 62 char *s; 63 public: 64 str() : s(0) {} 65 str(const str& other) : s(nulldup(other.s)) {} 66 explicit str(char *S) : s(S) {} 67 str& operator = (const str& other) { 68 freedup(s, other.s); 69 return *this; 70 } 71 str& operator = (char *S) { 72 freeset(s, S); 73 return *this; 74 } 75 ~str() { free(s); } 76 77 bool exists() const { return s; } 78 void assign(char *S) { s = S; } 79 const char *value() const { return s; } 80 }; 81 82 // ----------------------- 83 // location info 84 85 #define WITHVALISTFROM(format,CODE) do { va_list parg; va_start(parg, format); CODE; va_end(parg); } while(0) 86 #define VPRINTFORMAT(format) WITHVALISTFROM(format, vfprintf(stderr, format, parg)) 87 #define VCOMPILERMSG(msgtype,format) WITHVALISTFROM(format, vcompiler_msg(msgtype, format, parg)) 88 89 class locinfo //! stores source code location 90 { 91 const char *file; 92 int line; 93 94 __attribute__((format(__printf__, 2, 0))) void vcompiler_msg(const char *message_type, const char *format, va_list parg) const { 95 fprintf(stderr, "%s:%i: ", file, line); 47 96 if (message_type) fprintf(stderr, "%s: ", message_type); 48 97 vfprintf(stderr, format, parg); 49 98 } 50 51 #define WITHVALISTFROM(format,CODE) do { va_list parg; va_start(parg, format); CODE; va_end(parg); } while(0)52 #define VPRINTFORMAT(format) WITHVALISTFROM(format, vfprintf(stderr, format, parg))53 #define VCOMPILERMSG(file,line,msgtype,format) WITHVALISTFROM(format, vcompiler_msg(file, line, msgtype, format, parg))54 99 55 100 public: 56 101 locinfo() : file(0), line(0) {} 102 locinfo(const char *file_, int line_) : file(file_), line(line_) {} 103 104 bool exists() const { return file; } 105 106 const char *get_file() const { return file; } 107 int get_line() const { return line; } 108 109 __attribute__((format(printf, 2, 3))) void warningf(const char *format, ...) const { 110 GlobalTestData& global = test_data(); 111 if (global.show_warnings) { 112 FlushedOutput yes; 113 VCOMPILERMSG("Warning", format); 114 GlobalTestData::print_annotation(); 115 global.warnings++; 116 } 117 } 118 119 __attribute__((format(printf, 3, 4))) void errorf(bool fail, const char *format, ...) const { 120 { 121 FlushedOutput yes; 122 VCOMPILERMSG("Error", format); 123 GlobalTestData::print_annotation(); 124 } 125 if (fail) TRIGGER_ASSERTION(false); // fake an assertion failure 126 } 127 __attribute__((format(printf, 3, 4))) void ioerrorf(bool fail, const char *format, ...) const { 128 { 129 FlushedOutput yes; 130 VCOMPILERMSG("Error", format); 131 fprintf(stderr, " (errno=%i='%s')", errno, strerror(errno)); 132 GlobalTestData::print_annotation(); 133 } 134 if (fail) TRIGGER_ASSERTION(false); // fake an assertion failure 135 } 136 }; 137 138 // -------------------- 139 // StaticCode 140 141 struct StaticCode { 57 142 static void printf(const char *format, ...) __attribute__((format(printf, 1, 2))) { 58 143 FlushedOutputNoLF yes; 59 144 VPRINTFORMAT(format); 60 145 } 61 static void warningf(const char *filename, int lineno, const char *format, ...) __attribute__((format(printf, 3, 4))) {62 GlobalTestData& global = test_data();63 if (global.show_warnings) {64 FlushedOutput yes;65 VCOMPILERMSG(filename, lineno, "Warning", format);66 GlobalTestData::print_annotation();67 global.warnings++;68 }69 }70 static void errorf(const char *filename, int lineno, const char *format, ...) __attribute__((format(printf, 3, 4))) {71 {72 FlushedOutput yes;73 VCOMPILERMSG(filename, lineno, "Error", format);74 GlobalTestData::print_annotation();75 }76 TRIGGER_ASSERTION(false); // fake an assertion failure77 }78 static void ioerrorf(const char *filename, int lineno, const char *format, ...) __attribute__((format(printf, 3, 4))) {79 {80 FlushedOutput yes;81 VCOMPILERMSG(filename, lineno, "Error", format);82 fprintf(stderr, " (errno=%i='%s')", errno, strerror(errno));83 GlobalTestData::print_annotation();84 }85 TRIGGER_ASSERTION(false); // fake an assertion failure86 }87 146 #undef VPRINTFORMAT 88 147 #undef VCOMPILERMSG 89 148 #undef WITHVALISTFROM 90 149 91 static void print_readable_string(const char *s, FILE *out) {150 static char *readable_string(const char *s) { 92 151 // quote like C does! 93 152 if (s) { 94 fputc('\"', out); 95 for (int i_ = 0; s[i_]; ++i_) { 96 switch (s[i_]) { 97 case '\n': fputs("\\n", out); break; 98 case '\t': fputs("\\t", out); break; 99 case '\"': fputs("\\\"", out); break; 100 case '\\': fputs("\\\\", out); break; 101 default: fputc(s[i_], out); break; 153 size_t len = strlen(s)*4; 154 char *res = (char*)malloc(len+2+1); 155 156 int j = 0; 157 res[j++] = '\"'; 158 for (int i = 0; s[i]; ++i) { 159 unsigned char c = static_cast<unsigned char>(s[i]); 160 char esc = 0; 161 switch (c) { 162 case '\n': esc = 'n'; break; 163 case '\t': esc = 't'; break; 164 case '\"': esc = '\"'; break; 165 case '\\': esc = '\\'; break; 166 default: if (c<10) esc = c-1+'1'; break; 167 } 168 if (esc) { 169 res[j++] = '\\'; 170 res[j++] = esc; 171 } 172 else { 173 if (c >= 32 && c<127) { 174 res[j++] = c; 175 } 176 else { 177 j += sprintf(res+j, "\\x%02x", int(c)); 178 } 102 179 } 103 180 } 104 fputc('\"', out); 181 res[j++] = '\"'; 182 res[j++] = 0; 183 return res; 105 184 } 106 185 else { 107 fputs("(null)", out); 108 } 109 } 110 }; 111 112 inline void print(int i) { fprintf(stderr, "%i", i); } 113 inline void print_hex(int i) { fprintf(stderr, "0x%x", i); } 114 115 inline void print(long L) { fprintf(stderr, "%li", L); } 116 inline void print_hex(long L) { fprintf(stderr, "0x%lx", L); } 117 118 inline void print(const char *s) { StaticCode::print_readable_string(s, stderr); } 119 // no print_hex for strings 120 121 inline void print(size_t z) { fprintf(stderr, "%zu", z); } 122 inline void print_hex(size_t z) { fprintf(stderr, "0x%zx", z); } 123 124 inline void print(unsigned char c) { fprintf(stderr, "'%c'", c); } 125 inline void print_hex(unsigned char c) { print_hex(size_t(c)); } 126 127 inline void print(char c) { print((unsigned char)c); } 128 inline void print_hex(char c) { print_hex((unsigned char)c); } 186 return strdup("(null)"); 187 } 188 } 189 static void print_readable_string(const char *s, FILE *out) { 190 fputs(str(readable_string(s)).value(), out); 191 } 192 193 static char *vstrf(const char *format, va_list& parg) __attribute__((format(__printf__, 1, 0))) { 194 static const size_t max_vstrf_size = 10000; 195 static char vstrf_buf[max_vstrf_size]; 196 197 int printed = vsnprintf(vstrf_buf, max_vstrf_size, format, parg); 198 arb_assert(printed >= 0 && size_t(printed)<max_vstrf_size); 199 200 char *result = (char*)malloc(printed+1); 201 memcpy(result, vstrf_buf, printed); 202 result[printed] = 0; 203 return result; 204 } 205 206 static char *strf(const char *format, ...) __attribute__((format(__printf__, 1, 2))) { 207 va_list parg; 208 va_start(parg, format); 209 char *result = vstrf(format, parg); 210 va_end(parg); 211 return result; 212 } 213 214 }; 215 216 inline char *val2readable(bool b) { return strdup(b ? "true" : "false"); } 217 218 inline char *val2readable(int i) { return StaticCode::strf("%i", i); } 219 inline char *val2hex(int i) { return StaticCode::strf("0x%x", i); } 220 221 inline char *val2readable(long L) { return StaticCode::strf("%li", L); } 222 inline char *val2hex(long L) { return StaticCode::strf("0x%lx", L); } 223 224 inline char *val2readable(size_t z) { return StaticCode::strf("%zu", z); } 225 inline char *val2hex(size_t z) { return StaticCode::strf("0x%zx", z); } 129 226 130 227 // dont dup size_t: 131 228 #ifdef ARB_64 132 inline void print(unsigned u) { fprintf(stderr,"%u", u); }133 inline void print_hex(unsigned u) { fprintf(stderr,"0x%x", u); }229 inline char *val2readable(unsigned u) { return StaticCode::strf("%u", u); } 230 inline char *val2hex(unsigned u) { return StaticCode::strf("0x%x", u); } 134 231 #else 135 inline void print(long unsigned u) { fprintf(stderr,"%lu", u); }136 inline void print_hex(long unsigned u) { fprintf(stderr,"0x%lx", u); }232 inline char *val2readable(long unsigned u) { return StaticCode::strf("%lu", u); } 233 inline char *val2hex(long unsigned u) { return StaticCode::strf("0x%lx", u); } 137 234 #endif 235 236 inline char *val2readable(double d) { return StaticCode::strf("%f", d); } 237 238 inline char *val2readable(unsigned char c) { arb_assert(c); return StaticCode::strf("'%c'", c); } 239 inline char *val2readable(const char *s) { return StaticCode::readable_string(s); } 240 241 #ifdef TESTS_KNOW_STRING 242 inline char *val2readable(const std::string& s) { return StaticCode::readable_string(s.c_str()); } 243 #endif 244 245 template <typename T> inline void print(const T& t) { fputs(val2readable(make_copy(t)), stderr); } 246 template <typename T> inline void print_hex(const T& t) { fputs(val2hex(make_copy(t)), stderr); } 138 247 139 248 template <typename T1, typename T2> inline void print_pair(T1 t1, T2 t2) { 140 249 print(t1); 141 fputs(", ", stderr);250 fputs(",", stderr); 142 251 print(t2); 143 252 } … … 148 257 } 149 258 150 template <typename T> inline const char *nameoftype(T unspecialized) { 151 return specialized_nameoftype(unspecialized); // define instanciating type below! 152 } 153 154 #define NAMEOFTYPE(type) template <> inline const char * nameoftype<>(type) { return #type; } 155 NAMEOFTYPE(bool); 156 NAMEOFTYPE(char); 157 NAMEOFTYPE(unsigned char); 158 NAMEOFTYPE(const char*); 159 NAMEOFTYPE(int); 160 NAMEOFTYPE(unsigned int); 161 NAMEOFTYPE(long int); 162 NAMEOFTYPE(long unsigned int); 163 #undef NAMEOFTYPE 164 165 166 167 #ifdef TRACE_IS_EQUAL 168 template <typename T1, typename T2> inline bool bool_traced(const char *name, bool equal, T1 t1, T2 t2) { 169 fprintf(stderr, "%-5s = %s(%s ", (equal ? "true" : "false"), name, nameoftype(t1)); 170 print(t1); 171 fprintf(stderr, ",%s ", nameoftype(t2)); 172 print(t2); 173 fprintf(stderr, ")\n"); 174 return equal; 175 } 176 #else 177 template <typename T1, typename T2> inline bool bool_traced(const char *, bool equal, T1 , T2 ) { 178 return equal; 179 } 259 class epsilon_similar { 260 double epsilon; 261 public: 262 epsilon_similar(double epsilon_) : epsilon(epsilon_) {} 263 bool operator()(const double& d1, const double& d2) const { 264 double diff = d1-d2; 265 if (diff<0.0) diff = -diff; // do not use fabs() here 266 return diff <= epsilon; 267 } 268 }; 269 270 struct containing { 271 bool operator()(const char *str, const char *part) const { return strstr(str, part); } 272 #if defined(TESTS_KNOW_STRING) 273 bool operator()(const std::string& str, const std::string& part) const { return strstr(str.c_str(), part.c_str()); } 180 274 #endif 181 182 template <typename T1, typename T2> inline bool is_equal(T1 t1, T2 t2) { 183 return bool_traced("is_equal", t1 == t2, t1, t2); 184 } 185 template<> inline bool is_equal<>(const char *s1, const char *s2) { 186 return bool_traced("is_equal", (s1 == s2) || (s1 && s2 && strcmp(s1, s2) == 0), s1, s2); 187 } 188 template <typename T1, typename T2> inline bool is_less(T1 t1, T2 t2) { 189 return bool_traced("is_less", t1 < t2, t1, t2); 190 } 191 192 193 template <typename T1, typename T2> inline void print_failed_compare(T1 t1, T2 t2, const char *prefix, const char *infix, const char *suffix) { 194 FlushedOutput yes; 195 fputs(prefix, stderr); 196 print_pair(t1, t2); 197 fputs(infix, stderr); 198 print_hex_pair(t1, t2); 199 fputs(suffix, stderr); 200 } 201 template <typename T1, typename T2> inline void print_failed_equal(T1 t1, T2 t2) { 202 print_failed_compare(t1, t2, "test_equal(", ") (", ") returns false"); 203 } 204 template <typename T1, typename T2> inline void print_failed_less_equal(T1 t1, T2 t2) { 205 print_failed_compare(t1, t2, "test_less_equal(", ") (", ") returns false"); 206 } 207 template <typename T1, typename T2> inline void print_failed_different(T1 t1, T2 t2) { 208 print_failed_compare(t1, t2, "test_different(", ") (", ") returns false"); 209 } 210 211 template<> inline void print_failed_equal<>(const char *s1, const char *s2) { 212 FlushedOutput yes; 213 fputs("test_equal(", stderr); 214 print(s1); 215 fputs(",\n ", stderr); 216 print(s2); 217 fputs(") returns false", stderr); 218 } 219 template<> inline void print_failed_different<>(const char *s1, const char *) { 220 FlushedOutput yes; 221 fputs("test_different(", stderr); 222 print(s1); 223 fputs(", <same>", stderr); 224 fputs(") returns false", stderr); 225 } 226 227 template <typename T1, typename T2> inline bool test_equal(T1 t1, T2 t2) { 228 bool equal = is_equal(t1, t2); 229 if (!equal) print_failed_equal(t1, t2); 230 return equal; 231 } 232 template <typename T1, typename T2> inline bool test_less_equal(T1 lower, T2 upper) { 233 bool less_equal = is_equal(lower, upper) || is_less(lower, upper); 234 if (!less_equal) print_failed_less_equal(lower, upper); 235 return less_equal; 236 } 237 template <typename T1, typename T2> inline bool test_different(T1 t1, T2 t2) { 238 bool different = !is_equal(t1, t2); 239 if (!different) print_failed_different(t1, t2); 240 return different; 241 } 242 243 #define ACCEPT_NON_CONST_ARGUMENTS(FUN,TYPE) \ 244 template<> inline bool FUN<>(TYPE p1, TYPE p2) { return FUN((const TYPE)p1, (const TYPE)p2); } \ 245 template<> inline bool FUN<>(TYPE p1, const TYPE p2) { return FUN((const TYPE)p1, p2); } \ 246 template<> inline bool FUN<>(const TYPE p1, TYPE p2) { return FUN(p1, (const TYPE)p2); } 247 248 ACCEPT_NON_CONST_ARGUMENTS(test_equal, char*); 249 ACCEPT_NON_CONST_ARGUMENTS(test_different, char*); 250 251 #ifdef ARB_64 252 typedef long int NULLPTR; 253 #else 254 typedef int NULLPTR; 255 #endif 256 257 #define ACCEPT_NULLPTR_ARGUMENTS(FUN,TYPE) \ 258 template<> inline bool FUN<>(TYPE p1, NULLPTR p2) { TEST_ASSERT(!p2); return FUN((const TYPE)p1, (const TYPE)p2); } \ 259 template<> inline bool FUN<>(const TYPE p1, NULLPTR p2) { TEST_ASSERT(!p2); return FUN((const TYPE)p1, (const TYPE)p2); } \ 260 template<> inline bool FUN<>(NULLPTR p1, TYPE p2) { TEST_ASSERT(!p1); return FUN((const TYPE)p1, (const TYPE)p2); } \ 261 template<> inline bool FUN<>(NULLPTR p1, const TYPE p2) { TEST_ASSERT(!p1); return FUN((const TYPE)p1, (const TYPE)p2); } 262 263 ACCEPT_NULLPTR_ARGUMENTS(test_equal, char*); 264 ACCEPT_NULLPTR_ARGUMENTS(test_different, char*); 265 266 inline bool test_similar(double d1, double d2, double epsilon) { 267 double diff = d1-d2; 268 if (diff<0.0) diff = -diff; // do not use fabs() here 269 270 bool in_epsilon_range = diff < epsilon; 271 if (!in_epsilon_range) { 272 StaticCode::printf("test_similar(%f,%f,%f) returns false\n", d1, d2, epsilon); 273 } 274 return in_epsilon_range; 275 } 276 277 inline bool test_equal(double d1, double d2) { return test_similar(d1, d2, 0.000001); } 278 279 inline bool test_strcontains(const char *str, const char *part) { 280 const char *found = strstr(str, part); 281 if (!found) StaticCode::printf("string '%s'\ndoes not contain '%s'\n", str, part); 282 return found; 283 } 284 285 // inline bool is_equal(double d1, double d2) { 286 // return is_similar(d1, d2, 0.000001); 287 // } 275 }; 288 276 289 277 inline bool files_are_equal(const char *file1, const char *file2) { … … 362 350 return !error; 363 351 } 352 353 354 // ------------------ 355 // copy 356 357 358 template <typename T> 359 class copy //! makes char* copyable, so it can be handled like most other types 360 { 361 T t; 362 public: 363 copy(const T& t_) : t(t_) {} 364 operator const T&() const { return t; } 365 }; 366 367 template <> 368 class copy<const char *> { 369 str t; 370 public: 371 copy(const char *t_) : t(str(t_ ? strdup(t_) : NULL)) {} 372 operator const char *() const { return t.value(); } 373 }; 374 375 template <typename T> class copy< copy<T> > { copy(const copy<T>& t_); }; // avoid copies of copies 376 377 template <typename T> inline copy<T> make_copy(const T& t) { return copy<T>(t); } 378 379 inline copy<const char *> make_copy(const char *p) { return copy<const char *>(p); } 380 inline copy<const char *> make_copy(char *p) { return copy<const char *>(p); } 381 inline copy<const char *> make_copy(const unsigned char *p) { return copy<const char *>(reinterpret_cast<const char *>(p)); } 382 inline copy<const char *> make_copy(unsigned char *p) { return copy<const char *>(reinterpret_cast<const char *>(p)); } 383 inline copy<const char *> make_copy(const signed char *p) { return copy<const char *>(reinterpret_cast<const char *>(p)); } 384 inline copy<const char *> make_copy(signed char *p) { return copy<const char *>(reinterpret_cast<const char *>(p)); } 385 386 inline copy<unsigned char> make_copy(char p) { return copy<unsigned char>(p); } 387 inline copy<unsigned char> make_copy(unsigned char p) { return copy<unsigned char>(p); } 388 inline copy<unsigned char> make_copy(signed char p) { return copy<unsigned char>(p); } 389 390 template <typename T> str readable(const copy<T>& v) { return str(val2readable(v)); } 391 template <typename T> str readableHex(const copy<T>& v) { return str(val2readableHex(v)); } 392 393 template <typename T> bool operator == (const copy<T>& v1, const copy<T>& v2) { return static_cast<const T&>(v1) == static_cast<const T&>(v2); } 394 template <typename T> bool operator != (const copy<T>& v1, const copy<T>& v2) { return !(v1 == v2); } 395 396 template <> inline bool operator == <const char *>(const copy<const char *>& v1, const copy<const char *>& v2) { 397 const char *val1 = v1; 398 const char *val2 = v2; 399 400 return (val1 == val2) || (val1 && val2 && (strcmp(val1, val2) == 0)); 401 } 402 403 404 405 // ------------------------------- 406 // some output functions 407 408 inline void print(const char *s) { fputs(s, stderr); } 409 inline void print(char c) { fputc(c, stderr); } 410 inline void print(int i) { fprintf(stderr, "%i", i); } 411 412 inline void space() { print(' '); } 413 inline void nl() { print('\n'); } 414 415 inline void print_indent(int indent) { while (indent--) space(); } 416 417 inline void spaced(const char *word) { space(); print(word); space(); } 418 inline void select_spaced(bool first, const char *singular, const char *plural) { spaced(first ? singular : plural); } 419 420 421 #define HASTOBE_CLONABLE(type) virtual type *clone() const = 0 422 #define MAKE_CLONABLE(type) type *clone() const { return new type(*this); } 423 424 // ------------------------------ 425 // abstract expectation 426 427 struct expectation //! something expected. can be fulfilled or not (and can explain why/not) 428 { 429 virtual ~expectation() {} 430 HASTOBE_CLONABLE(expectation); 431 432 virtual bool fulfilled() const = 0; 433 virtual void explain(int indent) const = 0; 434 virtual void dump_brief_description() const = 0; 435 }; 436 437 // ------------------- 438 // asserters 439 440 class asserter : virtual Noncopyable { 441 expectation *expected; 442 locinfo loc; 443 const char *code; 444 445 virtual void announce_failure() const { TRIGGER_ASSERTION(false); } 446 447 void err(const char *format) const { loc.errorf(false, format, code); } 448 void warn(const char *format) const { loc.warningf(format, code); } 449 450 public: 451 asserter(const expectation& e, const char *nontmp_code, const char *file, int line) 452 : expected(e.clone()), 453 loc(file, line), 454 code(nontmp_code) 455 {} 456 virtual ~asserter() { delete expected; } 457 458 const char *get_code() const { return code; } 459 460 void expect_that() const { 461 if (!expected->fulfilled()) { 462 err("Failed expectation '%s'"); 463 print("expectation fails because\n"); 464 expected->explain(2); print('\n'); 465 announce_failure(); 466 } 467 } 468 void expect_broken() const { 469 if (expected->fulfilled()) { 470 err("Previously broken expectation '%s' succeeds"); 471 announce_failure(); 472 } 473 else { 474 warn("Expectation '%s' known as broken (accepted until fixed)"); 475 print("Broken because\n"); 476 expected->explain(2); print('\n'); 477 } 478 } 479 void expect_wanted_behavior() const { 480 if (expected->fulfilled()) { 481 err("Wanted behavior '%s' reached"); 482 announce_failure(); 483 } 484 else { 485 warn("Wanted behavior: '%s'"); 486 print("Unsatisfied because\n"); 487 expected->explain(2); print('\n'); 488 } 489 } 490 491 }; 492 493 class debug_asserter : public asserter { 494 virtual void announce_failure() const { 495 print("<<< would trigger assertion now! >>>\n"); 496 } 497 public: 498 debug_asserter(const expectation& e, const char *code_, const char *file, int line) 499 : asserter(e, code_, file, line) 500 {} 501 502 void debug_expectations() { 503 fprintf(stderr, "-------------------- [Debugging expectations for '%s']\n", get_code()); 504 expect_that(); 505 expect_broken(); 506 expect_wanted_behavior(); 507 } 508 }; 509 510 // ---------------------------------------- 511 // matchable + matcher (abstract) 512 513 struct matchable //! can be matched with corresponding matcher. 514 { 515 virtual ~matchable() {} 516 HASTOBE_CLONABLE(matchable); 517 518 virtual const char *name() const = 0; 519 virtual const char *readable_value() const = 0; 520 }; 521 522 struct matcher //! can match things. 523 { 524 virtual ~matcher() {} 525 HASTOBE_CLONABLE(matcher); 526 527 virtual bool matches(const matchable& thing) const = 0; 528 virtual void dump_expectation(const matchable& thing, int indent) const = 0; 529 virtual void dump_brief_description(const matchable& thing) const = 0; 530 }; 531 532 // ---------------------------------------------- 533 // expectation from matchable + matcher 534 535 536 class match_expectation : public expectation //! expectation composed from matcher and corresponding matchable. 537 { 538 matchable *thing; 539 matcher *condition; 540 public: 541 match_expectation(const matchable& thing_, const matcher& condition_) 542 : thing(thing_.clone()), 543 condition(condition_.clone()) 544 {} 545 match_expectation(const match_expectation& other) 546 : thing(other.thing->clone()), 547 condition(other.condition->clone()) 548 {} 549 DECLARE_ASSIGNMENT_OPERATOR(match_expectation); 550 MAKE_CLONABLE(match_expectation); 551 ~match_expectation() { 552 delete thing; 553 delete condition; 554 } 555 556 bool fulfilled() const { return condition->matches(*thing); } 557 void explain(int indent) const { condition->dump_expectation(*thing, indent); } 558 void dump_brief_description() const { condition->dump_brief_description(*thing); } 559 }; 560 561 // ------------------- 562 // predicate 563 564 565 class predicate_description { 566 const char *primary; 567 const char *inverse; 568 mutable str tmp; 569 570 void erase_last_from_tmp() const { 571 char *t = const_cast<char*>(tmp.value()); 572 int len = strlen(t); 573 t[len-1] = 0; 574 } 575 576 static bool ends_with_s(const char *s) { 577 int len = strlen(s); 578 return s[len-1] == 's'; 579 } 580 581 const char *make(const char *desc, bool got) const { 582 if (ends_with_s(desc)) { 583 if (got) return desc; 584 tmp = StaticCode::strf("doesnt %s", desc); 585 erase_last_from_tmp(); 586 } 587 else { 588 tmp = StaticCode::strf("%s %s", got ? "is" : "isnt", desc); 589 } 590 return tmp.value(); 591 } 592 593 public: 594 predicate_description(const char *primary_) : primary(primary_), inverse(NULL) {} 595 predicate_description(const char *primary_, const char *inverse_) : primary(primary_), inverse(inverse_) {} 596 predicate_description(const predicate_description& other) : primary(other.primary), inverse(other.inverse) {} 597 DECLARE_ASSIGNMENT_OPERATOR(predicate_description); 598 599 const char *make(bool expected, bool got) const { 600 if (expected) return make(primary, got); 601 if (inverse) return make(inverse, !got); 602 return make(primary, !got); 603 } 604 }; 605 606 template <typename FUNC> 607 class predicate { 608 FUNC pred; 609 predicate_description description; 610 public: 611 predicate(FUNC pred_, const char *name) : pred(pred_), description(name) {} 612 predicate(FUNC pred_, const char *name, const char *inverse) : pred(pred_), description(name, inverse) {} 613 614 template <typename T> bool matches(const copy<T>& v1, const copy<T>& v2) const { return pred(v1, v2); } 615 const char *describe(bool expected, bool got) const { return description.make(expected, got); } 616 }; 617 618 template <typename FUNC> predicate<FUNC> make_predicate(FUNC func, const char *primary, const char *inverse) { 619 return predicate<FUNC>(func, primary, inverse); 620 } 621 622 // ------------------------------------------ 623 // matchable + matcher (for values) 624 625 template <typename T> inline bool equals(const copy<T>& t1, const copy<T>& t2) { return t1 == t2; } 626 template <typename T> inline bool less(const copy<T>& t1, const copy<T>& t2) { return t1 < t2; } 627 template <typename T> inline bool more(const copy<T>& t1, const copy<T>& t2) { return t1 > t2; } 628 629 template <typename T> 630 class matchable_value : public matchable //! matchable for values 631 { 632 copy<T> val; 633 mutable str readable; 634 const char * code; 635 public: 636 matchable_value(copy<T> val_, const char *nontemp_code) : val(val_), code(nontemp_code) {} 637 matchable_value(const matchable_value<T>& other) : val(other.val), readable(other.readable), code(other.code) {} 638 DECLARE_ASSIGNMENT_OPERATOR(matchable_value); 639 MAKE_CLONABLE(matchable_value<T>); 640 641 const copy<T>& value() const { return val; } 642 char *gen_description() const { return StaticCode::strf("%s (=%s)", code, val.readable()); } 643 644 const char *name() const { return code; } 645 const char *readable_value() const { 646 if (!readable.exists()) readable = arb_test::readable(val); 647 return readable.value(); 648 } 649 650 template <typename U> inline match_expectation equals_expectation(bool invert, const U& other, const char *code) const; 651 template <typename U> inline match_expectation lessThan_expectation(bool invert, const U& other, const char *code) const; 652 template <typename U> inline match_expectation moreThan_expectation(bool invert, const U& other, const char *code) const; 653 654 template <typename FUNC> inline match_expectation predicate_expectation(bool wanted, predicate<FUNC> pred, matchable_value<T> arg) const; 655 template <typename U, typename FUNC> inline match_expectation predicate_expectation(bool wanted, FUNC pred, const char *pred_code, const U& arg, const char *arg_code) const; 656 }; 657 658 template <typename T, typename U> 659 inline const matchable_value<T> make_matchable_value(const U& other, const char *code_) { 660 return matchable_value<T>(T(other), code_); 661 } 662 #if defined(TESTS_KNOW_STRING) 663 template<> 664 inline const matchable_value<const char*> make_matchable_value<const char *, std::string>(const std::string& other, const char *code_) { 665 return matchable_value<const char *>(other.c_str(), code_); 666 } 667 #endif 668 669 template <typename T> template <typename U> 670 inline match_expectation matchable_value<T>::equals_expectation(bool wanted, const U& other, const char *code_) const { 671 return predicate_expectation(wanted, make_predicate(equals<T>, "equals", "differs"), make_matchable_value<T,U>(other, code_)); 672 } 673 template <typename T> template <typename U> 674 inline match_expectation matchable_value<T>::lessThan_expectation(bool wanted, const U& other, const char *code_) const { 675 return predicate_expectation(wanted, make_predicate(less<T>, "less than", "more or equal"), make_matchable_value<T,U>(other, code_)); 676 } 677 template <typename T> template <typename U> 678 inline match_expectation matchable_value<T>::moreThan_expectation(bool wanted, const U& other, const char *code_) const { 679 return predicate_expectation(wanted, make_predicate(more<T>, "more than", "less or equal"), make_matchable_value<T,U>(other, code_)); 680 } 681 682 template <typename T> 683 class value_matcher : public matcher //! matcher for values 684 { 685 matchable_value<T> expected; 686 public: 687 value_matcher(const matchable_value<T>& expected_) : expected(expected_) {} 688 virtual ~value_matcher() {} 689 690 virtual bool matches(const copy<T>& v1, const copy<T>& v2) const = 0; 691 virtual const char *relation(bool isMatch) const = 0; 692 693 const matchable_value<T>& get_expected() const { return expected; } 694 695 bool matches(const matchable& thing) const { 696 const matchable_value<T>& value_thing = dynamic_cast<const matchable_value<T>&>(thing); 697 return matches(value_thing.value(), expected.value()); 698 } 699 700 void dump_expectation(const matchable& thing, int indent) const { 701 bool isMatch = matches(thing); 702 print_indent(indent); 703 fprintf(stderr, "'%s' %s '%s'", thing.name(), relation(isMatch), expected.name()); 704 705 const matchable_value<T>& value_thing = dynamic_cast<const matchable_value<T>&>(thing); 706 if (equals<T>(value_thing.value(), expected.value())) { 707 fprintf(stderr, " (both are %s)", value_thing.readable_value()); 708 } 709 else { 710 int diff = strlen(thing.name())-strlen(expected.name()); 711 712 print(", where\n"); 713 indent += 2;; 714 print_indent(indent); fprintf(stderr, "'%s'%*s is %s, and\n", thing.name(), (diff>0 ? 0 : -diff), "", thing.readable_value()); 715 print_indent(indent); fprintf(stderr, "'%s'%*s is %s", expected.name(), (diff<0 ? 0 : diff), "", expected.readable_value()); 716 } 717 } 718 void dump_brief_description(const matchable& thing) const { 719 print(thing.name()); 720 print('.'); 721 print(relation(true)); 722 print('('); print(expected.name()); print(')'); 723 } 724 725 }; 726 727 // --------------------------- 728 // predicate_matcher 729 730 731 template <typename T, typename FUNC> 732 class predicate_matcher : public value_matcher<T> { 733 predicate<FUNC> pred; 734 bool expected_result; 735 736 public: 737 predicate_matcher(bool wanted, predicate<FUNC> pred_, const matchable_value<T>& arg) 738 : value_matcher<T>(arg), 739 pred(pred_), 740 expected_result(wanted) 741 {} 742 MAKE_CLONABLE(predicate_matcher); 743 744 bool matches(const copy<T>& v1, const copy<T>& v2) const { return correlated(pred.matches(v1, v2), expected_result); } 745 const char *relation(bool isMatch) const { return pred.describe(expected_result, correlated(isMatch, expected_result)); } 746 }; 747 748 template <typename T> template <typename FUNC> 749 inline match_expectation matchable_value<T>::predicate_expectation(bool wanted, predicate<FUNC> pred, matchable_value<T> arg) const { 750 return match_expectation(*this, predicate_matcher<T,FUNC>(wanted, pred, arg)); 751 } 752 template <typename T> template <typename U, typename FUNC> 753 inline match_expectation matchable_value<T>::predicate_expectation(bool wanted, FUNC pred, const char *pred_code, const U& arg, const char *arg_code) const { 754 return match_expectation(*this, predicate_matcher<T,FUNC>(wanted, predicate<FUNC>(pred, pred_code), make_matchable_value<T,U>(arg, arg_code))); 755 } 756 757 // ------------------------------------------------ 758 // matchable + matcher (for expectations) 759 760 const int MAX_GROUP_SIZE = 3; 761 class expectation_group : public matchable //! group of expectation. matchable with group_matcher 762 { 763 int count; 764 expectation *depend_on[MAX_GROUP_SIZE]; 765 766 expectation_group& operator = (const expectation_group&); // forbidden 767 protected: 768 769 public: 770 expectation_group(const expectation& e) : count(1) { 771 depend_on[0] = e.clone(); 772 } 773 expectation_group(const expectation& e1, const expectation& e2) : count(2) { 774 depend_on[0] = e1.clone(); 775 depend_on[1] = e2.clone(); 776 } 777 expectation_group(const expectation_group& other) : count(other.count) { 778 for (int i = 0; i<count; ++i) { 779 depend_on[i] = other.depend_on[i]->clone(); 780 } 781 } 782 virtual ~expectation_group() { 783 for (int i = 0; i<count; ++i) { 784 delete depend_on[i]; 785 } 786 } 787 MAKE_CLONABLE(expectation_group); 788 789 expectation_group& add(const expectation& e) { depend_on[count++] = e.clone(); return *this; } 790 791 const char *name() const { 792 return "<expectation_group>"; 793 } 794 const char *readable_value() const { 795 return "<value of expectation_group>"; 796 } 797 798 const expectation& dependent(int i) const { arb_assert(i<count); return *depend_on[i]; } 799 int size() const { return count; } 800 int count_fulfilled() const { 801 int ff = 0; 802 for (int i = 0; i<count; ++i) { 803 ff += dependent(i).fulfilled(); 804 } 805 return ff; 806 } 807 void dump_some_expectations(int indent, bool fulfilled, bool unfulfilled) const { 808 if (fulfilled||unfulfilled) { 809 bool all = fulfilled && unfulfilled; 810 bool wanted = fulfilled; 811 812 bool printed = false; 813 for (int i = 0; i<size(); ++i) { 814 const expectation& e = dependent(i); 815 816 bool is_fulfilled = e.fulfilled(); 817 if (all || is_fulfilled == wanted) { 818 if (printed) print('\n'); 819 e.explain(indent); 820 printed = true; 821 } 822 } 823 } 824 } 825 void dump_brief_description() const { 826 print("of("); 827 bool printed = false; 828 for (int i = 0; i<size(); ++i) { 829 if (printed) print(", "); 830 const expectation& e = dependent(i); 831 e.dump_brief_description(); 832 printed = true; 833 } 834 print(')'); 835 } 836 }; 837 838 struct group_match //! result of matching an expectation_group with a group_matcher 839 { 840 const int count; 841 const int fulfilled; 842 const int min_req; 843 const int max_req; 844 const int diff; 845 846 int required(int what) const { return what == -1 ? count : what; } 847 group_match(const expectation_group& group, int min, int max) 848 : count(group.size()), 849 fulfilled(group.count_fulfilled()), 850 min_req(required(min)), 851 max_req(required(max)), 852 diff(fulfilled<min_req 853 ? fulfilled-min_req 854 : (fulfilled>max_req ? fulfilled-max_req : 0)) 855 {} 856 857 858 inline static void is(int a) { select_spaced(a == 1, "is", "are"); } 859 inline static void was(int a) { select_spaced(a < 2, "was", "were"); } 860 inline static void amountzero(int a, const char *zero) { a ? print(a) : print(zero); } 861 862 void dump_num_of(int amount, const char *thing) const { 863 amountzero(amount, "no"); 864 space(); 865 print(thing); 866 if (amount != 1) print('s'); 867 } 868 869 void dump(const expectation_group& group, int indent) const { 870 print_indent(indent); 871 if (count == 1) { 872 print("expectation "); 873 print("'"); 874 group.dependent(0).dump_brief_description(); 875 print("' "); 876 print(fulfilled ? "fulfilled" : "fails"); 877 print(diff ? " unexpectedly" : " as expected"); 878 } 879 else { 880 print("expected "); 881 int that_many; 882 if (min_req == max_req) { 883 if (diff>0 && min_req>0) print("only "); 884 that_many = min_req; 885 } 886 else { 887 if (diff) { 888 print("at"); select_spaced(diff<0, "least", "most"); 889 that_many = diff<0 ? min_req : max_req; 890 } 891 else { 892 fprintf(stderr, "%i-", min_req); 893 that_many = max_req; 894 } 895 } 896 dump_num_of(that_many, "fulfilled expectation"); 897 space(); 898 group.dump_brief_description(); 899 nl(); 900 901 indent += 2; 902 print_indent(indent); 903 if (diff == 0) print("and "); else print("but "); 904 905 if (diff<0 && fulfilled>0) print("only "); 906 amountzero(fulfilled, "none"); is(fulfilled); print("fulfilled"); 907 } 908 909 print(", because\n"); 910 bool show_fulfilled = diff >= 0; 911 bool show_unfulfilled = diff <= 0; 912 group.dump_some_expectations(indent+2, show_fulfilled, show_unfulfilled); 913 } 914 }; 915 916 class group_matcher : public matcher //! matches expectation_group for degree of fulfilledness 917 { 918 int min, max; 919 group_matcher(int min_, int max_) : min(min_), max(max_) {} 920 public: 921 MAKE_CLONABLE(group_matcher); 922 923 bool matches(const matchable& thing) const { 924 return group_match(dynamic_cast<const expectation_group&>(thing), min, max).diff == 0; 925 } 926 927 void dump_expectation(const matchable& thing, int indent) const { 928 const expectation_group& group = dynamic_cast<const expectation_group&>(thing); 929 group_match matching(group, min, max); 930 matching.dump(group, indent); 931 } 932 933 // factories 934 static group_matcher all() { return group_matcher(-1, -1); } 935 static group_matcher none() { return group_matcher(0, 0); } 936 static group_matcher atleast(int min_) { return group_matcher(min_, -1); } 937 static group_matcher atmost(int max_) { return group_matcher(0, max_); } 938 static group_matcher exacly(int amount) { return group_matcher(amount, amount); } 939 940 // match_expectation factories 941 match_expectation of(const expectation& e) const { 942 return match_expectation(expectation_group(e), *this); 943 } 944 match_expectation of(const expectation& e1, const expectation& e2) const { 945 return match_expectation(expectation_group(e1, e2), *this); 946 } 947 match_expectation of(const expectation& e1, const expectation& e2, const expectation& e3) const { 948 return match_expectation(expectation_group(e1, e2).add(e3), *this); 949 } 950 951 void dump_brief_description(const matchable& thing) const { 952 if (max == -1) { 953 if (min == -1) { 954 print("all"); 955 } 956 else { 957 fprintf(stderr, "atleast(%i)", min); 958 } 959 } 960 else if (max == 0) { 961 print("none"); 962 } 963 else if (min == max) { 964 fprintf(stderr, "exactly(%i)", min); 965 } 966 else { 967 fprintf(stderr, "[%i-%i]", min, max); 968 } 969 970 print('.'); 971 972 const expectation_group& group = dynamic_cast<const expectation_group&>(thing); 973 group.dump_brief_description(); 974 } 975 }; 976 977 // -------------------------- 978 // helper functions 979 980 981 template <typename T> const matchable_value<T> CREATE_matchable(const copy<T>& val, const char *code) { return matchable_value<T>(val, code); } 982 983 inline group_matcher all() { return group_matcher::all(); } 984 inline group_matcher none() { return group_matcher::none(); } 985 inline group_matcher atleast(int min) { return group_matcher::atleast(min); } 986 inline group_matcher atmost(int max) { return group_matcher::atmost(max); } 987 inline group_matcher exacly(int amount) { return group_matcher::exacly(amount); } 988 989 inline match_expectation wrong(const expectation& e) { return none().of(e); } 364 990 }; 365 991 366 992 // -------------------------------------------------------------------------------- 367 993 368 #define TEST_WARNING(format,strarg) arb_test::StaticCode::warningf(__FILE__, __LINE__, format, (strarg)) 369 #define TEST_WARNING2(format,strarg1,strarg2) arb_test::StaticCode::warningf(__FILE__, __LINE__, format, (strarg1), (strarg2)) 370 371 #define TEST_ERROR(format,strarg) arb_test::StaticCode::errorf(__FILE__, __LINE__, format, (strarg)) 372 #define TEST_ERROR2(format,strarg1,strarg2) arb_test::StaticCode::errorf(__FILE__, __LINE__, format, (strarg1), (strarg2)) 373 #define TEST_IOERROR(format,strarg) arb_test::StaticCode::ioerrorf(__FILE__, __LINE__, format, (strarg)) 994 #define MATCHABLE_ARGS_UNTYPED(val) val, #val 995 #define MATCHABLE_ARGS_TYPED(val) make_copy(val), #val 996 997 #define equals(val) equals_expectation(true, MATCHABLE_ARGS_UNTYPED(val)) 998 #define differs(val) equals_expectation(false, MATCHABLE_ARGS_UNTYPED(val)) 999 1000 #define less_than(val) lessThan_expectation(true, MATCHABLE_ARGS_UNTYPED(val)) 1001 #define more_than(val) moreThan_expectation(true, MATCHABLE_ARGS_UNTYPED(val)) 1002 1003 #define less_or_equal(val) moreThan_expectation(false, MATCHABLE_ARGS_UNTYPED(val)) 1004 #define more_or_equal(val) lessThan_expectation(false, MATCHABLE_ARGS_UNTYPED(val)) 1005 1006 #define is(pred,arg) predicate_expectation(true, MATCHABLE_ARGS_UNTYPED(pred), MATCHABLE_ARGS_UNTYPED(arg)) 1007 #define is_not(pred,arg) predicate_expectation(false, MATCHABLE_ARGS_UNTYPED(pred), MATCHABLE_ARGS_UNTYPED(arg)) 1008 1009 #define that(thing) CREATE_matchable(MATCHABLE_ARGS_TYPED(thing)) 1010 1011 #define TEST_EXPECT(EXPCTN) do { using namespace arb_test; asserter(EXPCTN, #EXPCTN, __FILE__, __LINE__).expect_that(); } while(0) 1012 #define TEST_EXPECT__BROKEN(EXPCTN) do { using namespace arb_test; asserter(EXPCTN, #EXPCTN, __FILE__, __LINE__).expect_broken(); } while(0) 1013 #define TEST_EXPECT__WANTED(EXPCTN) do { using namespace arb_test; asserter(EXPCTN, #EXPCTN, __FILE__, __LINE__).expect_wanted_behavior(); } while(0) 1014 1015 #define DEBUG_TEST_EXPECT(EXPCTN) do { \ 1016 using namespace arb_test; \ 1017 debug_asserter(EXPCTN, #EXPCTN, __FILE__, __LINE__). \ 1018 debug_expectations(); \ 1019 debug_asserter(wrong(EXPCTN), "wrong(" #EXPCTN ")", __FILE__, __LINE__). \ 1020 debug_expectations(); \ 1021 } while(0) 1022 1023 // -------------------------------------------------------------------------------- 1024 1025 #define HERE arb_test::locinfo(__FILE__, __LINE__) 1026 1027 #define TEST_WARNING(format,strarg) HERE.warningf(format, (strarg)) 1028 #define TEST_WARNING2(format,strarg1,strarg2) HERE.warningf(format, (strarg1), (strarg2)) 1029 #define TEST_ERROR(format,strarg) HERE.errorf(true, format, (strarg)) 1030 #define TEST_ERROR2(format,strarg1,strarg2) HERE.errorf(true, format, (strarg1), (strarg2)) 1031 #define TEST_IOERROR(format,strarg) HERE.ioerrorf(true, format, (strarg)) 374 1032 375 1033 // -------------------------------------------------------------------------------- … … 392 1050 } while (0) 393 1051 394 395 #define TEST_ASSERT_ZERO(cond) TEST_ASSERT((cond) == 0) 396 #define TEST_ASSERT_ZERO__BROKEN(cond) TEST_ASSERT__BROKEN((cond) == 0) 1052 #define TEST_ASSERT_ZERO(cond) TEST_EXPECT(that(cond).equals(0)) 1053 #define TEST_ASSERT_ZERO__BROKEN(cond) TEST_EXPECT__BROKEN(that(cond).equals(0)) 397 1054 398 1055 #define TEST_ASSERT_ZERO_OR_SHOW_ERRNO(iocond) \ … … 426 1083 427 1084 428 #define TEST_ASSERT_NO_ERROR__BROKEN(error_cond) \ 1085 #define TEST_ASSERT_NO_ERROR__BROKEN(error_cond) \ 1086 do { \ 1087 const char *error_ = (error_cond); \ 1088 if (error_) { \ 1089 TEST_WARNING2("Known broken behavior ('%s' reports error '%s')", \ 1090 #error_cond, error_); \ 1091 } \ 1092 else { \ 1093 TEST_ERROR("Formerly broken test '%s' succeeds (reports no error)", \ 1094 #error_cond); \ 1095 } \ 1096 } while (0) 1097 1098 #define TEST_ASSERT_ERROR__BROKEN(error_cond) \ 1099 do { \ 1100 const char *error_ = (error_cond); \ 1101 if (!error_) { \ 1102 TEST_WARNING("Known broken behavior ('%s' fails to report error)", \ 1103 #error_cond); \ 1104 } \ 1105 else { \ 1106 TEST_ERROR2("Former broken test '%s' succeeds (reports error '%s')", \ 1107 #error_cond, error_); \ 1108 } \ 1109 } while (0) 1110 1111 1112 // -------------------------------------------------------------------------------- 1113 1114 #define TEST_EXPORTED_ERROR() (GB_have_error() ? GB_await_error() : NULL) 1115 1116 #define TEST_CLEAR_EXPORTED_ERROR() \ 429 1117 do { \ 430 const char *error = (error_cond); \ 431 if (error) { \ 432 TEST_WARNING2("Known broken behavior ('%s' reports error '%s')", \ 433 #error_cond, error); \ 434 } \ 435 else { \ 436 TEST_ERROR("Formerly broken test '%s' succeeds (reports no error)", \ 437 #error_cond); \ 1118 const char *error_ = TEST_EXPORTED_ERROR(); \ 1119 if (error_) { \ 1120 TEST_WARNING("detected and cleared exported error '%s'", \ 1121 error_); \ 438 1122 } \ 439 1123 } while (0) 440 1124 441 #define TEST_ASSERT_ERROR__BROKEN(error_cond) \ 442 do { \ 443 const char *error = (error_cond); \ 444 if (!error) { \ 445 TEST_WARNING("Known broken behavior ('%s' fails to report error)", \ 446 #error_cond); \ 447 } \ 448 else { \ 449 TEST_ERROR2("Former broken test '%s' succeeds (reports error '%s')", \ 450 #error_cond, error); \ 451 } \ 452 } while (0) 453 454 455 // -------------------------------------------------------------------------------- 456 457 #define TEST_EXPORTED_ERROR() (GB_have_error() ? GB_await_error() : NULL) 458 459 #define TEST_CLEAR_EXPORTED_ERROR() \ 460 do { \ 461 const char *error = TEST_EXPORTED_ERROR(); \ 462 if (error) { \ 463 TEST_WARNING("detected and cleared exported error '%s'", \ 464 error); \ 465 } \ 466 } while (0) 467 468 #define TEST_ASSERT_NORESULT__ERROREXPORTED_CHECKERROR(create_result,equal,contains) \ 469 do { \ 470 TEST_CLEAR_EXPORTED_ERROR(); \ 471 bool have_result = (create_result); \ 472 const char *error = TEST_EXPORTED_ERROR(); \ 473 if (have_result) { \ 474 if (error) { \ 475 TEST_WARNING("Error '%s' exported (when result returned)", \ 476 error); \ 477 } \ 478 TEST_ERROR("Expected '%s' to return NULL", #create_result); \ 479 } \ 480 else if (!error) { \ 481 TEST_ERROR("'%s' (w/o result) should always export error", \ 482 #create_result); \ 483 } \ 484 if (equal) TEST_ASSERT_EQUAL(error, equal); \ 485 if (contains) TEST_ASSERT_CONTAINS(error, contains); \ 1125 #define TEST_ASSERT_NORESULT__ERROREXPORTED_CHECKERROR(create_result,equal,contains) \ 1126 do { \ 1127 TEST_CLEAR_EXPORTED_ERROR(); \ 1128 bool have_result = (create_result); \ 1129 const char *error_ = TEST_EXPORTED_ERROR(); \ 1130 if (have_result) { \ 1131 if (error_) { \ 1132 TEST_WARNING("Error '%s' exported (when result returned)", \ 1133 error_); \ 1134 } \ 1135 TEST_ERROR("Expected '%s' to return NULL", #create_result); \ 1136 } \ 1137 else if (!error_) { \ 1138 TEST_ERROR("'%s' (w/o result) should always export error", \ 1139 #create_result); \ 1140 } \ 1141 if (equal) TEST_ASSERT_EQUAL(error_, equal); \ 1142 if (contains) TEST_ASSERT_CONTAINS(error_, contains); \ 486 1143 } while (0) 487 1144 … … 490 1147 491 1148 492 #define TEST_ASSERT_RESULT__NOERROREXPORTED(create_result) \493 do { \494 TEST_CLEAR_EXPORTED_ERROR(); \495 bool have_result = (create_result); \496 const char *error = TEST_EXPORTED_ERROR();\497 if (have_result) { \498 if (error ) {\499 TEST_ERROR("Error '%s' exported (when result returned)", \500 error );\501 } \502 } \503 else { \504 if (!error ) {\505 TEST_WARNING("'%s' (w/o result) should always export error", \506 #create_result); \507 } \508 else { \509 TEST_WARNING("exported error is '%s'", error );\510 } \511 TEST_ERROR2("Expected '%s' to return sth (exported=%s)", #create_result, error );\512 } \1149 #define TEST_ASSERT_RESULT__NOERROREXPORTED(create_result) \ 1150 do { \ 1151 TEST_CLEAR_EXPORTED_ERROR(); \ 1152 bool have_result = (create_result); \ 1153 const char *error_ = TEST_EXPORTED_ERROR(); \ 1154 if (have_result) { \ 1155 if (error_) { \ 1156 TEST_ERROR("Error '%s' exported (when result returned)", \ 1157 error_); \ 1158 } \ 1159 } \ 1160 else { \ 1161 if (!error_) { \ 1162 TEST_WARNING("'%s' (w/o result) should always export error", \ 1163 #create_result); \ 1164 } \ 1165 else { \ 1166 TEST_WARNING("exported error is '%s'", error_); \ 1167 } \ 1168 TEST_ERROR2("Expected '%s' to return sth (exported=%s)", #create_result, error_); \ 1169 } \ 513 1170 } while (0) 514 1171 … … 544 1201 // -------------------------------------------------------------------------------- 545 1202 546 #define TEST_ASSERT_NULL(n) TEST_ASSERT(arb_test::test_equal(n, (typeof(n))NULL)) 547 #define TEST_ASSERT_NULL__BROKEN(n) TEST_ASSERT__BROKEN(arb_test::test_equal(n, (typeof(n))NULL)) 548 549 #define TEST_ASSERT_EQUAL(e1,t2) TEST_ASSERT(arb_test::test_equal(e1, t2)) 550 #define TEST_ASSERT_EQUAL__BROKEN(e1,t2) TEST_ASSERT__BROKEN(arb_test::test_equal(e1, t2)) 551 552 #define TEST_ASSERT_SIMILAR(e1,t2,epsilon) TEST_ASSERT(arb_test::test_similar(e1, t2, epsilon)) 553 #define TEST_ASSERT_SIMILAR__BROKEN(e1,t2,epsilon) TEST_ASSERT__BROKEN(arb_test::test_similar(e1, t2, epsilon)) 554 555 #define TEST_ASSERT_DIFFERENT(e1,t2) TEST_ASSERT(arb_test::test_different(e1, t2)) 556 #define TEST_ASSERT_DIFFERENT__BROKEN(e1,t2) TEST_ASSERT__BROKEN(arb_test::test_different(e1, t2)) 557 558 #define TEST_ASSERT_LOWER_EQUAL(lower,upper) TEST_ASSERT(arb_test::test_less_equal(lower, upper)) 559 #define TEST_ASSERT_LOWER(lower,upper) do { TEST_ASSERT_LOWER_EQUAL(lower, upper); TEST_ASSERT_DIFFERENT(lower, upper); } while(0) 560 #define TEST_ASSERT_IN_RANGE(val,lower,upper) do { TEST_ASSERT_LOWER_EQUAL(lower, val); TEST_ASSERT_LOWER_EQUAL(val, upper); } while(0) 561 562 563 #define TEST_ASSERT_CONTAINS(str, part) TEST_ASSERT(arb_test::test_strcontains(str, part)) 1203 #define TEST_ASSERT_EQUAL(e1,t2) TEST_EXPECT(that(e1).equals(t2)) 1204 #define TEST_ASSERT_EQUAL__BROKEN(e1,t2) TEST_EXPECT__BROKEN(that(e1).equals(t2)) 1205 1206 #define TEST_ASSERT_NULL(n) TEST_ASSERT_EQUAL(n, NULL) 1207 #define TEST_ASSERT_NULL__BROKEN(n) TEST_ASSERT_EQUAL__BROKEN(n, NULL) 1208 1209 #define TEST_ASSERT_SIMILAR(e1,t2,epsilon) TEST_EXPECT(that(e1).is(epsilon_similar(epsilon), t2)) 1210 #define TEST_ASSERT_SIMILAR__BROKEN(e1,t2,epsilon) TEST_EXPECT__BROKEN(that(e1).is(epsilon_similar(epsilon), t2)) 1211 1212 #define TEST_ASSERT_DIFFERENT(e1,t2) TEST_EXPECT(that(e1).differs(t2)); 1213 #define TEST_ASSERT_DIFFERENT__BROKEN(e1,t2) TEST_EXPECT__BROKEN(that(e1).differs(t2)); 1214 1215 #define TEST_ASSERT_LOWER_EQUAL(lower,upper) TEST_EXPECT(that(lower).less_or_equal(upper)) 1216 #define TEST_ASSERT_LOWER(lower,upper) TEST_EXPECT(that(lower).less_than(upper)) 1217 #define TEST_ASSERT_IN_RANGE(val,lower,upper) TEST_EXPECT(all().of(that(val).more_or_equal(lower), that(val).less_or_equal(upper))) 1218 1219 #define TEST_ASSERT_CONTAINS(str, part) TEST_EXPECT(that(str).is(containing(), part)) 564 1220 565 1221 // -------------------------------------------------------------------------------- … … 574 1230 575 1231 namespace arb_test { 1232 inline bool test_mem_equal(const void *mem1, const void *mem2, size_t size) { 1233 FlushedOutputNoLF yes; 1234 return GB_test_mem_equal(reinterpret_cast<const unsigned char *>(mem1), 1235 reinterpret_cast<const unsigned char *>(mem2), size) == size; 1236 } 576 1237 inline bool test_files_equal(const char *file1, const char *file2) { 577 1238 FlushedOutputNoLF yes; … … 588 1249 }; 589 1250 1251 #define TEST_COPY_FILE(src, dst) TEST_ASSERT(system(GBS_global_string("cp '%s' '%s'", src, dst)) == 0) 1252 590 1253 #define TEST_ASSERT_TEXTFILE_DIFFLINES(f1,f2,diff) TEST_ASSERT(arb_test::test_textfile_difflines(f1,f2, diff)) 591 1254 #define TEST_ASSERT_TEXTFILE_DIFFLINES__BROKEN(f1,f2,diff) TEST_ASSERT__BROKEN(arb_test::test_textfile_difflines(f1,f2, diff)) … … 596 1259 #define TEST_ASSERT_FILES_EQUAL(f1,f2) TEST_ASSERT(arb_test::test_files_equal(f1,f2)) 597 1260 #define TEST_ASSERT_FILES_EQUAL__BROKEN(f1,f2) TEST_ASSERT__BROKEN(arb_test::test_files_equal(f1,f2)) 1261 1262 #define TEST_ASSERT_MEM_EQUAL(m1,m2,size) TEST_ASSERT(arb_test::test_mem_equal(m1,m2,size)) 1263 #define TEST_ASSERT_MEM_EQUAL__BROKEN(m1,m2,size) TEST_ASSERT__BROKEN(arb_test::test_mem_equal(m1,m2,size)) 598 1264 599 1265 #define TEST_ASSERT_TEXTFILES_EQUAL(f1,f2) TEST_ASSERT_TEXTFILE_DIFFLINES(f1,f2,0) … … 617 1283 // -------------------------------------------------------------------------------- 618 1284 619 #define TEST_SETUP_GLOBAL_ENVIRONMENT(modulename) TEST_ASSERT_NO_ERROR(GB_system("../test_environment setup " modulename)) 1285 #define TEST_SETUP_GLOBAL_ENVIRONMENT(modulename) do { \ 1286 arb_test::test_data().raiseLocalFlag(ANY_SETUP); \ 1287 TEST_ASSERT_NO_ERROR(GBK_system(GBS_global_string("../test_environment setup %s", (modulename)))); \ 1288 } while(0) 620 1289 // cleanup is done (by Makefile.suite) after all unit tests have been run 621 1290 -
branches/dev_elmar/UNIT_TESTER/valgrind/arb_valgrind_logged
r7209 r8224 10 10 local EXE=$1 11 11 shift 12 arb_valgrind -L $LOGGED.stdout $EXE "$@" > $LOGGING 12 arb_valgrind -L $LOGGED.stdout -E $LOGGED.stderr $EXE "$@" > $LOGGING 13 local EXITCODE=$? 13 14 sleep 2 14 15 cp $LOGGING $LOGGED … … 16 17 cat $LOGGED.stdout 17 18 rm $LOGGED.stdout 19 cat $LOGGED.stderr 1>&2 20 rm $LOGGED.stderr 21 return $EXITCODE 18 22 } 19 23 … … 58 62 rm_if $BASEDIR/flag.valgrind.leaks 59 63 rm_if $BASEDIR/flag.valgrind.reachable 64 rm_if $BASEDIR/flag.valgrind.callseen 60 65 } 61 66 -
branches/dev_elmar/WETC/WETC_main.cxx
r7945 r8224 31 31 } 32 32 else { 33 AW_root *aw_root = AWT_create_root(".arb_prop/ntree.arb", "ARB_WETC"); 33 GB_shell shell; 34 AW_root *aw_root = AWT_create_root("ntree.arb", "ARB_WETC"); 34 35 35 36 AWT_show_file(aw_root, file); … … 37 38 AWT_install_cb_guards(); 38 39 aw_root->main_loop(); 39 40 40 } 41 41 } -
branches/dev_elmar/WINDOW/AW_edit.cxx
r7945 r8224 111 111 if (command) { 112 112 aw_assert(!error); 113 error = GB _system(command);113 error = GBK_system(command); 114 114 if (error) { 115 115 aw_message(error); error = NULL; … … 135 135 } 136 136 137 void AW_system(AW_window *aww, GBDATA *gb_main,const char *command, const char *auto_help_file) {137 void AW_system(AW_window *aww, const char *command, const char *auto_help_file) { 138 138 if (auto_help_file) AW_POPUP_HELP(aww, (AW_CL)auto_help_file); 139 if (GBCMC_system(gb_main, command) != 0) { 140 const char *error = GBS_global_string("Failed to execute '%s'\n(Reason: %s)", command, GB_await_error()); 141 aw_message(error); 142 } 139 aw_message_if(GBK_system(command)); 143 140 } -
branches/dev_elmar/WINDOW/AW_file_selection.cxx
r7945 r8224 17 17 #include <arbdbt.h> 18 18 #include <arb_strbuf.h> 19 #include <arb_file.h> 19 20 20 21 #include <dirent.h> -
branches/dev_elmar/WINDOW/AW_help.cxx
r7945 r8224 16 16 #include "aw_msg.hxx" 17 17 18 #include <arbdbt.h> 18 #include <arbdb.h> 19 #include <arb_file.h> 19 20 20 21 #include <sys/stat.h> … … 283 284 } 284 285 285 if (sys[0] && !error) error = GB _system(sys);286 if (sys[0] && !error) error = GBK_system(sys); 286 287 287 288 return error; … … 414 415 char *gen_help_cmd = GBS_global_string_copy(gen_help_tmpl, GB_getenvDOCPATH(), searchtext, helpfilename); 415 416 416 error = GB _system(gen_help_cmd);417 error = GBK_system(gen_help_cmd); 417 418 418 419 free(gen_help_cmd); -
branches/dev_elmar/WINDOW/AW_nawar.cxx
r7669 r8224 14 14 #include "aw_msg.hxx" 15 15 #include <arbdb.h> 16 #include <arb_file.h> 16 17 #include <sys/stat.h> 17 18 … … 584 585 } 585 586 586 const char *AW_root::property_DB_fullname(const char *default_name) {587 const char *home = GB_getenvHOME();588 return GBS_global_string("%s/%s", home, default_name);589 }590 591 bool AW_root::property_DB_exists(const char *default_name) {592 return GB_is_regularfile(property_DB_fullname(default_name));593 }594 595 587 AW_default AW_root::load_properties(const char *default_name) { 596 GBDATA *gb_default = GB_open(default_name, "rwcD"); 588 GBDATA *gb_default = GB_open(default_name, "rwcD"); 589 GB_ERROR error = NULL; 597 590 598 591 if (gb_default) { … … 600 593 601 594 GBDATA *gb_tmp = GB_search(gb_default, "tmp", GB_CREATE_CONTAINER); 602 GB_set_temporary(gb_tmp);595 error = GB_set_temporary(gb_tmp); 603 596 } 604 597 else { 605 GB_ERROR error = GB_await_error(); 598 error = GB_await_error(); 599 } 600 601 if (error) { 606 602 const char *shown_name = strrchr(default_name, '/'); 607 603 if (!shown_name) shown_name = default_name; … … 609 605 GBK_terminatef("Error loading properties '%s': %s", shown_name, error); 610 606 } 607 611 608 return (AW_default) gb_default; 612 609 } … … 624 621 aw_update_awar_window_geometry(this); 625 622 error = GB_pop_transaction(gb_main); 626 if (!error) error = GB_save_in_ home(gb_main, filename, "a");623 if (!error) error = GB_save_in_arbprop(gb_main, filename, "a"); 627 624 } 628 625 } -
branches/dev_elmar/WINDOW/AW_status.cxx
r7945 r8224 806 806 807 807 GB_shell shell; 808 AW_root *aw_root = new AW_root(" .arb_prop/status.arb", "ARB_STATUS", true);808 AW_root *aw_root = new AW_root("status.arb", "ARB_STATUS", true); 809 809 create_status_awars(aw_root); 810 810 -
branches/dev_elmar/WINDOW/AW_window.cxx
r7945 r8224 24 24 #include <arbdbt.h> 25 25 #include <arb_handlers.h> 26 #include <arb_file.h> 26 27 27 28 #include <X11/keysym.h> … … 3382 3383 } 3383 3384 3384 GB_ERROR AW_root::start_macro_recording(const char *file, 3385 const char *application_id, const char *stop_action_name) {3385 GB_ERROR AW_root::start_macro_recording(const char *file, const char *application_id, const char *stop_action_name) { 3386 GB_ERROR error = NULL; 3386 3387 if (prvt->recording_macro_file) { 3387 return GB_export_error("Already Recording Macro"); 3388 } 3389 char *path = 0; 3390 if (file[0] == '/') { 3391 path = strdup(file); 3388 error = "Already recording macro"; 3392 3389 } 3393 3390 else { 3394 path = GBS_global_string_copy("%s/%s", GB_getenvARBMACROHOME(), file); 3395 } 3396 char *macro_header = GB_read_file("$(ARBHOME)/lib/macro.head"); 3397 if (!macro_header) { 3398 return GB_export_errorf("Cannot open file '%s'", "$(ARBHOME)/lib/macro.head"); 3399 } 3400 3401 prvt->recording_macro_file = fopen(path, "w"); 3402 prvt->recording_macro_path = path; 3403 if (!prvt->recording_macro_file) { 3404 delete macro_header; 3405 return GB_export_errorf("Cannot open file '%s' for writing", file); 3406 } 3407 prvt->stop_action_name = strdup(stop_action_name); 3408 prvt->application_name_for_macros = strdup(application_id); 3409 3410 fprintf(prvt->recording_macro_file, "%s", macro_header); 3411 free(macro_header); 3412 return 0; 3391 char *path = NULL; 3392 if (file[0] == '/') path = strdup(file); 3393 else path = GBS_global_string_copy("%s/%s", GB_getenvARBMACROHOME(), file); 3394 3395 char *macro_header = GB_read_file(GB_path_in_ARBLIB("macro.head")); 3396 if (!macro_header) error = GB_await_error(); 3397 else { 3398 prvt->recording_macro_file = fopen(path, "w"); 3399 3400 if (prvt->recording_macro_file) { 3401 prvt->stop_action_name = strdup(stop_action_name); 3402 prvt->application_name_for_macros = strdup(application_id); 3403 3404 fprintf(prvt->recording_macro_file, "%s", macro_header); 3405 reassign(prvt->recording_macro_path, path); 3406 } 3407 else error = GB_IO_error("recording to", file); 3408 free(macro_header); 3409 } 3410 free(path); 3411 } 3412 return error; 3413 3413 } 3414 3414 -
branches/dev_elmar/WINDOW/Makefile
r7945 r8224 242 242 AW_file_selection.o: $(ARBHOME)/INCLUDE/arb_core.h 243 243 AW_file_selection.o: $(ARBHOME)/INCLUDE/arb_error.h 244 AW_file_selection.o: $(ARBHOME)/INCLUDE/arb_file.h 244 245 AW_file_selection.o: $(ARBHOME)/INCLUDE/arb_msg.h 245 246 AW_file_selection.o: $(ARBHOME)/INCLUDE/arb_strbuf.h … … 302 303 AW_help.o: aw_window.hxx 303 304 AW_help.o: $(ARBHOME)/INCLUDE/ad_prot.h 304 AW_help.o: $(ARBHOME)/INCLUDE/ad_t_prot.h305 305 AW_help.o: $(ARBHOME)/INCLUDE/arb_assert.h 306 306 AW_help.o: $(ARBHOME)/INCLUDE/arb_core.h 307 307 AW_help.o: $(ARBHOME)/INCLUDE/arb_error.h 308 AW_help.o: $(ARBHOME)/INCLUDE/arb_file.h 308 309 AW_help.o: $(ARBHOME)/INCLUDE/arb_msg.h 309 310 AW_help.o: $(ARBHOME)/INCLUDE/arb_string.h 310 311 AW_help.o: $(ARBHOME)/INCLUDE/arbdb.h 311 312 AW_help.o: $(ARBHOME)/INCLUDE/arbdb_base.h 312 AW_help.o: $(ARBHOME)/INCLUDE/arbdbt.h313 313 AW_help.o: $(ARBHOME)/INCLUDE/arbtools.h 314 314 AW_help.o: $(ARBHOME)/INCLUDE/attributes.h … … 353 353 AW_nawar.o: $(ARBHOME)/INCLUDE/arb_core.h 354 354 AW_nawar.o: $(ARBHOME)/INCLUDE/arb_error.h 355 AW_nawar.o: $(ARBHOME)/INCLUDE/arb_file.h 355 356 AW_nawar.o: $(ARBHOME)/INCLUDE/arb_msg.h 356 357 AW_nawar.o: $(ARBHOME)/INCLUDE/arb_string.h … … 542 543 AW_window.o: $(ARBHOME)/INCLUDE/arb_defs.h 543 544 AW_window.o: $(ARBHOME)/INCLUDE/arb_error.h 545 AW_window.o: $(ARBHOME)/INCLUDE/arb_file.h 544 546 AW_window.o: $(ARBHOME)/INCLUDE/arb_handlers.h 545 547 AW_window.o: $(ARBHOME)/INCLUDE/arb_msg.h -
branches/dev_elmar/WINDOW/aw_position.hxx
r7669 r8224 32 32 33 33 #if defined(DEBUG) 34 34 35 #define ISVALID(a) aw_assert((a).valid()) 36 37 inline const double& NONAN(const double& d) { 38 aw_assert(d == d); 39 return d; 40 } 41 35 42 #else 36 43 #define ISVALID(a) 44 #define NONAN(d) (d) 37 45 #endif // DEBUG 38 46 … … 78 86 79 87 Position(double X, double Y) : x(X), y(Y) { ISVALID(*this); } 88 // Position(const Position& other) : x(other.x), y(other.y) { ISVALID(*this); } 80 89 Position() : x(NAN), y(NAN) {} // default is no position 81 90 ~Position() {} … … 87 96 const double& ypos() const { return y; } 88 97 89 void setx(const double& X) { x = X; }90 void sety(const double& Y) { y = Y; }91 92 void movex(const double& X) { x += X; }93 void movey(const double& Y) { y += Y; }98 void setx(const double& X) { x = NONAN(X); } 99 void sety(const double& Y) { y = NONAN(Y); } 100 101 void movex(const double& X) { x += NONAN(X); } 102 void movey(const double& Y) { y += NONAN(Y); } 94 103 95 104 void move(const Vector& movement) { *this += movement; } … … 103 112 extern const Position Origin; 104 113 114 inline bool nearlyEqual(const Position& p1, const Position& p2) { 115 return 116 nearlyEqual(p1.xpos(), p2.xpos()) && 117 nearlyEqual(p1.ypos(), p2.ypos()); 118 } 119 105 120 // ------------------------------- 106 121 // a 2D vector … … 176 191 extern const Vector ZeroVector; 177 192 193 inline bool nearlyEqual(const Vector& v1, const Vector& v2) { return nearlyEqual(v1.endpoint(), v2.endpoint()); } 194 178 195 // ----------------------------------------- 179 196 // inline Position members … … 273 290 inline bool is_vertical(const LineVector& line) { return is_vertical(line.line_vector()); } 274 291 inline bool is_horizontal(const LineVector& line) { return is_horizontal(line.line_vector()); } 275 292 inline bool nearlyEqual(const LineVector& L1, const LineVector& L2) { 293 return 294 nearlyEqual(L1.line_vector(), L2.line_vector()) && 295 nearlyEqual(L1.start(), L2.start()); 296 } 297 276 298 // --------------------- 277 299 // a rectangle … … 468 490 } 469 491 470 inline bool are_orthographic(const Vector& v1, const Vector& v2) { 492 inline bool are_orthographic(const Vector& v1, const Vector& v2) { // orthogonal (dt.) 471 493 return are_equal(scalarProduct(v1, v2), 0); 472 494 } 495 473 496 #endif // DEBUG 474 497 -
branches/dev_elmar/WINDOW/aw_root.hxx
r7945 r8224 147 147 void unlink_awars_from_DB(GBDATA *gb_main); // use before calling GB_close for 'gb_main', if you have AWARs in DB 148 148 149 static const char *property_DB_fullname(const char *default_name);150 static bool property_DB_exists(const char *default_name);151 152 149 AW_default check_properties(AW_default aw_props) { 153 150 return aw_props ? aw_props : application_database; … … 189 186 inline AW_default get_AW_ROOT_DEFAULT() { return AW_root::SINGLETON->check_properties(NULL); } 190 187 191 void AW_system(AW_window *aww, GBDATA *gb_main,const char *command, const char *auto_help_file);188 void AW_system(AW_window *aww, const char *command, const char *auto_help_file); 192 189 193 190 #else -
branches/dev_elmar/arb_LICENSE.txt
r7945 r8224 236 236 which is provided in 'lib/GPL.txt'. 237 237 238 molphy239 240 MOLPHY: A Computer Program Package for Molecular Phylogenetics241 242 Readme243 This is the MOLPHY (ProtML) distribution, version 2.3.244 Copyright (c) 1992-1996, Jun Adachi & Masami Hasegawa.245 All rights reserved.246 247 MOLPHY is a program package for MOLecular PHYlogenetics.248 249 ProtML is a main program in MOLPHY for inferring evolutionary trees from250 PROTein (amino acid) sequences by using the Maximum Likelihood method.251 252 Programs (C language)253 ProtML: Maximum Likelihood Inference of Protein Phylogeny254 NucML: Maximum Likelihood Inference of Nucleic Acid Phylogeny255 ProtST: Basic Statistics of Protein Sequences256 NucST: Basic Statistics of Nucleic Acid Sequences257 NJdist: Neighbor Joining Phylogeny from Distance Matrix258 Utilities (Perl)259 mollist: get identifiers list molrev: reverse DNA sequences260 molcat: concatenate sequences molcut: get partial sequences261 molmerge: merge sequences nuc2ptn: DNA -> Amino acid262 rminsdel: remove INS/DEL sites molcodon: get specified codon sites263 molinfo: get varied sites mol2mol: MOLPHY format beautifer264 inl2mol: Interleaved -> MOLPHY mol2inl: MOLPHY -> Interleaved265 mol2phy: MOLPHY -> Sequential phy2mol: Sequential -> MOLPHY266 must2mol: MUST -> MOLPHY etc.267 268 MOLPHY is a free software, and you can use and redistribute it.269 The programs are written in a standard subset of C with UNIX-like OS.270 The utilities are written in the "Perl" (Ver.4.036) with UNIX-like OS.271 MOLPHY has been tested on SUN4's (cc & gcc with SUN-OS 4.1.3) and272 HP9000/700 (cc, c89 & gcc with HP-UX 9.05).273 However, MOLPHY has NOT been tested on VAX, IBM-PC, and Macintosh.274 275 NETWORK DISTRIBUTION ONLY: The latest version of MOLPHY is always available276 by anonymous ftp in ftp.ism.ac.jp: /pub/ISMLIB/MOLPHY/.277 278 238 readseq 279 239 -
branches/dev_elmar/arb_README.txt
r6211 r8224 9 9 ARB is currently developed on Linux PCs only. 10 10 11 Compiling ARB using the gcc compiler ( versions 2.95.3, 3.x and4.x series)11 Compiling ARB using the gcc compiler (4.x series) 12 12 as well works on Mac OSX and Sun OS - but we do not publish or support 13 13 these versions. … … 39 39 'arb.64.*.tgz' // 64 bit versions 40 40 41 'arb.*.SuSE*.tgz // SuSE version42 'arb.*.Ubuntu*.tgz // Ubuntu version (recommended)43 44 41 'arb.*.OPENGL.tgz' // OPENGL version (contains RNA3D, a 3D-molecule-viewer) 45 42 … … 48 45 choose a 64-bit-version, if your system is 64-bit. 49 46 50 Normally one of the Ubuntu versions should work for you, only 51 use one of the SuSE versions, if the Ubuntu version has problems 52 (e.g. does not display group names in ARB_EDIT4). 47 You need only ONE of the available 'arb.*.tgz'! 53 48 54 49 … … 66 61 'arb_install.sh' // install script 67 62 'arb_README.txt' // this file 68 'arb.*.tgz' // ARB binaries 63 'arb.*.tgz' // your chosen ARB version 64 69 65 70 66 are located and type -
branches/dev_elmar/arb_UBUNTU.txt
r7489 r8224 1 1 2 ARB requirements on Ubuntu 8.103 ------------------------------- 2 ARB requirements on Ubuntu 10.04 3 -------------------------------- 4 4 5 5 [Note:] -
branches/dev_elmar/lib/arb_tcp_org.dat
r6708 r8224 32 32 33 33 ARB_TEST_PT_SERVER localhost:3200 arb_pt_server -D$(ARBHOME)/UNIT_TESTER/run/TEST_pt.arb 34 34 ARB_TEST_PT_SERVER_GENE localhost:3201 arb_pt_server -D$(ARBHOME)/UNIT_TESTER/run/TEST_gpt.arb 35 35 36 36 #*********** Private Servers (for each user) ****************** -
branches/dev_elmar/lib/pictures/ad_gen_create.fig
- Property svn:mergeinfo changed from /trunk/lib/pictures/ad_gen_create.fig:7771-7998 to /trunk/lib/pictures/ad_gen_create.fig:7771-8223
-
branches/dev_elmar/lib/pictures/awt/export.fig
r4087 r8224 1 #FIG 2.1 2 80 2 3 6 84 169 474 539 4 2 1 0 1 -1 0 0 0 0.000 -1 0 0 5 239 204 84 204 84 574 474 574 474 204 319 204 9999 9999 1 #FIG 3.2 Produced by xfig version 3.2.5b 2 Landscape 3 Center 4 Metric 5 A4 6 100.00 7 Single 8 -2 9 1200 2 10 6 1275 2550 7125 8100 11 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 6 12 3600 3075 1275 3075 1275 8625 7125 8625 7125 3075 4800 3075 6 13 -6 7 6 89 159 469 2298 4 0 18 12 0 -1 0 0.00000 4 15 28 89 264 $box9 4 2 18 12 0 -1 0 0.00000 4 15 33 469 233 $filter10 4 2 18 12 0 -1 0 0.00000 4 15 33 409 229 Suffix11 4 0 18 12 0 -1 0 0.00000 4 15 153 94 229 Directories (D) and Files (f)12 4 1 18 12 0 -1 0 0.00000 4 15 52 279 209 Filename14 6 1350 2400 7050 3450 15 4 0 -1 0 0 18 12 0.0000 4 210 495 1350 3975 $box\001 16 4 2 -1 0 0 18 12 0.0000 4 210 585 7050 3510 $filter\001 17 4 2 -1 0 0 18 12 0.0000 4 165 570 6150 3450 Suffix\001 18 4 0 -1 0 0 18 12 0.0000 4 210 2805 1425 3450 Directories (D) and Files (f)\001 19 4 1 -1 0 0 18 12 0.0000 4 165 930 4200 3150 Filename\001 13 20 -6 14 2 2 0 1 -1 0 0 0 0.000 0 0 0 15 479 624 479 34 74 34 74 624 479 624 9999 9999 16 4 0 18 12 0 -1 0 0.00000 4 15 38 89 64 $close 17 4 2 18 12 0 -1 0 0.00000 4 15 31 469 64 $help 18 4 2 18 12 0 -1 0 0.00000 4 15 78 469 564 $to:file_name 19 4 0 18 12 0 -1 0 0.00000 4 15 63 89 564 $file_name 20 4 2 18 12 0 -1 0 0.00000 4 15 43 469 514 $to:box 21 4 0 18 12 0 -1 0 0.00000 4 15 57 89 534 File Name 22 4 0 18 12 0 -1 0 0.00000 4 15 34 89 99 $what 23 4 0 18 12 0 -1 0 0.00000 4 15 81 89 134 $remove_root 24 4 0 18 12 0 -1 0 0.00000 4 15 81 89 179 $color 25 4 0 18 12 0 -1 0 0.00000 4 15 28 89 609 $xfig 26 4 2 18 12 0 -1 0 0.00000 4 15 43 184 609 $to:xfig 27 4 0 18 12 0 -1 0 0.00000 4 15 45 339 609 $cancel 28 4 2 18 12 0 -1 0 0.00000 4 15 60 454 609 $to:cancel 21 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 22 7200 9375 7200 525 1125 525 1125 9375 7200 9375 23 4 0 -1 0 0 18 12 0.0000 4 210 675 1350 975 $close\001 24 4 2 -1 0 0 18 12 0.0000 4 225 570 7050 975 $help\001 25 4 2 -1 0 0 18 12 0.0000 4 225 1380 7050 8475 $to:file_name\001 26 4 0 -1 0 0 18 12 0.0000 4 225 1095 1350 8475 $file_name\001 27 4 2 -1 0 0 18 12 0.0000 4 210 780 7050 7725 $to:box\001 28 4 0 -1 0 0 18 12 0.0000 4 165 1020 1350 8025 File Name\001 29 4 0 -1 0 0 18 12 0.0000 4 210 600 1350 1500 $what\001 30 4 0 -1 0 0 18 12 0.0000 4 225 1440 1350 2025 $remove_root\001 31 4 0 -1 0 0 18 12 0.0000 4 210 660 1350 2700 $color\001 32 4 0 -1 0 0 18 12 0.0000 4 225 480 1350 9150 $xfig\001 -
branches/dev_elmar/lib/pictures/awt/secExport.fig
r4750 r8224 1 #FIG 3.2 1 #FIG 3.2 Produced by xfig version 3.2.5b 2 2 Landscape 3 3 Center … … 12 12 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 1 13 13 7155 8865 14 4 0 -1 0 0 18 12 0.0000 4 165 450 1440 8595 $xfig\001 15 4 0 -1 0 0 18 12 0.0000 4 150 900 1305 7155 $file_name\001 16 4 2 -1 0 0 2 12 0.0000 4 150 720 5895 2250 X:Suffix\001 17 4 0 -1 0 0 18 12 0.0000 4 135 360 1350 2745 $box\001 18 4 0 -1 0 0 2 14 0.0000 4 135 810 1350 6750 File Name\001 19 4 2 -1 0 0 18 12 0.0000 4 165 720 3375 8595 $to:xfig\001 20 4 0 -1 0 0 18 12 0.0000 4 135 540 1710 8100 $color\001 21 4 2 -1 0 0 18 12 0.0000 4 150 1350 7065 7290 $to:X:file_name\001 22 4 0 -1 0 0 18 12 0.0000 4 135 450 1710 7695 $what\001 23 4 0 -1 0 0 2 14 0.0000 4 165 3150 1350 1935 Select Path to export the STRUCTURE\001 24 4 0 -1 0 0 2 13 0.0000 4 165 2610 1350 2295 Directories (D) and Files (f)\001 25 4 2 -1 0 0 18 12 0.0000 4 150 810 7065 6390 $to:X:box\001 26 4 2 -1 0 0 18 12 0.0000 4 150 810 7065 2340 $X:filter\001 27 4 2 -1 0 0 18 12 0.0000 4 150 810 7065 8595 $X:cancel\001 28 4 0 -1 0 0 18 12 0.0000 4 135 540 1350 1575 $close\001 29 4 2 -1 0 0 18 12 0.0000 4 165 630 7065 1620 $X:help\001 14 4 0 -1 0 0 18 12 0.0000 4 225 480 1440 8595 $xfig\001 15 4 0 -1 0 0 18 12 0.0000 4 225 1095 1305 7155 $file_name\001 16 4 2 -1 0 0 2 12 0.0000 4 150 750 5895 2250 X:Suffix\001 17 4 0 -1 0 0 18 12 0.0000 4 210 495 1350 2745 $box\001 18 4 0 -1 0 0 2 14 0.0000 4 165 1080 1350 6750 File Name\001 19 4 0 -1 0 0 18 12 0.0000 4 210 660 1710 8100 $color\001 20 4 2 -1 0 0 18 12 0.0000 4 225 1590 7065 7290 $to:X:file_name\001 21 4 0 -1 0 0 18 12 0.0000 4 210 600 1710 7695 $what\001 22 4 0 -1 0 0 2 14 0.0000 4 225 4200 1350 1935 Select Path to export the STRUCTURE\001 23 4 0 -1 0 0 2 13 0.0000 4 195 2445 1350 2295 Directories (D) and Files (f)\001 24 4 2 -1 0 0 18 12 0.0000 4 210 990 7065 6390 $to:X:box\001 25 4 2 -1 0 0 18 12 0.0000 4 210 795 7065 2340 $X:filter\001 26 4 0 -1 0 0 18 12 0.0000 4 210 675 1350 1575 $close\001 27 4 2 -1 0 0 18 12 0.0000 4 225 780 7065 1620 $X:help\001 -
branches/dev_elmar/lib/pictures/dbbrowser.fig
r2753 r8224 1 #FIG 3.2 1 #FIG 3.2 Produced by xfig version 3.2.5b 2 2 Landscape 3 3 Center … … 8 8 -2 9 9 1200 2 10 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 1 11 600 825 12 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 13 8865 10200 8865 10275 14 4 0 -1 0 0 18 13 0.0000 4 180 600 750 1200 $close\001 15 4 2 -1 0 0 18 12 0.0000 4 180 645 8700 1200 $X:help\001 16 4 2 -1 0 0 18 13 0.0000 4 195 945 8700 2385 $to:X:path\001 17 4 0 -1 0 0 18 13 0.0000 4 135 420 855 2250 Path\001 18 4 0 -1 0 0 18 13 0.0000 4 135 840 855 1755 Database\001 19 4 0 -1 0 0 18 13 0.0000 4 135 1335 855 7695 Y:Information:\001 20 4 2 -1 0 0 18 13 0.0000 4 180 1350 8700 7380 $to:XY:browse\001 21 4 2 -1 0 0 18 13 0.0000 4 180 1035 8700 10170 $to:XY:info\001 22 4 0 -1 0 0 18 13 0.0000 4 135 750 855 2790 Browse:\001 23 4 0 -1 0 0 18 13 0.0000 4 180 780 855 3150 $browse\001 24 4 0 -1 0 0 18 13 0.0000 4 180 660 855 8190 $Y:info\001 25 4 0 -1 0 0 18 13 0.0000 4 195 510 2115 2250 $path\001 26 4 0 -1 0 0 18 13 0.0000 4 180 345 2115 1755 $db\001 27 4 0 -1 0 0 18 13 0.0000 4 195 1080 4050 2745 $navigation\001 28 4 0 -1 0 0 18 13 0.0000 4 180 600 2115 2745 $order\001 10 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 1 11 675 990 12 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 1 13 19440 13770 14 4 0 -1 0 0 18 13 0.0000 4 210 675 750 1200 $close\001 15 4 0 -1 0 0 18 13 0.0000 4 165 975 2475 1260 Database\001 16 4 0 -1 0 0 18 13 0.0000 4 210 390 3735 1260 $db\001 17 4 0 -1 0 0 18 13 0.0000 4 165 480 2475 1845 Path\001 18 4 0 -1 0 0 18 13 0.0000 4 225 585 3735 1845 $path\001 19 4 0 -1 0 0 18 13 0.0000 4 210 690 2115 2385 $order\001 20 4 0 -1 0 0 18 13 0.0000 4 225 1215 4815 2385 $navigation\001 21 4 0 -1 0 0 18 13 0.0000 4 165 840 855 2430 Browse:\001 22 4 0 -1 0 0 18 13 0.0000 4 210 870 855 2790 $browse\001 23 4 2 -1 0 0 18 12 0.0000 4 225 780 19365 1350 $X:help\001 24 4 2 -1 0 0 18 13 0.0000 4 225 1080 19365 1980 $to:X:path\001 25 4 2 -1 0 0 18 13 0.0000 4 210 1155 19365 13725 $to:XY:info\001 26 4 0 -1 0 0 18 13 0.0000 4 165 1260 9540 2745 Information:\001 27 4 0 -1 0 0 18 13 0.0000 4 210 510 9540 3105 $info\001 28 4 2 -1 0 0 18 13 0.0000 4 210 1380 9495 13725 $to:Y:browse\001 29 4 0 -1 0 0 18 13 0.0000 4 225 855 11835 2700 $infoopt\001 -
branches/dev_elmar/util/arb_srclst.pl
r7999 r8224 168 168 qr/\/UNIT_TESTER\/run\/.*\.tree$/o, 169 169 qr/\/UNIT_TESTER\/run\/impexp\/.*\.exported$/o, 170 qr/\/UNIT_TESTER\/run\/TEST_.*\.pt$/o, # has to move to skipped_when_matchesFull (when merging test env)171 170 qr/\/UNIT_TESTER\/valgrind\/arb_valgrind_logged$/o, 172 171 qr/^\.\/etc\//o, … … 211 210 qr/^\.\/SOURCE_TOOLS\/valgrind2grep\.lst$/o, 212 211 qr/^\.\/TEMPLATES\/arb_build\.h$/o, 212 qr/^\.\/UNIT_TESTER\/run\/TEST_g?pt\.arb$/o, 213 qr/^\.\/UNIT_TESTER\/run\/.*\.ARM$/o, 214 qr/^\.\/UNIT_TESTER\/run\/.*\.ARF$/o, 213 215 qr/date\.xsl$/o, 214 216 );
