corosync-objctl.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. /*
  2. * Copyright (c) 2008 Allied Telesis Labs NZ
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Angus Salkeld <angus.salkeld@alliedtelesis.co.nz>
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include <config.h>
  35. #include <sys/select.h>
  36. #include <stdio.h>
  37. #include <stdlib.h>
  38. #include <errno.h>
  39. #include <unistd.h>
  40. #include <string.h>
  41. #include <ctype.h>
  42. #include <sys/types.h>
  43. #include <sys/un.h>
  44. #include <corosync/corotypes.h>
  45. #include <corosync/confdb.h>
  46. #define SEPERATOR '.'
  47. #define SEPERATOR_STR "."
  48. #define OBJ_NAME_SIZE 512
  49. typedef enum {
  50. ACTION_READ,
  51. ACTION_WRITE,
  52. ACTION_CREATE,
  53. ACTION_DELETE,
  54. ACTION_PRINT_ALL,
  55. ACTION_PRINT_DEFAULT,
  56. ACTION_TRACK,
  57. } action_types_t;
  58. typedef enum {
  59. FIND_OBJECT_ONLY,
  60. FIND_OBJECT_OR_KEY,
  61. FIND_KEY_ONLY
  62. } find_object_of_type_t;
  63. static void tail_key_changed(confdb_handle_t handle,
  64. confdb_change_type_t change_type,
  65. hdb_handle_t parent_object_handle,
  66. hdb_handle_t object_handle,
  67. const void *object_name,
  68. size_t object_name_len,
  69. const void *key_name,
  70. size_t key_name_len,
  71. const void *key_value,
  72. size_t key_value_len);
  73. static void tail_object_created(confdb_handle_t handle,
  74. hdb_handle_t parent_object_handle,
  75. hdb_handle_t object_handle,
  76. const void *name_pt,
  77. size_t name_len);
  78. static void tail_object_deleted(confdb_handle_t handle,
  79. hdb_handle_t parent_object_handle,
  80. const void *name_pt,
  81. size_t name_len);
  82. static confdb_callbacks_t callbacks = {
  83. .confdb_key_change_notify_fn = tail_key_changed,
  84. .confdb_object_create_change_notify_fn = tail_object_created,
  85. .confdb_object_delete_change_notify_fn = tail_object_deleted,
  86. };
  87. static int action;
  88. /* Recursively dump the object tree */
  89. static void print_config_tree(confdb_handle_t handle, hdb_handle_t parent_object_handle, char * parent_name)
  90. {
  91. hdb_handle_t object_handle;
  92. char object_name[OBJ_NAME_SIZE];
  93. size_t object_name_len;
  94. char key_name[OBJ_NAME_SIZE];
  95. size_t key_name_len;
  96. char key_value[OBJ_NAME_SIZE];
  97. size_t key_value_len;
  98. cs_error_t res;
  99. int children_printed;
  100. /* Show the keys */
  101. res = confdb_key_iter_start(handle, parent_object_handle);
  102. if (res != CS_OK) {
  103. fprintf(stderr, "error resetting key iterator for object "HDB_X_FORMAT" %d\n", parent_object_handle, res);
  104. exit(EXIT_FAILURE);
  105. }
  106. children_printed = 0;
  107. while ( (res = confdb_key_iter(handle,
  108. parent_object_handle,
  109. key_name,
  110. &key_name_len,
  111. key_value,
  112. &key_value_len)) == CS_OK) {
  113. key_name[key_name_len] = '\0';
  114. key_value[key_value_len] = '\0';
  115. if (parent_name != NULL)
  116. printf("%s%c%s=%s\n", parent_name, SEPERATOR,key_name, key_value);
  117. else
  118. printf("%s=%s\n", key_name, key_value);
  119. children_printed++;
  120. }
  121. /* Show sub-objects */
  122. res = confdb_object_iter_start(handle, parent_object_handle);
  123. if (res != CS_OK) {
  124. fprintf(stderr, "error resetting object iterator for object "HDB_X_FORMAT" %d\n", parent_object_handle, res);
  125. exit(EXIT_FAILURE);
  126. }
  127. while ( (res = confdb_object_iter(handle,
  128. parent_object_handle,
  129. &object_handle,
  130. object_name,
  131. &object_name_len)) == CS_OK) {
  132. object_name[object_name_len] = '\0';
  133. if (parent_name != NULL) {
  134. snprintf(key_value, OBJ_NAME_SIZE, "%s%c%s", parent_name, SEPERATOR, object_name);
  135. } else {
  136. if ((action == ACTION_PRINT_DEFAULT) && strcmp(object_name, "internal_configuration") == 0) continue;
  137. snprintf(key_value, OBJ_NAME_SIZE, "%s", object_name);
  138. }
  139. print_config_tree(handle, object_handle, key_value);
  140. children_printed++;
  141. }
  142. if (children_printed == 0 && parent_name != NULL) {
  143. printf("%s\n", parent_name);
  144. }
  145. }
  146. static int print_all(void)
  147. {
  148. confdb_handle_t handle;
  149. int result;
  150. result = confdb_initialize (&handle, &callbacks);
  151. if (result != CS_OK) {
  152. fprintf (stderr, "Could not initialize objdb library. Error %d\n", result);
  153. return 1;
  154. }
  155. print_config_tree(handle, OBJECT_PARENT_HANDLE, NULL);
  156. result = confdb_finalize (handle);
  157. return 0;
  158. }
  159. static int print_help(void)
  160. {
  161. printf("\n");
  162. printf ("usage: corosync-objctl object%ckey ... Print an object\n", SEPERATOR);
  163. printf (" corosync-objctl -c object%cchild_obj ... Create Object\n", SEPERATOR);
  164. printf (" corosync-objctl -d object%cchild_obj ... Delete object\n", SEPERATOR);
  165. printf (" corosync-objctl -w object%cchild_obj.key=value ... Create a key\n", SEPERATOR);
  166. printf (" corosync-objctl -t object%cchild_obj ... Track changes\n", SEPERATOR);
  167. printf (" corosync-objctl -a Print all objects\n");
  168. printf("\n");
  169. return 0;
  170. }
  171. static cs_error_t validate_name(char * obj_name_pt)
  172. {
  173. if ((strchr (obj_name_pt, SEPERATOR) == NULL) &&
  174. (strchr (obj_name_pt, '=') == NULL))
  175. return CS_OK;
  176. else
  177. return CS_ERR_INVALID_PARAM;
  178. }
  179. static void get_parent_name(const char * name_pt, char * parent_name)
  180. {
  181. char * tmp;
  182. strcpy(parent_name, name_pt);
  183. /* first remove the value (it could be a file path */
  184. tmp = strchr(parent_name, '=');
  185. if (tmp != NULL) *tmp = '\0';
  186. /* then truncate the child name */
  187. tmp = strrchr(parent_name, SEPERATOR);
  188. if (tmp != NULL) *tmp = '\0';
  189. }
  190. static void get_key(const char * name_pt, char * key_name, char * key_value)
  191. {
  192. char * tmp;
  193. char str_copy[OBJ_NAME_SIZE];
  194. strcpy(str_copy, name_pt);
  195. /* first remove the value (it could have a SEPERATOR in it */
  196. tmp = strchr(str_copy, '=');
  197. if (tmp != NULL && strlen(tmp) > 0) {
  198. strcpy(key_value, tmp+1);
  199. *tmp = '\0';
  200. } else {
  201. key_value[0] = '\0';
  202. }
  203. /* then remove the name */
  204. tmp = strrchr(str_copy, SEPERATOR);
  205. if (tmp == NULL) tmp = str_copy;
  206. strcpy(key_name, tmp+1);
  207. }
  208. static cs_error_t find_object (confdb_handle_t handle,
  209. char * name_pt,
  210. find_object_of_type_t type,
  211. hdb_handle_t * out_handle)
  212. {
  213. char * obj_name_pt;
  214. char * save_pt;
  215. hdb_handle_t obj_handle;
  216. confdb_handle_t parent_object_handle = OBJECT_PARENT_HANDLE;
  217. char tmp_name[OBJ_NAME_SIZE];
  218. cs_error_t res = CS_OK;
  219. strncpy (tmp_name, name_pt, OBJ_NAME_SIZE);
  220. obj_name_pt = strtok_r(tmp_name, SEPERATOR_STR, &save_pt);
  221. while (obj_name_pt != NULL) {
  222. res = confdb_object_find_start(handle, parent_object_handle);
  223. if (res != CS_OK) {
  224. fprintf (stderr, "Could not start object_find %d\n", res);
  225. exit (EXIT_FAILURE);
  226. }
  227. res = confdb_object_find(handle, parent_object_handle,
  228. obj_name_pt, strlen (obj_name_pt), &obj_handle);
  229. if (res != CS_OK) {
  230. return res;
  231. }
  232. parent_object_handle = obj_handle;
  233. obj_name_pt = strtok_r (NULL, SEPERATOR_STR, &save_pt);
  234. }
  235. *out_handle = parent_object_handle;
  236. return res;
  237. }
  238. static void read_object(confdb_handle_t handle, char * name_pt)
  239. {
  240. char parent_name[OBJ_NAME_SIZE];
  241. hdb_handle_t obj_handle;
  242. cs_error_t res;
  243. get_parent_name(name_pt, parent_name);
  244. res = find_object (handle, name_pt, FIND_OBJECT_OR_KEY, &obj_handle);
  245. if (res == CS_OK) {
  246. print_config_tree(handle, obj_handle, parent_name);
  247. }
  248. }
  249. static void write_key(confdb_handle_t handle, char * path_pt)
  250. {
  251. hdb_handle_t obj_handle;
  252. char parent_name[OBJ_NAME_SIZE];
  253. char key_name[OBJ_NAME_SIZE];
  254. char key_value[OBJ_NAME_SIZE];
  255. char old_key_value[OBJ_NAME_SIZE];
  256. size_t old_key_value_len;
  257. cs_error_t res;
  258. /* find the parent object */
  259. get_parent_name(path_pt, parent_name);
  260. get_key(path_pt, key_name, key_value);
  261. if (validate_name(key_name) != CS_OK) {
  262. fprintf(stderr, "Incorrect key name, can not have \"=\" or \"%c\"\n", SEPERATOR);
  263. exit(EXIT_FAILURE);
  264. }
  265. res = find_object (handle, parent_name, FIND_OBJECT_ONLY, &obj_handle);
  266. if (res != CS_OK) {
  267. fprintf(stderr, "Can't find parent object of \"%s\"\n", path_pt);
  268. exit(EXIT_FAILURE);
  269. }
  270. /* get the current key */
  271. res = confdb_key_get (handle,
  272. obj_handle,
  273. key_name,
  274. strlen(key_name),
  275. old_key_value,
  276. &old_key_value_len);
  277. if (res == CS_OK) {
  278. /* replace the current value */
  279. res = confdb_key_replace (handle,
  280. obj_handle,
  281. key_name,
  282. strlen(key_name),
  283. old_key_value,
  284. old_key_value_len,
  285. key_value,
  286. strlen(key_value));
  287. if (res != CS_OK)
  288. fprintf(stderr, "Failed to replace the key %s=%s. Error %d\n", key_name, key_value, res);
  289. } else {
  290. /* not there, create a new key */
  291. res = confdb_key_create (handle,
  292. obj_handle,
  293. key_name,
  294. strlen(key_name),
  295. key_value,
  296. strlen(key_value));
  297. if (res != CS_OK)
  298. fprintf(stderr, "Failed to create the key %s=%s. Error %d\n", key_name, key_value, res);
  299. }
  300. }
  301. static void create_object(confdb_handle_t handle, char * name_pt)
  302. {
  303. char * obj_name_pt;
  304. char * save_pt;
  305. hdb_handle_t obj_handle;
  306. hdb_handle_t parent_object_handle = OBJECT_PARENT_HANDLE;
  307. char tmp_name[OBJ_NAME_SIZE];
  308. cs_error_t res;
  309. strncpy (tmp_name, name_pt, OBJ_NAME_SIZE);
  310. obj_name_pt = strtok_r(tmp_name, SEPERATOR_STR, &save_pt);
  311. while (obj_name_pt != NULL) {
  312. res = confdb_object_find_start(handle, parent_object_handle);
  313. if (res != CS_OK) {
  314. fprintf (stderr, "Could not start object_find %d\n", res);
  315. exit (EXIT_FAILURE);
  316. }
  317. res = confdb_object_find(handle, parent_object_handle,
  318. obj_name_pt, strlen (obj_name_pt), &obj_handle);
  319. if (res != CS_OK) {
  320. if (validate_name(obj_name_pt) != CS_OK) {
  321. fprintf(stderr, "Incorrect object name \"%s\", \"=\" not allowed.\n",
  322. obj_name_pt);
  323. exit(EXIT_FAILURE);
  324. }
  325. res = confdb_object_create (handle,
  326. parent_object_handle,
  327. obj_name_pt,
  328. strlen (obj_name_pt),
  329. &obj_handle);
  330. if (res != CS_OK)
  331. fprintf(stderr, "Failed to create object \"%s\". Error %d.\n",
  332. obj_name_pt, res);
  333. }
  334. parent_object_handle = obj_handle;
  335. obj_name_pt = strtok_r (NULL, SEPERATOR_STR, &save_pt);
  336. }
  337. }
  338. /* Print "?" in place of any non-printable byte of OBJ. */
  339. static void print_name (FILE *fp, const void *obj, size_t obj_len)
  340. {
  341. const char *p = obj;
  342. size_t i;
  343. for (i = 0; i < obj_len; i++) {
  344. int c = *p++;
  345. if (!isprint (c)) {
  346. c = '?';
  347. }
  348. fputc (c, fp);
  349. }
  350. }
  351. static void tail_key_changed(confdb_handle_t handle,
  352. confdb_change_type_t change_type,
  353. hdb_handle_t parent_object_handle,
  354. hdb_handle_t object_handle,
  355. const void *object_name_pt,
  356. size_t object_name_len,
  357. const void *key_name_pt,
  358. size_t key_name_len,
  359. const void *key_value_pt,
  360. size_t key_value_len)
  361. {
  362. /* printf("key_changed> %.*s.%.*s=%.*s\n", */
  363. fputs("key_changed> ", stdout);
  364. print_name (stdout, object_name_pt, object_name_len);
  365. fputs(".", stdout);
  366. print_name (stdout, key_name_pt, key_name_len);
  367. fputs("=", stdout);
  368. print_name (stdout, key_value_pt, key_value_len);
  369. fputs("\n", stdout);
  370. }
  371. static void tail_object_created(confdb_handle_t handle,
  372. hdb_handle_t parent_object_handle,
  373. hdb_handle_t object_handle,
  374. const void *name_pt,
  375. size_t name_len)
  376. {
  377. fputs("object_created>", stdout);
  378. print_name(stdout, name_pt, name_len);
  379. fputs("\n", stdout);
  380. }
  381. static void tail_object_deleted(confdb_handle_t handle,
  382. hdb_handle_t parent_object_handle,
  383. const void *name_pt,
  384. size_t name_len)
  385. {
  386. fputs("object_deleted>", stdout);
  387. print_name(stdout, name_pt, name_len);
  388. fputs("\n", stdout);
  389. }
  390. static void listen_for_object_changes(confdb_handle_t handle)
  391. {
  392. int result;
  393. fd_set read_fds;
  394. int select_fd;
  395. int quit = CS_FALSE;
  396. FD_ZERO (&read_fds);
  397. if (confdb_fd_get (handle, &select_fd) != CS_OK) {
  398. printf ("can't get the confdb selector object.\n");
  399. return;
  400. }
  401. printf ("Type \"q\" to finish\n");
  402. do {
  403. FD_SET (select_fd, &read_fds);
  404. FD_SET (STDIN_FILENO, &read_fds);
  405. result = select (select_fd + 1, &read_fds, 0, 0, 0);
  406. if (result == -1) {
  407. perror ("select\n");
  408. }
  409. if (FD_ISSET (STDIN_FILENO, &read_fds)) {
  410. char inbuf[3];
  411. if (fgets(inbuf, sizeof(inbuf), stdin) == NULL)
  412. quit = CS_TRUE;
  413. else if (strncmp(inbuf, "q", 1) == 0)
  414. quit = CS_TRUE;
  415. }
  416. if (FD_ISSET (select_fd, &read_fds)) {
  417. if (confdb_dispatch (handle, CONFDB_DISPATCH_ALL) != CS_OK)
  418. exit(1);
  419. }
  420. } while (result && quit == CS_FALSE);
  421. (void)confdb_stop_track_changes(handle);
  422. }
  423. static void track_object(confdb_handle_t handle, char * name_pt)
  424. {
  425. cs_error_t res;
  426. hdb_handle_t obj_handle;
  427. res = find_object (handle, name_pt, FIND_OBJECT_ONLY, &obj_handle);
  428. if (res != CS_OK) {
  429. fprintf (stderr, "Could not find object \"%s\". Error %d\n",
  430. name_pt, res);
  431. return;
  432. }
  433. res = confdb_track_changes (handle, obj_handle, CONFDB_TRACK_DEPTH_RECURSIVE);
  434. if (res != CS_OK) {
  435. fprintf (stderr, "Could not enable tracking on object \"%s\". Error %d\n",
  436. name_pt, res);
  437. return;
  438. }
  439. }
  440. static void stop_tracking(confdb_handle_t handle)
  441. {
  442. cs_error_t res;
  443. res = confdb_stop_track_changes (handle);
  444. if (res != CS_OK) {
  445. fprintf (stderr, "Could not stop tracking. Error %d\n", res);
  446. return;
  447. }
  448. }
  449. static void delete_object(confdb_handle_t handle, char * name_pt)
  450. {
  451. cs_error_t res;
  452. hdb_handle_t obj_handle;
  453. res = find_object (handle, name_pt, FIND_OBJECT_ONLY, &obj_handle);
  454. if (res == CS_OK) {
  455. res = confdb_object_destroy (handle, obj_handle);
  456. if (res != CS_OK)
  457. fprintf(stderr, "Failed to find object \"%s\" to delete. Error %d\n", name_pt, res);
  458. } else {
  459. char parent_name[OBJ_NAME_SIZE];
  460. char key_name[OBJ_NAME_SIZE];
  461. char key_value[OBJ_NAME_SIZE];
  462. /* find the parent object */
  463. get_parent_name(name_pt, parent_name);
  464. get_key(name_pt, key_name, key_value);
  465. res = find_object (handle, parent_name, FIND_OBJECT_ONLY, &obj_handle);
  466. if (res != CS_OK) {
  467. fprintf(stderr, "Failed to find the key's parent object \"%s\". Error %d\n", parent_name, res);
  468. exit (EXIT_FAILURE);
  469. }
  470. res = confdb_key_delete (handle,
  471. obj_handle,
  472. key_name,
  473. strlen(key_name),
  474. key_value,
  475. strlen(key_value));
  476. if (res != CS_OK)
  477. fprintf(stderr, "Failed to delete key \"%s=%s\" from object \"%s\". Error %d\n",
  478. key_name, key_value, parent_name, res);
  479. }
  480. }
  481. int main (int argc, char *argv[]) {
  482. confdb_handle_t handle;
  483. cs_error_t result;
  484. int c;
  485. action = ACTION_READ;
  486. for (;;){
  487. c = getopt (argc,argv,"hawcdtp:");
  488. if (c==-1) {
  489. break;
  490. }
  491. switch (c) {
  492. case 'h':
  493. return print_help();
  494. break;
  495. case 'a':
  496. action = ACTION_PRINT_ALL;
  497. break;
  498. case 'p':
  499. printf("%s:%d NOT Implemented yet.\n", __FUNCTION__, __LINE__);
  500. return -1;
  501. //return read_in_config_file();
  502. break;
  503. case 'c':
  504. action = ACTION_CREATE;
  505. break;
  506. case 'd':
  507. action = ACTION_DELETE;
  508. break;
  509. case 'w':
  510. action = ACTION_WRITE;
  511. break;
  512. case 't':
  513. action = ACTION_TRACK;
  514. break;
  515. default :
  516. action = ACTION_READ;
  517. break;
  518. }
  519. }
  520. if (argc == 1) {
  521. action = ACTION_PRINT_DEFAULT;
  522. return print_all();
  523. } else if (action == ACTION_PRINT_ALL) {
  524. return print_all();
  525. } else if (optind >= argc) {
  526. fprintf(stderr, "Expected an object path after options\n");
  527. exit(EXIT_FAILURE);
  528. }
  529. result = confdb_initialize (&handle, &callbacks);
  530. if (result != CS_OK) {
  531. fprintf (stderr, "Failed to initialize the objdb API. Error %d\n", result);
  532. exit (EXIT_FAILURE);
  533. }
  534. while (optind < argc) {
  535. switch (action) {
  536. case ACTION_READ:
  537. read_object(handle, argv[optind++]);
  538. break;
  539. case ACTION_WRITE:
  540. write_key(handle, argv[optind++]);
  541. break;
  542. case ACTION_CREATE:
  543. create_object(handle, argv[optind++]);
  544. break;
  545. case ACTION_DELETE:
  546. delete_object(handle, argv[optind++]);
  547. break;
  548. case ACTION_TRACK:
  549. track_object(handle, argv[optind++]);
  550. break;
  551. }
  552. }
  553. if (action == ACTION_TRACK) {
  554. listen_for_object_changes(handle);
  555. stop_tracking(handle);
  556. }
  557. result = confdb_finalize (handle);
  558. if (result != CS_OK) {
  559. fprintf (stderr, "Error finalizing objdb API. Error %d\n", result);
  560. exit(EXIT_FAILURE);
  561. }
  562. return 0;
  563. }