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; }
/** * midgard_connection_open_from_file: * @mgd: #MidgardConnection instance * @filepath: configuration file path * @error: pointer to store error * * Opens a connection to the database. * The configuration file is read from given filepath. * * Take a look at midgard_connection_open() wrt #MidgardSchema. * * Returns: %TRUE if the operation succeeded, %FALSE otherwise. */ gboolean midgard_connection_open_from_file( MidgardConnection *mgd, const char *filepath, GError **error) { g_assert(mgd != NULL); g_assert (filepath != NULL); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); gboolean rv = TRUE; __SELF_REOPEN (mgd, rv); if (!rv) return rv; /* FIXME, it should be handled by GError */ if(mgd->priv->config != NULL){ midgard_set_error(mgd, MGD_GENERIC_ERROR, MGD_ERR_USER_DATA, "MidgardConfig already associated with " "MidgardConnection"); return FALSE; } MidgardConfig *config = midgard_config_new(); GError *rf_error = NULL; if(!midgard_config_read_file_at_path(config, filepath, &rf_error)) { if(rf_error) g_propagate_error(error, rf_error); return FALSE; } if(error) g_clear_error(&rf_error); mgd->priv->config = config; GHashTable *hash = NULL; if(!__midgard_connection_open(mgd, &hash, TRUE)) rv = FALSE; if(hash) g_hash_table_destroy(hash); return rv; }
static PHP_METHOD(midgard_config, read_file_at_path) { RETVAL_FALSE; char *path; int path_length; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &path_length) == FAILURE) { return; } MidgardConfig *config = (MidgardConfig *) __php_gobject_ptr(getThis()); gboolean rv = midgard_config_read_file_at_path(config, path, NULL); RETURN_BOOL(rv); }
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; }