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
00508 typedef void (*col_item_cleanup_fn)(const char *property,
00509 int property_len,
00510 int type,
00511 void *data,
00512 int length,
00513 void *custom_data);
00514
00536 void col_destroy_collection_with_cb(struct collection_item *ci,
00537 col_item_cleanup_fn cb,
00538 void *custom_data);
00539
00564 typedef int (*col_copy_cb)(struct collection_item *item,
00565 void *ext_data,
00566 int *skip);
00567
00594 int col_copy_collection_with_cb(struct collection_item **col_copy,
00595 struct collection_item *col_to_copy,
00596 const char *name_to_use,
00597 int copy_mode,
00598 col_copy_cb copy_cb,
00599 void *ext_data);
00600
00618 int col_copy_collection(struct collection_item **col_copy,
00619 struct collection_item *col_to_copy,
00620 const char *name_to_use,
00621 int copy_mode);
00622
00654 int col_add_collection_to_collection(struct collection_item *ci,
00655 const char *subcollection,
00656 const char *as_property,
00657 struct collection_item *ci_to_add,
00658 int mode);
00685 typedef int (*col_item_fn)(const char *property,
00686 int property_len,
00687 int type,
00688 void *data,
00689 int length,
00690 void *custom_data,
00691 int *stop);
00692
00714 int col_traverse_collection(struct collection_item *ci,
00715 int mode_flags,
00716 col_item_fn item_handler,
00717 void *custom_data);
00718
00753 int col_get_item_and_do(struct collection_item *ci,
00754 const char *property_to_find,
00755 int type,
00756 int mode_flags,
00757 col_item_fn item_handler,
00758 void *custom_data);
00759
00798 int col_get_item(struct collection_item *ci,
00799 const char *property_to_find,
00800 int type,
00801 int mode_flags,
00802 struct collection_item **item);
00803
00833 int col_sort_collection(struct collection_item *col,
00834 unsigned cmp_flags,
00835 unsigned sort_flags);
00836
00868 int col_delete_property(struct collection_item *ci,
00869 const char *property_to_find,
00870 int type,
00871 int mode_flags);
00872
00897 int col_is_item_in_collection(struct collection_item *ci,
00898 const char *property_to_find,
00899 int type,
00900 int mode_flags,
00901 int *found);
00902
00924 int col_get_collection_reference(struct collection_item *ci,
00925 struct collection_item **acceptor,
00926 const char *col_to_find);
00927
00947 int col_get_reference_from_item(struct collection_item *item,
00948 struct collection_item **acceptor);
00949
00950
00951
00980 int col_get_collection_class(struct collection_item *ci,
00981 unsigned *cclass);
00982
00996 int col_set_collection_class(struct collection_item *ci,
00997 unsigned cclass);
00998
01017 int col_get_collection_count(struct collection_item *ci,
01018 unsigned *count);
01019
01020
01034 int col_is_of_class(struct collection_item *ci,
01035 unsigned cclass);
01036
01037
01110 int col_add_str_property(struct collection_item *ci,
01111 const char *subcollection,
01112 const char *property,
01113 const char *string,
01114 int length);
01115
01142 int col_add_binary_property(struct collection_item *ci,
01143 const char *subcollection,
01144 const char *property,
01145 void *binary_data,
01146 int length);
01147
01173 int col_add_int_property(struct collection_item *ci,
01174 const char *subcollection,
01175 const char *property,
01176 int32_t number);
01177
01203 int col_add_unsigned_property(struct collection_item *ci,
01204 const char *subcollection,
01205 const char *property,
01206 uint32_t number);
01207
01233 int col_add_long_property(struct collection_item *ci,
01234 const char *subcollection,
01235 const char *property,
01236 int64_t number);
01237
01263 int col_add_ulong_property(struct collection_item *ci,
01264 const char *subcollection,
01265 const char *property,
01266 uint64_t number);
01267
01293 int col_add_double_property(struct collection_item *ci,
01294 const char *subcollection,
01295 const char *property,
01296 double number);
01322 int col_add_bool_property(struct collection_item *ci,
01323 const char *subcollection,
01324 const char *property,
01325 unsigned char logical);
01326
01327
01355 int col_add_any_property(struct collection_item *ci,
01356 const char *subcollection,
01357 const char *property,
01358 int type,
01359 void *data,
01360 int length);
01361
01421 int col_add_str_property_with_ref(struct collection_item *ci,
01422 const char *subcollection,
01423 const char *property,
01424 char *string, int length,
01425 struct collection_item **ret_ref);
01426
01455 int col_add_binary_property_with_ref(struct collection_item *ci,
01456 const char *subcollection,
01457 const char *property,
01458 void *binary_data, int length,
01459 struct collection_item **ret_ref);
01460
01488 int col_add_int_property_with_ref(struct collection_item *ci,
01489 const char *subcollection,
01490 const char *property, int32_t number,
01491 struct collection_item **ret_ref);
01492
01520 int col_add_unsigned_property_with_ref(struct collection_item *ci,
01521 const char *subcollection,
01522 const char *property, uint32_t number,
01523 struct collection_item **ret_ref);
01524
01552 int col_add_long_property_with_ref(struct collection_item *ci,
01553 const char *subcollection,
01554 const char *property, int64_t number,
01555 struct collection_item **ret_ref);
01556
01584 int col_add_ulong_property_with_ref(struct collection_item *ci,
01585 const char *subcollection,
01586 const char *property, uint64_t number,
01587 struct collection_item **ret_ref);
01588
01616 int col_add_double_property_with_ref(struct collection_item *ci,
01617 const char *subcollection,
01618 const char *property, double number,
01619 struct collection_item **ret_ref);
01620
01648 int col_add_bool_property_with_ref(struct collection_item *ci,
01649 const char *subcollection,
01650 const char *property, unsigned char logical,
01651 struct collection_item **ret_ref);
01652
01653
01683 int col_add_any_property_with_ref(struct collection_item *ci,
01684 const char *subcollection,
01685 const char *property,
01686 int type, void *data, int length,
01687 struct collection_item **ret_ref);
01688
01743 int col_insert_str_property(struct collection_item *ci,
01744 const char *subcollection,
01745 int disposition,
01746 const char *refprop,
01747 int idx,
01748 unsigned flags,
01749 const char *property,
01750 const char *string,
01751 int length);
01752
01754 int col_insert_binary_property(struct collection_item *ci,
01755 const char *subcollection,
01756 int disposition,
01757 const char *refprop,
01758 int idx,
01759 unsigned flags,
01760 const char *property,
01761 void *binary_data,
01762 int length);
01763
01765 int col_insert_int_property(struct collection_item *ci,
01766 const char *subcollection,
01767 int disposition,
01768 const char *refprop,
01769 int idx,
01770 unsigned flags,
01771 const char *property,
01772 int32_t number);
01773
01775 int col_insert_unsinged_property(struct collection_item *ci,
01776 const char *subcollection,
01777 int disposition,
01778 const char *refprop,
01779 int idx,
01780 unsigned flags,
01781 const char *property,
01782 uint32_t number);
01783
01785 int col_insert_long_property(struct collection_item *ci,
01786 const char *subcollection,
01787 int disposition,
01788 const char *refprop,
01789 int idx,
01790 unsigned flags,
01791 const char *property,
01792 int64_t number);
01793
01795 int col_insert_ulong_property(struct collection_item *ci,
01796 const char *subcollection,
01797 int disposition,
01798 const char *refprop,
01799 int idx,
01800 unsigned flags,
01801 const char *property,
01802 uint64_t number);
01803
01805 int col_insert_double_property(struct collection_item *ci,
01806 const char *subcollection,
01807 int disposition,
01808 const char *refprop,
01809 int idx,
01810 unsigned flags,
01811 const char *property,
01812 double number);
01813
01815 int col_insert_bool_property(struct collection_item *ci,
01816 const char *subcollection,
01817 int disposition,
01818 const char *refprop,
01819 int idx,
01820 unsigned flags,
01821 const char *property,
01822 unsigned char logical);
01823
01825 int col_insert_str_property_with_ref(struct collection_item *ci,
01826 const char *subcollection,
01827 int disposition,
01828 const char *refprop,
01829 int idx,
01830 unsigned flags,
01831 const char *property,
01832 const char *string,
01833 int length,
01834 struct collection_item **ret_ref);
01835
01837 int col_insert_binary_property_with_ref(struct collection_item *ci,
01838 const char *subcollection,
01839 int disposition,
01840 const char *refprop,
01841 int idx,
01842 unsigned flags,
01843 const char *property,
01844 void *binary_data,
01845 int length,
01846 struct collection_item **ret_ref);
01847
01849 int col_insert_int_property_with_ref(struct collection_item *ci,
01850 const char *subcollection,
01851 int disposition,
01852 const char *refprop,
01853 int idx,
01854 unsigned flags,
01855 const char *property,
01856 int32_t number,
01857 struct collection_item **ret_ref);
01858
01860 int col_insert_unsinged_property_with_ref(struct collection_item *ci,
01861 const char *subcollection,
01862 int disposition,
01863 const char *refprop,
01864 int idx,
01865 unsigned flags,
01866 const char *property,
01867 uint32_t number,
01868 struct collection_item **ret_ref);
01869
01871 int col_insert_long_property_with_ref(struct collection_item *ci,
01872 const char *subcollection,
01873 int disposition,
01874 const char *refprop,
01875 int idx,
01876 unsigned flags,
01877 const char *property,
01878 int64_t number,
01879 struct collection_item **ret_ref);
01880
01882 int col_insert_ulong_property_with_ref(struct collection_item *ci,
01883 const char *subcollection,
01884 int disposition,
01885 const char *refprop,
01886 int idx,
01887 unsigned flags,
01888 const char *property,
01889 uint64_t number,
01890 struct collection_item **ret_ref);
01891
01896 int col_insert_double_property_with_ref(struct collection_item *ci,
01897 const char *subcollection,
01898 int disposition,
01899 const char *refprop,
01900 int idx,
01901 unsigned flags,
01902 const char *property,
01903 double number,
01904 struct collection_item **ret_ref);
01905
01907 int col_insert_bool_property_with_ref(struct collection_item *ci,
01908 const char *subcollection,
01909 int disposition,
01910 const char *refprop,
01911 int idx,
01912 unsigned flags,
01913 const char *property,
01914 unsigned char logical,
01915 struct collection_item **ret_ref);
01916
01918 int col_insert_property_with_ref(struct collection_item *ci,
01919 const char *subcollection,
01920 int disposition,
01921 const char *refprop,
01922 int idx,
01923 unsigned flags,
01924 const char *property,
01925 int type,
01926 const void *data,
01927 int length,
01928 struct collection_item **ret_ref);
01929
01930
01979 int col_update_str_property(struct collection_item *ci,
01980 const char *property,
01981 int mode_flags,
01982 char *string,
01983 int length);
01987 int col_update_binary_property(struct collection_item *ci,
01988 const char *property,
01989 int mode_flags,
01990 void *binary_data,
01991 int length);
01995 int col_update_int_property(struct collection_item *ci,
01996 const char *property,
01997 int mode_flags,
01998 int32_t number);
02002 int col_update_unsigned_property(struct collection_item *ci,
02003 const char *property,
02004 int mode_flags,
02005 uint32_t number);
02009 int col_update_long_property(struct collection_item *ci,
02010 const char *property,
02011 int mode_flags,
02012 int64_t number);
02016 int col_update_ulong_property(struct collection_item *ci,
02017 const char *property,
02018 int mode_flags,
02019 uint64_t number);
02023 int col_update_double_property(struct collection_item *ci,
02024 const char *property,
02025 int mode_flags,
02026 double number);
02030 int col_update_bool_property(struct collection_item *ci,
02031 const char *property,
02032 int mode_flags,
02033 unsigned char logical);
02034
02042 int col_update_property(struct collection_item *ci,
02043 const char *property,
02044 int type,
02045 void *new_data,
02046 int length,
02047 int mode_flags);
02048
02049
02081 #define COL_CMPIN_PROP_EQU 0x000000004
02082
02083 #define COL_CMPIN_PROP_BEG 0x000000005
02084
02085 #define COL_CMPIN_PROP_MID 0x000000006
02086
02087 #define COL_CMPIN_PROP_END 0x000000007
02088
02100 #define COL_CMPIN_PROP_DOT 0x000000008
02101
02103 #define COL_CMPIN_PROP_LEN 0x000000010
02104
02106 #define COL_CMPIN_TYPE 0x000000020
02107
02109 #define COL_CMPIN_DATA_LEN 0x000000040
02110
02119 #define COL_CMPIN_DATA 0x000000080
02120
02141 #define COL_CMPOUT_PROP_STR 0x00000001
02142
02149 #define COL_CMPOUT_PROP_LEN 0x00000002
02150
02156 #define COL_CMPOUT_DATA_LEN 0x00000004
02157
02165 #define COL_CMPOUT_DATA 0x00000008
02166
02192 #define COL_DSP_END 0
02193
02203 #define COL_DSP_FRONT 1
02204
02216 #define COL_DSP_BEFORE 2
02217
02229 #define COL_DSP_AFTER 3
02230
02248 #define COL_DSP_INDEX 4
02249
02266 #define COL_DSP_FIRSTDUP 5
02267
02286 #define COL_DSP_LASTDUP 6
02287
02316 #define COL_DSP_NDUP 7
02317
02336 #define COL_INSERT_NOCHECK 0
02337
02341 #define COL_INSERT_DUPOVER 1
02342
02346 #define COL_INSERT_DUPOVERT 2
02347
02348 #define COL_INSERT_DUPERROR 3
02349
02353 #define COL_INSERT_DUPERRORT 4
02354
02357 #define COL_INSERT_DUPMOVE 5
02358
02361 #define COL_INSERT_DUPMOVET 6
02362
02389 const char *col_get_item_property(struct collection_item *ci,
02390 int *property_len);
02391
02404 int col_get_item_type(struct collection_item *ci);
02405
02419 int col_get_item_length(struct collection_item *ci);
02420
02433 void *col_get_item_data(struct collection_item *ci);
02434
02454 uint64_t col_get_item_hash(struct collection_item *ci);
02455
02479 uint64_t col_make_hash(const char *string, int sub_len, int *length);
02480
02481
02508 int col_compare_items(struct collection_item *first,
02509 struct collection_item *second,
02510 unsigned in_flags,
02511 unsigned *out_flags);
02512
02513
02514
02549 int col_modify_item(struct collection_item *item,
02550 const char *property,
02551 int type,
02552 const void *data,
02553 int length);
02554
02572 int col_modify_item_property(struct collection_item *item,
02573 const char *property);
02574
02588 int col_modify_str_item(struct collection_item *item,
02589 const char *property,
02590 const char *string,
02591 int length);
02602 int col_modify_binary_item(struct collection_item *item,
02603 const char *property,
02604 void *binary_data,
02605 int length);
02616 int col_modify_bool_item(struct collection_item *item,
02617 const char *property,
02618 unsigned char logical);
02629 int col_modify_int_item(struct collection_item *item,
02630 const char *property,
02631 int32_t number);
02642 int col_modify_long_item(struct collection_item *item,
02643 const char *property,
02644 int64_t number);
02655 int col_modify_ulong_item(struct collection_item *item,
02656 const char *property,
02657 uint64_t number);
02668 int col_modify_unsigned_item(struct collection_item *item,
02669 const char *property,
02670 uint32_t number);
02681 int col_modify_double_item(struct collection_item *item,
02682 const char *property,
02683 double number);
02684
02748 int col_extract_item(struct collection_item *ci,
02749 const char *subcollection,
02750 int disposition,
02751 const char *refprop,
02752 int idx,
02753 int type,
02754 struct collection_item **ret_ref);
02755
02796 int col_extract_item_from_current(struct collection_item *ci,
02797 int disposition,
02798 const char *refprop,
02799 int idx,
02800 int type,
02801 struct collection_item **ret_ref);
02802
02850 int col_remove_item(struct collection_item *ci,
02851 const char *subcollection,
02852 int disposition,
02853 const char *refprop,
02854 int idx,
02855 int type);
02856
02857
02896 int col_remove_item_from_current(struct collection_item *ci,
02897 int disposition,
02898 const char *refprop,
02899 int idx,
02900 int type);
02901
02961 int col_insert_item(struct collection_item *ci,
02962 const char *subcollection,
02963 struct collection_item *item,
02964 int disposition,
02965 const char *refprop,
02966 int idx,
02967 unsigned flags);
02968
03009 int col_insert_item_into_current(struct collection_item *ci,
03010 struct collection_item *item,
03011 int disposition,
03012 const char *refprop,
03013 int idx,
03014 unsigned flags);
03015
03016
03017
03031 void col_delete_item(struct collection_item *item);
03032
03067 int col_bind_iterator(struct collection_iterator **iterator,
03068 struct collection_item *ci,
03069 int mode_flags);
03070
03076 void col_unbind_iterator(struct collection_iterator *iterator);
03077
03098 int col_iterate_collection(struct collection_iterator *iterator,
03099 struct collection_item **item);
03100
03118 int col_iterate_up(struct collection_iterator *iterator, unsigned level);
03119
03151 int col_get_iterator_depth(struct collection_iterator *iterator, int *depth);
03152
03167 int col_get_item_depth(struct collection_iterator *iterator, int *depth);
03168
03217 void col_pin_iterator(struct collection_iterator *iterator);
03218
03231 void col_rewind_iterator(struct collection_iterator *iterator);
03232
03233
03242 #endif