cc_int32 ccs_list_add (ccs_list_t io_list, ccs_object_t in_object) { cc_int32 err = ccNoError; cc_uint64 add_index; if (!io_list ) { err = cci_check_error (ccErrBadParam); } if (!in_object) { err = cci_check_error (ccErrBadParam); } if (!err) { add_index = cci_array_count (io_list->objects); err = cci_array_insert (io_list->objects, in_object, add_index); } if (!err) { /* Fixup iterator indexes */ cc_uint64 i; for (i = 0; !err && i < cci_array_count (io_list->iterators); i++) { ccs_list_iterator_t iterator = cci_array_object_at_index (io_list->iterators, i); err = ccs_list_iterator_update (iterator, ccs_list_action_insert, add_index); } } return cci_check_error (err); }
cc_int32 ccs_list_push_front (ccs_list_t io_list, cci_identifier_t in_identifier) { cc_int32 err = ccNoError; cc_uint64 push_front_index; if (!io_list ) { err = cci_check_error (ccErrBadParam); } if (!in_identifier) { err = cci_check_error (ccErrBadParam); } if (!err) { err = ccs_list_find_index (io_list, in_identifier, &push_front_index); } if (!err) { err = cci_array_push_front (io_list->objects, push_front_index); } if (!err) { /* Fixup iterator indexes */ cc_uint64 i; for (i = 0; !err && i < cci_array_count (io_list->iterators); i++) { ccs_list_iterator_t iterator = cci_array_object_at_index (io_list->iterators, i); err = ccs_list_iterator_update (iterator, ccs_list_action_push_front, push_front_index); } } return cci_check_error (err); }
static cc_int32 ccs_list_find_iterator_index (ccs_list_t in_list, cci_identifier_t in_identifier, cc_uint64 *out_object_index) { cc_int32 err = ccNoError; cc_int32 found = 0; if (!in_list ) { err = cci_check_error (ccErrBadParam); } if (!in_identifier ) { err = cci_check_error (ccErrBadParam); } if (!out_object_index) { err = cci_check_error (ccErrBadParam); } if (!err && !found) { cc_uint64 i; for (i = 0; !err && i < cci_array_count (in_list->iterators); i++) { cc_uint32 equal = 0; ccs_list_iterator_t iterator = ccs_list_iterator_at_index (in_list, i); err = cci_identifier_compare (iterator->identifier, in_identifier, &equal); if (!err && equal) { found = 1; *out_object_index = i; break; } } } if (!err && !found) { // Don't report this error to the log file. Non-fatal. return in_list->object_not_found_err; } else { return cci_check_error (err); } }
static cc_int32 ccs_list_find_iterator_index (ccs_list_t in_list, cci_identifier_t in_identifier, cc_uint64 *out_object_index) { cc_int32 err = ccNoError; cc_int32 found = 0; if (!in_list ) { err = cci_check_error (ccErrBadParam); } if (!in_identifier ) { err = cci_check_error (ccErrBadParam); } if (!out_object_index) { err = cci_check_error (ccErrBadParam); } if (!err && !found) { cc_uint64 i; for (i = 0; !err && i < cci_array_count (in_list->iterators); i++) { cc_uint32 equal = 0; ccs_list_iterator_t iterator = cci_array_object_at_index (in_list->iterators, i); err = cci_identifier_compare (iterator->identifier, in_identifier, &equal); if (!err && equal) { found = 1; *out_object_index = i; } } } if (!err && !found) { err = cci_check_error (in_list->object_not_found_err); } return cci_check_error (err); }
static cc_int32 ccs_list_iterator_new (ccs_list_iterator_t *out_list_iterator, ccs_list_t io_list, ccs_pipe_t in_client_pipe) { cc_int32 err = ccNoError; ccs_list_iterator_t list_iterator = NULL; if (!out_list_iterator) { err = cci_check_error (ccErrBadParam); } if (!io_list ) { err = cci_check_error (ccErrBadParam); } /* client_pipe may be NULL if the iterator exists for internal server use */ if (!err) { list_iterator = malloc (sizeof (*list_iterator)); if (list_iterator) { *list_iterator = ccs_list_iterator_initializer; } else { err = cci_check_error (ccErrNoMem); } } if (!err) { err = ccs_server_new_identifier (&list_iterator->identifier); } if (!err) { list_iterator->list = io_list; list_iterator->current = 0; err = cci_array_insert (io_list->iterators, (cci_array_object_t) list_iterator, cci_array_count (io_list->iterators)); } if (!err && ccs_pipe_valid (in_client_pipe)) { ccs_client_t client = NULL; err = ccs_pipe_copy (&list_iterator->client_pipe, in_client_pipe); if (!err) { err = ccs_server_client_for_pipe (in_client_pipe, &client); } if (!err) { err = ccs_client_add_iterator (client, list_iterator); } } if (!err) { *out_list_iterator = list_iterator; list_iterator = NULL; } ccs_list_iterator_release (list_iterator); return cci_check_error (err); }
cc_int32 ccs_list_count (ccs_list_t in_list, cc_uint64 *out_count) { cc_int32 err = ccNoError; if (!in_list ) { err = cci_check_error (ccErrBadParam); } if (!out_count) { err = cci_check_error (ccErrBadParam); } if (!err) { *out_count = cci_array_count (in_list->objects); } return cci_check_error (err); }
cc_int32 ccs_list_iterator_current (ccs_list_iterator_t io_list_iterator, ccs_object_t *out_object) { cc_int32 err = ccNoError; if (!io_list_iterator) { err = cci_check_error (ccErrBadParam); } if (!out_object ) { err = cci_check_error (ccErrBadParam); } if (!err) { if (io_list_iterator->current < cci_array_count (io_list_iterator->list->objects)) { *out_object = cci_array_object_at_index (io_list_iterator->list->objects, io_list_iterator->current); } else { err = ccIteratorEnd; } } return cci_check_error (err); }
cc_int32 ccs_list_release (ccs_list_t io_list) { cc_int32 err = ccNoError; if (!io_list) { err = ccErrBadParam; } if (!err) { cc_uint64 i; for (i = 0; i < cci_array_count (io_list->iterators); i++) { ccs_list_iterator_release (cci_array_object_at_index (io_list->iterators, i)); } free (io_list->iterators); cci_array_release (io_list->objects); free (io_list); } return err; }
static cc_int32 ccs_list_iterator_new (ccs_list_iterator_t *out_list_iterator, ccs_list_t io_list) { cc_int32 err = ccNoError; ccs_list_iterator_t list_iterator = NULL; if (!out_list_iterator) { err = cci_check_error (ccErrBadParam); } if (!io_list ) { err = cci_check_error (ccErrBadParam); } if (!err) { list_iterator = malloc (sizeof (*list_iterator)); if (list_iterator) { *list_iterator = ccs_list_iterator_initializer; } else { err = cci_check_error (ccErrNoMem); } } if (!err) { err = ccs_server_new_identifier (&list_iterator->identifier); } if (!err) { list_iterator->list = io_list; list_iterator->current = 0; err = cci_array_insert (io_list->iterators, list_iterator, cci_array_count (io_list->iterators)); } if (!err) { *out_list_iterator = list_iterator; list_iterator = NULL; } ccs_list_iterator_release (list_iterator); return cci_check_error (err); }
inline cc_uint64 ccs_client_array_count (ccs_client_array_t in_array) { return cci_array_count (in_array); }
cc_uint64 ccs_iteratorref_array_count (ccs_iteratorref_array_t in_array) { return cci_array_count (in_array); }
cc_uint64 ccs_callbackref_array_count (ccs_callbackref_array_t in_array) { return cci_array_count (in_array); }
cc_uint64 ccs_lock_array_count (ccs_lock_array_t in_array) { return cci_array_count (in_array); }