static char *get_params(char **params, char *cur_param) { char *str; int i; int j; char *tmp; i = 0; j = 0; str = ft_strnew(ft_strlen(cur_param) - 1); while (cur_param[++i] != 0) if (!in_args(*params, str, cur_param[i])) str[j++] = cur_param[i]; tmp = *params; *params = ft_strjoin(*params, str); free(tmp); free(str); return (*params); }
void CpInAdapterBase::AdapterImpl::AdaptPluginArguments ( CpInPtr instance, const pI_bool initialized) { pInPtr ip; try { ip = _base->GetpIn(); } catch (...) { _base->_delete_impl = true; return; } Arguments in_args(ip->GetInputSignature()); Arguments out_args(ip->GetOutputSignature()); // in case both input and output argument lists are empty (odd plugin) do nothing but return if ((in_args.size() == 0) && (out_args.size() == 0)) { if (initialized == pI_FALSE) { instance->input_arg_signature = 0; instance->output_arg_signature = 0; } return; } // if input arguments already set, delete and rebuild them if ((initialized == pI_TRUE) && (instance->input_arg_signature != 0) && (instance->output_arg_signature != 0)) { // delete whole available argument list instance->plugin_runtime->FreeArgumentList ( instance->plugin_runtime, instance->input_arg_signature, pI_TRUE, // free arguments pI_TRUE); // free argument data instance->plugin_runtime->FreeArgumentList ( instance->plugin_runtime, instance->output_arg_signature, pI_TRUE, // free arguments pI_TRUE); // free argument data } // create the argument lists instance->input_arg_signature = instance->plugin_runtime->AllocateArgumentList ( instance->plugin_runtime, in_args.size()); if (instance->input_arg_signature == 0) { throw exception::MemoryException("CpInAdapter failed allocating argument memory"); } instance->output_arg_signature = instance->plugin_runtime->AllocateArgumentList ( instance->plugin_runtime, out_args.size()); if (instance->output_arg_signature == 0) { throw exception::MemoryException("CpInAdapter failed allocating argument memory"); } // fill the argument list with copies from c++ descriptors for (pI_size lv = 0; lv < in_args.size(); ++lv) { instance->input_arg_signature->list[lv] = instance->plugin_runtime->CopyArgument ( instance->plugin_runtime, GetCArgument(in_args[lv]), pI_TRUE); // copy data (on the other hand, this should not be necessary // do not throw an exception in case of out of memory - object is still valid if (instance->input_arg_signature->list[lv] == 0) { // BUT do set error code SET_PLUGIN_ERROR ( instance, CpIn_Error_InsufficientMemory, "CpInAdapter failed in input argument cloning"); } } for (pI_size lv = 0; lv < out_args.size(); ++lv) { instance->output_arg_signature->list[lv] = instance->plugin_runtime->CopyArgument ( instance->plugin_runtime, GetCArgument(out_args[lv]), pI_TRUE); // copy data (on the other hand, this should not be necessary // do not throw an exception in case of out of memory - object is still valid if (instance->output_arg_signature->list[lv] == 0) { // BUT do set error code SET_PLUGIN_ERROR ( instance, CpIn_Error_InsufficientMemory, "CpInAdapter failed in output argument cloning"); } } } // void CpInAdapterBase::AdapterImpl::AdaptPluginArguments()