00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef COLLECTION_H
00023 #define COLLECTION_H
00024
00025 #include <stdint.h>
00026
00108 #ifndef EOK
00109 #define EOK 0
00110 #endif
00111
00120 #define COL_CLASS_DEFAULT 0
00121
00127 #define COL_NOMATCH 0
00128
00133 #define COL_MATCH 1
00134
00135
00145 #define COL_TYPE_STRING 0x00000001
00146
00147 #define COL_TYPE_BINARY 0x00000002
00148
00149 #define COL_TYPE_INTEGER 0x00000004
00150
00151 #define COL_TYPE_UNSIGNED 0x00000008
00152
00153 #define COL_TYPE_LONG 0x00000010
00154
00155 #define COL_TYPE_ULONG 0x00000020
00156
00157 #define COL_TYPE_DOUBLE 0x00000040
00158
00159 #define COL_TYPE_BOOL 0x00000080
00160
00166 #define COL_TYPE_COLLECTION 0x00000100
00167
00173 #define COL_TYPE_COLLECTIONREF 0x00000200
00174
00179 #define COL_TYPE_END 0x10000000
00180
00186 #define COL_TYPE_ANY 0x0FFFFFFF
00187
00200 #define COL_ADD_MODE_REFERENCE 0
00201
00211 #define COL_ADD_MODE_EMBED 1
00212
00217 #define COL_ADD_MODE_CLONE 2
00218
00225 #define COL_ADD_MODE_FLAT 3
00226
00238 #define COL_ADD_MODE_FLATDOT 4
00239
00261 #define COL_TRAVERSE_DEFAULT 0x00000000
00262
00269 #define COL_TRAVERSE_ONELEVEL 0x00000001
00270
00280 #define COL_TRAVERSE_END 0x00000002
00281
00282 #define COL_TRAVERSE_IGNORE 0x00000004
00283
00296 #define COL_TRAVERSE_FLAT 0x00000008
00297
00322 #define COL_TRAVERSE_SHOWSUB 0x00010000
00323
00330 #define COL_TRAVERSE_ONLYSUB 0x00020000
00331
00353 #define COL_COPY_NORMAL 0
00354
00359 #define COL_COPY_FLAT 1
00360
00365 #define COL_COPY_FLATDOT 2
00366
00367 #define COL_COPY_KEEPREF 3
00368
00369 #define COL_COPY_TOP 4
00370
00385 #define COL_SORT_ASC 0x00000000
00386
00387 #define COL_SORT_DESC 0x00000001
00388
00389 #define COL_SORT_SUB 0x00000002
00390
00395 #define COL_SORT_MYSUB 0x00000004
00396
00401
00402 #ifndef COLLECTION_PRIV_H
00403
00418 struct collection_item;
00431 struct collection_iterator;
00432
00433 #endif
00434
00435
00472 int col_create_collection(struct collection_item **ci,
00473 const char *name,
00474 unsigned cclass);
00475
00484 void col_destroy_collection(struct collection_item *ci);
00485
00507 typedef void (*col_item_cleanup_fn)(const char *property,
00508 int property_len,
00509 int type,
00510 void *data,
00511 int length,
00512 void *custom_data);
00513
00535 void col_destroy_collection_with_cb(struct collection_item *ci,
00536 col_item_cleanup_fn cb,
00537 void *custom_data);
00538
00563 typedef int (*col_copy_cb)(struct collection_item *item,
00564 void *ext_data,
00565 int *skip);
00566
00593 int col_copy_collection_with_cb(struct collection_item **col_copy,
00594 struct collection_item *col_to_copy,
00595 const char *name_to_use,
00596 int copy_mode,
00597 col_copy_cb copy_cb,
00598 void *ext_data);
00599
00617 int col_copy_collection(struct collection_item **col_copy,
00618 struct collection_item *col_to_copy,
00619 const char *name_to_use,
00620 int copy_mode);
00621
00653 int col_add_collection_to_collection(struct collection_item *ci,
00654 const char *subcollection,
00655 const char *as_property,
00656 struct collection_item *ci_to_add,
00657 int mode);
00684 typedef int (*col_item_fn)(const char *property,
00685 int property_len,
00686 int type,
00687 void *data,
00688 int length,
00689 void *custom_data,
00690 int *stop);
00691
00713 int col_traverse_collection(struct collection_item *ci,
00714 int mode_flags,
00715 col_item_fn item_handler,
00716 void *custom_data);
00717
00752 int col_get_item_and_do(struct collection_item *ci,
00753 const char *property_to_find,
00754 int type,
00755 int mode_flags,
00756 col_item_fn item_handler,
00757 void *custom_data);
00758
00797 int col_get_item(struct collection_item *ci,
00798 const char *property_to_find,
00799 int type,
00800 int mode_flags,
00801 struct collection_item **item);
00802
00832 int col_sort_collection(struct collection_item *col,
00833 unsigned cmp_flags,
00834 unsigned sort_flags);
00835
00867 int col_delete_property(struct collection_item *ci,
00868 const char *property_to_find,
00869 int type,
00870 int mode_flags);
00871
00896 int col_is_item_in_collection(struct collection_item *ci,
00897 const char *property_to_find,
00898 int type,
00899 int mode_flags,
00900 int *found);
00901
00923 int col_get_collection_reference(struct collection_item *ci,
00924 struct collection_item **acceptor,
00925 const char *col_to_find);
00926
00946 int col_get_reference_from_item(struct collection_item *item,
00947 struct collection_item **acceptor);
00948
00949
00950
00979 int col_get_collection_class(struct collection_item *ci,
00980 unsigned *cclass);
00981
00995 int col_set_collection_class(struct collection_item *ci,
00996 unsigned cclass);
00997
01016 int col_get_collection_count(struct collection_item *ci,
01017 unsigned *count);
01018
01019
01033 int col_is_of_class(struct collection_item *ci,
01034 unsigned cclass);
01035
01036
01109 int col_add_str_property(struct collection_item *ci,
01110 const char *subcollection,
01111 const char *property,
01112 const char *string,
01113 int length);
01114
01141 int col_add_binary_property(struct collection_item *ci,
01142 const char *subcollection,
01143 const char *property,
01144 void *binary_data,
01145 int length);
01146
01172 int col_add_int_property(struct collection_item *ci,
01173 const char *subcollection,
01174 const char *property,
01175 int32_t number);
01176
01202 int col_add_unsigned_property(struct collection_item *ci,
01203 const char *subcollection,
01204 const char *property,
01205 uint32_t number);
01206
01232 int col_add_long_property(struct collection_item *ci,
01233 const char *subcollection,
01234 const char *property,
01235 int64_t number);
01236
01262 int col_add_ulong_property(struct collection_item *ci,
01263 const char *subcollection,
01264 const char *property,
01265 uint64_t number);
01266
01292 int col_add_double_property(struct collection_item *ci,
01293 const char *subcollection,
01294 const char *property,
01295 double number);
01321 int col_add_bool_property(struct collection_item *ci,
01322 const char *subcollection,
01323 const char *property,
01324 unsigned char logical);
01325
01326
01354 int col_add_any_property(struct collection_item *ci,
01355 const char *subcollection,
01356 const char *property,
01357 int type,
01358 void *data,
01359 int length);
01360
01420 int col_add_str_property_with_ref(struct collection_item *ci,
01421 const char *subcollection,
01422 const char *property,
01423 char *string, int length,
01424 struct collection_item **ret_ref);
01425
01454 int col_add_binary_property_with_ref(struct collection_item *ci,
01455 const char *subcollection,
01456 const char *property,
01457 void *binary_data, int length,
01458 struct collection_item **ret_ref);
01459
01487 int col_add_int_property_with_ref(struct collection_item *ci,
01488 const char *subcollection,
01489 const char *property, int32_t number,
01490 struct collection_item **ret_ref);
01491
01519 int col_add_unsigned_property_with_ref(struct collection_item *ci,
01520 const char *subcollection,
01521 const char *property, uint32_t number,
01522 struct collection_item **ret_ref);
01523
01551 int col_add_long_property_with_ref(struct collection_item *ci,
01552 const char *subcollection,
01553 const char *property, int64_t number,
01554 struct collection_item **ret_ref);
01555
01583 int col_add_ulong_property_with_ref(struct collection_item *ci,
01584 const char *subcollection,
01585 const char *property, uint64_t number,
01586 struct collection_item **ret_ref);
01587
01615 int col_add_double_property_with_ref(struct collection_item *ci,
01616 const char *subcollection,
01617 const char *property, double number,
01618 struct collection_item **ret_ref);
01619
01647 int col_add_bool_property_with_ref(struct collection_item *ci,
01648 const char *subcollection,
01649 const char *property, unsigned char logical,
01650 struct collection_item **ret_ref);
01651
01652
01682 int col_add_any_property_with_ref(struct collection_item *ci,
01683 const char *subcollection,
01684 const char *property,
01685 int type, void *data, int length,
01686 struct collection_item **ret_ref);
01687
01742 int col_insert_str_property(struct collection_item *ci,
01743 const char *subcollection,
01744 int disposition,
01745 const char *refprop,
01746 int idx,
01747 unsigned flags,
01748 const char *property,
01749 const char *string,
01750 int length);
01751
01753 int col_insert_binary_property(struct collection_item *ci,
01754 const char *subcollection,
01755 int disposition,
01756 const char *refprop,
01757 int idx,
01758 unsigned flags,
01759 const char *property,
01760 void *binary_data,
01761 int length);
01762
01764 int col_insert_int_property(struct collection_item *ci,
01765 const char *subcollection,
01766 int disposition,
01767 const char *refprop,
01768 int idx,
01769 unsigned flags,
01770 const char *property,
01771 int32_t number);
01772
01774 int col_insert_unsigned_property(struct collection_item *ci,
01775 const char *subcollection,
01776 int disposition,
01777 const char *refprop,
01778 int idx,
01779 unsigned flags,
01780 const char *property,
01781 uint32_t number);
01782
01784 int col_insert_long_property(struct collection_item *ci,
01785 const char *subcollection,
01786 int disposition,
01787 const char *refprop,
01788 int idx,
01789 unsigned flags,
01790 const char *property,
01791 int64_t number);
01792
01794 int col_insert_ulong_property(struct collection_item *ci,
01795 const char *subcollection,
01796 int disposition,
01797 const char *refprop,
01798 int idx,
01799 unsigned flags,
01800 const char *property,
01801 uint64_t number);
01802
01804 int col_insert_double_property(struct collection_item *ci,
01805 const char *subcollection,
01806 int disposition,
01807 const char *refprop,
01808 int idx,
01809 unsigned flags,
01810 const char *property,
01811 double number);
01812
01814 int col_insert_bool_property(struct collection_item *ci,
01815 const char *subcollection,
01816 int disposition,
01817 const char *refprop,
01818 int idx,
01819 unsigned flags,
01820 const char *property,
01821 unsigned char logical);
01822
01824 int col_insert_str_property_with_ref(struct collection_item *ci,
01825 const char *subcollection,
01826 int disposition,
01827 const char *refprop,
01828 int idx,
01829 unsigned flags,
01830 const char *property,
01831 const char *string,
01832 int length,
01833 struct collection_item **ret_ref);
01834
01836 int col_insert_binary_property_with_ref(struct collection_item *ci,
01837 const char *subcollection,
01838 int disposition,
01839 const char *refprop,
01840 int idx,
01841 unsigned flags,
01842 const char *property,
01843 void *binary_data,
01844 int length,
01845 struct collection_item **ret_ref);
01846
01848 int col_insert_int_property_with_ref(struct collection_item *ci,
01849 const char *subcollection,
01850 int disposition,
01851 const char *refprop,
01852 int idx,
01853 unsigned flags,
01854 const char *property,
01855 int32_t number,
01856 struct collection_item **ret_ref);
01857
01859 int col_insert_unsigned_property_with_ref(struct collection_item *ci,
01860 const char *subcollection,
01861 int disposition,
01862 const char *refprop,
01863 int idx,
01864 unsigned flags,
01865 const char *property,
01866 uint32_t number,
01867 struct collection_item **ret_ref);
01868
01870 int col_insert_long_property_with_ref(struct collection_item *ci,
01871 const char *subcollection,
01872 int disposition,
01873 const char *refprop,
01874 int idx,
01875 unsigned flags,
01876 const char *property,
01877 int64_t number,
01878 struct collection_item **ret_ref);
01879
01881 int col_insert_ulong_property_with_ref(struct collection_item *ci,
01882 const char *subcollection,
01883 int disposition,
01884 const char *refprop,
01885 int idx,
01886 unsigned flags,
01887 const char *property,
01888 uint64_t number,
01889 struct collection_item **ret_ref);
01890
01895 int col_insert_double_property_with_ref(struct collection_item *ci,
01896 const char *subcollection,
01897 int disposition,
01898 const char *refprop,
01899 int idx,
01900 unsigned flags,
01901 const char *property,
01902 double number,
01903 struct collection_item **ret_ref);
01904
01906 int col_insert_bool_property_with_ref(struct collection_item *ci,
01907 const char *subcollection,
01908 int disposition,
01909 const char *refprop,
01910 int idx,
01911 unsigned flags,
01912 const char *property,
01913 unsigned char logical,
01914 struct collection_item **ret_ref);
01915
01917 int col_insert_property_with_ref(struct collection_item *ci,
01918 const char *subcollection,
01919 int disposition,
01920 const char *refprop,
01921 int idx,
01922 unsigned flags,
01923 const char *property,
01924 int type,
01925 const void *data,
01926 int length,
01927 struct collection_item **ret_ref);
01928
01929
01978 int col_update_str_property(struct collection_item *ci,
01979 const char *property,
01980 int mode_flags,
01981 char *string,
01982 int length);
01986 int col_update_binary_property(struct collection_item *ci,
01987 const char *property,
01988 int mode_flags,
01989 void *binary_data,
01990 int length);
01994 int col_update_int_property(struct collection_item *ci,
01995 const char *property,
01996 int mode_flags,
01997 int32_t number);
02001 int col_update_unsigned_property(struct collection_item *ci,
02002 const char *property,
02003 int mode_flags,
02004 uint32_t number);
02008 int col_update_long_property(struct collection_item *ci,
02009 const char *property,
02010 int mode_flags,
02011 int64_t number);
02015 int col_update_ulong_property(struct collection_item *ci,
02016 const char *property,
02017 int mode_flags,
02018 uint64_t number);
02022 int col_update_double_property(struct collection_item *ci,
02023 const char *property,
02024 int mode_flags,
02025 double number);
02029 int col_update_bool_property(struct collection_item *ci,
02030 const char *property,
02031 int mode_flags,
02032 unsigned char logical);
02033
02041 int col_update_property(struct collection_item *ci,
02042 const char *property,
02043 int type,
02044 void *new_data,
02045 int length,
02046 int mode_flags);
02047
02048
02080 #define COL_CMPIN_PROP_EQU 0x000000004
02081
02082 #define COL_CMPIN_PROP_BEG 0x000000005
02083
02084 #define COL_CMPIN_PROP_MID 0x000000006
02085
02086 #define COL_CMPIN_PROP_END 0x000000007
02087
02099 #define COL_CMPIN_PROP_DOT 0x000000008
02100
02102 #define COL_CMPIN_PROP_LEN 0x000000010
02103
02105 #define COL_CMPIN_TYPE 0x000000020
02106
02108 #define COL_CMPIN_DATA_LEN 0x000000040
02109
02118 #define COL_CMPIN_DATA 0x000000080
02119
02140 #define COL_CMPOUT_PROP_STR 0x00000001
02141
02148 #define COL_CMPOUT_PROP_LEN 0x00000002
02149
02155 #define COL_CMPOUT_DATA_LEN 0x00000004
02156
02164 #define COL_CMPOUT_DATA 0x00000008
02165
02191 #define COL_DSP_END 0
02192
02202 #define COL_DSP_FRONT 1
02203
02215 #define COL_DSP_BEFORE 2
02216
02228 #define COL_DSP_AFTER 3
02229
02247 #define COL_DSP_INDEX 4
02248
02265 #define COL_DSP_FIRSTDUP 5
02266
02285 #define COL_DSP_LASTDUP 6
02286
02315 #define COL_DSP_NDUP 7
02316
02335 #define COL_INSERT_NOCHECK 0
02336
02340 #define COL_INSERT_DUPOVER 1
02341
02345 #define COL_INSERT_DUPOVERT 2
02346
02347 #define COL_INSERT_DUPERROR 3
02348
02352 #define COL_INSERT_DUPERRORT 4
02353
02356 #define COL_INSERT_DUPMOVE 5
02357
02360 #define COL_INSERT_DUPMOVET 6
02361
02388 const char *col_get_item_property(struct collection_item *ci,
02389 int *property_len);
02390
02403 int col_get_item_type(struct collection_item *ci);
02404
02418 int col_get_item_length(struct collection_item *ci);
02419
02432 void *col_get_item_data(struct collection_item *ci);
02433
02453 uint64_t col_get_item_hash(struct collection_item *ci);
02454
02478 uint64_t col_make_hash(const char *string, int sub_len, int *length);
02479
02480
02507 int col_compare_items(struct collection_item *first,
02508 struct collection_item *second,
02509 unsigned in_flags,
02510 unsigned *out_flags);
02511
02512
02513
02548 int col_modify_item(struct collection_item *item,
02549 const char *property,
02550 int type,
02551 const void *data,
02552 int length);
02553
02571 int col_modify_item_property(struct collection_item *item,
02572 const char *property);
02573
02587 int col_modify_str_item(struct collection_item *item,
02588 const char *property,
02589 const char *string,
02590 int length);
02601 int col_modify_binary_item(struct collection_item *item,
02602 const char *property,
02603 void *binary_data,
02604 int length);
02615 int col_modify_bool_item(struct collection_item *item,
02616 const char *property,
02617 unsigned char logical);
02628 int col_modify_int_item(struct collection_item *item,
02629 const char *property,
02630 int32_t number);
02641 int col_modify_long_item(struct collection_item *item,
02642 const char *property,
02643 int64_t number);
02654 int col_modify_ulong_item(struct collection_item *item,
02655 const char *property,
02656 uint64_t number);
02667 int col_modify_unsigned_item(struct collection_item *item,
02668 const char *property,
02669 uint32_t number);
02680 int col_modify_double_item(struct collection_item *item,
02681 const char *property,
02682 double number);
02683
02747 int col_extract_item(struct collection_item *ci,
02748 const char *subcollection,
02749 int disposition,
02750 const char *refprop,
02751 int idx,
02752 int type,
02753 struct collection_item **ret_ref);
02754
02795 int col_extract_item_from_current(struct collection_item *ci,
02796 int disposition,
02797 const char *refprop,
02798 int idx,
02799 int type,
02800 struct collection_item **ret_ref);
02801
02849 int col_remove_item(struct collection_item *ci,
02850 const char *subcollection,
02851 int disposition,
02852 const char *refprop,
02853 int idx,
02854 int type);
02855
02856
02895 int col_remove_item_from_current(struct collection_item *ci,
02896 int disposition,
02897 const char *refprop,
02898 int idx,
02899 int type);
02900
02960 int col_insert_item(struct collection_item *ci,
02961 const char *subcollection,
02962 struct collection_item *item,
02963 int disposition,
02964 const char *refprop,
02965 int idx,
02966 unsigned flags);
02967
03008 int col_insert_item_into_current(struct collection_item *ci,
03009 struct collection_item *item,
03010 int disposition,
03011 const char *refprop,
03012 int idx,
03013 unsigned flags);
03014
03015
03016
03030 void col_delete_item(struct collection_item *item);
03031
03066 int col_bind_iterator(struct collection_iterator **iterator,
03067 struct collection_item *ci,
03068 int mode_flags);
03069
03075 void col_unbind_iterator(struct collection_iterator *iterator);
03076
03097 int col_iterate_collection(struct collection_iterator *iterator,
03098 struct collection_item **item);
03099
03117 int col_iterate_up(struct collection_iterator *iterator, unsigned level);
03118
03150 int col_get_iterator_depth(struct collection_iterator *iterator, int *depth);
03151
03166 int col_get_item_depth(struct collection_iterator *iterator, int *depth);
03167
03213 void col_pin_iterator(struct collection_iterator *iterator);
03214
03224 void col_rewind_iterator(struct collection_iterator *iterator);
03225
03226
03235 #endif