corosync-objctl.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  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 <signal.h>
  40. #include <unistd.h>
  41. #include <string.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. void *object_name,
  68. int object_name_len,
  69. void *key_name,
  70. int key_name_len,
  71. void *key_value,
  72. int 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. uint8_t *name_pt,
  77. int name_len);
  78. static void tail_object_deleted(confdb_handle_t handle,
  79. hdb_handle_t parent_object_handle,
  80. uint8_t *name_pt,
  81. int name_len);
  82. 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. int object_name_len;
  94. char key_name[OBJ_NAME_SIZE];
  95. int key_name_len;
  96. char key_value[OBJ_NAME_SIZE];
  97. int 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 %llu: %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 %llu: %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. void get_child_name(char * name_pt, char * child_name)
  180. {
  181. char * tmp;
  182. char str_copy[OBJ_NAME_SIZE];
  183. strcpy(str_copy, name_pt);
  184. /* first remove the value (it could be a file path */
  185. tmp = strchr(str_copy, '=');
  186. if (tmp != NULL) *tmp = '\0';
  187. /* truncate the */
  188. tmp = strrchr(str_copy, SEPERATOR);
  189. if (tmp == NULL) tmp = str_copy;
  190. strcpy(child_name, tmp+1);
  191. }
  192. void get_parent_name(char * name_pt, char * parent_name)
  193. {
  194. char * tmp;
  195. strcpy(parent_name, name_pt);
  196. /* first remove the value (it could be a file path */
  197. tmp = strchr(parent_name, '=');
  198. if (tmp != NULL) *tmp = '\0';
  199. /* then truncate the child name */
  200. tmp = strrchr(parent_name, SEPERATOR);
  201. if (tmp != NULL) *tmp = '\0';
  202. }
  203. void get_key(char * name_pt, char * key_name, char * key_value)
  204. {
  205. char * tmp;
  206. char str_copy[OBJ_NAME_SIZE];
  207. strcpy(str_copy, name_pt);
  208. /* first remove the value (it could have a SEPERATOR in it */
  209. tmp = strchr(str_copy, '=');
  210. if (tmp != NULL && strlen(tmp) > 0) {
  211. strcpy(key_value, tmp+1);
  212. *tmp = '\0';
  213. } else {
  214. key_value[0] = '\0';
  215. }
  216. /* then remove the name */
  217. tmp = strrchr(str_copy, SEPERATOR);
  218. if (tmp == NULL) tmp = str_copy;
  219. strcpy(key_name, tmp+1);
  220. }
  221. static cs_error_t find_object (confdb_handle_t handle,
  222. char * name_pt,
  223. find_object_of_type_t type,
  224. hdb_handle_t * out_handle)
  225. {
  226. char * obj_name_pt;
  227. char * save_pt;
  228. hdb_handle_t obj_handle;
  229. confdb_handle_t parent_object_handle = OBJECT_PARENT_HANDLE;
  230. char tmp_name[OBJ_NAME_SIZE];
  231. cs_error_t res;
  232. strncpy (tmp_name, name_pt, OBJ_NAME_SIZE);
  233. obj_name_pt = strtok_r(tmp_name, SEPERATOR_STR, &save_pt);
  234. while (obj_name_pt != NULL) {
  235. res = confdb_object_find_start(handle, parent_object_handle);
  236. if (res != CS_OK) {
  237. fprintf (stderr, "Could not start object_find %d\n", res);
  238. exit (EXIT_FAILURE);
  239. }
  240. res = confdb_object_find(handle, parent_object_handle,
  241. obj_name_pt, strlen (obj_name_pt), &obj_handle);
  242. if (res != CS_OK) {
  243. return res;
  244. }
  245. parent_object_handle = obj_handle;
  246. obj_name_pt = strtok_r (NULL, SEPERATOR_STR, &save_pt);
  247. }
  248. *out_handle = parent_object_handle;
  249. return res;
  250. }
  251. static void read_object(confdb_handle_t handle, char * name_pt)
  252. {
  253. char parent_name[OBJ_NAME_SIZE];
  254. hdb_handle_t obj_handle;
  255. cs_error_t res;
  256. get_parent_name(name_pt, parent_name);
  257. res = find_object (handle, name_pt, FIND_OBJECT_OR_KEY, &obj_handle);
  258. if (res == CS_OK) {
  259. print_config_tree(handle, obj_handle, parent_name);
  260. }
  261. }
  262. static void write_key(confdb_handle_t handle, char * path_pt)
  263. {
  264. hdb_handle_t obj_handle;
  265. char parent_name[OBJ_NAME_SIZE];
  266. char key_name[OBJ_NAME_SIZE];
  267. char key_value[OBJ_NAME_SIZE];
  268. char old_key_value[OBJ_NAME_SIZE];
  269. int old_key_value_len;
  270. cs_error_t res;
  271. /* find the parent object */
  272. get_parent_name(path_pt, parent_name);
  273. get_key(path_pt, key_name, key_value);
  274. if (validate_name(key_name) != CS_OK) {
  275. fprintf(stderr, "Incorrect key name, can not have \"=\" or \"%c\"\n", SEPERATOR);
  276. exit(EXIT_FAILURE);
  277. }
  278. res = find_object (handle, parent_name, FIND_OBJECT_ONLY, &obj_handle);
  279. if (res != CS_OK) {
  280. fprintf(stderr, "Can't find parent object of \"%s\"\n", path_pt);
  281. exit(EXIT_FAILURE);
  282. }
  283. /* get the current key */
  284. res = confdb_key_get (handle,
  285. obj_handle,
  286. key_name,
  287. strlen(key_name),
  288. old_key_value,
  289. &old_key_value_len);
  290. if (res == CS_OK) {
  291. /* replace the current value */
  292. res = confdb_key_replace (handle,
  293. obj_handle,
  294. key_name,
  295. strlen(key_name),
  296. old_key_value,
  297. old_key_value_len,
  298. key_value,
  299. strlen(key_value));
  300. if (res != CS_OK)
  301. fprintf(stderr, "Failed to replace the key %s=%s. Error %d\n", key_name, key_value, res);
  302. } else {
  303. /* not there, create a new key */
  304. res = confdb_key_create (handle,
  305. obj_handle,
  306. key_name,
  307. strlen(key_name),
  308. key_value,
  309. strlen(key_value));
  310. if (res != CS_OK)
  311. fprintf(stderr, "Failed to create the key %s=%s. Error %d\n", key_name, key_value, res);
  312. }
  313. }
  314. static void create_object(confdb_handle_t handle, char * name_pt)
  315. {
  316. char * obj_name_pt;
  317. char * save_pt;
  318. hdb_handle_t obj_handle;
  319. hdb_handle_t parent_object_handle = OBJECT_PARENT_HANDLE;
  320. char tmp_name[OBJ_NAME_SIZE];
  321. cs_error_t res;
  322. strncpy (tmp_name, name_pt, OBJ_NAME_SIZE);
  323. obj_name_pt = strtok_r(tmp_name, SEPERATOR_STR, &save_pt);
  324. while (obj_name_pt != NULL) {
  325. res = confdb_object_find_start(handle, parent_object_handle);
  326. if (res != CS_OK) {
  327. fprintf (stderr, "Could not start object_find %d\n", res);
  328. exit (EXIT_FAILURE);
  329. }
  330. res = confdb_object_find(handle, parent_object_handle,
  331. obj_name_pt, strlen (obj_name_pt), &obj_handle);
  332. if (res != CS_OK) {
  333. if (validate_name(obj_name_pt) != CS_OK) {
  334. fprintf(stderr, "Incorrect object name \"%s\", \"=\" not allowed.\n",
  335. obj_name_pt);
  336. exit(EXIT_FAILURE);
  337. }
  338. res = confdb_object_create (handle,
  339. parent_object_handle,
  340. obj_name_pt,
  341. strlen (obj_name_pt),
  342. &obj_handle);
  343. if (res != CS_OK)
  344. fprintf(stderr, "Failed to create object \"%s\". Error %d.\n",
  345. obj_name_pt, res);
  346. }
  347. parent_object_handle = obj_handle;
  348. obj_name_pt = strtok_r (NULL, SEPERATOR_STR, &save_pt);
  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. void *object_name_pt,
  356. int object_name_len,
  357. void *key_name_pt,
  358. int key_name_len,
  359. void *key_value_pt,
  360. int key_value_len)
  361. {
  362. char * on = (char*)object_name_pt;
  363. char * kn = (char*)key_name_pt;
  364. char * kv = (char*)key_value_pt;
  365. on[object_name_len] = '\0';
  366. kv[key_value_len] = '\0';
  367. kn[key_name_len] = '\0';
  368. printf("key_changed> %s.%s=%s\n", on, kn, kv);
  369. }
  370. static void tail_object_created(confdb_handle_t handle,
  371. hdb_handle_t parent_object_handle,
  372. hdb_handle_t object_handle,
  373. uint8_t *name_pt,
  374. int name_len)
  375. {
  376. name_pt[name_len] = '\0';
  377. printf("object_created> %s\n", name_pt);
  378. }
  379. static void tail_object_deleted(confdb_handle_t handle,
  380. hdb_handle_t parent_object_handle,
  381. uint8_t *name_pt,
  382. int name_len)
  383. {
  384. name_pt[name_len] = '\0';
  385. printf("object_deleted> %s\n", name_pt);
  386. }
  387. static void listen_for_object_changes(confdb_handle_t handle)
  388. {
  389. int result;
  390. fd_set read_fds;
  391. int select_fd;
  392. int quit = CS_FALSE;
  393. FD_ZERO (&read_fds);
  394. if (confdb_fd_get (handle, &select_fd) != CS_OK) {
  395. printf ("can't get the confdb selector object.\n");
  396. return;
  397. }
  398. printf ("Type \"q\" to finish\n");
  399. do {
  400. FD_SET (select_fd, &read_fds);
  401. FD_SET (STDIN_FILENO, &read_fds);
  402. result = select (select_fd + 1, &read_fds, 0, 0, 0);
  403. if (result == -1) {
  404. perror ("select\n");
  405. }
  406. if (FD_ISSET (STDIN_FILENO, &read_fds)) {
  407. char inbuf[3];
  408. if (fgets(inbuf, sizeof(inbuf), stdin) == NULL)
  409. quit = CS_TRUE;
  410. else if (strncmp(inbuf, "q", 1) == 0)
  411. quit = CS_TRUE;
  412. }
  413. if (FD_ISSET (select_fd, &read_fds)) {
  414. if (confdb_dispatch (handle, CONFDB_DISPATCH_ALL) != CS_OK)
  415. exit(1);
  416. }
  417. } while (result && quit == CS_FALSE);
  418. (void)confdb_stop_track_changes(handle);
  419. }
  420. static void track_object(confdb_handle_t handle, char * name_pt)
  421. {
  422. cs_error_t res;
  423. hdb_handle_t obj_handle;
  424. res = find_object (handle, name_pt, FIND_OBJECT_ONLY, &obj_handle);
  425. if (res != CS_OK) {
  426. fprintf (stderr, "Could not find object \"%s\". Error %d\n",
  427. name_pt, res);
  428. return;
  429. }
  430. res = confdb_track_changes (handle, obj_handle, CONFDB_TRACK_DEPTH_RECURSIVE);
  431. if (res != CS_OK) {
  432. fprintf (stderr, "Could not enable tracking on object \"%s\". Error %d\n",
  433. name_pt, res);
  434. return;
  435. }
  436. }
  437. static void stop_tracking(confdb_handle_t handle)
  438. {
  439. cs_error_t res;
  440. res = confdb_stop_track_changes (handle);
  441. if (res != CS_OK) {
  442. fprintf (stderr, "Could not stop tracking. Error %d\n", res);
  443. return;
  444. }
  445. }
  446. static void delete_object(confdb_handle_t handle, char * name_pt)
  447. {
  448. cs_error_t res;
  449. hdb_handle_t obj_handle;
  450. res = find_object (handle, name_pt, FIND_OBJECT_ONLY, &obj_handle);
  451. if (res == CS_OK) {
  452. res = confdb_object_destroy (handle, obj_handle);
  453. if (res != CS_OK)
  454. fprintf(stderr, "Failed to find object \"%s\" to delete. Error %d\n", name_pt, res);
  455. } else {
  456. char parent_name[OBJ_NAME_SIZE];
  457. char key_name[OBJ_NAME_SIZE];
  458. char key_value[OBJ_NAME_SIZE];
  459. /* find the parent object */
  460. get_parent_name(name_pt, parent_name);
  461. get_key(name_pt, key_name, key_value);
  462. res = find_object (handle, parent_name, FIND_OBJECT_ONLY, &obj_handle);
  463. if (res != CS_OK) {
  464. fprintf(stderr, "Failed to find the key's parent object \"%s\". Error %d\n", parent_name, res);
  465. exit (EXIT_FAILURE);
  466. }
  467. res = confdb_key_delete (handle,
  468. obj_handle,
  469. key_name,
  470. strlen(key_name),
  471. key_value,
  472. strlen(key_value));
  473. if (res != CS_OK)
  474. fprintf(stderr, "Failed to delete key \"%s=%s\" from object \"%s\". Error %d\n",
  475. key_name, key_value, parent_name, res);
  476. }
  477. }
  478. int main (int argc, char *argv[]) {
  479. confdb_handle_t handle;
  480. cs_error_t result;
  481. int c;
  482. action = ACTION_READ;
  483. for (;;){
  484. c = getopt (argc,argv,"hawcdtp:");
  485. if (c==-1) {
  486. break;
  487. }
  488. switch (c) {
  489. case 'h':
  490. return print_help();
  491. break;
  492. case 'a':
  493. action = ACTION_PRINT_ALL;
  494. break;
  495. case 'p':
  496. printf("%s:%d NOT Implemented yet.\n", __FUNCTION__, __LINE__);
  497. return -1;
  498. //return read_in_config_file();
  499. break;
  500. case 'c':
  501. action = ACTION_CREATE;
  502. break;
  503. case 'd':
  504. action = ACTION_DELETE;
  505. break;
  506. case 'w':
  507. action = ACTION_WRITE;
  508. break;
  509. case 't':
  510. action = ACTION_TRACK;
  511. break;
  512. default :
  513. action = ACTION_READ;
  514. break;
  515. }
  516. }
  517. if (argc == 1) {
  518. action = ACTION_PRINT_DEFAULT;
  519. return print_all();
  520. } else if (action == ACTION_PRINT_ALL) {
  521. return print_all();
  522. } else if (optind >= argc) {
  523. fprintf(stderr, "Expected an object path after options\n");
  524. exit(EXIT_FAILURE);
  525. }
  526. result = confdb_initialize (&handle, &callbacks);
  527. if (result != CS_OK) {
  528. fprintf (stderr, "Failed to initialize the objdb API. Error %d\n", result);
  529. exit (EXIT_FAILURE);
  530. }
  531. while (optind < argc) {
  532. switch (action) {
  533. case ACTION_READ:
  534. read_object(handle, argv[optind++]);
  535. break;
  536. case ACTION_WRITE:
  537. write_key(handle, argv[optind++]);
  538. break;
  539. case ACTION_CREATE:
  540. create_object(handle, argv[optind++]);
  541. break;
  542. case ACTION_DELETE:
  543. delete_object(handle, argv[optind++]);
  544. break;
  545. case ACTION_TRACK:
  546. track_object(handle, argv[optind++]);
  547. break;
  548. }
  549. }
  550. if (action == ACTION_TRACK) {
  551. listen_for_object_changes(handle);
  552. stop_tracking(handle);
  553. }
  554. result = confdb_finalize (handle);
  555. if (result != CS_OK) {
  556. fprintf (stderr, "Error finalizing objdb API. Error %d\n", result);
  557. exit(EXIT_FAILURE);
  558. }
  559. return 0;
  560. }