本文整理汇总了C++中osync_assert函数的典型用法代码示例。如果您正苦于以下问题:C++ osync_assert函数的具体用法?C++ osync_assert怎么用?C++ osync_assert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osync_assert函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: osync_module_load
/*! @brief dlopen()s a format plugin
*
* The get_info() function on the format plugin gets called
*
* @param env The environment in which to open the plugin
* @param path Where to find this plugin
* @param error Pointer to a error struct
* @return Pointer to the plugin on success, NULL otherwise
*
*/
osync_bool osync_module_load(OSyncModule *module, const char *path, OSyncError **error)
{
osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, module, path, error);
osync_assert(module);
osync_assert(!module->module);
if (!g_module_supported()) {
osync_error_set(error, OSYNC_ERROR_GENERIC, "This platform does not support loading of modules");
goto error;
}
/* Try to open the module or fail if an error occurs */
module->module = g_module_open(path, 0);
if (!module->module) {
osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to open module %s: %s", path, g_module_error());
goto error;
}
module->path = g_strdup(path);
osync_trace(TRACE_EXIT, "%s", __func__);
return TRUE;
error:
osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error));
return FALSE;
}
开发者ID:ianmartin,项目名称:autoimportopensync,代码行数:37,代码来源:opensync_module.c
示例2: osync_xml_validate_document
osync_bool osync_xml_validate_document(xmlDocPtr doc, char *schemafilepath)
{
int rc = 0;
xmlSchemaParserCtxtPtr xmlSchemaParserCtxt = NULL;
xmlSchemaPtr xmlSchema = NULL;
xmlSchemaValidCtxtPtr xmlSchemaValidCtxt = NULL;
osync_assert(doc);
osync_assert(schemafilepath);
xmlSchemaParserCtxt = xmlSchemaNewParserCtxt(schemafilepath);
xmlSchema = xmlSchemaParse(xmlSchemaParserCtxt);
xmlSchemaFreeParserCtxt(xmlSchemaParserCtxt);
xmlSchemaValidCtxt = xmlSchemaNewValidCtxt(xmlSchema);
if (xmlSchemaValidCtxt == NULL) {
xmlSchemaFree(xmlSchema);
rc = 1;
}else{
/* Validate the document */
rc = xmlSchemaValidateDoc(xmlSchemaValidCtxt, doc);
xmlSchemaFree(xmlSchema);
xmlSchemaFreeValidCtxt(xmlSchemaValidCtxt);
}
if(rc != 0)
return FALSE;
return TRUE;
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:29,代码来源:opensync_xml.c
示例3: osync_xmlfield_set_key_value
osync_bool osync_xmlfield_set_key_value(OSyncXMLField *xmlfield, const char *key, const char *value, OSyncError **error)
{
xmlNodePtr cur = NULL;
osync_assert(xmlfield);
osync_assert(key);
// If value is null we don't add it to a xmlfield
if (!value)
return TRUE;
cur = xmlfield->node->children;
for(; cur != NULL; cur = cur->next) {
if(!xmlStrcmp(cur->name, BAD_CAST key)) {
xmlNodeSetContent(xmlfield->node, BAD_CAST value);
break;
}
}
/* TODO: error handling */
if(cur == NULL)
cur = xmlNewTextChild(xmlfield->node, NULL, BAD_CAST key, BAD_CAST value);
if (!osync_xmlfield_new_xmlfield(xmlfield, cur, error))
goto error;
xmlfield->sorted = FALSE;
return TRUE;
error:
return FALSE;
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:32,代码来源:opensync_xmlfield.c
示例4: osync_plugin_info_set_main_sink
void osync_plugin_info_set_main_sink(OSyncPluginInfo *info, OSyncObjTypeSink *sink)
{
osync_assert(info);
osync_assert(sink);
info->main_sink = sink;
osync_objtype_sink_ref(sink);
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:7,代码来源:opensync_plugin_info.c
示例5: get_conversion_info
osync_bool get_conversion_info(OSyncFormatEnv *env, OSyncError **error)
{
OSyncFormatConverter *conv = NULL;
/* mock converter */
OSyncObjFormat *mockformat1 = osync_format_env_find_objformat(env, "mockformat1");
osync_assert(mockformat1);
OSyncObjFormat *mockformat2 = osync_format_env_find_objformat(env, "mockformat2");
osync_assert(mockformat2);
conv = osync_converter_new(OSYNC_CONVERTER_DECAP, mockformat1, mockformat2, conv_file_to_plain, error);
osync_assert(conv);
osync_format_env_register_converter(env, conv);
osync_converter_unref(conv);
conv = osync_converter_new(OSYNC_CONVERTER_ENCAP, mockformat2, mockformat1, conv_plain_to_file, error);
osync_assert(conv);
osync_format_env_register_converter(env, conv);
osync_converter_unref(conv);
return TRUE;
}
开发者ID:ianmartin,项目名称:opensync,代码行数:26,代码来源:mock_format.c
示例6: get_format_info
osync_bool get_format_info(OSyncFormatEnv *env, OSyncError **error)
{
OSyncObjFormat *format = NULL;
/* mockformat1 */
format = osync_objformat_new("mockformat1", "mockobjtype1", error);
osync_assert(format);
_format_set_functions(format);
osync_format_env_register_objformat(env, format);
osync_objformat_unref(format);
/* mockformat2 */
format = osync_objformat_new("mockformat2", "mockobjtype2", error);
osync_assert(format);
_format_set_functions(format);
osync_format_env_register_objformat(env, format);
osync_objformat_unref(format);
/* mockformat3 */
format = osync_objformat_new("mockformat3", "mockobjtype3", error);
osync_assert(format);
_format_set_functions(format);
osync_format_env_register_objformat(env, format);
osync_objformat_unref(format);
return TRUE;
}
开发者ID:ianmartin,项目名称:opensync,代码行数:33,代码来源:mock_format.c
示例7: mock_mainsink_disconnect
static void mock_mainsink_disconnect(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data)
{
osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, sink, info, ctx, data);
mock_env *env = data;
osync_assert(data);
GList *o = env->directories;
for (; o; o = o->next) {
MockDir *sink_dir = o->data;
if (!g_getenv("NO_COMMITTED_ALL_CHECK"))
osync_assert(sink_dir->committed_all == TRUE);
sink_dir->committed_all = FALSE;
}
if (mock_get_error(info->memberid, "DISCONNECT_ERROR")) {
osync_context_report_error(ctx, OSYNC_ERROR_EXPECTED, "Triggering DISCONNECT_ERROR error");
return;
}
if (mock_get_error(info->memberid, "DISCONNECT_TIMEOUT"))
return;
osync_context_report_success(ctx);
osync_trace(TRACE_EXIT, "%s", __func__);
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:27,代码来源:mock_sync.c
示例8: osync_data_compare
OSyncConvCmpResult osync_data_compare(OSyncData *leftdata, OSyncData *rightdata)
{
OSyncConvCmpResult ret = 0;
osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, leftdata, rightdata);
osync_assert(leftdata);
osync_assert(rightdata);
if (leftdata == rightdata) {
osync_trace(TRACE_EXIT, "%s: SAME: OK. data is the same", __func__);
return OSYNC_CONV_DATA_SAME;
}
if (leftdata->data == rightdata->data && leftdata->size == rightdata->size) {
osync_trace(TRACE_EXIT, "%s: SAME: OK. data point to same memory", __func__);
return OSYNC_CONV_DATA_SAME;
}
if (!leftdata->objformat || !rightdata->objformat || strcmp(osync_objformat_get_name(leftdata->objformat), osync_objformat_get_name(rightdata->objformat))) {
osync_trace(TRACE_EXIT, "%s: MISMATCH: Objformats do not match", __func__);
return OSYNC_CONV_DATA_MISMATCH;
}
if (!rightdata->data || !leftdata->data) {
osync_trace(TRACE_EXIT, "%s: MISMATCH: One change has no data", __func__);
return OSYNC_CONV_DATA_MISMATCH;
}
ret = osync_objformat_compare(leftdata->objformat, leftdata->data, leftdata->size, rightdata->data, rightdata->size);
osync_trace(TRACE_EXIT, "%s: %i", __func__, ret);
return ret;
}
开发者ID:ianmartin,项目名称:autoimportopensync,代码行数:31,代码来源:opensync_data.c
示例9: osync_merger_demerge
osync_bool osync_merger_demerge(OSyncMerger *merger, OSyncChange *change, OSyncCapabilities *caps, OSyncError **error)
{
char *buffer;
unsigned int size;
osync_assert(merger);
osync_assert(change);
osync_return_val_if_fail(caps, TRUE);
OSyncData *data = osync_change_get_data(change);
osync_data_get_data(data, &buffer, &size);
if (size == 0) {
osync_error_set(error, OSYNC_ERROR_GENERIC, "Can't demerge data with 0 size.");
goto error;
}
if (buffer == NULL) {
osync_error_set(error, OSYNC_ERROR_GENERIC, "No data to demerge.");
goto error;
}
if (!merger->demerge_func(&buffer, &size, caps, NULL /*userdata!*/, error))
goto error;
return TRUE;
error:
return FALSE;
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:32,代码来源:opensync_merger.c
示例10: _inject_changelog_entries
static osync_bool _inject_changelog_entries(OSyncObjEngine *engine, OSyncError **error) {
OSyncList *ids = NULL;
OSyncList *changetypes = NULL;
OSyncList *j = NULL, *t = NULL;
osync_trace(TRACE_ENTRY, "%s(%p)", __func__, engine);
osync_assert(engine);
osync_assert(engine->archive);
osync_assert(engine->objtype);
if (!osync_archive_load_ignored_conflicts(engine->archive, engine->objtype, &ids, &changetypes, error)) {
osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error));
return FALSE;
}
t = changetypes;
for (j = ids; j; j = j->next) {
long long int id = (long long int)GPOINTER_TO_INT(j->data);
OSyncMapping *ignored_mapping = osync_mapping_table_find_mapping(engine->mapping_table, id);
GList *e;
for (e = engine->mapping_engines; e; e = e->next) {
OSyncMappingEngine *mapping_engine = e->data;
if (mapping_engine->mapping == ignored_mapping) {
GList *m;
for (m = mapping_engine->entries; m; m = m->next) {
OSyncMappingEntryEngine *entry = m->data;
OSyncChangeType changetype = (OSyncChangeType) t->data;
OSyncChange *ignored_change = osync_change_new(error);
OSyncObjFormat *dummyformat = NULL;
OSyncData *data = NULL;
osync_change_set_changetype(ignored_change, changetype);
osync_entry_engine_update(entry, ignored_change);
dummyformat = osync_objformat_new("plain", engine->objtype, NULL);
data = osync_data_new(NULL, 0, dummyformat, NULL);
osync_change_set_data(ignored_change, data);
osync_objformat_unref(dummyformat);
osync_change_set_uid(ignored_change, osync_mapping_entry_get_uid(entry->entry));
osync_trace(TRACE_INTERNAL, "CHANGE: %p", entry->change);
}
break;
}
}
t = t->next;
}
osync_list_free(ids);
osync_list_free(changetypes);
osync_trace(TRACE_EXIT, "%s", __func__);
return TRUE;
}
开发者ID:ianmartin,项目名称:autoimportopensync,代码行数:60,代码来源:opensync_obj_engine.c
示例11: osync_trace
OSyncCapabilitiesObjType *osync_capabilities_add_new_objtype(OSyncCapabilities *capabilities, const char *objtype, OSyncError **error)
{
OSyncCapabilitiesObjType *capsobjtype = NULL;
osync_trace(TRACE_ENTRY, "%s: %p %p", __func__, capabilities, objtype);
osync_assert(capabilities);
osync_assert(objtype);
capsobjtype = osync_capabilities_objtype_new(objtype, error);
if (!capsobjtype)
goto error;
osync_capabilities_add_objtype(capabilities, capsobjtype);
osync_capabilities_objtype_unref(capsobjtype);
osync_trace(TRACE_EXIT, "%s: %p", __func__, capsobjtype);
return capsobjtype;
error:
if (capsobjtype)
osync_capabilities_objtype_unref(capsobjtype);
osync_trace(TRACE_EXIT, "%s: %s", __func__, osync_error_print(error));
return NULL;
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:25,代码来源:opensync_capabilities.c
示例12: osync_trace
OSyncSinkEngine *osync_sink_engine_new(int position, OSyncClientProxy *proxy, OSyncObjEngine *objengine, OSyncError **error)
{
OSyncSinkEngine *sinkengine = NULL;
osync_trace(TRACE_ENTRY, "%s(%i, %p, %p, %p)", __func__, position, proxy, objengine, error);
osync_assert(proxy);
osync_assert(objengine);
sinkengine = osync_try_malloc0(sizeof(OSyncSinkEngine), error);
if (!sinkengine)
goto error;
sinkengine->ref_count = 1;
sinkengine->position = position;
/* we dont reference the proxy to avoid circular dependencies. This object is completely
* dependent on the proxy anyways */
sinkengine->proxy = proxy;
sinkengine->engine = objengine;
osync_obj_engine_ref(objengine);
osync_trace(TRACE_EXIT, "%s: %p", __func__, sinkengine);
return sinkengine;
error:
osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error));
return NULL;
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:27,代码来源:opensync_sink_engine.c
示例13: osync_xmlfield_set_name
void osync_xmlfield_set_name(OSyncXMLField *xmlfield, const char *name)
{
osync_assert(xmlfield);
osync_assert(name);
xmlNodeSetName(xmlfield->node, BAD_CAST name);
}
开发者ID:ianmartin,项目名称:autoimportopensync,代码行数:7,代码来源:opensync_xmlfield.c
示例14: conv_mockformat1_to_mockformat1a
static osync_bool conv_mockformat1_to_mockformat1a(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error)
{
osync_trace(TRACE_INTERNAL, "Converting file to fileA");
*free_input = FALSE;
char *identifier = " ";
OSyncFileFormat *file = (OSyncFileFormat *)input;
OSyncFileFormat *fileA = osync_try_malloc0(sizeof(OSyncFileFormat), error);
osync_assert(fileA);
char *filedata = osync_try_malloc0(file->size + 2, error);
memcpy(filedata, file->data, file->size);
memcpy(filedata + file->size, identifier , 2);
fileA->path = file->path;
osync_assert(*error == NULL);
fileA->data = filedata;
fileA->size = file->size + 2;
*output = (char *)fileA;
*outpsize = sizeof(OSyncFileFormat);
return TRUE;
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:26,代码来源:mock_format.c
示例15: compare_file
static OSyncConvCmpResult compare_file(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *user_data, OSyncError **error)
{
osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %i)", __func__, leftdata, leftsize, rightdata, rightsize);
osync_assert(leftdata);
osync_assert(rightdata);
OSyncFileFormat *leftfile = (OSyncFileFormat *)leftdata;
OSyncFileFormat *rightfile = (OSyncFileFormat *)rightdata;
osync_assert(rightfile->path);
osync_assert(leftfile->path);
osync_trace(TRACE_INTERNAL, "Comparing %s and %s", leftfile->path, rightfile->path);
if (mock_format_get_error("MOCK_FORMAT_PATH_COMPARE_NO") || !strcmp(leftfile->path, rightfile->path)) {
if (leftfile->size == rightfile->size) {
if (leftfile->size == 0 || !memcmp(leftfile->data, rightfile->data, rightfile->size)) {
osync_trace(TRACE_EXIT, "%s: Same", __func__);
return OSYNC_CONV_DATA_SAME;
}
}
osync_trace(TRACE_EXIT, "%s: Similar", __func__);
return OSYNC_CONV_DATA_SIMILAR;
}
osync_trace(TRACE_EXIT, "%s: Mismatch", __func__);
return OSYNC_CONV_DATA_MISMATCH;
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:30,代码来源:mock_format.c
示例16: osync_capabilities_save
osync_bool osync_capabilities_save(OSyncCapabilities *capabilities, const char *file, OSyncError **error)
{
unsigned int size;
char *buffer;
osync_bool ret;
osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, capabilities, __NULLSTR(file), error);
osync_assert(capabilities);
osync_assert(file);
osync_capabilities_sort(capabilities);
ret = osync_capabilities_assemble(capabilities, &buffer, &size, error);
if (!ret)
goto error;
ret = osync_file_write(file, buffer, size, 0600, error);
osync_free(buffer);
if (!ret)
goto error;
osync_trace(TRACE_EXIT, "%s", __func__);
return TRUE;
error:
osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error));
return FALSE;
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:30,代码来源:opensync_capabilities.c
示例17: osync_capabilities_objtype_assemble
osync_bool osync_capabilities_objtype_assemble(OSyncCapabilitiesObjType *capsobjtype, xmlNode *node, OSyncError **error)
{
const char *name;
OSyncList *l;
xmlNode *cur;
osync_assert(capsobjtype);
osync_assert(node);
name = osync_capabilities_objtype_get_name(capsobjtype);
osync_assert(name);
cur = xmlNewChild(node, NULL, (xmlChar*)"ObjType", NULL);
if (!cur)
goto error_oom;
xmlSetProp(cur, (const xmlChar*)"Name", (const xmlChar*)name);
for (l = capsobjtype->capabilities; l; l = l->next) {
OSyncCapability *capability;
capability = (OSyncCapability *) l->data;
if (!osync_capability_assemble(capability, cur, error))
goto error;
}
return TRUE;
error_oom:
osync_error_set(error, OSYNC_ERROR_GENERIC, "Couldn't allocate memory to assemble capabilities objtype file.");
error:
osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error));
return FALSE;
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:32,代码来源:opensync_capabilities_objtype.c
示例18: osync_module_load
osync_bool osync_module_load(OSyncModule *module, const char *path, OSyncError **error)
{
osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, module, path, error);
osync_assert(module);
osync_assert(!module->module);
if (!g_module_supported()) {
osync_error_set(error, OSYNC_ERROR_GENERIC, "This platform does not support loading of modules");
goto error;
}
/* Try to open the module or fail if an error occurs.
*
* Do local bind to avoid symbol-clashing - i.e. plugins having the same
* functions name - e.g. finalize().
*
* Don't do lazy binding, otherwise symbols of kdepim-sync can't get loaded.
* Related to C++ and dlopen?
*/
module->module = g_module_open(path, G_MODULE_BIND_LOCAL);
if (!module->module) {
osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to open module %s: %s", path, g_module_error());
goto error;
}
module->path = osync_strdup(path);
osync_trace(TRACE_EXIT, "%s", __func__);
return TRUE;
error:
osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error));
return FALSE;
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:34,代码来源:opensync_module.c
示例19: osync_trace
OSyncXMLField *osync_xmlfield_new(OSyncXMLFormat *xmlformat, const char *name, OSyncError **error)
{
xmlNodePtr node = NULL;
OSyncXMLField *xmlfield = NULL;
osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, xmlformat, name, error);
osync_assert(xmlformat);
osync_assert(name);
node = xmlNewTextChild(xmlDocGetRootElement(xmlformat->doc), NULL, BAD_CAST name, NULL);
xmlfield = osync_xmlfield_new_node(xmlformat, node, error);
if(!xmlfield) {
xmlUnlinkNode(node);
xmlFreeNode(node);
osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error));
return NULL;
}
/* XMLFormat entry got added - not sure if it is still sorted */
osync_xmlformat_set_unsorted(xmlformat);
/* This XMLField has no keys, so it's for sure it's sorted */
xmlfield->sorted = TRUE;
osync_trace(TRACE_EXIT, "%s: %p", __func__, xmlfield);
return xmlfield;
}
开发者ID:ianmartin,项目名称:autoimportopensync,代码行数:27,代码来源:opensync_xmlfield.c
示例20: osync_assert
/** @brief Creates a simple OSyncPluginConfig with a single resource.
* If config is not null the resource information gets added.
*
* @param config OSyncPluginConfig pointer to add resource info
* @param path relative path of resource
* @param objformat the objformat of the resource
* @param format_config the format converter config paramter
* @returns OSyncPluginConfig pointer or asserts on error
*
*/
OSyncPluginConfig *simple_plugin_config(OSyncPluginConfig *config, const char *path, const char *objtype, const char *objformat, const char *format_config) {
OSyncError *error = NULL;
OSyncObjFormatSink *format_sink = NULL;
OSyncPluginResource *res = NULL;
osync_assert(objtype);
osync_assert(objformat);
if (!config)
config = osync_plugin_config_new(&error);
fail_unless(config != NULL, NULL);
fail_unless(error == NULL, NULL);
format_sink = osync_objformat_sink_new(objformat, &error);
if (format_config)
osync_objformat_sink_set_config(format_sink, format_config);
res = osync_plugin_resource_new(&error);
osync_plugin_resource_set_objtype(res, objtype);
osync_plugin_resource_set_path(res, path);
osync_plugin_resource_enable(res, TRUE);
osync_plugin_resource_add_objformat_sink(res, format_sink);
osync_plugin_config_add_resource(config, res);
return config;
}
开发者ID:luizluca,项目名称:opensync-luizluca,代码行数:38,代码来源:support.c
注:本文中的osync_assert函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论