objdb.c 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503
  1. /*
  2. * Copyright (c) 2006 MontaVista Software, Inc.
  3. * Copyright (c) 2007-2008 Red Hat, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@redhat.com)
  8. *
  9. * This software licensed under BSD license, the text of which follows:
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * - Redistributions in binary form must reproduce the above copyright notice,
  17. * this list of conditions and the following disclaimer in the documentation
  18. * and/or other materials provided with the distribution.
  19. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  33. * THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #include <stdio.h>
  36. #include <errno.h>
  37. #include "objdb.h"
  38. #include "config.h"
  39. #include "main.h"
  40. #include "../lcr/lcr_comp.h"
  41. #include "../include/hdb.h"
  42. #include "../include/list.h"
  43. struct object_key {
  44. void *key_name;
  45. int key_len;
  46. void *value;
  47. int value_len;
  48. struct list_head list;
  49. };
  50. struct object_tracker {
  51. unsigned int object_handle;
  52. void * data_pt;
  53. object_track_depth_t depth;
  54. object_key_change_notify_fn_t key_change_notify_fn;
  55. object_create_notify_fn_t object_create_notify_fn;
  56. object_destroy_notify_fn_t object_destroy_notify_fn;
  57. struct list_head tracker_list;
  58. struct list_head object_list;
  59. };
  60. struct object_instance {
  61. void *object_name;
  62. int object_name_len;
  63. unsigned int object_handle;
  64. unsigned int parent_handle;
  65. struct list_head key_head;
  66. struct list_head child_head;
  67. struct list_head child_list;
  68. struct list_head *find_child_list;
  69. struct list_head *iter_key_list;
  70. struct list_head *iter_list;
  71. void *priv;
  72. struct object_valid *object_valid_list;
  73. int object_valid_list_entries;
  74. struct object_key_valid *object_key_valid_list;
  75. int object_key_valid_list_entries;
  76. struct list_head track_head;
  77. };
  78. struct object_find_instance {
  79. struct list_head *find_child_list;
  80. struct list_head *child_head;
  81. void *object_name;
  82. int object_len;
  83. };
  84. struct objdb_iface_ver0 objdb_iface;
  85. struct list_head objdb_trackers_head;
  86. static struct hdb_handle_database object_instance_database = {
  87. .handle_count = 0,
  88. .handles = 0,
  89. .iterator = 0,
  90. .mutex = PTHREAD_MUTEX_INITIALIZER
  91. };
  92. static struct hdb_handle_database object_find_instance_database = {
  93. .handle_count = 0,
  94. .handles = 0,
  95. .iterator = 0,
  96. .mutex = PTHREAD_MUTEX_INITIALIZER
  97. };
  98. static int objdb_init (void)
  99. {
  100. unsigned int handle;
  101. struct object_instance *instance;
  102. unsigned int res;
  103. res = hdb_handle_create (&object_instance_database,
  104. sizeof (struct object_instance), &handle);
  105. if (res != 0) {
  106. goto error_exit;
  107. }
  108. res = hdb_handle_get (&object_instance_database,
  109. handle, (void *)&instance);
  110. if (res != 0) {
  111. goto error_destroy;
  112. }
  113. instance->find_child_list = &instance->child_head;
  114. instance->object_name = "parent";
  115. instance->object_name_len = strlen ("parent");
  116. instance->object_handle = handle;
  117. instance->priv = NULL;
  118. instance->object_valid_list = NULL;
  119. instance->object_valid_list_entries = 0;
  120. list_init (&instance->key_head);
  121. list_init (&instance->child_head);
  122. list_init (&instance->child_list);
  123. list_init (&instance->track_head);
  124. list_init (&objdb_trackers_head);
  125. hdb_handle_put (&object_instance_database, handle);
  126. return (0);
  127. error_destroy:
  128. hdb_handle_destroy (&object_instance_database, handle);
  129. error_exit:
  130. return (-1);
  131. }
  132. static int _object_notify_deleted_children(struct object_instance *parent_pt)
  133. {
  134. struct list_head *list;
  135. struct list_head *notify_list;
  136. int res;
  137. struct object_instance *obj_pt = NULL;
  138. struct object_tracker * tracker_pt;
  139. for (list = parent_pt->child_head.next;
  140. list != &parent_pt->child_head; list = list->next) {
  141. obj_pt = list_entry(list, struct object_instance,
  142. child_list);
  143. res = _object_notify_deleted_children(obj_pt);
  144. if (res)
  145. return res;
  146. for (notify_list = obj_pt->track_head.next;
  147. notify_list != &obj_pt->track_head;
  148. notify_list = notify_list->next) {
  149. tracker_pt = list_entry (notify_list, struct object_tracker, object_list);
  150. if ((tracker_pt != NULL) &&
  151. (tracker_pt->object_destroy_notify_fn != NULL))
  152. tracker_pt->object_destroy_notify_fn(parent_pt->object_handle,
  153. obj_pt->object_name,
  154. obj_pt->object_name_len,
  155. tracker_pt->data_pt);
  156. }
  157. }
  158. return 0;
  159. }
  160. static void object_created_notification(unsigned int object_handle,
  161. unsigned int parent_object_handle,
  162. void *name_pt, int name_len)
  163. {
  164. struct list_head * list;
  165. struct object_instance * obj_pt;
  166. struct object_tracker * tracker_pt;
  167. unsigned int obj_handle = object_handle;
  168. unsigned int res;
  169. do {
  170. res = hdb_handle_get (&object_instance_database,
  171. obj_handle, (void *)&obj_pt);
  172. for (list = obj_pt->track_head.next;
  173. list != &obj_pt->track_head; list = list->next) {
  174. tracker_pt = list_entry (list, struct object_tracker, object_list);
  175. if (((obj_handle == parent_object_handle) ||
  176. (tracker_pt->depth == OBJECT_TRACK_DEPTH_RECURSIVE)) &&
  177. (tracker_pt->object_create_notify_fn != NULL)) {
  178. tracker_pt->object_create_notify_fn(object_handle, parent_object_handle,
  179. name_pt, name_len,
  180. tracker_pt->data_pt);
  181. }
  182. }
  183. hdb_handle_put (&object_instance_database, obj_handle);
  184. obj_handle = obj_pt->parent_handle;
  185. } while (obj_pt->object_handle != OBJECT_PARENT_HANDLE);
  186. }
  187. static void object_pre_deletion_notification(unsigned int object_handle,
  188. unsigned int parent_object_handle,
  189. void *name_pt, int name_len)
  190. {
  191. struct list_head * list;
  192. struct object_instance * obj_pt;
  193. struct object_tracker * tracker_pt;
  194. unsigned int obj_handle = object_handle;
  195. unsigned int res;
  196. do {
  197. res = hdb_handle_get (&object_instance_database,
  198. obj_handle, (void *)&obj_pt);
  199. for (list = obj_pt->track_head.next;
  200. list != &obj_pt->track_head; list = list->next) {
  201. tracker_pt = list_entry (list, struct object_tracker, object_list);
  202. if (((obj_handle == parent_object_handle) ||
  203. (tracker_pt->depth == OBJECT_TRACK_DEPTH_RECURSIVE)) &&
  204. (tracker_pt->object_destroy_notify_fn != NULL)) {
  205. tracker_pt->object_destroy_notify_fn(parent_object_handle,
  206. name_pt, name_len,
  207. tracker_pt->data_pt);
  208. }
  209. }
  210. /* notify child object listeners */
  211. if (obj_handle == object_handle)
  212. _object_notify_deleted_children(obj_pt);
  213. hdb_handle_put (&object_instance_database, obj_handle);
  214. obj_handle = obj_pt->parent_handle;
  215. } while (obj_pt->object_handle != OBJECT_PARENT_HANDLE);
  216. }
  217. static void object_key_changed_notification(unsigned int object_handle,
  218. void *name_pt, int name_len,
  219. void *value_pt, int value_len,
  220. object_change_type_t type)
  221. {
  222. struct list_head * list;
  223. struct object_instance * obj_pt;
  224. struct object_instance * owner_pt = NULL;
  225. struct object_tracker * tracker_pt;
  226. unsigned int obj_handle = object_handle;
  227. unsigned int res;
  228. do {
  229. res = hdb_handle_get (&object_instance_database,
  230. obj_handle, (void *)&obj_pt);
  231. if (owner_pt == NULL)
  232. owner_pt = obj_pt;
  233. for (list = obj_pt->track_head.next;
  234. list != &obj_pt->track_head; list = list->next) {
  235. tracker_pt = list_entry (list, struct object_tracker, object_list);
  236. if (((obj_handle == object_handle) ||
  237. (tracker_pt->depth == OBJECT_TRACK_DEPTH_RECURSIVE)) &&
  238. (tracker_pt->key_change_notify_fn != NULL))
  239. tracker_pt->key_change_notify_fn(type, obj_pt->parent_handle, object_handle,
  240. owner_pt->object_name, owner_pt->object_name_len,
  241. name_pt, name_len,
  242. value_pt, value_len,
  243. tracker_pt->data_pt);
  244. }
  245. hdb_handle_put (&object_instance_database, obj_handle);
  246. obj_handle = obj_pt->parent_handle;
  247. } while (obj_pt->object_handle != OBJECT_PARENT_HANDLE);
  248. }
  249. /*
  250. * object db create/destroy/set
  251. */
  252. static int object_create (
  253. unsigned int parent_object_handle,
  254. unsigned int *object_handle,
  255. void *object_name,
  256. unsigned int object_name_len)
  257. {
  258. struct object_instance *object_instance;
  259. struct object_instance *parent_instance;
  260. unsigned int res;
  261. int found = 0;
  262. int i;
  263. res = hdb_handle_get (&object_instance_database,
  264. parent_object_handle, (void *)&parent_instance);
  265. if (res != 0) {
  266. goto error_exit;
  267. }
  268. /*
  269. * Do validation check if validation is configured for the parent object
  270. */
  271. if (parent_instance->object_valid_list_entries) {
  272. for (i = 0; i < parent_instance->object_valid_list_entries; i++) {
  273. if ((object_name_len ==
  274. parent_instance->object_valid_list[i].object_len) &&
  275. (memcmp (object_name,
  276. parent_instance->object_valid_list[i].object_name,
  277. object_name_len) == 0)) {
  278. found = 1;
  279. break;
  280. }
  281. }
  282. /*
  283. * Item not found in validation list
  284. */
  285. if (found == 0) {
  286. goto error_object_put;
  287. }
  288. }
  289. res = hdb_handle_create (&object_instance_database,
  290. sizeof (struct object_instance), object_handle);
  291. if (res != 0) {
  292. goto error_object_put;
  293. }
  294. res = hdb_handle_get (&object_instance_database,
  295. *object_handle, (void *)&object_instance);
  296. if (res != 0) {
  297. goto error_destroy;
  298. }
  299. list_init (&object_instance->key_head);
  300. list_init (&object_instance->child_head);
  301. list_init (&object_instance->child_list);
  302. list_init (&object_instance->track_head);
  303. object_instance->object_name = malloc (object_name_len);
  304. if (object_instance->object_name == 0) {
  305. goto error_put_destroy;
  306. }
  307. memcpy (object_instance->object_name, object_name, object_name_len);
  308. object_instance->object_name_len = object_name_len;
  309. list_add_tail (&object_instance->child_list, &parent_instance->child_head);
  310. object_instance->object_handle = *object_handle;
  311. object_instance->find_child_list = &object_instance->child_head;
  312. object_instance->iter_key_list = &object_instance->key_head;
  313. object_instance->iter_list = &object_instance->child_head;
  314. object_instance->priv = NULL;
  315. object_instance->object_valid_list = NULL;
  316. object_instance->object_valid_list_entries = 0;
  317. object_instance->parent_handle = parent_object_handle;
  318. hdb_handle_put (&object_instance_database, *object_handle);
  319. hdb_handle_put (&object_instance_database, parent_object_handle);
  320. object_created_notification(object_instance->object_handle,
  321. object_instance->parent_handle,
  322. object_instance->object_name,
  323. object_instance->object_name_len);
  324. return (0);
  325. error_put_destroy:
  326. hdb_handle_put (&object_instance_database, *object_handle);
  327. error_destroy:
  328. hdb_handle_destroy (&object_instance_database, *object_handle);
  329. error_object_put:
  330. hdb_handle_put (&object_instance_database, parent_object_handle);
  331. error_exit:
  332. return (-1);
  333. }
  334. static int object_priv_set (
  335. unsigned int object_handle,
  336. void *priv)
  337. {
  338. int res;
  339. struct object_instance *object_instance;
  340. res = hdb_handle_get (&object_instance_database,
  341. object_handle, (void *)&object_instance);
  342. if (res != 0) {
  343. goto error_exit;
  344. }
  345. object_instance->priv = priv;
  346. hdb_handle_put (&object_instance_database, object_handle);
  347. return (0);
  348. error_exit:
  349. return (-1);
  350. }
  351. static int object_key_create (
  352. unsigned int object_handle,
  353. void *key_name,
  354. int key_len,
  355. void *value,
  356. int value_len)
  357. {
  358. struct object_instance *instance;
  359. struct object_key *object_key;
  360. unsigned int res;
  361. int found = 0;
  362. int i;
  363. unsigned int val;
  364. res = hdb_handle_get (&object_instance_database,
  365. object_handle, (void *)&instance);
  366. if (res != 0) {
  367. goto error_exit;
  368. }
  369. /*
  370. * Do validation check if validation is configured for the parent object
  371. */
  372. if (instance->object_key_valid_list_entries) {
  373. for (i = 0; i < instance->object_key_valid_list_entries; i++) {
  374. if ((key_len ==
  375. instance->object_key_valid_list[i].key_len) &&
  376. (memcmp (key_name,
  377. instance->object_key_valid_list[i].key_name,
  378. key_len) == 0)) {
  379. found = 1;
  380. break;
  381. }
  382. }
  383. /*
  384. * Item not found in validation list
  385. */
  386. if (found == 0) {
  387. goto error_put;
  388. } else {
  389. if (instance->object_key_valid_list[i].validate_callback) {
  390. res = instance->object_key_valid_list[i].validate_callback (
  391. key_name, key_len, value, value_len);
  392. if (res != 0) {
  393. goto error_put;
  394. }
  395. }
  396. }
  397. }
  398. object_key = malloc (sizeof (struct object_key));
  399. if (object_key == 0) {
  400. goto error_put;
  401. }
  402. object_key->key_name = malloc (key_len);
  403. if (object_key->key_name == 0) {
  404. goto error_put_object;
  405. }
  406. memcpy (&val, value, 4);
  407. object_key->value = malloc (value_len);
  408. if (object_key->value == 0) {
  409. goto error_put_key;
  410. }
  411. memcpy (object_key->key_name, key_name, key_len);
  412. memcpy (object_key->value, value, value_len);
  413. object_key->key_len = key_len;
  414. object_key->value_len = value_len;
  415. list_init (&object_key->list);
  416. list_add_tail (&object_key->list, &instance->key_head);
  417. object_key_changed_notification(object_handle, key_name, key_len,
  418. value, value_len, OBJECT_KEY_CREATED);
  419. return (0);
  420. error_put_key:
  421. free (object_key->key_name);
  422. error_put_object:
  423. free (object_key);
  424. error_put:
  425. hdb_handle_put (&object_instance_database, object_handle);
  426. error_exit:
  427. return (-1);
  428. }
  429. static int _clear_object(struct object_instance *instance)
  430. {
  431. struct list_head *list;
  432. int res;
  433. struct object_instance *find_instance = NULL;
  434. struct object_key *object_key = NULL;
  435. for (list = instance->key_head.next;
  436. list != &instance->key_head; ) {
  437. object_key = list_entry (list, struct object_key,
  438. list);
  439. list = list->next;
  440. list_del(&object_key->list);
  441. free(object_key->key_name);
  442. free(object_key->value);
  443. }
  444. for (list = instance->child_head.next;
  445. list != &instance->child_head; ) {
  446. find_instance = list_entry (list, struct object_instance,
  447. child_list);
  448. res = _clear_object(find_instance);
  449. if (res)
  450. return res;
  451. list = list->next;
  452. list_del(&find_instance->child_list);
  453. free(find_instance->object_name);
  454. free(find_instance);
  455. }
  456. return 0;
  457. }
  458. static int object_destroy (
  459. unsigned int object_handle)
  460. {
  461. struct object_instance *instance;
  462. unsigned int res;
  463. res = hdb_handle_get (&object_instance_database,
  464. object_handle, (void *)&instance);
  465. if (res != 0) {
  466. return (res);
  467. }
  468. object_pre_deletion_notification(object_handle,
  469. instance->parent_handle,
  470. instance->object_name,
  471. instance->object_name_len);
  472. /* Recursively clear sub-objects & keys */
  473. res = _clear_object(instance);
  474. list_del(&instance->child_list);
  475. free(instance->object_name);
  476. free(instance);
  477. return (res);
  478. }
  479. static int object_valid_set (
  480. unsigned int object_handle,
  481. struct object_valid *object_valid_list,
  482. unsigned int object_valid_list_entries)
  483. {
  484. struct object_instance *instance;
  485. unsigned int res;
  486. res = hdb_handle_get (&object_instance_database,
  487. object_handle, (void *)&instance);
  488. if (res != 0) {
  489. goto error_exit;
  490. }
  491. instance->object_valid_list = object_valid_list;
  492. instance->object_valid_list_entries = object_valid_list_entries;
  493. hdb_handle_put (&object_instance_database, object_handle);
  494. return (0);
  495. error_exit:
  496. return (-1);
  497. }
  498. static int object_key_valid_set (
  499. unsigned int object_handle,
  500. struct object_key_valid *object_key_valid_list,
  501. unsigned int object_key_valid_list_entries)
  502. {
  503. struct object_instance *instance;
  504. unsigned int res;
  505. res = hdb_handle_get (&object_instance_database,
  506. object_handle, (void *)&instance);
  507. if (res != 0) {
  508. goto error_exit;
  509. }
  510. instance->object_key_valid_list = object_key_valid_list;
  511. instance->object_key_valid_list_entries = object_key_valid_list_entries;
  512. hdb_handle_put (&object_instance_database, object_handle);
  513. return (0);
  514. error_exit:
  515. return (-1);
  516. }
  517. /*
  518. * object db reading
  519. */
  520. static int object_find_create (
  521. unsigned int object_handle,
  522. void *object_name,
  523. int object_len,
  524. unsigned int *object_find_handle)
  525. {
  526. unsigned int res;
  527. struct object_instance *object_instance;
  528. struct object_find_instance *object_find_instance;
  529. res = hdb_handle_get (&object_instance_database,
  530. object_handle, (void *)&object_instance);
  531. if (res != 0) {
  532. goto error_exit;
  533. }
  534. res = hdb_handle_create (&object_find_instance_database,
  535. sizeof (struct object_find_instance), object_find_handle);
  536. if (res != 0) {
  537. goto error_put;
  538. }
  539. res = hdb_handle_get (&object_find_instance_database,
  540. *object_find_handle, (void *)&object_find_instance);
  541. if (res != 0) {
  542. goto error_destroy;
  543. }
  544. object_find_instance->find_child_list = &object_instance->child_head;
  545. object_find_instance->child_head = &object_instance->child_head;
  546. object_find_instance->object_name = object_name;
  547. object_find_instance->object_len = object_len;
  548. hdb_handle_put (&object_instance_database, object_handle);
  549. hdb_handle_put (&object_find_instance_database, *object_find_handle);
  550. return (0);
  551. error_destroy:
  552. hdb_handle_destroy (&object_instance_database, *object_find_handle);
  553. error_put:
  554. hdb_handle_put (&object_instance_database, object_handle);
  555. error_exit:
  556. return (-1);
  557. }
  558. static int object_find_next (
  559. unsigned int object_find_handle,
  560. unsigned int *object_handle)
  561. {
  562. unsigned int res;
  563. struct object_find_instance *object_find_instance;
  564. struct object_instance *object_instance = NULL;
  565. struct list_head *list;
  566. unsigned int found = 0;
  567. res = hdb_handle_get (&object_find_instance_database,
  568. object_find_handle, (void *)&object_find_instance);
  569. if (res != 0) {
  570. goto error_exit;
  571. }
  572. res = -1;
  573. for (list = object_find_instance->find_child_list->next;
  574. list != object_find_instance->child_head; list = list->next) {
  575. object_instance = list_entry (list, struct object_instance,
  576. child_list);
  577. if ((object_instance->object_name_len ==
  578. object_find_instance->object_len) &&
  579. (memcmp (object_instance->object_name,
  580. object_find_instance->object_name,
  581. object_find_instance->object_len) == 0)) {
  582. found = 1;
  583. break;
  584. }
  585. }
  586. object_find_instance->find_child_list = list;
  587. hdb_handle_put (&object_find_instance_database, object_find_handle);
  588. if (found) {
  589. *object_handle = object_instance->object_handle;
  590. res = 0;
  591. }
  592. return (res);
  593. error_exit:
  594. return (-1);
  595. }
  596. static int object_find_destroy (
  597. unsigned int object_find_handle)
  598. {
  599. return (0);
  600. }
  601. static int object_key_get (
  602. unsigned int object_handle,
  603. void *key_name,
  604. int key_len,
  605. void **value,
  606. int *value_len)
  607. {
  608. unsigned int res = 0;
  609. struct object_instance *instance;
  610. struct object_key *object_key = NULL;
  611. struct list_head *list;
  612. int found = 0;
  613. res = hdb_handle_get (&object_instance_database,
  614. object_handle, (void *)&instance);
  615. if (res != 0) {
  616. goto error_exit;
  617. }
  618. for (list = instance->key_head.next;
  619. list != &instance->key_head; list = list->next) {
  620. object_key = list_entry (list, struct object_key, list);
  621. if ((object_key->key_len == key_len) &&
  622. (memcmp (object_key->key_name, key_name, key_len) == 0)) {
  623. found = 1;
  624. break;
  625. }
  626. }
  627. if (found) {
  628. *value = object_key->value;
  629. if (value_len) {
  630. *value_len = object_key->value_len;
  631. }
  632. }
  633. else {
  634. res = -1;
  635. }
  636. hdb_handle_put (&object_instance_database, object_handle);
  637. return (res);
  638. error_exit:
  639. return (-1);
  640. }
  641. static int object_key_delete (
  642. unsigned int object_handle,
  643. void *key_name,
  644. int key_len,
  645. void *value,
  646. int value_len)
  647. {
  648. unsigned int res;
  649. int ret = 0;
  650. struct object_instance *instance;
  651. struct object_key *object_key = NULL;
  652. struct list_head *list;
  653. int found = 0;
  654. res = hdb_handle_get (&object_instance_database,
  655. object_handle, (void *)&instance);
  656. if (res != 0) {
  657. goto error_exit;
  658. }
  659. for (list = instance->key_head.next;
  660. list != &instance->key_head; list = list->next) {
  661. object_key = list_entry (list, struct object_key, list);
  662. if ((object_key->key_len == key_len) &&
  663. (memcmp (object_key->key_name, key_name, key_len) == 0) &&
  664. (value == NULL ||
  665. (object_key->value_len == value_len &&
  666. (memcmp (object_key->value, value, value_len) == 0)))) {
  667. found = 1;
  668. break;
  669. }
  670. }
  671. if (found) {
  672. list_del(&object_key->list);
  673. free(object_key->key_name);
  674. free(object_key->value);
  675. free(object_key);
  676. }
  677. else {
  678. ret = -1;
  679. errno = ENOENT;
  680. }
  681. hdb_handle_put (&object_instance_database, object_handle);
  682. if (ret == 0)
  683. object_key_changed_notification(object_handle, key_name, key_len,
  684. value, value_len, OBJECT_KEY_DELETED);
  685. return (ret);
  686. error_exit:
  687. return (-1);
  688. }
  689. static int object_key_replace (
  690. unsigned int object_handle,
  691. void *key_name,
  692. int key_len,
  693. void *old_value,
  694. int old_value_len,
  695. void *new_value,
  696. int new_value_len)
  697. {
  698. unsigned int res;
  699. int ret = 0;
  700. struct object_instance *instance;
  701. struct object_key *object_key = NULL;
  702. struct list_head *list;
  703. int found = 0;
  704. res = hdb_handle_get (&object_instance_database,
  705. object_handle, (void *)&instance);
  706. if (res != 0) {
  707. goto error_exit;
  708. }
  709. for (list = instance->key_head.next;
  710. list != &instance->key_head; list = list->next) {
  711. object_key = list_entry (list, struct object_key, list);
  712. if ((object_key->key_len == key_len) &&
  713. (memcmp (object_key->key_name, key_name, key_len) == 0) &&
  714. (old_value == NULL ||
  715. (object_key->value_len == old_value_len &&
  716. (memcmp (object_key->value, old_value, old_value_len) == 0)))) {
  717. found = 1;
  718. break;
  719. }
  720. }
  721. if (found) {
  722. int i;
  723. /*
  724. * Do validation check if validation is configured for the parent object
  725. */
  726. if (instance->object_key_valid_list_entries) {
  727. for (i = 0; i < instance->object_key_valid_list_entries; i++) {
  728. if ((key_len ==
  729. instance->object_key_valid_list[i].key_len) &&
  730. (memcmp (key_name,
  731. instance->object_key_valid_list[i].key_name,
  732. key_len) == 0)) {
  733. found = 1;
  734. break;
  735. }
  736. }
  737. /*
  738. * Item not found in validation list
  739. */
  740. if (found == 0) {
  741. goto error_put;
  742. } else {
  743. if (instance->object_key_valid_list[i].validate_callback) {
  744. res = instance->object_key_valid_list[i].validate_callback (
  745. key_name, key_len, new_value, new_value_len);
  746. if (res != 0) {
  747. goto error_put;
  748. }
  749. }
  750. }
  751. }
  752. if (new_value_len <= object_key->value_len) {
  753. void *replacement_value;
  754. replacement_value = malloc(new_value_len);
  755. if (!replacement_value)
  756. goto error_exit;
  757. free(object_key->value);
  758. object_key->value = replacement_value;
  759. }
  760. memcpy(object_key->value, new_value, new_value_len);
  761. object_key->value_len = new_value_len;
  762. }
  763. else {
  764. ret = -1;
  765. errno = ENOENT;
  766. }
  767. hdb_handle_put (&object_instance_database, object_handle);
  768. if (ret == 0)
  769. object_key_changed_notification(object_handle, key_name, key_len,
  770. new_value, new_value_len, OBJECT_KEY_REPLACED);
  771. return (ret);
  772. error_put:
  773. hdb_handle_put (&object_instance_database, object_handle);
  774. error_exit:
  775. return (-1);
  776. }
  777. static int object_priv_get (
  778. unsigned int object_handle,
  779. void **priv)
  780. {
  781. int res;
  782. struct object_instance *object_instance;
  783. res = hdb_handle_get (&object_instance_database,
  784. object_handle, (void *)&object_instance);
  785. if (res != 0) {
  786. goto error_exit;
  787. }
  788. *priv = object_instance->priv;
  789. hdb_handle_put (&object_instance_database, object_handle);
  790. return (0);
  791. error_exit:
  792. return (-1);
  793. }
  794. static int _dump_object(struct object_instance *instance, FILE *file, int depth)
  795. {
  796. struct list_head *list;
  797. int res;
  798. int i;
  799. struct object_instance *find_instance = NULL;
  800. struct object_key *object_key = NULL;
  801. char stringbuf1[1024];
  802. char stringbuf2[1024];
  803. memcpy(stringbuf1, instance->object_name, instance->object_name_len);
  804. stringbuf1[instance->object_name_len] = '\0';
  805. for (i=0; i<depth; i++)
  806. fprintf(file, " ");
  807. if (instance->object_handle != OBJECT_PARENT_HANDLE)
  808. fprintf(file, "%s {\n", stringbuf1);
  809. for (list = instance->key_head.next;
  810. list != &instance->key_head; list = list->next) {
  811. object_key = list_entry (list, struct object_key,
  812. list);
  813. memcpy(stringbuf1, object_key->key_name, object_key->key_len);
  814. stringbuf1[object_key->key_len] = '\0';
  815. memcpy(stringbuf2, object_key->value, object_key->value_len);
  816. stringbuf2[object_key->value_len] = '\0';
  817. for (i=0; i<depth+1; i++)
  818. fprintf(file, " ");
  819. fprintf(file, "%s: %s\n", stringbuf1, stringbuf2);
  820. }
  821. for (list = instance->child_head.next;
  822. list != &instance->child_head; list = list->next) {
  823. find_instance = list_entry (list, struct object_instance,
  824. child_list);
  825. res = _dump_object(find_instance, file, depth+1);
  826. if (res)
  827. return res;
  828. }
  829. for (i=0; i<depth; i++)
  830. fprintf(file, " ");
  831. if (instance->object_handle != OBJECT_PARENT_HANDLE)
  832. fprintf(file, "}\n");
  833. return 0;
  834. }
  835. static int object_key_iter_reset(unsigned int object_handle)
  836. {
  837. unsigned int res;
  838. struct object_instance *instance;
  839. res = hdb_handle_get (&object_instance_database,
  840. object_handle, (void *)&instance);
  841. if (res != 0) {
  842. goto error_exit;
  843. }
  844. instance->iter_key_list = &instance->key_head;
  845. hdb_handle_put (&object_instance_database, object_handle);
  846. return (0);
  847. error_exit:
  848. return (-1);
  849. }
  850. static int object_key_iter(unsigned int parent_object_handle,
  851. void **key_name,
  852. int *key_len,
  853. void **value,
  854. int *value_len)
  855. {
  856. unsigned int res;
  857. struct object_instance *instance;
  858. struct object_key *find_key = NULL;
  859. struct list_head *list;
  860. unsigned int found = 0;
  861. res = hdb_handle_get (&object_instance_database,
  862. parent_object_handle, (void *)&instance);
  863. if (res != 0) {
  864. goto error_exit;
  865. }
  866. res = -ENOENT;
  867. list = instance->iter_key_list->next;
  868. if (list != &instance->key_head) {
  869. find_key = list_entry (list, struct object_key, list);
  870. found = 1;
  871. }
  872. instance->iter_key_list = list;
  873. if (found) {
  874. *key_name = find_key->key_name;
  875. if (key_len)
  876. *key_len = find_key->key_len;
  877. *value = find_key->value;
  878. if (value_len)
  879. *value_len = find_key->value_len;
  880. res = 0;
  881. }
  882. else {
  883. res = -1;
  884. }
  885. hdb_handle_put (&object_instance_database, parent_object_handle);
  886. return (res);
  887. error_exit:
  888. return (-1);
  889. }
  890. static int object_iter_reset(unsigned int parent_object_handle)
  891. {
  892. unsigned int res;
  893. struct object_instance *instance;
  894. res = hdb_handle_get (&object_instance_database,
  895. parent_object_handle, (void *)&instance);
  896. if (res != 0) {
  897. goto error_exit;
  898. }
  899. instance->iter_list = &instance->child_head;
  900. hdb_handle_put (&object_instance_database, parent_object_handle);
  901. return (0);
  902. error_exit:
  903. return (-1);
  904. }
  905. static int object_iter(unsigned int parent_object_handle,
  906. void **object_name,
  907. int *name_len,
  908. unsigned int *object_handle)
  909. {
  910. unsigned int res;
  911. struct object_instance *instance;
  912. struct object_instance *find_instance = NULL;
  913. struct list_head *list;
  914. unsigned int found = 0;
  915. res = hdb_handle_get (&object_instance_database,
  916. parent_object_handle, (void *)&instance);
  917. if (res != 0) {
  918. goto error_exit;
  919. }
  920. res = -ENOENT;
  921. list = instance->iter_list->next;
  922. if (list != &instance->child_head) {
  923. find_instance = list_entry (list, struct object_instance,
  924. child_list);
  925. found = 1;
  926. }
  927. instance->iter_list = list;
  928. if (found) {
  929. *object_handle = find_instance->object_handle;
  930. *object_name = find_instance->object_name;
  931. *name_len = find_instance->object_name_len;
  932. res = 0;
  933. }
  934. else {
  935. res = -1;
  936. }
  937. return (res);
  938. error_exit:
  939. return (-1);
  940. }
  941. static int object_find_from(unsigned int parent_object_handle,
  942. unsigned int start_pos,
  943. void *object_name,
  944. int object_name_len,
  945. unsigned int *object_handle,
  946. unsigned int *next_pos)
  947. {
  948. unsigned int res;
  949. unsigned int pos = 0;
  950. struct object_instance *instance;
  951. struct object_instance *find_instance = NULL;
  952. struct list_head *list;
  953. unsigned int found = 0;
  954. res = hdb_handle_get (&object_instance_database,
  955. parent_object_handle, (void *)&instance);
  956. if (res != 0) {
  957. goto error_exit;
  958. }
  959. res = -ENOENT;
  960. for (list = instance->child_head.next;
  961. list != &instance->child_head; list = list->next) {
  962. find_instance = list_entry (list, struct object_instance,
  963. child_list);
  964. if ((find_instance->object_name_len == object_name_len) &&
  965. (memcmp (find_instance->object_name, object_name,
  966. object_name_len) == 0)) {
  967. if (pos++ == start_pos) {
  968. found = 1;
  969. break;
  970. }
  971. }
  972. }
  973. hdb_handle_put (&object_instance_database, parent_object_handle);
  974. if (found) {
  975. *object_handle = find_instance->object_handle;
  976. res = 0;
  977. }
  978. *next_pos = pos;
  979. return (res);
  980. error_exit:
  981. return (-1);
  982. }
  983. static int object_iter_from(unsigned int parent_object_handle,
  984. unsigned int start_pos,
  985. void **object_name,
  986. int *name_len,
  987. unsigned int *object_handle)
  988. {
  989. unsigned int res;
  990. unsigned int pos = 0;
  991. struct object_instance *instance;
  992. struct object_instance *find_instance = NULL;
  993. struct list_head *list;
  994. unsigned int found = 0;
  995. res = hdb_handle_get (&object_instance_database,
  996. parent_object_handle, (void *)&instance);
  997. if (res != 0) {
  998. goto error_exit;
  999. }
  1000. res = -ENOENT;
  1001. for (list = instance->child_head.next;
  1002. list != &instance->child_head; list = list->next) {
  1003. find_instance = list_entry (list, struct object_instance,
  1004. child_list);
  1005. if (pos++ == start_pos) {
  1006. found = 1;
  1007. break;
  1008. }
  1009. }
  1010. if (found) {
  1011. *object_handle = find_instance->object_handle;
  1012. *object_name = find_instance->object_name;
  1013. *name_len = find_instance->object_name_len;
  1014. res = 0;
  1015. }
  1016. else {
  1017. res = -1;
  1018. }
  1019. return (res);
  1020. error_exit:
  1021. return (-1);
  1022. }
  1023. static int object_key_iter_from(unsigned int parent_object_handle,
  1024. unsigned int start_pos,
  1025. void **key_name,
  1026. int *key_len,
  1027. void **value,
  1028. int *value_len)
  1029. {
  1030. unsigned int pos = 0;
  1031. unsigned int res;
  1032. struct object_instance *instance;
  1033. struct object_key *find_key = NULL;
  1034. struct list_head *list;
  1035. unsigned int found = 0;
  1036. res = hdb_handle_get (&object_instance_database,
  1037. parent_object_handle, (void *)&instance);
  1038. if (res != 0) {
  1039. goto error_exit;
  1040. }
  1041. res = -ENOENT;
  1042. for (list = instance->key_head.next;
  1043. list != &instance->key_head; list = list->next) {
  1044. find_key = list_entry (list, struct object_key, list);
  1045. if (pos++ == start_pos) {
  1046. found = 1;
  1047. break;
  1048. }
  1049. }
  1050. if (found) {
  1051. *key_name = find_key->key_name;
  1052. if (key_len)
  1053. *key_len = find_key->key_len;
  1054. *value = find_key->value;
  1055. if (value_len)
  1056. *value_len = find_key->value_len;
  1057. res = 0;
  1058. }
  1059. else {
  1060. res = -1;
  1061. }
  1062. hdb_handle_put (&object_instance_database, parent_object_handle);
  1063. return (res);
  1064. error_exit:
  1065. return (-1);
  1066. }
  1067. static int object_parent_get(unsigned int object_handle,
  1068. unsigned int *parent_handle)
  1069. {
  1070. struct object_instance *instance;
  1071. unsigned int res;
  1072. res = hdb_handle_get (&object_instance_database,
  1073. object_handle, (void *)&instance);
  1074. if (res != 0) {
  1075. return (res);
  1076. }
  1077. if (object_handle == OBJECT_PARENT_HANDLE)
  1078. *parent_handle = 0;
  1079. else
  1080. *parent_handle = instance->parent_handle;
  1081. hdb_handle_put (&object_instance_database, object_handle);
  1082. return (0);
  1083. }
  1084. static int object_track_start(unsigned int object_handle,
  1085. object_track_depth_t depth,
  1086. object_key_change_notify_fn_t key_change_notify_fn,
  1087. object_create_notify_fn_t object_create_notify_fn,
  1088. object_destroy_notify_fn_t object_destroy_notify_fn,
  1089. void * priv_data_pt)
  1090. {
  1091. struct object_instance *instance;
  1092. unsigned int res;
  1093. struct object_tracker * tracker_pt;
  1094. res = hdb_handle_get (&object_instance_database,
  1095. object_handle, (void *)&instance);
  1096. if (res != 0) {
  1097. return (res);
  1098. }
  1099. tracker_pt = malloc(sizeof(struct object_tracker));
  1100. tracker_pt->depth = depth;
  1101. tracker_pt->object_handle = object_handle;
  1102. tracker_pt->key_change_notify_fn = key_change_notify_fn;
  1103. tracker_pt->object_create_notify_fn = object_create_notify_fn;
  1104. tracker_pt->object_destroy_notify_fn = object_destroy_notify_fn;
  1105. tracker_pt->data_pt = priv_data_pt;
  1106. list_init(&tracker_pt->object_list);
  1107. list_init(&tracker_pt->tracker_list);
  1108. list_add(&tracker_pt->object_list, &instance->track_head);
  1109. list_add(&tracker_pt->tracker_list, &objdb_trackers_head);
  1110. hdb_handle_put (&object_instance_database, object_handle);
  1111. return (res);
  1112. }
  1113. static void object_track_stop(object_key_change_notify_fn_t key_change_notify_fn,
  1114. object_create_notify_fn_t object_create_notify_fn,
  1115. object_destroy_notify_fn_t object_destroy_notify_fn,
  1116. void * priv_data_pt)
  1117. {
  1118. struct object_instance *instance;
  1119. struct object_tracker * tracker_pt = NULL;
  1120. struct object_tracker * obj_tracker_pt = NULL;
  1121. struct list_head *list, *tmp_list;
  1122. struct list_head *obj_list, *tmp_obj_list;
  1123. unsigned int res;
  1124. /* go through the global list and find all the trackers to stop */
  1125. for (list = objdb_trackers_head.next, tmp_list = list->next;
  1126. list != &objdb_trackers_head; list = tmp_list, tmp_list = tmp_list->next) {
  1127. tracker_pt = list_entry (list, struct object_tracker, tracker_list);
  1128. if (tracker_pt && (tracker_pt->data_pt == priv_data_pt) &&
  1129. (tracker_pt->object_create_notify_fn == object_create_notify_fn) &&
  1130. (tracker_pt->object_destroy_notify_fn == object_destroy_notify_fn) &&
  1131. (tracker_pt->key_change_notify_fn == key_change_notify_fn)) {
  1132. /* get the object & take this tracker off of it's list. */
  1133. res = hdb_handle_get (&object_instance_database,
  1134. tracker_pt->object_handle, (void *)&instance);
  1135. if (res != 0) continue;
  1136. for (obj_list = instance->track_head.next, tmp_obj_list = obj_list->next;
  1137. obj_list != &instance->track_head; obj_list = tmp_obj_list, tmp_obj_list = tmp_obj_list->next) {
  1138. obj_tracker_pt = list_entry (obj_list, struct object_tracker, object_list);
  1139. if (obj_tracker_pt == tracker_pt) {
  1140. /* this is the tracker we are after. */
  1141. list_del(obj_list);
  1142. }
  1143. }
  1144. hdb_handle_put (&object_instance_database, tracker_pt->object_handle);
  1145. /* remove the tracker off of the global list */
  1146. list_del(list);
  1147. free(tracker_pt);
  1148. }
  1149. }
  1150. }
  1151. static int object_dump(unsigned int object_handle,
  1152. FILE *file)
  1153. {
  1154. struct object_instance *instance;
  1155. unsigned int res;
  1156. res = hdb_handle_get (&object_instance_database,
  1157. object_handle, (void *)&instance);
  1158. if (res != 0) {
  1159. return (res);
  1160. }
  1161. res = _dump_object(instance, file, -1);
  1162. hdb_handle_put (&object_instance_database, object_handle);
  1163. return (res);
  1164. }
  1165. static int object_write_config(char **error_string)
  1166. {
  1167. struct config_iface_ver0 **modules;
  1168. int num_modules;
  1169. int i;
  1170. int res;
  1171. main_get_config_modules(&modules, &num_modules);
  1172. for (i=0; i<num_modules; i++) {
  1173. if (modules[i]->config_writeconfig) {
  1174. res = modules[i]->config_writeconfig(&objdb_iface, error_string);
  1175. if (res)
  1176. return res;
  1177. }
  1178. }
  1179. return 0;
  1180. }
  1181. static int object_reload_config(int flush, char **error_string)
  1182. {
  1183. struct config_iface_ver0 **modules;
  1184. int num_modules;
  1185. int i;
  1186. int res;
  1187. main_get_config_modules(&modules, &num_modules);
  1188. /* phase 1. Each module should verify that it can reload the config
  1189. * and error out here if possible at all
  1190. */
  1191. for (i=0; i<num_modules; i++) {
  1192. if (modules[i]->config_verifyconfig) {
  1193. res = modules[i]->config_verifyconfig(&objdb_iface, error_string);
  1194. if (res)
  1195. return res;
  1196. }
  1197. }
  1198. /* phase 2. Do it.. */
  1199. for (i=0; i<num_modules; i++) {
  1200. if (modules[i]->config_reloadconfig) {
  1201. res = modules[i]->config_reloadconfig(&objdb_iface, flush, error_string);
  1202. if (res)
  1203. return res;
  1204. }
  1205. }
  1206. return 0;
  1207. }
  1208. struct objdb_iface_ver0 objdb_iface = {
  1209. .objdb_init = objdb_init,
  1210. .object_create = object_create,
  1211. .object_priv_set = object_priv_set,
  1212. .object_key_create = object_key_create,
  1213. .object_key_delete = object_key_delete,
  1214. .object_key_replace = object_key_replace,
  1215. .object_destroy = object_destroy,
  1216. .object_valid_set = object_valid_set,
  1217. .object_key_valid_set = object_key_valid_set,
  1218. .object_find_create = object_find_create,
  1219. .object_find_next = object_find_next,
  1220. .object_find_destroy = object_find_destroy,
  1221. .object_find_from = object_find_from,
  1222. .object_key_get = object_key_get,
  1223. .object_key_iter = object_key_iter,
  1224. .object_key_iter_reset = object_key_iter_reset,
  1225. .object_key_iter_from = object_key_iter_from,
  1226. .object_iter = object_iter,
  1227. .object_iter_reset = object_iter_reset,
  1228. .object_iter_from = object_iter_from,
  1229. .object_priv_get = object_priv_get,
  1230. .object_parent_get = object_parent_get,
  1231. .object_track_start = object_track_start,
  1232. .object_track_stop = object_track_stop,
  1233. .object_dump = object_dump,
  1234. .object_write_config = object_write_config,
  1235. .object_reload_config = object_reload_config,
  1236. };
  1237. struct lcr_iface objdb_iface_ver0[1] = {
  1238. {
  1239. .name = "objdb",
  1240. .version = 0,
  1241. .versions_replace = 0,
  1242. .versions_replace_count = 0,
  1243. .dependencies = 0,
  1244. .dependency_count = 0,
  1245. .constructor = NULL,
  1246. .destructor = NULL,
  1247. .interfaces = NULL,
  1248. }
  1249. };
  1250. struct lcr_comp objdb_comp_ver0 = {
  1251. .iface_count = 1,
  1252. .ifaces = objdb_iface_ver0
  1253. };
  1254. __attribute__ ((constructor)) static void objdb_comp_register (void) {
  1255. lcr_interfaces_set (&objdb_iface_ver0[0], &objdb_iface);
  1256. lcr_component_register (&objdb_comp_ver0);
  1257. }