Files
mdbtools/src/libmdb/worktable.c

75 lines
2.1 KiB
C
Raw Normal View History

2004-01-09 22:28:47 +00:00
/* MDB Tools - A library for reading MS Access database files
* Copyright (C) 2004 Brian Bruns
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "mdbtools.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
/*
* Temp table routines. These are currently used to generate mock results for
* commands like "list tables" and "describe table"
*/
2004-03-06 23:59:54 +00:00
void
mdb_fill_temp_col(MdbColumn *tcol, char *col_name, int col_size, int col_type, int is_fixed)
{
memset(tcol,0,sizeof(MdbColumn));
strcpy(tcol->name, col_name);
tcol->col_size = col_size;
tcol->col_type = col_type;
tcol->is_fixed = is_fixed;
}
void
mdb_fill_temp_field(MdbField *field, void *value, int siz, int is_fixed, int is_null, int start, int colnum)
{
field->value = value;
field->siz = siz;
field->is_fixed = is_fixed;
field->is_null = is_null;
field->start = start;
field->colnum = colnum;
}
2004-01-09 22:28:47 +00:00
MdbTableDef *
mdb_create_temp_table(MdbHandle *mdb, char *name)
{
2004-06-23 04:22:45 +00:00
MdbCatalogEntry *entry;
2004-01-09 22:28:47 +00:00
MdbTableDef *table;
/* dummy up a catalog entry */
2004-06-23 04:22:45 +00:00
entry = (MdbCatalogEntry *) g_malloc0(sizeof(MdbCatalogEntry));
entry->mdb = mdb;
entry->object_type = MDB_TABLE;
entry->table_pg = 0;
strcpy(entry->object_name, name);
2004-01-09 22:28:47 +00:00
2004-06-23 04:22:45 +00:00
table = mdb_alloc_tabledef(entry);
2004-01-09 22:28:47 +00:00
table->columns = g_ptr_array_new();
return table;
}
void
mdb_temp_table_add_col(MdbTableDef *table, MdbColumn *col)
{
col->col_num = table->num_cols;
2004-06-23 04:22:45 +00:00
g_ptr_array_add(table->columns, g_memdup(col, sizeof(MdbColumn)));
2004-01-09 22:28:47 +00:00
table->num_cols++;
}