33#define PI_LONG (1 << 0)
34#define PI_RECURSIVE (1 << 1)
35#define PI_VALUE (1 << 2)
36#define PI_HEX (1 << 3)
37#define PI_PAUSE (1 << 4)
68 printf(
"Database commands ([] are options, <> are placeholders):\n\n");
69 printf(
"alarm - reset all alarms\n");
70 printf(
"cd <dir> - change current directory\n");
71 printf(
"chat - enter chat mode\n");
72 printf(
"chmod <mode> <key> - change access mode of a key\n");
73 printf(
" 1=read | 2=write | 4=delete\n");
74 printf(
"cleanup [client] [-f] - delete hanging clients [force]\n");
75 printf(
"copy <src> <dest> - copy a subtree to a new location\n");
76 printf(
"create <type> <key> - create a key of a certain type\n");
77 printf(
"create <type> <key>[n] - create an array of size [n]\n");
78 printf(
"create string <key>[n][m] - create an array of [n] strings of [m] characters\n");
79 printf(
"del/rm [-l] [-f] <key> - delete a key and its subkeys\n");
80 printf(
" -l follow links\n");
81 printf(
" -f force deletion without asking\n");
82 printf(
"exec <key>/<cmd> - execute shell command (stored in key) on server\n");
83 printf(
"exp <key> <filename> - import key into ASCII file\n");
84 printf(
"find <pattern> - find a key with wildcard pattern\n");
85 printf(
"help/? [command] - print this help [for a specific command]\n");
86 printf(
"hi [analyzer] [id] - tell analyzer to clear histos\n");
87 printf(
"imp <filename> [key] - import ASCII file into string key\n");
88 printf(
"json <odb path> - print \"ODB save\" encoding of current directory or given odb path\n");
89 printf(
"jsls - print \"ls\" encoding of current directory\n");
90 printf(
"jsvalues - print \"get_values\" encoding of current directory\n");
91 printf(
"ln <source> <linkname> - create a link to <source> key\n");
92 printf(
"load <file> - load database from .ODB file at current position\n");
93 printf(
"-- hit return for more --\r");
95 printf(
"ls/dir [-lhvrp] [<pat>] - show database entries which match pattern\n");
96 printf(
" -l detailed info\n");
97 printf(
" -h hex format\n");
98 printf(
" -v only value\n");
99 printf(
" -r show database entries recursively\n");
100 printf(
" -p pause between screens\n");
101 printf(
"make [analyzer name] - create experim.h\n");
102 printf(
"mem [-v] - show memeory usage [verbose]\n");
103 printf(
"mkdir <subdir> - make new <subdir>\n");
104 printf(
"move <key> [top/bottom/[n]] - move key to position in keylist\n");
105 printf(
"msg [user] <msg> - send chat message (from interactive odbedit)\n");
106 printf(
"msg <facility> <type> <name> <msg> - send message to [facility] log\n");
107 printf(
"old [n] - display old n messages\n");
108 printf(
"passwd - change MIDAS password\n");
109 printf(
"pause - pause current run\n");
110 printf(
"pwd - show current directory\n");
111 printf(
"resume - resume current run\n");
112 printf(
"rename <old> <new> - rename key\n");
113 printf(
"-- hit return for more --\r");
115 printf(
"save [-c -s -x -j -cs] <file> - save database at current position\n");
116 printf(
" in ASCII format\n");
117 printf(
" -c as a C structure\n");
118 printf(
" -s as a #define'd string\n");
119 printf(
" -x as an XML file, or use file.xml\n");
120 printf(
" -j as a JSON file, or use file.json\n");
121 printf(
" -z as value-only JSON file\n");
122 printf(
"set <key> <value> - set the value of a key\n");
123 printf(
"set <key>[i] <value> - set the value of index i\n");
124 printf(
"set <key>[*] <value> - set the value of all indices of a key\n");
125 printf(
"set <key>[i..j] <value> - set the value of all indices i..j\n");
126 printf(
"scl [-w] - show all active clients [with watchdog info]\n");
127 printf(
"shutdown <client>/all - shutdown individual or all clients\n");
128 printf(
"sor - show open records in current subtree\n");
129 printf(
"start [number][now][-v] - start a run [with a specific number],\n");
130 printf(
" [now] w/o asking parameters, [-v] debug output\n");
131 printf(
"stop [-v] - stop current run, [-v] debug output\n");
132 printf(
"test_rpc - test mserver RPC connection and parameter encoding and decoding\n");
133 printf(
"trunc <key> <index> - truncate key to [index] values\n");
134 printf(
"ver - show MIDAS library version\n");
135 printf(
"webpasswd - change WWW password for mhttpd\n");
136 printf(
"wait <key> - wait for key to get modified\n");
137 printf(
"watch <key> - watch key or ODB tree to be modified\n");
139 printf(
"\nquit/exit - exit\n");
144 printf(
"cd <dir> - change current directory. Use \"cd /\" to change to the root\n");
145 printf(
" of the ODB, \"cd ..\" to change to the parent directory.\n");
147 printf(
"chat - enter chat mode. In this mode, users can \"talk\" to each other.\n");
148 printf(
" Each user running ODBEdit connected to the same experiment can see\n");
149 printf(
" the other messages and each user running ODBEdit in chat mode can\n");
150 printf(
" produce messages. All messages are logged in the MIDAS logging file.\n");
152 printf(
"No specific help available for command \"%s\".\n", command);
165 assert(
sizeof(
str) >= 32);
215 if ((flags &
PI_PAUSE) && (l % 24) == 23) {
216 printf(
"Press any key to continue or q to quit ");
245 while (s->length() < pos)
306 if ((
pi->index != -1 &&
i ==
pi->index) ||
pi->index == -1)
332 xline +=
" -> (empty)";
334 if (
pi->index != -1) {
337 xline += std::to_string(
pi->index);
340 if (
xline.length() >= 32) {
348 if (
pi->index != -1) {
448 else if (
delta < 3600)
450 else if (
delta < 86400)
452 else if (
delta < 86400 * 99)
485 xline +=
"<multi-line>";
491 xline +=
"<multi-line>";
522 yline += std::to_string(
i);
532 if ((
pi->index != -1 &&
i ==
pi->index) ||
pi->index == -1)
579 printf(
"Write access not allowed\n");
594 static char data_str[256], line[256];
619 strcpy(
data_str,
"<no read access>");
648 strcpy(
data_str,
"<no read access>");
667 else if (
delta < 3600)
669 else if (
delta < 86400)
671 else if (
delta < 86400 * 99)
756 char head[256],
tail[256], key_name[256],
c;
770 while (*
pc && *
pc !=
' ')
772 while (*
pc && *
pc ==
' ')
774 }
while (*
pc ==
'-');
777 strcpy(key_name,
pc);
785 if (key_name[0] ==
'"')
786 ystr = (key_name + 1);
789 if (key_name[0] !=
'/') {
807 if (
strlen(key_name) > 0 && key_name[
strlen(key_name) - 1] !=
' ')
898 for (
pc = key_name +
strlen(key_name) - 1;
pc > key_name && *
pc !=
'/';
910 if (key_name[0] !=
'"') {
912 key_name[
i + 1] = key_name[
i];
921 if (key_name[0] ==
'"' && key_name[
strlen(key_name) - 1] !=
'"')
938 if (
match > 1 && key_name[0]) {
972 for (
pc = key_name +
strlen(key_name) - 1;
pc > key_name && *
pc !=
'/';
pc--)
977 for (
i = 0;
i <
j;
i++)
983 if (key_name[0] !=
'"') {
985 key_name[
i + 1] = key_name[
i];
1011 char *pattern = (
char *)
info;
1015 std::string line = path +
" : ";
1033 printf(
"%s\n", line.c_str());
1043 printf(
"%s\n", line.c_str());
1074static void xwrite(
const char *filename,
int fd,
const void *
data,
int size) {
1089 "/********************************************************************\\\n\
1092 Created by: ODBedit program\n\
1094 Contents: This file contains C structures for the \"Experiment\"\n\
1095 tree in the ODB and the \"/Analyzer/Parameters\" tree.\n\
1097 Additionally, it contains the \"Settings\" subtree for\n\
1098 all items listed under \"/Equipment\" as well as their\n\
1099 event definition.\n\
1101 It can be used by the frontend and analyzer to work\n\
1102 with these information.\n\
1104 All C structures are accompanied with a string represen-\n\
1105 tation which can be used in the db_create_record function\n\
1106 to setup an ODB structure which matches the C structure.\n\
1109 "\\********************************************************************/\n\n";
1116 cm_msg(
MERROR,
"create_experim_h",
"cannot open experim.h file.");
1130 sprintf(
str,
"#define EXP_PARAM_DEFINED\n\n");
1140 sprintf(
str,
"#define EXP_EDIT_DEFINED\n\n");
1151 printf(
"Analyzer \"%s\" not found in ODB, skipping analyzer parameters.\n",
1293 printf(
"Server connection broken.\n");
1309 if (
name[0] !=
'/') {
1327 const char *
state_char[] = {
"U",
"S",
"P",
"R"};
1328 const char *
state_str[] = {
"Unknown",
"Stopped",
"Paused",
"Running"};
1332 size =
sizeof(
mask);
1333 strcpy(
mask,
"[%h:%e:%s]%p>");
1337 size =
sizeof(
state);
1352 assert(
sizeof(
str) >= 32);
1355 strcpy(
pp,
str + 11);
1380 while (*
pc !=
'/' &&
pc !=
pwd)
1404 printf(
"callback for invalid or deleted hkey %d odb path %s\n",
hKey, path.c_str());
1409 printf(
"%s modified\n", path.c_str());
1415 printf(
"%s = \"%s\"\n", path.c_str(),
data.c_str());
1418 int size =
sizeof(
data);
1421 printf(
"%s = %s\n", path.c_str(),
str.c_str());
1425 printf(
"%s[*] modified\n", path.c_str());
1433 int size =
sizeof(
data);
1447 char line[2000],
prompt[256];
1448 char param[10][2000];
1455 char user_name[80] =
"";
1458 char message[2000], client_name[256], *p;
1472 printf(
"Directory \"%s\" not found.\n",
pwd);
1477 if (cmd[0] ==
'@') {
1480 printf(
"Command file %s not found.\n", cmd + 1);
1494 }
else if (cmd[0] !=
'@')
1497 memset(line, 0,
sizeof(line));
1500 if (s ==
NULL || line[0] == 0)
1504 while (
strlen(line) > 0 && line[
strlen(line) - 1] ==
'\n')
1505 line[
strlen(line) - 1] = 0;
1525 }
else if (*
pc ==
'\'') {
1527 for (
i = 0; *
pc && *
pc !=
'\'' &&
i < (
int)
sizeof(
param[0]) - 1;
i++)
1531 }
else if (*
pc ==
'`') {
1551 else if ((
param[0][0] ==
'l' &&
param[0][1] ==
's') || (
param[0][0] ==
'd' &&
param[0][1] ==
'i')) {
1559 for (
i = 1;
i < 4;
i++)
1560 if (
param[
i][0] ==
'-') {
1575 for (
i = 1;
param[
i][0] ==
'-';
i++)
1581 for (p =
strchr(
param[
i],
'[') + 1; *p && *p !=
']'; p++)
1585 if (*p && *p ==
']') {
1605 printf(
"link %s points to invalid location\n",
param[
i]);
1611 printf(
"Key name Type #Val Size Last Opn Mode Value\n");
1612 printf(
"---------------------------------------------------------------------------\n");
1645 else if (
param[0][0] ==
'c' &&
param[0][1] ==
'd') {
1658 printf(
"key has no subkeys\n");
1664 printf(
"key not found\n");
1668 else if (
param[0][0] ==
'p' &&
param[0][1] ==
'w') {
1673 else if (
param[0][0] ==
'c' &&
param[0][1] ==
'r') {
1698 printf(
"Unknown type. Must be one of:\n");
1699 printf(
"{ UINT8,INT8,UINT16,INT16,UINT32,INT32,UINT64,INT64,BOOL,FLOAT,DOUBLE,STRING }\n");
1736 else if (
param[0][0] ==
'm' &&
param[0][1] ==
'k') {
1742 else if (
param[0][0] ==
'l' &&
param[0][1] ==
'n') {
1748 else if (
param[0][0] ==
'c' && (
param[0][1] ==
'o' ||
param[0][1] ==
'p')) {
1756 printf(
"Overwrite existing key\n\"%s\"\n(y/[n]) ",
str);
1783 size =
sizeof(
data);
1786 printf(
"error: db_copy() status %d, odbedit internal buffer is too small, size %d\n",
status, size);
1795 printf(
"key not found\n");
1801 else if ((
param[0][0] ==
'd' &&
param[0][1] ==
'e') || (
param[0][0] ==
'r' &&
param[0][1] ==
'm')) {
1808 for (
i = 1;
param[
i][0] ==
'-';
i++)
1821 printf(
"Are you sure to delete the key\n\"%s\"\nand all its subkeys? (y/[n]) ",
1824 printf(
"Are you sure to delete the key\n\"%s\"\n(y/[n]) ",
str);
1829 if (
str[0] ==
'y') {
1832 printf(
"deletion of key not allowed\n");
1834 printf(
"key is open by other client\n");
1840 printf(
"key not found\n");
1844 else if (
param[0][0] ==
's' &&
param[0][1] ==
'e') {
1851 std::vector<HNDLE> keys;
1855 printf(
"Error: Key \"%s\" not found\n",
name);
1866 else if (
param[0][0] ==
'c' &&
param[0][1] ==
'h' &&
param[0][2] ==
'm') {
1868 printf(
"Please specify mode and key\n");
1885 printf(
"Are you sure to change the mode of key\n %s\nand all its subkeys\n",
1895 printf(
"Error: Key \"%s\" not found\n",
str);
1906 printf(
"RPC test passed!\n");
1908 printf(
"RPC test failed!\n");
1912 else if (
param[0][0] ==
't' &&
param[0][1] ==
'r') {
1913 if (
param[1][0] == 0) {
1914 printf(
"Please specify key\n");
1927 printf(
"Error: Key \"%s\" not found\n",
str);
1935 else if (
param[0][0] ==
'r' &&
param[0][1] ==
'e' &&
param[0][2] ==
'n') {
1936 if (
param[1][0] == 0) {
1937 printf(
"Please specify key\n");
1949 printf(
"Error: Key \"%s\" not found\n",
str);
1957 else if (
param[0][0] ==
'm' &&
param[0][1] ==
'o') {
1958 if (
param[1][0] == 0) {
1959 printf(
"Please specify key\n");
1969 if (
param[2][0] ==
't')
1971 else if (
param[2][0] ==
'b')
1978 printf(
"no write access to key\n");
1980 printf(
"key is open by other client\n");
1982 printf(
"Error: Key \"%s\" not found\n",
str);
1990 else if (
param[0][0] ==
'f' &&
param[0][1] ==
'i') {
1996 printf(
"current key is invalid / no read access\n");
2000 else if (
param[0][0] ==
'l' &&
param[0][1] ==
'o') {
2007 else if (
param[0][0] ==
's' &&
param[0][1] ==
'a') {
2014 else if (
param[1][0] ==
'-') {
2015 if (
param[1][1] ==
'c' &&
param[1][2] ==
's') {
2018 }
else if (
param[1][1] ==
'c')
2020 else if (
param[1][1] ==
's')
2022 else if (
param[1][1] ==
'x')
2024 else if (
param[1][1] ==
'j')
2026 else if (
param[1][1] ==
'z')
2036 if (
param[1][0] ==
'/') {
2045 char *buffer =
NULL;
2046 int buffer_size = 0;
2061 char *buffer =
NULL;
2062 int buffer_size = 0;
2081 if (
param[1][0] ==
'/') {
2090 char *buffer =
NULL;
2091 int buffer_size = 0;
2103 else if (
param[0][0] ==
'm' &&
param[0][1] ==
'a') {
2111 else if (
param[0][0] ==
'p' &&
param[0][1] ==
'a' &&
param[0][2] ==
's') {
2131 printf(
"Mismatch - password unchanged\n");
2135 printf(
"Wrong password\n");
2142 printf(
"Mismatch - password not set\n");
2150 "/Experiment/Security/Allowed hosts/host.sample.domain",
2160 else if (
param[0][0] ==
'w' &&
param[0][1] ==
'e' &&
param[0][2] ==
'b') {
2174 printf(
"Mismatch - password unchanged\n");
2178 printf(
"Wrong password\n");
2185 printf(
"Mismatch - password not set\n");
2194 else if (
param[0][0] ==
'h' &&
param[0][1] ==
'i') {
2206 printf(
"No client currently exports the CLEAR HISTO functionality.\n");
2213 size =
sizeof(client_name);
2231 strcpy(client_name,
param[1]);
2244 if (client_name[0]) {
2249 printf(
"Cannot connect to client %s\n", client_name);
2254 else if (
param[0][0] ==
'i' &&
param[0][1] ==
'm') {
2266 char *buf = (
char *)
malloc(size + 1);
2278 }
else if (buf[size - 1] != 0) {
2283 if (
param[2][0] == 0) {
2303 else if (
param[0][0] ==
'e' &&
param[0][1] ==
'x' &&
param[0][2] ==
'p') {
2306 if (
param[1][0] == 0)
2307 printf(
"please specify key\n");
2313 printf(
"Error: Key \"%s\" not found\n",
param[1]);
2315 if (
param[2][0] == 0) {
2327 printf(
"Only export of STRING key possible\n");
2343 else if (
param[0][0] ==
'a' &&
param[0][1] ==
'l') {
2356 printf(
"Alarm of class \"%s\" reset sucessfully\n",
key.
name);
2362 else if (
param[0][0] ==
'm' &&
param[0][1] ==
'e') {
2364 printf(
"This function works only locally\n");
2366#ifdef LOCAL_ROUTINES
2374 printf(
"This MIDAS only works remotely\n");
2380 else if (
param[0][0] ==
's' &&
param[0][1] ==
'o') {
2388 else if (
param[0][0] ==
's' &&
param[0][1] ==
'c') {
2392 "cannot find System/Clients entry in database");
2394 if (
param[1][1] ==
'w')
2395 printf(
"Name Host Timeout Last called\n");
2406 size =
sizeof(
name);
2419 if (
param[1][1] ==
'w') {
2433 else if (
param[0][0] ==
's' &&
param[0][1] ==
't' &&
param[0][2] ==
'a') {
2434 debug_flag = ((
param[1][0] ==
'-' &&
param[1][1] ==
'v') || (
param[2][0] ==
'-' &&
param[2][1] ==
'v') || (
param[3][0] ==
'-' &&
param[3][1] ==
'v'));
2442 printf(
"Run is already started\n");
2444 printf(
"Run is paused, please use \"resume\"\n");
2472 if (
str.find(
"Options ") == 0)
2522 if (line[0] &&
atoi(line) > 0)
2526 printf(
"Are the above parameters correct? ([y]/n/q): ");
2529 }
while (line[0] ==
'n' || line[0] ==
'N');
2532 if (line[0] !=
'q' && line[0] !=
'Q') {
2554 else if (
param[0][0] ==
's' &&
param[0][1] ==
't' &&
param[0][2] ==
'o') {
2555 debug_flag = ((
param[1][0] ==
'-' &&
param[1][1] ==
'v') || (
param[2][0] ==
'-' &&
param[2][1] ==
'v') || (
param[3][0] ==
'-' &&
param[3][1] ==
'v'));
2564 printf(
"Run is already stopped. Stop again? (y/[n]) ");
2568 if (
param[1][0] ==
'n')
2577 printf(
"Deferred stop already in progress, enter \"stop now\" to force stop\n");
2584 else if (
param[0][0] ==
'p' &&
param[0][1] ==
'a' &&
param[0][2] ==
'u') {
2585 debug_flag = ((
param[1][0] ==
'-' &&
param[1][1] ==
'v') || (
param[2][0] ==
'-' &&
param[2][1] ==
'v'));
2592 printf(
"Run is not started\n");
2594 if (
param[1][0] ==
'n')
2602 printf(
"Deferred pause already in progress, enter \"pause now\" to force pause\n");
2609 else if (
param[0][0] ==
'r' &&
param[0][1] ==
'e' &&
param[0][2] ==
's') {
2610 debug_flag = ((
param[1][0] ==
'-' &&
param[1][1] ==
'v') || (
param[2][0] ==
'-' &&
param[2][1] ==
'v'));
2617 printf(
"Run is not paused\n");
2626 else if (
param[0][0] ==
'm' &&
param[0][1] ==
's') {
2629 printf(
"Error: Not enough parameters. Please use\n\n");
2630 printf(
" msg <facility> <type> <name> <message>\n\n");
2631 printf(
"where <facility> can be \"midas\", \"chat\", ...\n");
2632 printf(
"and <type> must be \"error\", \"info\", \"debug\", \"user\", \"log\", \"talk\" or \"call\".\n");
2650 printf(
"Error: inavlid type \"%s\".\n",
param[2]);
2651 printf(
"<type> must be one of \"error\", \"info\", \"debug\", \"user\", \"log\", \"talk\", \"call\".\n");
2661 else if (
param[0][0] ==
'c' &&
param[0][1] ==
'h' &&
param[0][2] ==
'a') {
2669 printf(
"Exit chat mode with empty line.\n");
2685 else if (
param[0][0] ==
'o' &&
param[0][1] ==
'l') {
2696 else if (
param[0][0] ==
'c' &&
param[0][1] ==
'l') {
2701 if (
param[1][0] ==
'-' &&
param[1][1] ==
'f')
2703 if (
param[2][0] ==
'-' &&
param[2][1] ==
'f')
2716 else if (
param[0][0] ==
's' &&
param[0][1] ==
'h') {
2717 if (
param[1][0] == 0)
2718 printf(
"Please enter client name or \"all\" to shutdown all clients.\n");
2723 printf(
"No clients found\n");
2731 else if (
param[0][0] ==
'v' &&
param[0][1] ==
'e') {
2738 else if (
param[0][0] ==
'e' &&
param[0][1] ==
'x' &&
param[0][2] ==
'e') {
2745 printf(
"Key contains no command\n");
2759 else if (
param[0][0] ==
'w' &&
param[0][1] ==
'a' &&
param[0][2] ==
'i') {
2760 if (
param[1][0] == 0) {
2761 printf(
"Please specify key\n");
2773 printf(
"Waiting for key \"%s\" to be modified, abort with any key\n",
key.
name);
2775 char *buf = (
char *)
malloc(size);
2798 printf(
"Wait aborted.\n");
2800 printf(
"Key has been modified.\n");
2807 else if (
param[0][0] ==
'w' &&
param[0][1] ==
'a' &&
param[0][2] ==
't') {
2808 if (
param[1][0] == 0) {
2809 printf(
"Please specify key\n");
2817 printf(
"Watch key \"%s\" to be modified, abort with any key\n",
str);
2819 printf(
"Watch ODB tree \"%s\" to be modified, abort with any key\n",
str);
2841 else if (
param[0][0] ==
't' &&
param[0][1] ==
'1') {
2866 printf(
"%d accesses per second\n",
i / 5);
2870 else if (
param[0][0] ==
't' &&
param[0][1] ==
'2') {
2875 }
while (
i > 0 &&
i != 4);
2884 else if (
param[0][0] ==
't' &&
param[0][1] ==
'3') {
2885#ifdef USE_ADDRESS_SANITIZER
2887 int *a = (
int *)
malloc(
sizeof(
int) * 10);
2891 printf(
"test address sanitizer is disabled!\n");
2896 else if ((
param[0][0] ==
'e' &&
param[0][1] ==
'x' &&
param[0][2] ==
'i') || (
param[0][0] ==
'q'))
2899 else if (
param[0][0] == 0)
2947 char cmd[2000], dir[256];
2954 cmd[0] = dir[0] = 0;
2967 if (!
getenv(
"MIDASSYS")) {
2968 puts(
"Please define environment variable 'MIDASSYS'");
2969 puts(
"pointing to the midas source installation directory.");
2976 else if (
argv[
i][0] ==
'-' &&
argv[
i][1] ==
'q')
2978 else if (
argv[
i][0] ==
'-' &&
argv[
i][1] ==
'R')
2980 else if (
argv[
i][0] ==
'-' &&
argv[
i][1] ==
'C')
2982 else if (
argv[
i][0] ==
'-') {
2985 if (
argv[
i][1] ==
'e')
2987 else if (
argv[
i][1] ==
'h')
2989 else if (
argv[
i][1] ==
'c') {
2991 printf(
"error: command line too long (>%d bytes)\n", (
int)
sizeof(cmd));
2996 }
else if (
argv[
i][1] ==
'd')
2998 else if (
argv[
i][1] ==
's')
3002 printf(
"usage: odbedit [-h Hostname] [-e Experiment] [-d ODB Subtree]\n");
3003 printf(
" [-q] [-c Command] [-c @CommandFile] [-s size]\n");
3004 printf(
" [-g (debug)] [-C (connect to corrupted ODB)]\n");
3005 printf(
" [-R (reload ODB from .ODB.SHM)]\n\n");
3006 printf(
"For a list of valid commands start odbedit interactively\n");
3007 printf(
"and type \"help\".\n");
3016#ifdef LOCAL_ROUTINES
3019 printf(
"Cannot setup experiment name and path.\n");
3023 printf(
"MIDAS ODB shared memory was deleted, ss_shm_delete(ODB) status %d\n",
status);
3024 printf(
"Please run odbedit again without \'-R\' and ODB will be reloaded from .ODB.SHM\n");
3027 printf(
"This odbedit only works remotely, -R is not supported\n");
3050 printf(
"ODB is corrupted, connecting anyway...\n");
3083 cm_msg(
MINFO,
"odbedit",
"Execute command from command line: \"%s\"", cmd);
INT al_reset_alarm(const char *alarm_name)
INT bm_open_buffer(const char *buffer_name, INT buffer_size, INT *buffer_handle)
INT bm_close_buffer(INT buffer_handle)
INT cm_shutdown(const char *name, BOOL bUnique)
INT cm_yield(INT millisec)
INT cm_get_experiment_database(HNDLE *hDB, HNDLE *hKeyClient)
INT cm_connect_client(const char *client_name, HNDLE *hConn)
INT cm_transition(INT transition, INT run_number, char *errstr, INT errstr_size, INT async_flag, INT debug_flag)
INT cm_connect_experiment1(const char *host_name, const char *default_exp_name, const char *client_name, void(*func)(char *), INT odb_size, DWORD watchdog_timeout)
void cm_ack_ctrlc_pressed()
INT cm_execute(const char *command, char *result, INT bufsize)
INT cm_get_watchdog_info(HNDLE hDB, const char *client_name, DWORD *timeout, DWORD *last)
INT cm_cleanup(const char *client_name, BOOL ignore_timeout)
INT cm_disconnect_experiment(void)
int cm_set_experiment_local(const char *exp_name)
INT cm_get_environment(char *host_name, int host_name_size, char *exp_name, int exp_name_size)
const char * cm_get_version()
const char * cm_get_revision()
BOOL cm_is_ctrlc_pressed()
INT cm_set_watchdog_params(BOOL call_watchdog, DWORD timeout)
#define CM_DEFERRED_TRANSITION
#define CM_TRANSITION_IN_PROGRESS
#define CM_WRONG_PASSWORD
#define DB_INVALID_HANDLE
#define DB_NO_MORE_SUBKEYS
INT ss_shm_delete(const char *name)
INT ss_getchar(BOOL reset)
char * ss_getpass(const char *prompt)
std::string ss_tid_to_string(midas_thread_t thread_id)
midas_thread_t ss_gettid(void)
INT ss_sleep(INT millisec)
char * ss_crypt(const char *buf, const char *salt)
char * ss_gets(char *string, int size)
void * ss_ctrlc_handler(void(*func)(int))
INT cm_msg1(INT message_type, const char *filename, INT line, const char *facility, const char *routine, const char *format,...)
INT cm_msg_register(EVENT_HANDLER *func)
INT cm_msg_flush_buffer()
std::string cm_get_error(INT code)
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
INT cm_msg_retrieve(INT n_message, char *message, INT buf_size)
INT cm_set_msg_print(INT system_mask, INT user_mask, int(*func)(const char *))
BOOL equal_ustring(const char *str1, const char *str2)
INT db_sprintfh(char *string, const void *data, INT data_size, INT idx, DWORD type)
INT db_get_data_index(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, INT idx, DWORD type)
INT db_delete_key(HNDLE hDB, HNDLE hKey, BOOL follow_links)
INT db_find_link(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
INT db_get_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, void *data, INT *buf_size, DWORD type, BOOL create)
INT db_reorder_key(HNDLE hDB, HNDLE hKey, INT idx)
INT db_save_json(HNDLE hDB, HNDLE hKey, const char *filename, int flags)
INT db_open_record(HNDLE hDB, HNDLE hKey, void *ptr, INT rec_size, WORD access_mode, void(*dispatcher)(INT, INT, void *), void *info)
INT db_get_open_records(HNDLE hDB, HNDLE hKey, char *str, INT buf_size, BOOL fix)
INT db_show_mem(HNDLE hDB, char **result, BOOL verbose)
INT db_save_xml(HNDLE hDB, HNDLE hKey, const char *filename)
INT db_set_link_data(HNDLE hDB, HNDLE hKey, const void *data, INT buf_size, INT num_values, DWORD type)
INT db_get_path(HNDLE hDB, HNDLE hKey, char *path, INT buf_size)
INT db_copy(HNDLE hDB, HNDLE hKey, char *buffer, INT *buffer_size, const char *path)
INT db_set_link_data_index(HNDLE hDB, HNDLE hKey, const void *data, INT data_size, INT idx, DWORD type)
INT db_get_record_size(HNDLE hDB, HNDLE hKey, INT align, INT *buf_size)
INT db_get_data(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, DWORD type)
INT db_create_key(HNDLE hDB, HNDLE hKey, const char *key_name, DWORD type)
INT db_copy_json_save(HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
INT db_save_struct(HNDLE hDB, HNDLE hKey, const char *file_name, const char *struct_name, BOOL append)
INT db_unwatch(HNDLE hDB, HNDLE hKey)
INT db_set_mode(HNDLE hDB, HNDLE hKey, WORD mode, BOOL recurse)
INT db_save(HNDLE hDB, HNDLE hKey, const char *filename, BOOL bRemote)
INT db_scan_tree(HNDLE hDB, HNDLE hKey, INT level, INT(*callback)(HNDLE, HNDLE, KEY *, INT, void *), void *info)
INT db_get_key(HNDLE hDB, HNDLE hKey, KEY *key)
INT db_get_link(HNDLE hDB, HNDLE hKey, KEY *key)
INT db_load(HNDLE hDB, HNDLE hKeyRoot, const char *filename, BOOL bRemote)
INT EXPRT db_get_value_string(HNDLE hdb, HNDLE hKeyRoot, const char *key_name, int index, std::string *s, BOOL create, int create_string_length)
INT db_set_data_index(HNDLE hDB, HNDLE hKey, const void *data, INT data_size, INT idx, DWORD type)
INT db_find_keys(HNDLE hDB, HNDLE hKeyRoot, char *odbpath, std::vector< HNDLE > &hKeyVector)
INT db_save_string(HNDLE hDB, HNDLE hKey, const char *file_name, const char *string_name, BOOL append)
INT db_paste(HNDLE hDB, HNDLE hKeyRoot, const char *buffer)
INT db_watch(HNDLE hDB, HNDLE hKey, void(*dispatcher)(INT, INT, INT, void *), void *info)
INT db_set_data(HNDLE hDB, HNDLE hKey, const void *data, INT buf_size, INT num_values, DWORD type)
INT db_enum_link(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
INT db_copy_json_ls(HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
INT db_sprintf(char *string, const void *data, INT data_size, INT idx, DWORD type)
void strarrayindex(char *odbpath, int *index1, int *index2)
INT db_copy_json_values(HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end, int omit_names, int omit_last_written, time_t omit_old_timestamp, int preserve_case)
INT db_set_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, const void *data, INT data_size, INT num_values, DWORD type)
INT db_find_key(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
INT db_get_link_data(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, DWORD type)
INT db_rename_key(HNDLE hDB, HNDLE hKey, const char *name)
INT db_get_key_time(HNDLE hDB, HNDLE hKey, DWORD *delta)
INT db_enum_key(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
INT db_close_record(HNDLE hDB, HNDLE hKey)
INT db_sscanf(const char *data_str, void *data, INT *data_size, INT i, DWORD tid)
INT db_set_num_values(HNDLE hDB, HNDLE hKey, INT num_values)
INT db_create_link(HNDLE hDB, HNDLE hKey, const char *link_name, const char *destination)
INT rpc_client_call(HNDLE hConn, DWORD routine_id,...)
const char * rpc_tid_name(INT id)
#define RPC_ANA_CLEAR_HISTOS
char exp_name[NAME_LENGTH]
const char * analyzer_name
BOOL debug
debug printouts
char host_name[HOST_NAME_LENGTH]
std::string msprintf(const char *format,...)
#define DEFAULT_WATCHDOG_TIMEOUT
#define JSFLAG_FOLLOW_LINKS
#define JSFLAG_OMIT_LAST_WRITTEN
#define DEFAULT_BUFFER_SIZE
#define EVENT_BUFFER_NAME
#define message(type, str)
#define write(n, a, f, d)
INT cmd_edit(const char *prompt, char *cmd, INT(*dir)(char *, INT *), INT(*idle)())
void watch_callback(HNDLE hDB, HNDLE hKey, INT index, void *info)
void ctrlc_odbedit(INT i)
void compose_name(char *pwd, char *name, char *full_name)
int print_message(const char *msg)
BOOL check_abort(int flags, int l)
void set_key(HNDLE hDB, HNDLE hKey, int index1, int index2, char *value)
void print_help(char *command)
static void xwrite(const char *filename, int fd, const void *data, int size)
void del_tree(HNDLE hDB, HNDLE hKey, INT level)
INT cmd_dir(char *line, INT *cursor)
void assemble_prompt(char *prompt, int psize, char *host_name, char *exp_name, char *pwd)
INT search_key(HNDLE hDB, HNDLE hKey, KEY *key, INT level, void *info)
static void pad_to_pos(std::string *s, size_t pos)
void process_message(HNDLE hBuf, HNDLE id, EVENT_HEADER *pheader, void *message)
BOOL match(char *pat, char *str)
void create_experim_h(HNDLE hDB, const char *analyzer_name)
int command_loop(char *host_name, char *exp_name, char *cmd, char *start_dir)
void key_update(HNDLE hDB, HNDLE hkey, void *info)
INT print_key(HNDLE hDB, HNDLE hKey, KEY *pkey, INT level, void *info)
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)