int main (int argc, char **argv) { midgard_init (); MidgardConfig *config = midgard_config_new (); midgard_config_read_file_at_path (config, "/tmp/test_SQLITE.conf", NULL); MidgardConnection *mgd = midgard_connection_new (); midgard_connection_open_config (mgd, config); //midgard_storage_create_base_storage (mgd); //midgard_storage_create (mgd,"midgard_snippetdir"); MidgardObject *obj = midgard_object_new (mgd, "midgard_snippetdir", NULL); midgard_object_create (obj); MidgardObject *obja = midgard_object_new (mgd, "midgard_snippetdir", NULL); midgard_object_create (obja); MidgardObject *objb = midgard_object_new (mgd, "midgard_snippetdir", NULL); midgard_object_create (objb); MidgardObject *objc = midgard_object_new (mgd, "midgard_snippetdir", NULL); midgard_object_create (objc); MidgardObject *objd = midgard_object_new (mgd, "midgard_snippetdir", NULL); midgard_object_create (objd); g_print ("END TEST FUNC \n"); return 0; }
int main() { midgard_init(); MidgardConfig *config = midgard_config_new(); g_object_set (config, "dbtype", "SQLite", "dbdir", "/tmp", "database", "MidgardStaticDB", NULL); MidgardConnection *mgd = midgard_connection_new(); midgard_connection_open_config (mgd, config, NULL); g_print("Connected '%s' \n", midgard_connection_get_error_string(mgd)); midgard_storage_create_base_storage(mgd); g_print("Created storage: '%s' \n", midgard_connection_get_error_string(mgd)); return 0; }
int main (int argc, char **argv) { midgard_init (); MidgardConfig *config = midgard_config_new (); midgard_config_read_file_at_path (config, "/tmp/test_SQLITE.conf", NULL); MidgardConnection *mgd = midgard_connection_new (); midgard_connection_open_config (mgd, config); GThreadPool *pool = g_thread_pool_new (pool_func, (gpointer) mgd, 10, TRUE, NULL); //midgard_storage_create_base_storage (mgd); //midgard_storage_create (mgd,"midgard_snippetdir"); g_print ("START OPERATIONS \n"); MidgardObject *obj = midgard_object_new (mgd, "midgard_snippetdir", NULL); g_thread_pool_push (pool, (gpointer) obj, NULL); MidgardObject *obja = midgard_object_new (mgd, "midgard_snippetdir", NULL); g_thread_pool_push (pool, (gpointer) obja, NULL); MidgardObject *objb = midgard_object_new (mgd, "midgard_snippetdir", NULL); g_thread_pool_push (pool, (gpointer) objb, NULL); MidgardObject *objc = midgard_object_new (mgd, "midgard_snippetdir", NULL); g_thread_pool_push (pool, (gpointer) objc, NULL); MidgardObject *objd = midgard_object_new (mgd, "midgard_snippetdir", NULL); g_thread_pool_push (pool, (gpointer) objd, NULL); g_print ("END OPERATIONS \n"); g_print ("THREADS REMAIN (%d) \n", g_thread_pool_unprocessed (pool)); g_thread_pool_free (pool, FALSE, TRUE); return 0; }
static PHP_METHOD(midgard_connection, open_config) { RETVAL_FALSE; zval *cnf_object; zend_bool rv; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &cnf_object, php_midgard_config_class) == FAILURE) return; MidgardConfig *config = MIDGARD_CONFIG(__php_gobject_ptr(cnf_object)); MidgardConnection *mgd = __midgard_connection_get_ptr(getThis()); rv = (zend_bool) midgard_connection_open_config(mgd, config); // if (rv) { // zval_add_ref(&cnf_object); // } RETURN_BOOL(rv); }
int main (int argc, gchar **argv) { g_return_val_if_fail(argc == 2, 1); gchar *config_file = argv[1]; midgard_init(); mgd = midgard_connection_new(); if(!mgd) g_error("Can not initialize midgard connection"); MidgardConfig *config = g_object_new(MIDGARD_TYPE_CONFIG, NULL); GError *error = NULL; if(!midgard_config_read_file(config, (const gchar *)config_file, TRUE, &error)) { if(error) { g_warning("%s", error->message); g_error_free(error); } return 1; } if(!midgard_connection_open_config(mgd, config)) return 1; rep = g_string_new(""); _run_binary_test(); //_run_string_tests(); //_print_report(); }
MidgardConnection *midgard_test_connection_open_user_config(const gchar *name, MidgardConfig **config) { g_assert(*config == NULL); MidgardConnection *mgd = midgard_connection_new(); gboolean opened = FALSE; GError *err = NULL; *config = midgard_test_config_new_user_config(name); g_assert(*config != NULL); opened = midgard_connection_open_config(mgd, *config, err); /* Fail, we didn't make connection */ g_assert(opened == TRUE); /* Fail if we connected and error is set */ g_assert(err == NULL); /* Fail if midgard error is not OK */ MIDGARD_TEST_ERROR_OK(mgd); return mgd; }