1444 {
1446 char line[2000], prompt[256];
1447 char param[10][2000];
1448 char str[2000], str2[80],
name[256], *pc;
1449 char old_password[32], new_password[32];
1450 INT nparam, flags, index1, index2, debug_flag, mthread_flag;
1454 char user_name[80] = "";
1455 FILE *cmd_file = NULL;
1456 DWORD last_msg_time = 0;
1457 char message[2000], client_name[256], *p;
1460
1462
1463
1464 if (start_dir[0])
1465 strcpy(
pwd, start_dir);
1466 else
1468
1469
1471 printf(
"Directory \"%s\" not found.\n",
pwd);
1472 return -1;
1473 }
1474
1475
1476 if (cmd[0] == '@') {
1477 cmd_file = fopen(cmd + 1, "r");
1478 if (cmd_file == NULL) {
1479 printf("Command file %s not found.\n", cmd + 1);
1480 return -1;
1481 }
1482 }
1483
1484 do {
1485
1488
1490 line[0] = 0;
1493 } else if (cmd[0] != '@')
1494 mstrlcpy(line, cmd, sizeof(line));
1495 else {
1496 memset(line, 0, sizeof(line));
1497 char *s = fgets(line, sizeof(line), cmd_file);
1498
1499 if (s == NULL || line[0] == 0)
1500 break;
1501
1502
1503 while (strlen(line) > 0 && line[strlen(line) - 1] == '\n')
1504 line[strlen(line) - 1] = 0;
1505
1506 if (line[0] == 0)
1507 continue;
1508 }
1509
1510
1511 nparam = 0;
1512 pc = line;
1513 while (*pc == ' ')
1514 pc++;
1515
1517 do {
1518 if (*pc == '"') {
1519 pc++;
1520 for (
i = 0; *pc && *pc !=
'"' &&
i < (int)
sizeof(
param[0]) - 1;
i++)
1521 param[nparam][
i] = *pc++;
1522 if (*pc)
1523 pc++;
1524 } else if (*pc == '\'') {
1525 pc++;
1526 for (
i = 0; *pc && *pc !=
'\'' &&
i < (int)
sizeof(
param[0]) - 1;
i++)
1527 param[nparam][
i] = *pc++;
1528 if (*pc)
1529 pc++;
1530 } else if (*pc == '`') {
1531 pc++;
1532 for (
i = 0; *pc && *pc !=
'`' &&
i < (int)
sizeof(
param[0]) - 1;
i++)
1533 param[nparam][
i] = *pc++;
1534 if (*pc)
1535 pc++;
1536 } else
1537 for (
i = 0; *pc && *pc !=
' ' &&
i < (int)
sizeof(
param[0]) - 1;
i++)
1538 param[nparam][
i] = *pc++;
1540 while (*pc == ' ')
1541 pc++;
1542 nparam++;
1543 } while (*pc);
1544
1545
1548
1549
1550 else if ((
param[0][0] ==
'l' &&
param[0][1] ==
's') || (
param[0][0] ==
'd' &&
param[0][1] ==
'i')) {
1552 print_info.
flags = 0;
1556
1557
1558 for (
i = 1;
i < 4;
i++)
1559 if (
param[
i][0] ==
'-') {
1571 }
1572 }
1573
1574 for (
i = 1;
param[
i][0] ==
'-';
i++)
1575 ;
1576
1577
1578 print_info.
index = -1;
1580 for (p = strchr(
param[
i],
'[') + 1; *p && *p !=
']'; p++)
1581 if (!isdigit(*p))
1582 break;
1583
1584 if (*p && *p == ']') {
1585 print_info.
index = atoi(strchr(
param[
i],
'[') + 1);
1586 *strchr(
param[
i],
'[') = 0;
1587 }
1588 }
1589
1591 if (strpbrk(
param[
i],
"*?") != NULL) {
1592
1594 } else {
1597 else
1599
1601 printf(
"key %s not found\n",
param[
i]);
1602
1604 printf(
"link %s points to invalid location\n",
param[
i]);
1605 }
1606 }
1607
1610 printf("Key name Type #Val Size Last Opn Mode Value\n");
1611 printf("---------------------------------------------------------------------------\n");
1612 }
1613
1618 } else {
1622 else
1626 break;
1627 }
1628
1630
1632 break;
1633
1637 break;
1638 }
1639 }
1640 }
1641 }
1642
1643
1644 else if (
param[0][0] ==
'c' &&
param[0][1] ==
'd') {
1645 if (strlen(
param[1]) == 0)
1647 else
1649
1651
1652 if (strcmp(
str,
"/") == 0)
1657 printf("key has no subkeys\n");
1658 else {
1660 mstrlcpy(
pwd, path.c_str(),
sizeof(
pwd));
1661 }
1662 } else
1663 printf("key not found\n");
1664 }
1665
1666
1667 else if (
param[0][0] ==
'p' &&
param[0][1] ==
'w') {
1668 printf(
"%s\n",
pwd);
1669 }
1670
1671
1672 else if (
param[0][0] ==
'c' &&
param[0][1] ==
'r') {
1674
1675
1676
1679 if (
str[strlen(
str) - 1] ==
']') {
1680 if (strchr(
str,
'[')) {
1681 j = atoi(strchr(
str,
'[') + 1);
1682 mstrlcpy(str2, strchr(
str,
'[') + 1,
sizeof(str2));
1683 *strchr(
str,
'[') = 0;
1684 if (strchr(str2, '['))
1685 k = atoi(strchr(str2,
'[') + 1);
1686 }
1687 } else
1689
1690
1693 break;
1694 }
1695
1697 printf("Unknown type. Must be one of:\n");
1698 printf("{ UINT8,INT8,UINT16,INT16,UINT32,INT32,UINT64,INT64,BOOL,FLOAT,DOUBLE,STRING }\n");
1699 } else {
1703
1710 else
1714 else
1716
1720 free(buf);
1721 }
1722
1729 free(buf);
1730 }
1731 }
1732 }
1733
1734
1735 else if (
param[0][0] ==
'm' &&
param[0][1] ==
'k') {
1738 }
1739
1740
1741 else if (
param[0][0] ==
'l' &&
param[0][1] ==
'n') {
1744 }
1745
1746
1747 else if (
param[0][0] ==
'c' && (
param[0][1] ==
'o' ||
param[0][1] ==
'p')) {
1748
1754 else {
1755 printf(
"Overwrite existing key\n\"%s\"\n(y/[n]) ",
str);
1757 }
1760 }
1761
1764
1768
1771
1779 free(buf);
1780 } else {
1782 size =
sizeof(
data);
1785 printf(
"error: db_copy() status %d, odbedit internal buffer is too small, size %d\n",
status, size);
1787 printf(
"error: db_copy() status %d\n",
status);
1788 } else {
1791 }
1792 }
1793 } else {
1794 printf("key not found\n");
1795 }
1796 }
1797 }
1798
1799
1800 else if ((
param[0][0] ==
'd' &&
param[0][1] ==
'e') || (
param[0][0] ==
'r' &&
param[0][1] ==
'm')) {
1801 flags = 0;
1803 flags |= (1 << 0);
1804
1805 for (
i = 1;
param[
i][0] ==
'-';
i++)
1806 ;
1807
1809
1812
1816 else {
1818 printf("Are you sure to delete the key\n\"%s\"\nand all its subkeys? (y/[n]) ",
1820 else
1821 printf(
"Are you sure to delete the key\n\"%s\"\n(y/[n]) ",
str);
1822
1824 }
1825
1826 if (
str[0] ==
'y') {
1829 printf("deletion of key not allowed\n");
1831 printf("key is open by other client\n");
1833 printf(
"Error, db_delete_key() status %d\n",
status);
1834 }
1835 }
1836 } else
1837 printf("key not found\n");
1838 }
1839
1840
1841 else if (
param[0][0] ==
's' &&
param[0][1] ==
'e') {
1842
1843 index1 = index2 = 0;
1847
1848 std::vector<HNDLE> keys;
1850
1852 printf(
"Error: Key \"%s\" not found\n",
name);
1854 return -1;
1855 } else {
1856 for (
HNDLE hMatchedKey : keys) {
1858 }
1859 }
1860 }
1861
1862
1863 else if (
param[0][0] ==
'c' &&
param[0][1] ==
'h' &&
param[0][2] ==
'm') {
1865 printf("Please specify mode and key\n");
1866 } else {
1868
1869 mode = atoi(
param[1]);
1870
1871 if (strcmp(
str,
"/") != 0) {
1873 } else {
1876 }
1877
1881 else {
1882 printf("Are you sure to change the mode of key\n %s\nand all its subkeys\n",
1884 printf(
"to mode [%c%c%c%c]? (y/[n]) ", mode &
MODE_READ ?
'R' : 0,
1888 }
1891 } else {
1892 printf(
"Error: Key \"%s\" not found\n",
str);
1894 return -1;
1895 }
1896 }
1897 }
1898
1899
1900 else if (strcmp(
param[0],
"test_rpc") == 0) {
1903 printf("RPC test passed!\n");
1904 else
1905 printf("RPC test failed!\n");
1906 }
1907
1908
1909 else if (
param[0][0] ==
't' &&
param[0][1] ==
'r') {
1910 if (
param[1][0] == 0) {
1911 printf("Please specify key\n");
1912 } else {
1914
1916
1920
1923 else {
1924 printf(
"Error: Key \"%s\" not found\n",
str);
1926 return -1;
1927 }
1928 }
1929 }
1930
1931
1932 else if (
param[0][0] ==
'r' &&
param[0][1] ==
'e' &&
param[0][2] ==
'n') {
1933 if (
param[1][0] == 0) {
1934 printf("Please specify key\n");
1935 } else {
1937
1938 if (strcmp(
str,
"/") != 0)
1940 else
1942
1945 else {
1946 printf(
"Error: Key \"%s\" not found\n",
str);
1948 return -1;
1949 }
1950 }
1951 }
1952
1953
1954 else if (
param[0][0] ==
'm' &&
param[0][1] ==
'o') {
1955 if (
param[1][0] == 0) {
1956 printf("Please specify key\n");
1957 } else {
1959
1960 if (strcmp(
str,
"/") != 0)
1962 else
1964
1966 if (
param[2][0] ==
't')
1968 else if (
param[2][0] ==
'b')
1970 else
1972
1975 printf("no write access to key\n");
1977 printf("key is open by other client\n");
1978 } else {
1979 printf(
"Error: Key \"%s\" not found\n",
str);
1981 return -1;
1982 }
1983 }
1984 }
1985
1986
1987 else if (
param[0][0] ==
'f' &&
param[0][1] ==
'i') {
1989
1992 else
1993 printf("current key is invalid / no read access\n");
1994 }
1995
1996
1997 else if (
param[0][0] ==
'l' &&
param[0][1] ==
'o') {
1999
2001 }
2002
2003
2004 else if (
param[0][0] ==
's' &&
param[0][1] ==
'a') {
2006
2007 if (strstr(
param[1],
".xml") || strstr(
param[1],
".XML"))
2009 else if (strstr(
param[1],
".json") || strstr(
param[1],
".js"))
2011 else if (
param[1][0] ==
'-') {
2012 if (
param[1][1] ==
'c' &&
param[1][2] ==
's') {
2015 }
else if (
param[1][1] ==
'c')
2017 else if (
param[1][1] ==
's')
2019 else if (
param[1][1] ==
'x')
2021 else if (
param[1][1] ==
'j')
2023 else if (
param[1][1] ==
'z')
2026 } else
2028 }
2029
2030
2031 else if (strncmp(
param[0],
"json", 8) == 0) {
2032
2033 if (
param[1][0] ==
'/') {
2035 }
else if (strlen(
param[1]) > 0) {
2038 } else {
2040 }
2041
2042 char *buffer = NULL;
2043 int buffer_size = 0;
2044 int buffer_end = 0;
2045
2047
2048 printf(
"status: %d, json: %s\n",
status, buffer);
2049
2050 if (buffer)
2051 free(buffer);
2052 }
2053
2054
2055 else if (strncmp(
param[0],
"jsvalues", 8) == 0) {
2057
2058 char *buffer = NULL;
2059 int buffer_size = 0;
2060 int buffer_end = 0;
2061
2062 int omit_names = 0;
2063 int omit_last_written = 0;
2064 time_t omit_old_timestamp = 0;
2065 int preserve_case = 0;
2066
2068
2069 printf(
"status: %d, json: %s\n",
status, buffer);
2070
2071 if (buffer)
2072 free(buffer);
2073 }
2074
2075
2076 else if (strncmp(
param[0],
"jsls", 4) == 0) {
2077
2078 if (
param[1][0] ==
'/') {
2080 }
else if (strlen(
param[1]) > 0) {
2083 } else {
2085 }
2086
2087 char *buffer = NULL;
2088 int buffer_size = 0;
2089 int buffer_end = 0;
2090
2092
2093 printf(
"jsls \"%s\", status: %d, json: %s\n",
pwd,
status, buffer);
2094
2095 if (buffer)
2096 free(buffer);
2097 }
2098
2099
2100 else if (
param[0][0] ==
'm' &&
param[0][1] ==
'a') {
2103 else
2105 }
2106
2107
2108 else if (
param[0][0] ==
'p' &&
param[0][1] ==
'a' &&
param[0][2] ==
's') {
2109
2110
2111
2112
2113
2114
2116 size = sizeof(old_password);
2118
2121
2122 if (strcmp(
str, old_password) == 0 || strcmp(
str,
"mid7qBxsNMHux") == 0) {
2125
2127 if (strcmp(new_password,
ss_crypt(
str,
"mi")) != 0)
2128 printf("Mismatch - password unchanged\n");
2129 else
2131 } else
2132 printf("Wrong password\n");
2133 } else {
2136
2138 if (strcmp(new_password,
ss_crypt(
str,
"mi")) != 0)
2139 printf("Mismatch - password not set\n");
2140 else {
2141
2142 db_set_value(
hDB, 0,
"/Experiment/Security/Password", new_password, 32, 1,
2144
2145
2147 "/Experiment/Security/Allowed hosts/host.sample.domain",
2151 }
2152 }
2153
2154 }
2155
2156
2157 else if (
param[0][0] ==
'w' &&
param[0][1] ==
'e' &&
param[0][2] ==
'b') {
2159 size = sizeof(old_password);
2161
2164
2165 if (strcmp(
str, old_password) == 0 || strcmp(
str,
"mid7qBxsNMHux") == 0) {
2168
2170 if (strcmp(new_password,
ss_crypt(
str,
"mi")) != 0)
2171 printf("Mismatch - password unchanged\n");
2172 else
2174 } else
2175 printf("Wrong password\n");
2176 } else {
2179
2181 if (strcmp(new_password,
ss_crypt(
str,
"mi")) != 0)
2182 printf("Mismatch - password not set\n");
2183 else
2184
2185 db_set_value(
hDB, 0,
"/Experiment/Security/Web Password", new_password, 32,
2187 }
2188 }
2189
2190
2191 else if (
param[0][0] ==
'h' &&
param[0][1] ==
'i') {
2193
2194 client_name[0] = 0;
2195
2196 if (!isalpha(
param[1][0])) {
2197
2203 printf("No client currently exports the CLEAR HISTO functionality.\n");
2204 break;
2205 }
2206
2210 size = sizeof(client_name);
2213 break;
2214 }
2215 }
2216 }
2217
2218 if (isdigit(
param[1][0]))
2219 n1 = atoi(
param[1]);
2220 else
2221 n1 = 0;
2222
2223 if (isdigit(
param[2][0]))
2224 n2 = atoi(
param[2]);
2225 else
2226 n2 = n1;
2227 } else {
2228 strcpy(client_name,
param[1]);
2229
2230 if (isdigit(
param[2][0]))
2231 n1 = atoi(
param[2]);
2232 else
2233 n1 = 0;
2234
2235 if (isdigit(
param[3][0]))
2236 n2 = atoi(
param[3]);
2237 else
2238 n2 = n1;
2239 }
2240
2241 if (client_name[0]) {
2244
2245 } else
2246 printf("Cannot connect to client %s\n", client_name);
2247 }
2248 }
2249
2250
2251 else if (
param[0][0] ==
'i' &&
param[0][1] ==
'm') {
2253 if (fh < 0) {
2254 printf(
"Could not open file \"%s\", errno %d (%s)\n",
param[1], errno, strerror(errno));
2255 } else {
2256 off_t off = lseek(fh, 0, SEEK_END);
2257 if (off < 0) {
2258 printf(
"Could not get size of file \"%s\", lseek(SEEK_END) errno %d (%s)\n",
param[1], errno, strerror(errno));
2259 close(fh);
2260 } else {
2261 lseek(fh, 0, SEEK_SET);
2262 size_t size = off;
2263 char *buf = (char *) malloc(size + 1);
2264 ssize_t rd =
read(fh, buf, size);
2265 if (rd < 0) {
2266 printf(
"Could not read file \"%s\", read(%zu) errno %d (%s)\n",
param[1], size, errno, strerror(errno));
2267 close(fh);
2268 free(buf);
2269 } else {
2270 close(fh);
2271 size = rd;
2272 if (size == 0) {
2273 buf[size] = 0;
2274 size++;
2275 } else if (buf[size - 1] != 0) {
2276 buf[size] = 0;
2277 size++;
2278 }
2279
2280 if (
param[2][0] == 0) {
2281 printf("Key name: ");
2283 } else {
2285 }
2286
2288
2292 free(buf);
2293 }
2294 }
2295 }
2296
2297 }
2298
2299
2300 else if (
param[0][0] ==
'e' &&
param[0][1] ==
'x' &&
param[0][2] ==
'p') {
2301 FILE *f;
2302
2303 if (
param[1][0] == 0)
2304 printf("please specify key\n");
2305 else {
2307
2310 printf(
"Error: Key \"%s\" not found\n",
param[1]);
2311 else {
2312 if (
param[2][0] == 0) {
2313 printf("File name: ");
2315 } else
2317
2318 f = fopen(
name,
"w");
2319 if (f == NULL)
2320 printf(
"Cannot open file \"%s\"\n",
name);
2321 else {
2324 printf("Only export of STRING key possible\n");
2325 else {
2328 memset(buf, 0, size);
2330 fprintf(f, "%s", buf);
2331 fclose(f);
2332 free(buf);
2333 }
2334 }
2335 }
2336 }
2337 }
2338
2339
2340 else if (
param[0][0] ==
'a' &&
param[0][1] ==
'l') {
2341
2346
2348 break;
2349
2353 printf(
"Alarm of class \"%s\" reset sucessfully\n",
key.
name);
2354 }
2355 }
2356 }
2357
2358
2359 else if (
param[0][0] ==
'm' &&
param[0][1] ==
'e') {
2361 printf("This function works only locally\n");
2362 else {
2363#ifdef LOCAL_ROUTINES
2365 puts(buf.c_str());
2366#else
2367 printf("This MIDAS only works remotely\n");
2368#endif
2369 }
2370 }
2371
2372
2373 else if (
param[0][0] ==
's' &&
param[0][1] ==
'o') {
2378 }
2379
2380
2381 else if (
param[0][0] ==
's' &&
param[0][1] ==
'c') {
2385 "cannot find System/Clients entry in database");
2386 else {
2387 if (
param[1][1] ==
'w')
2388 printf("Name Host Timeout Last called\n");
2389 else
2390 printf("Name Host\n");
2391
2392
2396 break;
2397
2399 size =
sizeof(
name);
2402 for (
int j = 0;
j < 20 - (int) strlen(
name);
j++)
2403 printf(" ");
2404
2408 for (
int j = 0;
j < 20 - (int) strlen(
str);
j++)
2409 printf(" ");
2410
2411
2412 if (
param[1][1] ==
'w') {
2413 DWORD timeout, last;
2414
2416 printf("%-10d %-10d", timeout, last);
2417 }
2418
2419 printf("\n");
2420 }
2421 }
2422 }
2423 }
2424
2425
2426 else if (
param[0][0] ==
's' &&
param[0][1] ==
't' &&
param[0][2] ==
'a') {
2427 debug_flag = ((
param[1][0] ==
'-' &&
param[1][1] ==
'v') || (
param[2][0] ==
'-' &&
param[2][1] ==
'v') || (
param[3][0] ==
'-' &&
param[3][1] ==
'v'));
2428 mthread_flag = ((
param[1][0] ==
'-' &&
param[1][1] ==
'm') || (
param[2][0] ==
'-' &&
param[2][1] ==
'm') || (
param[3][0] ==
'-' &&
param[3][1] ==
'm'));
2429
2430
2435 printf("Run is already started\n");
2437 printf("Run is paused, please use \"resume\"\n");
2438 } else {
2439
2440 old_run_number = 0;
2443 assert(old_run_number >= 0);
2444
2445
2447 new_run_number = old_run_number + 1;
2448 line[0] = 'y';
2449 } else {
2451 do {
2455
2457 break;
2458
2461
2463 continue;
2464
2465 if (
str.find(
"Options ") == 0)
2466 continue;
2467
2470
2473
2477 free(buf);
2478 continue;
2479 }
2480
2483 std::string xprompt;
2486 xprompt += " : ";
2487 } else {
2489 }
2490
2491 strcpy(line, xdata_str.c_str());
2495
2496 if (line[0]) {
2499 }
2500 }
2501
2502 free(buf);
2503 }
2504 }
2505
2506
2507 new_run_number = old_run_number + 1;
2508
2510 printf("Run number: %d\n", new_run_number);
2511 } else {
2512
2513 printf("Run number [%d]: ", new_run_number);
2515 if (line[0] && atoi(line) > 0)
2516 new_run_number = atoi(line);
2517 }
2518
2519 printf("Are the above parameters correct? ([y]/n/q): ");
2521
2522 } while (line[0] == 'n' || line[0] == 'N');
2523 }
2524
2525 if (line[0] != 'q' && line[0] != 'Q') {
2526
2527 printf("Starting run #%d\n", new_run_number);
2528
2529 assert(new_run_number > 0);
2530
2534
2537 sizeof(old_run_number), 1,
TID_INT);
2539
2540 printf(
"Error: %s\n",
str);
2541 }
2542 }
2543 }
2544 }
2545
2546
2547 else if (
param[0][0] ==
's' &&
param[0][1] ==
't' &&
param[0][2] ==
'o') {
2548 debug_flag = ((
param[1][0] ==
'-' &&
param[1][1] ==
'v') || (
param[2][0] ==
'-' &&
param[2][1] ==
'v') || (
param[3][0] ==
'-' &&
param[3][1] ==
'v'));
2549 mthread_flag = ((
param[1][0] ==
'-' &&
param[1][1] ==
'm') || (
param[2][0] ==
'-' &&
param[2][1] ==
'm') || (
param[3][0] ==
'-' &&
param[3][1] ==
'm'));
2550
2551
2557 printf("Run is already stopped. Stop again? (y/[n]) ");
2559 }
2561 if (
param[1][0] ==
'n')
2564 else
2566
2568 printf(
"%s\n",
str);
2570 printf("Deferred stop already in progress, enter \"stop now\" to force stop\n");
2572 printf(
"Error: %s\n",
str);
2573 }
2574 }
2575
2576
2577 else if (
param[0][0] ==
'p' &&
param[0][1] ==
'a' &&
param[0][2] ==
'u') {
2578 debug_flag = ((
param[1][0] ==
'-' &&
param[1][1] ==
'v') || (
param[2][0] ==
'-' &&
param[2][1] ==
'v'));
2579
2580
2585 printf("Run is not started\n");
2586 } else {
2587 if (
param[1][0] ==
'n')
2589 else
2591
2593 printf(
"%s\n",
str);
2595 printf("Deferred pause already in progress, enter \"pause now\" to force pause\n");
2597 printf(
"Error: %s\n",
str);
2598 }
2599 }
2600
2601
2602 else if (
param[0][0] ==
'r' &&
param[0][1] ==
'e' &&
param[0][2] ==
's') {
2603 debug_flag = ((
param[1][0] ==
'-' &&
param[1][1] ==
'v') || (
param[2][0] ==
'-' &&
param[2][1] ==
'v'));
2604
2605
2610 printf("Run is not paused\n");
2611 } else {
2614 printf(
"Error: %s\n",
str);
2615 }
2616 }
2617
2618
2619 else if (
param[0][0] ==
'm' &&
param[0][1] ==
's') {
2620
2622 printf("Error: Not enough parameters. Please use\n\n");
2623 printf(" msg <facility> <type> <name> <message>\n\n");
2624 printf("where <facility> can be \"midas\", \"chat\", ...\n");
2625 printf("and <type> must be \"error\", \"info\", \"debug\", \"user\", \"log\", \"talk\" or \"call\".\n");
2626 } else {
2643 printf(
"Error: inavlid type \"%s\".\n",
param[2]);
2644 printf("<type> must be one of \"error\", \"info\", \"debug\", \"user\", \"log\", \"talk\", \"call\".\n");
2645 } else {
2646
2649 }
2650 }
2651 }
2652
2653
2654 else if (
param[0][0] ==
'c' &&
param[0][1] ==
'h' &&
param[0][2] ==
'a') {
2656
2657 if (
ss_time() - last_msg_time > 300) {
2658 printf("Your name> ");
2660 }
2661
2662 printf("Exit chat mode with empty line.\n");
2663 do {
2668
2671
2673
2675 }
2676
2677
2678 else if (
param[0][0] ==
'o' &&
param[0][1] ==
'l') {
2682
2685 printf(
"%s\n\n",
data);
2686 }
2687
2688
2689 else if (
param[0][0] ==
'c' &&
param[0][1] ==
'l') {
2692
2694 if (
param[1][0] ==
'-' &&
param[1][1] ==
'f')
2696 if (
param[2][0] ==
'-' &&
param[2][1] ==
'f')
2698
2700
2703 else
2706 }
2707
2708
2709 else if (
param[0][0] ==
's' &&
param[0][1] ==
'h') {
2710 if (
param[1][0] == 0)
2711 printf("Please enter client name or \"all\" to shutdown all clients.\n");
2712 else {
2715 if (strcmp(
param[1],
"all") == 0)
2716 printf("No clients found\n");
2717 else
2718 printf(
"Client \"%s\" not active\n",
param[1]);
2719 }
2720 }
2721 }
2722
2723
2724 else if (
param[0][0] ==
'v' &&
param[0][1] ==
'e') {
2728 }
2729
2730
2731 else if (
param[0][0] ==
'e' &&
param[0][1] ==
'x' &&
param[0][2] ==
'e') {
2738 printf("Key contains no command\n");
2739 continue;
2740 }
2743
2745 } else {
2747 }
2749 }
2750
2751
2752 else if (
param[0][0] ==
'w' &&
param[0][1] ==
'a' &&
param[0][2] ==
'i') {
2753 if (
param[1][0] == 0) {
2754 printf("Please specify key\n");
2755 } else {
2757
2761 } else
2763
2766 printf(
"Waiting for key \"%s\" to be modified, abort with any key\n",
key.
name);
2768 char *buf = (char *) malloc(size);
2771
2772 do {
2775 break;
2777
2780
2782 if (buf) {
2783 free(buf);
2784 buf = NULL;
2785 }
2786
2788 break;
2789
2791 printf("Wait aborted.\n");
2792 else
2793 printf("Key has been modified.\n");
2794 } else
2795 printf(
"key \"%s\" not found\n",
str);
2796 }
2797 }
2798
2799
2800 else if (
param[0][0] ==
'w' &&
param[0][1] ==
'a' &&
param[0][2] ==
't') {
2801 if (
param[1][0] == 0) {
2802 printf("Please specify key\n");
2803 } else {
2805
2810 printf(
"Watch key \"%s\" to be modified, abort with any key\n",
str);
2811 else
2812 printf(
"Watch ODB tree \"%s\" to be modified, abort with any key\n",
str);
2814
2815 do {
2818 break;
2820
2823
2825
2827 break;
2828 } else
2829 printf(
"key \"%s\" not found\n",
str);
2830 }
2831 }
2832
2833
2834 else if (
param[0][0] ==
't' &&
param[0][1] ==
'1') {
2838
2843
2845 do {
2858
2859 printf(
"%d accesses per second\n",
i / 5);
2860 }
2861
2862
2863 else if (
param[0][0] ==
't' &&
param[0][1] ==
'2') {
2864 do {
2865 do {
2868 }
while (
i > 0 &&
i != 4);
2869
2872
2874 }
2875
2876
2877 else if (
param[0][0] ==
't' &&
param[0][1] ==
'3') {
2878#ifdef USE_ADDRESS_SANITIZER
2879
2880 int *a = (int *) malloc(sizeof(int) * 10);
2882 free(a);
2883#else
2884 printf("test address sanitizer is disabled!\n");
2885#endif
2886 }
2887
2888
2889 else if ((
param[0][0] ==
'e' &&
param[0][1] ==
'x' &&
param[0][2] ==
'i') || (
param[0][0] ==
'q'))
2890 break;
2891
2892 else if (
param[0][0] == 0)
2893 ;
2894
2895 else
2897
2898
2900 break;
2901
2902
2905 break;
2906
2908
2909
2911
2912 return 1;
2913}
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_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)
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)
const char * cm_get_version()
const char * cm_get_revision()
#define CM_DEFERRED_TRANSITION
#define CM_TRANSITION_IN_PROGRESS
#define DB_NO_MORE_SUBKEYS
char * ss_getpass(const char *prompt)
INT ss_sleep(INT millisec)
char * ss_crypt(const char *buf, const char *salt)
INT cm_msg1(INT message_type, const char *filename, INT line, const char *facility, const char *routine, const char *format,...)
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 db_delete_key(HNDLE hDB, HNDLE hKey, BOOL follow_links)
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_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)
std::string db_show_mem(HNDLE hDB, BOOL verbose)
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_load(HNDLE hDB, HNDLE hKeyRoot, const char *filename, BOOL bRemote)
INT db_set_data_index(HNDLE hDB, HNDLE hKey, const void *data, INT data_size, INT idx, DWORD type)
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_copy_json_ls(HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
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_rename_key(HNDLE hDB, HNDLE hKey, const char *name)
INT db_find_keys(HNDLE hDB, HNDLE hKeyRoot, const char *odbpath, std::vector< HNDLE > &hKeyVector)
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
std::string msprintf(const char *format,...)
#define JSFLAG_FOLLOW_LINKS
#define JSFLAG_OMIT_LAST_WRITTEN
#define DEFAULT_BUFFER_SIZE
#define EVENT_BUFFER_NAME
#define message(type, str)
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 compose_name(char *pwd, char *name, char *full_name)
void set_key(HNDLE hDB, HNDLE hKey, int index1, int index2, char *value)
void print_help(char *command)
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)
void create_experim_h(HNDLE hDB, const char *analyzer_name)
void key_update(HNDLE hDB, HNDLE hkey, void *info)
INT print_key(HNDLE hDB, HNDLE hKey, KEY *pkey, INT level, void *info)