GRASS Programmer's Manual
6.4.2(2012)
|
00001 #include <grass/dbmi.h> 00002 #include "macros.h" 00003 00004 00005 int db__send_table_definition(dbTable * table) 00006 { 00007 int i; 00008 00009 DB_SEND_INT(table->numColumns); 00010 00011 for (i = 0; i < table->numColumns; i++) { 00012 DB_SEND_COLUMN_DEFINITION(&table->columns[i]); 00013 } 00014 DB_SEND_STRING(&table->tableName); 00015 DB_SEND_STRING(&table->description); 00016 00017 DB_SEND_INT(table->priv_insert); 00018 DB_SEND_INT(table->priv_delete); 00019 00020 return DB_OK; 00021 } 00022 00023 int db__recv_table_definition(dbTable ** table) 00024 { 00025 int i, ncols; 00026 dbTable *t; 00027 00028 DB_RECV_INT(&ncols); 00029 00030 *table = t = db_alloc_table(ncols); 00031 if (t == NULL) 00032 return db_get_error_code(); 00033 00034 for (i = 0; i < t->numColumns; i++) { 00035 DB_RECV_COLUMN_DEFINITION(&t->columns[i]); 00036 } 00037 DB_RECV_STRING(&t->tableName); 00038 DB_RECV_STRING(&t->description); 00039 00040 DB_RECV_INT(&t->priv_insert); 00041 DB_RECV_INT(&t->priv_delete); 00042 00043 return DB_OK; 00044 } 00045 00046 int db__send_table_data(dbTable * table) 00047 { 00048 int i, ncols; 00049 00050 ncols = table->numColumns; 00051 DB_SEND_INT(ncols); 00052 for (i = 0; i < ncols; i++) { 00053 DB_SEND_COLUMN_VALUE(db_get_table_column(table, i)); 00054 } 00055 00056 return DB_OK; 00057 } 00058 00059 int db__recv_table_data(dbTable * table) 00060 { 00061 int i, ncols; 00062 00063 ncols = table->numColumns; 00064 DB_RECV_INT(&i); 00065 00066 if (i != ncols) { 00067 db_error("fetch: table has wrong number of columns"); 00068 return DB_FAILED; 00069 } 00070 for (i = 0; i < ncols; i++) { 00071 DB_RECV_COLUMN_VALUE(db_get_table_column(table, i)); 00072 } 00073 00074 return DB_OK; 00075 }