gboolean is_key;
} Field;
-typedef struct
-{
- gint id;
- gchar *name;
- GList *fields;
- gchar *fields_sql;
- GList *keys;
- gchar *keys_sql;
-} Table;
-
typedef struct
{
gchar **values;
static ZakAudit *zak_audit_new_ (void);
static gboolean load_fields (ZakAudit *zak_audit,
ZakAuditDatasource *datasource,
- Table *table);
+ ZakAuditTable *table);
static gboolean load_tables (ZakAudit *zak_audit,
ZakAuditDatasource *datasource);
static gboolean load_datasources (ZakAudit *zak_audit, va_list ap);
static Field *get_field_from_name (ZakAudit *zak_audit,
- Table *table,
+ ZakAuditTable *table,
const char *field);
-static Table *get_table_from_name (ZakAudit *zak_audit,
+static ZakAuditTable *get_table_from_name (ZakAudit *zak_audit,
ZakAuditDatasource *datasource,
const char *table);
static ZakAuditDatasource *get_datasource_from_name (ZakAudit *zak_audit,
const char *datasource);
static gboolean insert_value (ZakAudit *zak_audit,
gint id_actions,
- Table *table,
+ ZakAuditTable *table,
gchar *field_name,
gchar *value);
static gchar *string_unquote (const gchar *value);
g_free (f->name);
}
-static void
-free_table (gpointer data)
-{
- Table *t;
-
- t = (Table *)data;
-
- g_free (t->name);
- g_list_free_full (t->fields, free_field);
- g_free (t->fields_sql);
- g_list_free_full (t->keys, free_field);
- g_free (t->keys_sql);
-}
-
static gboolean
load_fields (ZakAudit *zak_audit,
ZakAuditDatasource *datasource,
- Table *table)
+ ZakAuditTable *table)
{
GdaDataModel *dm;
GdaDataModel *dm_table;
GdaDataModel *dm;
gchar *sql;
gint rows, row;
- Table *tab;
+ ZakAuditTable *tab;
ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit);
for (row = 0; row < rows; row++)
{
- tab = g_new0 (Table, 1);
+ tab = g_new0 (ZakAuditTable, 1);
tab->id = gdaex_data_model_get_field_value_integer_at (dm, row, "id");
tab->name = gdaex_data_model_get_field_value_stringify_at (dm, row, "name");
static Field
*get_field_from_name (ZakAudit *zak_audit,
- Table *table,
+ ZakAuditTable *table,
const char *field)
{
Field *ret_field;
return ret_field;
}
-static Table
+static ZakAuditTable
*get_table_from_name (ZakAudit *zak_audit,
ZakAuditDatasource *datasource,
const char *table)
{
- Table *ret_table;
+ ZakAuditTable *ret_table;
GList *t = g_list_first (datasource->tables);
gchar *real_table;
ret_table = NULL;
while (t != NULL)
{
- if (g_strcmp0 (((Table *)t->data)->name, real_table) == 0)
+ if (g_strcmp0 (((ZakAuditTable *)t->data)->name, real_table) == 0)
{
- ret_table = (Table *)t->data;
+ ret_table = (ZakAuditTable *)t->data;
break;
}
static gboolean
insert_value (ZakAudit *zak_audit,
gint id_actions,
- Table *table,
+ ZakAuditTable *table,
gchar *field_name,
gchar *value)
{
gint col;
GDateTime *gdt;
ZakAuditDatasource *datasource;
- Table *table;
+ ZakAuditTable *table;
ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit);
gboolean ret;
ZakAuditDatasource *datasource;
- Table *table;
+ ZakAuditTable *table;
GdaConnection *conn;
GdaSqlParser *parser;
GtkWidget *ret;
ZakAuditDatasource *datasource;
- Table *table;
+ ZakAuditTable *table;
Field *field;
guint l;
const gchar **key_values)
{
ZakAuditDatasource *datasource;
- Table *table;
+ ZakAuditTable *table;
Field *field;
guint l;
return ret;
}
+ZakAuditTable
+*zak_audit_table_copy (ZakAuditTable *table)
+{
+ ZakAuditTable *t;
+
+ t = g_slice_new (ZakAuditTable);
+ t->id = table->id;
+ t->name = g_strdup (table->name);
+ t->fields = g_list_copy (table->fields);
+ t->fields_sql = g_strdup (table->fields_sql);
+ t->keys = g_list_copy (table->keys);
+ t->keys_sql = g_strdup (table->keys_sql);
+
+ return t;
+}
+
+void
+zak_audit_table_free (ZakAuditTable *table)
+{
+ g_free (table->name);
+ g_list_free_full (table->fields, free_field);
+ g_free (table->fields_sql);
+ g_list_free_full (table->keys, free_field);
+ g_free (table->keys_sql);
+ g_slice_free (ZakAuditTable, table);
+}
+
ZakAuditDatasource
*zak_audit_datasource_copy (ZakAuditDatasource *datasource)
{
- ZakAuditDatasource *b;
+ ZakAuditDatasource *d;
- b = g_slice_new (ZakAuditDatasource);
- b->id = datasource->id;
- b->name = g_strdup (datasource->name);
- b->cnc_string = g_strdup (datasource->cnc_string);
- b->gdaex = g_object_ref (datasource->gdaex);
- b->tables = g_list_copy (datasource->tables);
+ d = g_slice_new (ZakAuditDatasource);
+ d->id = datasource->id;
+ d->name = g_strdup (datasource->name);
+ d->cnc_string = g_strdup (datasource->cnc_string);
+ d->gdaex = g_object_ref (datasource->gdaex);
+ d->tables = g_list_copy (datasource->tables);
- return b;
+ return d;
}
void
g_free (datasource->name);
g_free (datasource->cnc_string);
g_object_unref (datasource->gdaex);
- g_list_free_full (datasource->tables, free_table);
+ g_list_free_full (datasource->tables, g_free);
g_slice_free (ZakAuditDatasource, datasource);
}