ssize_t action_query_to_fast(void *userdata, request_t *request, f_hash_to_fast callback){ // {{{ ssize_t ret; request_t *t, *n; request_t *q_request; request_t *q_request_clean = NULL; hash_data_get(ret, TYPE_HASHT, q_request, request, HK(request)); if(ret != 0) return -EINVAL; if(hash_iter(q_request, (hash_iterator)&remove_symlinks, &q_request_clean, 0) == ITER_OK){ fastcall_query fargs = { { 3, ACTION_QUERY }, q_request_clean }; ret = callback(userdata, &fargs); }else{ ret = -EFAULT; } for(t = q_request_clean; t; t = n){ n = t[1].data.ptr; // inline hash free(t); } return ret; } // }}}
void cleanup_remote_files() { hash_table_type *remote = hash_exists_p(hashtable_remote); hash_iter(remote, unlink_remote_file); }
static ssize_t data_list_t_convert_from(data_t *dst, fastcall_convert_from *fargs){ // {{{ ssize_t ret = 0; list_t *fdata; uintmax_t transfered = 0; data_t sl_input = DATA_SLIDERT(fargs->src, 0); switch(fargs->format){ case FORMAT(native): case FORMAT(human): case FORMAT(config):; return data_list_t(dst); case FORMAT(hash):; hash_t *config; data_get(ret, TYPE_HASHT, config, fargs->src); if(ret != 0) return -EINVAL; if((fdata = dst->ptr) == NULL){ if( (fdata = dst->ptr = list_t_alloc()) == NULL) return -ENOMEM; } if(hash_iter(config, (hash_iterator)&iter_list_t_convert_from, dst, 0) != ITER_OK){ list_t_free(dst->ptr); return -EFAULT; } return 0; case FORMAT(packed):; data_t item; data_t d_item = DATA_PTR_DATAT(&item); if((fdata = dst->ptr) == NULL){ if( (fdata = dst->ptr = list_t_alloc()) == NULL) return -ENOMEM; } while(1){ data_set_void(&item); fastcall_convert_from r_convert = { { 5, ACTION_CONVERT_FROM }, &sl_input, FORMAT(packed) }; if( (ret = data_query(&d_item, &r_convert)) < 0) break; data_slider_t_set_offset(&sl_input, r_convert.transfered, SEEK_CUR); if(item.type == TYPE_LISTENDT) break; if( (ret = list_t_push(fdata, &item)) < 0) break; } transfered = data_slider_t_get_offset(&sl_input); break; default: return -ENOSYS; }; if(fargs->header.nargs >= 5) fargs->transfered = transfered; return ret; } // }}}
static int run_test (void) { HASH_STRING_MAP colors; size_t i; // Check the <bind> operation. for (i = 0; warm_colors[i] != 0; i++) { if (colors.bind (color_sorts[0], warm_colors[i]) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s in %s\n"), warm_colors[i], color_sorts[0]), -1); } HASH_STRING_ENTRY *entry = 0; for (i = 0; cold_colors[i] != 0; i++) { if (colors.bind (color_sorts[1], cold_colors[i], entry) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s in %s\n"), cold_colors[i], color_sorts[1]), -1); } HASH_STRING_VALUE_SET value_set; entry = 0; for (i = 0; neutral_colors[i] != 0; i++) value_set.insert (neutral_colors[i]); if (colors.bind (color_sorts[2], value_set, entry) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s\n"), color_sorts[2]), -1); // Check the <trybind> operation. value_set.reset (); if (colors.trybind (color_sorts[2], value_set) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s\n"), color_sorts[2]), -1); value_set.reset (); entry = 0; if (colors.trybind (color_sorts[2], value_set, entry) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s\n"), color_sorts[2]), -1); value_set.reset (); entry = 0; if (colors.trybind (color_sorts[2], value_set, entry) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s\n"), color_sorts[2]), -1); // Check the <rebind> operation. value_set.reset (); value_set.insert (neutral_colors[0]); if (colors.rebind (color_sorts[2], value_set) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s\n"), color_sorts[2]), -1); value_set.reset (); value_set.insert (neutral_colors[1]); entry = 0; if (colors.rebind (color_sorts[2], value_set, entry) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s\n"), color_sorts[2]), -1); value_set.reset (); value_set.insert (neutral_colors[0]); HASH_STRING_VALUE_SET old_value_set; if (colors.rebind (color_sorts[2], value_set, old_value_set) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s\n"), color_sorts[2]), -1); value_set.reset (); value_set.insert (neutral_colors[1]); old_value_set.reset (); entry = 0; if (colors.rebind (color_sorts[2], value_set, old_value_set, entry) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s\n"), color_sorts[2]), -1); value_set.reset (); value_set.insert (neutral_colors[0]); const ACE_TCHAR *old_key; old_value_set.reset (); if (colors.rebind (color_sorts[2], value_set, old_key, old_value_set) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s\n"), color_sorts[2]), -1); value_set.reset (); for (i = 0; neutral_colors[i] != 0; i++) value_set.insert (neutral_colors[i]); old_key = 0; old_value_set.reset (); entry = 0; if (colors.rebind (color_sorts[2], value_set, old_key, old_value_set, entry) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s\n"), color_sorts[2]), -1); // Check the <find> operation. for (i = 0; color_sorts[i] != 0; i++) if (colors.find (color_sorts[i]) == 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s found\n"), color_sorts[i])); else ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%s not found\n"), color_sorts[i]), -1); entry = 0; for (i = 0; color_sorts[i] != 0; i++) if (colors.find (color_sorts[i], entry) == 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s found\n"), color_sorts[i])); else ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%s not found\n"), color_sorts[i]), -1); value_set.reset (); for (i = 0; color_sorts[i] != 0; i++) if (colors.find (color_sorts[i], value_set) == 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s found\n"), color_sorts[i])); else ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%s not found\n"), color_sorts[i]), -1); for (i = 0; warm_colors[i] != 0; i++) if (colors.find (color_sorts[0], warm_colors[i]) == 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s color %s found\n"), color_sorts[0], warm_colors[i])); else ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%s color %s not found\n"), color_sorts[0], warm_colors[i]), -1); // Check the iterator. i = 0; entry = 0; for (HASH_STRING_ITERATOR hash_iter (colors); hash_iter.next (entry) != 0; hash_iter.advance ()) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("iterating (%d): %s:\n"), i, entry->ext_id_)); i++; for (HASH_STRING_VALUE_SET_ITERATOR iter (entry->int_id_set_); iter != entry->int_id_set_.end (); iter++) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s \n"), *iter)); } } // Check the unbind operation. if (colors.unbind (color_sorts[0]) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("unbind failed for %s\n"), color_sorts[1]), -1); for (i = 0; warm_colors[i] != 0; i++) { if (colors.bind (color_sorts[0], warm_colors[i]) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s in %s\n"), warm_colors[i], color_sorts[0]), -1); } value_set.reset (); if (colors.unbind (color_sorts[0], value_set) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("unbind failed for %s\n"), color_sorts[1]), -1); for (i = 0; warm_colors[i] != 0; i++) { if (colors.bind (color_sorts[0], warm_colors[i]) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed for %s in %s\n"), warm_colors[i], color_sorts[0]), -1); } for (i = 0; warm_colors[i] != 0; i++) { if (colors.unbind (color_sorts[0], warm_colors[i]) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("unbind failed for %s in %s\n"), warm_colors[i], color_sorts[0]), -1); } // Check the reverse iterator. i = 0; entry = 0; for (HASH_STRING_REVERSE_ITERATOR hash_iter (colors); hash_iter.next (entry) != 0; hash_iter.advance ()) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("reverse iterating (%d): %s\n"), i, entry->ext_id_)); i++; for (HASH_STRING_VALUE_SET_ITERATOR iter (entry->int_id_set_); iter != entry->int_id_set_.end (); iter++) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s \n"), *iter)); } } entry = 0; colors.find (color_sorts[1], entry); if (colors.unbind (entry) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("unbind failed for %s\n"), color_sorts[1]), -1); // Check the const iterator. i = 0; entry = 0; for (HASH_STRING_CONST_ITERATOR hash_iter (colors); hash_iter.next (entry) != 0; hash_iter.advance ()) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("const iterating (%d): %s\n"), i, entry->ext_id_)); i++; for (HASH_STRING_VALUE_SET_ITERATOR iter (entry->int_id_set_); iter != entry->int_id_set_.end (); iter++) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s \n"), *iter)); } } // Check the unbind_all operation. if (colors.unbind_all () != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("unbind_all failed\n")), -1); return 0; }