libcollection  0.2.91
 All Data Structures Functions Typedefs Groups Pages
collection.h
1 /*
2  COLLECTION LIBRARY
3 
4  Header file for collection interface.
5 
6  Copyright (C) Dmitri Pal <dpal@redhat.com> 2009
7 
8  Collection Library is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  Collection Library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with Collection Library. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #ifndef COLLECTION_H
23 #define COLLECTION_H
24 
25 #include <stdint.h>
26 
108 #ifndef EOK
109 #define EOK 0
110 #endif
111 
120 #define COL_CLASS_DEFAULT 0
121 
127 #define COL_NOMATCH 0
128 
133 #define COL_MATCH 1
134 
135 
145 #define COL_TYPE_STRING 0x00000001
146 
147 #define COL_TYPE_BINARY 0x00000002
148 
149 #define COL_TYPE_INTEGER 0x00000004
150 
151 #define COL_TYPE_UNSIGNED 0x00000008
152 
153 #define COL_TYPE_LONG 0x00000010
154 
155 #define COL_TYPE_ULONG 0x00000020
156 
157 #define COL_TYPE_DOUBLE 0x00000040
158 
159 #define COL_TYPE_BOOL 0x00000080
160 
166 #define COL_TYPE_COLLECTION 0x00000100
167 
173 #define COL_TYPE_COLLECTIONREF 0x00000200
174 
179 #define COL_TYPE_END 0x10000000
180 
186 #define COL_TYPE_ANY 0x0FFFFFFF
187 
200 #define COL_ADD_MODE_REFERENCE 0
201 
211 #define COL_ADD_MODE_EMBED 1
212 
217 #define COL_ADD_MODE_CLONE 2
218 
225 #define COL_ADD_MODE_FLAT 3
226 
238 #define COL_ADD_MODE_FLATDOT 4
239 
261 #define COL_TRAVERSE_DEFAULT 0x00000000
262 
269 #define COL_TRAVERSE_ONELEVEL 0x00000001
270 
280 #define COL_TRAVERSE_END 0x00000002
281 
282 #define COL_TRAVERSE_IGNORE 0x00000004
283 
296 #define COL_TRAVERSE_FLAT 0x00000008
297 
322 #define COL_TRAVERSE_SHOWSUB 0x00010000
323 
330 #define COL_TRAVERSE_ONLYSUB 0x00020000
331 
353 #define COL_COPY_NORMAL 0
354 
359 #define COL_COPY_FLAT 1
360 
365 #define COL_COPY_FLATDOT 2
366 
367 #define COL_COPY_KEEPREF 3
368 
369 #define COL_COPY_TOP 4
370 
385 #define COL_SORT_ASC 0x00000000
386 
387 #define COL_SORT_DESC 0x00000001
388 
389 #define COL_SORT_SUB 0x00000002
390 
395 #define COL_SORT_MYSUB 0x00000004
396 
401 /* Public declaration of the private data */
402 #ifndef COLLECTION_PRIV_H
403 
431 struct collection_iterator;
432 
433 #endif /* COLLECTION_PRIV_H */
434 
435 
472 int col_create_collection(struct collection_item **ci,
473  const char *name,
474  unsigned cclass);
475 
484 void col_destroy_collection(struct collection_item *ci);
485 
508 typedef void (*col_item_cleanup_fn)(const char *property,
509  int property_len,
510  int type,
511  void *data,
512  int length,
513  void *custom_data);
514 
538  void *custom_data);
539 
564 typedef int (*col_copy_cb)(struct collection_item *item,
565  void *ext_data,
566  int *skip);
567 
594 int col_copy_collection_with_cb(struct collection_item **col_copy,
595  struct collection_item *col_to_copy,
596  const char *name_to_use,
597  int copy_mode,
598  col_copy_cb copy_cb,
599  void *ext_data);
600 
618 int col_copy_collection(struct collection_item **col_copy,
619  struct collection_item *col_to_copy,
620  const char *name_to_use,
621  int copy_mode);
622 
655  const char *subcollection,
656  const char *as_property,
657  struct collection_item *ci_to_add,
658  int mode);
685 typedef int (*col_item_fn)(const char *property,
686  int property_len,
687  int type,
688  void *data,
689  int length,
690  void *custom_data,
691  int *stop);
692 
715  int mode_flags,
716  col_item_fn item_handler,
717  void *custom_data);
718 
753 int col_get_item_and_do(struct collection_item *ci,
754  const char *property_to_find,
755  int type,
756  int mode_flags,
757  col_item_fn item_handler,
758  void *custom_data);
759 
798 int col_get_item(struct collection_item *ci,
799  const char *property_to_find,
800  int type,
801  int mode_flags,
802  struct collection_item **item);
803 
833 int col_sort_collection(struct collection_item *col,
834  unsigned cmp_flags,
835  unsigned sort_flags);
836 
868 int col_delete_property(struct collection_item *ci,
869  const char *property_to_find,
870  int type,
871  int mode_flags);
872 
898  const char *property_to_find,
899  int type,
900  int mode_flags,
901  int *found);
902 
925  struct collection_item **acceptor,
926  const char *col_to_find);
927 
948  struct collection_item **acceptor);
949 
950 
951 
981  unsigned *cclass);
982 
997  unsigned cclass);
998 
1018  unsigned *count);
1019 
1020 
1034 int col_is_of_class(struct collection_item *ci,
1035  unsigned cclass);
1036 
1037 
1110 int col_add_str_property(struct collection_item *ci,
1111  const char *subcollection,
1112  const char *property,
1113  const char *string,
1114  int length);
1115 
1143  const char *subcollection,
1144  const char *property,
1145  void *binary_data,
1146  int length);
1147 
1173 int col_add_int_property(struct collection_item *ci,
1174  const char *subcollection,
1175  const char *property,
1176  int32_t number);
1177 
1204  const char *subcollection,
1205  const char *property,
1206  uint32_t number);
1207 
1233 int col_add_long_property(struct collection_item *ci,
1234  const char *subcollection,
1235  const char *property,
1236  int64_t number);
1237 
1264  const char *subcollection,
1265  const char *property,
1266  uint64_t number);
1267 
1294  const char *subcollection,
1295  const char *property,
1296  double number);
1322 int col_add_bool_property(struct collection_item *ci,
1323  const char *subcollection,
1324  const char *property,
1325  unsigned char logical);
1326 
1327 
1355 int col_add_any_property(struct collection_item *ci,
1356  const char *subcollection,
1357  const char *property,
1358  int type,
1359  void *data,
1360  int length);
1361 
1422  const char *subcollection,
1423  const char *property,
1424  char *string, int length,
1425  struct collection_item **ret_ref);
1426 
1456  const char *subcollection,
1457  const char *property,
1458  void *binary_data, int length,
1459  struct collection_item **ret_ref);
1460 
1489  const char *subcollection,
1490  const char *property, int32_t number,
1491  struct collection_item **ret_ref);
1492 
1521  const char *subcollection,
1522  const char *property, uint32_t number,
1523  struct collection_item **ret_ref);
1524 
1553  const char *subcollection,
1554  const char *property, int64_t number,
1555  struct collection_item **ret_ref);
1556 
1585  const char *subcollection,
1586  const char *property, uint64_t number,
1587  struct collection_item **ret_ref);
1588 
1617  const char *subcollection,
1618  const char *property, double number,
1619  struct collection_item **ret_ref);
1620 
1649  const char *subcollection,
1650  const char *property, unsigned char logical,
1651  struct collection_item **ret_ref);
1652 
1653 
1684  const char *subcollection,
1685  const char *property,
1686  int type, void *data, int length,
1687  struct collection_item **ret_ref);
1688 
1744  const char *subcollection,
1745  int disposition,
1746  const char *refprop,
1747  int idx,
1748  unsigned flags,
1749  const char *property,
1750  const char *string,
1751  int length);
1752 
1755  const char *subcollection,
1756  int disposition,
1757  const char *refprop,
1758  int idx,
1759  unsigned flags,
1760  const char *property,
1761  void *binary_data,
1762  int length);
1763 
1766  const char *subcollection,
1767  int disposition,
1768  const char *refprop,
1769  int idx,
1770  unsigned flags,
1771  const char *property,
1772  int32_t number);
1773 
1776  const char *subcollection,
1777  int disposition,
1778  const char *refprop,
1779  int idx,
1780  unsigned flags,
1781  const char *property,
1782  uint32_t number);
1783 
1786  const char *subcollection,
1787  int disposition,
1788  const char *refprop,
1789  int idx,
1790  unsigned flags,
1791  const char *property,
1792  int64_t number);
1793 
1796  const char *subcollection,
1797  int disposition,
1798  const char *refprop,
1799  int idx,
1800  unsigned flags,
1801  const char *property,
1802  uint64_t number);
1803 
1806  const char *subcollection,
1807  int disposition,
1808  const char *refprop,
1809  int idx,
1810  unsigned flags,
1811  const char *property,
1812  double number);
1813 
1816  const char *subcollection,
1817  int disposition,
1818  const char *refprop,
1819  int idx,
1820  unsigned flags,
1821  const char *property,
1822  unsigned char logical);
1823 
1826  const char *subcollection,
1827  int disposition,
1828  const char *refprop,
1829  int idx,
1830  unsigned flags,
1831  const char *property,
1832  const char *string,
1833  int length,
1834  struct collection_item **ret_ref);
1835 
1838  const char *subcollection,
1839  int disposition,
1840  const char *refprop,
1841  int idx,
1842  unsigned flags,
1843  const char *property,
1844  void *binary_data,
1845  int length,
1846  struct collection_item **ret_ref);
1847 
1850  const char *subcollection,
1851  int disposition,
1852  const char *refprop,
1853  int idx,
1854  unsigned flags,
1855  const char *property,
1856  int32_t number,
1857  struct collection_item **ret_ref);
1858 
1861  const char *subcollection,
1862  int disposition,
1863  const char *refprop,
1864  int idx,
1865  unsigned flags,
1866  const char *property,
1867  uint32_t number,
1868  struct collection_item **ret_ref);
1869 
1872  const char *subcollection,
1873  int disposition,
1874  const char *refprop,
1875  int idx,
1876  unsigned flags,
1877  const char *property,
1878  int64_t number,
1879  struct collection_item **ret_ref);
1880 
1883  const char *subcollection,
1884  int disposition,
1885  const char *refprop,
1886  int idx,
1887  unsigned flags,
1888  const char *property,
1889  uint64_t number,
1890  struct collection_item **ret_ref);
1891 
1897  const char *subcollection,
1898  int disposition,
1899  const char *refprop,
1900  int idx,
1901  unsigned flags,
1902  const char *property,
1903  double number,
1904  struct collection_item **ret_ref);
1905 
1908  const char *subcollection,
1909  int disposition,
1910  const char *refprop,
1911  int idx,
1912  unsigned flags,
1913  const char *property,
1914  unsigned char logical,
1915  struct collection_item **ret_ref);
1916 
1919  const char *subcollection,
1920  int disposition,
1921  const char *refprop,
1922  int idx,
1923  unsigned flags,
1924  const char *property,
1925  int type,
1926  const void *data,
1927  int length,
1928  struct collection_item **ret_ref);
1929 
1930 
1980  const char *property,
1981  int mode_flags,
1982  char *string,
1983  int length);
1988  const char *property,
1989  int mode_flags,
1990  void *binary_data,
1991  int length);
1996  const char *property,
1997  int mode_flags,
1998  int32_t number);
2003  const char *property,
2004  int mode_flags,
2005  uint32_t number);
2010  const char *property,
2011  int mode_flags,
2012  int64_t number);
2017  const char *property,
2018  int mode_flags,
2019  uint64_t number);
2024  const char *property,
2025  int mode_flags,
2026  double number);
2031  const char *property,
2032  int mode_flags,
2033  unsigned char logical);
2034 
2042 int col_update_property(struct collection_item *ci,
2043  const char *property,
2044  int type,
2045  void *new_data,
2046  int length,
2047  int mode_flags);
2048 
2049 
2081 #define COL_CMPIN_PROP_EQU 0x000000004
2082 
2083 #define COL_CMPIN_PROP_BEG 0x000000005
2084 
2085 #define COL_CMPIN_PROP_MID 0x000000006
2086 
2087 #define COL_CMPIN_PROP_END 0x000000007
2088 
2100 #define COL_CMPIN_PROP_DOT 0x000000008
2101 
2103 #define COL_CMPIN_PROP_LEN 0x000000010
2104 
2106 #define COL_CMPIN_TYPE 0x000000020
2107 
2109 #define COL_CMPIN_DATA_LEN 0x000000040
2110 
2119 #define COL_CMPIN_DATA 0x000000080
2120 
2141 #define COL_CMPOUT_PROP_STR 0x00000001
2142 
2149 #define COL_CMPOUT_PROP_LEN 0x00000002
2150 
2156 #define COL_CMPOUT_DATA_LEN 0x00000004
2157 
2165 #define COL_CMPOUT_DATA 0x00000008
2166 
2192 #define COL_DSP_END 0
2193 
2203 #define COL_DSP_FRONT 1
2204 
2216 #define COL_DSP_BEFORE 2
2217 
2229 #define COL_DSP_AFTER 3
2230 
2248 #define COL_DSP_INDEX 4
2249 
2266 #define COL_DSP_FIRSTDUP 5
2267 
2286 #define COL_DSP_LASTDUP 6
2287 
2316 #define COL_DSP_NDUP 7
2317 
2336 #define COL_INSERT_NOCHECK 0
2337 
2341 #define COL_INSERT_DUPOVER 1
2342 
2346 #define COL_INSERT_DUPOVERT 2
2347 
2348 #define COL_INSERT_DUPERROR 3
2349 
2353 #define COL_INSERT_DUPERRORT 4
2354 
2357 #define COL_INSERT_DUPMOVE 5
2358 
2361 #define COL_INSERT_DUPMOVET 6
2362 
2389 const char *col_get_item_property(struct collection_item *ci,
2390  int *property_len);
2391 
2404 int col_get_item_type(struct collection_item *ci);
2405 
2419 int col_get_item_length(struct collection_item *ci);
2420 
2433 void *col_get_item_data(struct collection_item *ci);
2434 
2454 uint64_t col_get_item_hash(struct collection_item *ci);
2455 
2479 uint64_t col_make_hash(const char *string, int sub_len, int *length);
2480 
2481 
2508 int col_compare_items(struct collection_item *first,
2509  struct collection_item *second,
2510  unsigned in_flags,
2511  unsigned *out_flags);
2512 
2513 
2514 
2549 int col_modify_item(struct collection_item *item,
2550  const char *property,
2551  int type,
2552  const void *data,
2553  int length);
2554 
2572 int col_modify_item_property(struct collection_item *item,
2573  const char *property);
2574 
2588 int col_modify_str_item(struct collection_item *item,
2589  const char *property,
2590  const char *string,
2591  int length);
2602 int col_modify_binary_item(struct collection_item *item,
2603  const char *property,
2604  void *binary_data,
2605  int length);
2616 int col_modify_bool_item(struct collection_item *item,
2617  const char *property,
2618  unsigned char logical);
2629 int col_modify_int_item(struct collection_item *item,
2630  const char *property,
2631  int32_t number);
2642 int col_modify_long_item(struct collection_item *item,
2643  const char *property,
2644  int64_t number);
2655 int col_modify_ulong_item(struct collection_item *item,
2656  const char *property,
2657  uint64_t number);
2668 int col_modify_unsigned_item(struct collection_item *item,
2669  const char *property,
2670  uint32_t number);
2681 int col_modify_double_item(struct collection_item *item,
2682  const char *property,
2683  double number);
2684 
2748 int col_extract_item(struct collection_item *ci,
2749  const char *subcollection,
2750  int disposition,
2751  const char *refprop,
2752  int idx,
2753  int type,
2754  struct collection_item **ret_ref);
2755 
2797  int disposition,
2798  const char *refprop,
2799  int idx,
2800  int type,
2801  struct collection_item **ret_ref);
2802 
2850 int col_remove_item(struct collection_item *ci,
2851  const char *subcollection,
2852  int disposition,
2853  const char *refprop,
2854  int idx,
2855  int type);
2856 
2857 
2897  int disposition,
2898  const char *refprop,
2899  int idx,
2900  int type);
2901 
2961 int col_insert_item(struct collection_item *ci,
2962  const char *subcollection,
2963  struct collection_item *item,
2964  int disposition,
2965  const char *refprop,
2966  int idx,
2967  unsigned flags);
2968 
3010  struct collection_item *item,
3011  int disposition,
3012  const char *refprop,
3013  int idx,
3014  unsigned flags);
3015 
3016 
3017 
3031 void col_delete_item(struct collection_item *item);
3032 
3067 int col_bind_iterator(struct collection_iterator **iterator,
3068  struct collection_item *ci,
3069  int mode_flags);
3070 
3076 void col_unbind_iterator(struct collection_iterator *iterator);
3077 
3098 int col_iterate_collection(struct collection_iterator *iterator,
3099  struct collection_item **item);
3100 
3118 int col_iterate_up(struct collection_iterator *iterator, unsigned level);
3119 
3151 int col_get_iterator_depth(struct collection_iterator *iterator, int *depth);
3152 
3167 int col_get_item_depth(struct collection_iterator *iterator, int *depth);
3168 
3217 void col_pin_iterator(struct collection_iterator *iterator);
3218 
3231 void col_rewind_iterator(struct collection_iterator *iterator);
3232 
3233 
3242 #endif