xdrindex.c

Go to the documentation of this file.
00001 #include <grass/dbmi.h>
00002 #include "macros.h"
00003 
00004 
00005 int db__send_index(dbIndex * index)
00006 {
00007     int i;
00008 
00009     DB_SEND_STRING(&index->indexName);
00010     DB_SEND_STRING(&index->tableName);
00011     DB_SEND_CHAR(index->unique);
00012 
00013     DB_SEND_INT(index->numColumns);
00014 
00015     for (i = 0; i < index->numColumns; i++) {
00016         DB_SEND_STRING(&index->columnNames[i]);
00017     }
00018 
00019     return DB_OK;
00020 }
00021 
00022 int db__send_index_array(dbIndex * list, int count)
00023 {
00024     int i;
00025 
00026     DB_SEND_INT(count);
00027     for (i = 0; i < count; i++) {
00028         DB_SEND_INDEX(&list[i]);
00029     }
00030     return DB_OK;
00031 }
00032 
00033 int db__recv_index(dbIndex * index)
00034 {
00035     int i, ncols;
00036 
00037     db_init_index(index);
00038     DB_RECV_STRING(&index->indexName);
00039     DB_RECV_STRING(&index->tableName);
00040     DB_RECV_CHAR(&index->unique);
00041 
00042     DB_RECV_INT(&ncols);
00043 
00044     if (db_alloc_index_columns(index, ncols) != DB_OK)
00045         return db_get_error_code();
00046 
00047     for (i = 0; i < ncols; i++) {
00048         DB_RECV_STRING(&index->columnNames[i]);
00049     }
00050 
00051     return DB_OK;
00052 }
00053 
00054 int db__recv_index_array(dbIndex ** list, int *count)
00055 {
00056     int i;
00057 
00058     DB_RECV_INT(count);
00059 
00060     *list = db_alloc_index_array(*count);
00061     if (*list == NULL)
00062         return db_get_error_code();
00063 
00064     for (i = 0; i < *count; i++) {
00065         DB_RECV_INDEX(&((*list)[i]));
00066     }
00067 
00068     return DB_OK;
00069 }