GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
xdrvalue.c
Go to the documentation of this file.
1 #include <grass/dbmi.h>
2 #include "macros.h"
3 
4 int db__send_value(dbValue * value, int Ctype)
5 {
6  DB_SEND_CHAR(value->isNull);
7  if (value->isNull)
8  return DB_OK;
9 
10  switch (Ctype) {
11  case DB_C_TYPE_INT:
12  DB_SEND_INT(value->i);
13  break;
14  case DB_C_TYPE_DOUBLE:
15  DB_SEND_DOUBLE(value->d);
16  break;
17  case DB_C_TYPE_STRING:
18  DB_SEND_STRING(&value->s);
19  break;
20  case DB_C_TYPE_DATETIME:
21  DB_SEND_DATETIME(&value->t);
22  break;
23  default:
24  db_error("send data: invalid C-type");
25  return DB_FAILED;
26  }
27  return DB_OK;
28 }
29 
30 int db__recv_value(dbValue * value, int Ctype)
31 {
32  DB_RECV_CHAR(&value->isNull);
33  if (value->isNull)
34  return DB_OK;
35 
36  switch (Ctype) {
37  case DB_C_TYPE_INT:
38  DB_RECV_INT(&value->i);
39  break;
40  case DB_C_TYPE_DOUBLE:
41  DB_RECV_DOUBLE(&value->d);
42  break;
43  case DB_C_TYPE_STRING:
44  DB_RECV_STRING(&value->s);
45  break;
46  case DB_C_TYPE_DATETIME:
47  DB_RECV_DATETIME(&value->t);
48  break;
49  default:
50  db_error("send data: invalid C-type");
51  return DB_FAILED;
52  }
53  return DB_OK;
54 }
#define DB_SEND_CHAR(x)
Definition: macros.h:23
#define DB_SEND_INT(x)
Definition: macros.h:37
#define DB_RECV_INT(x)
Definition: macros.h:39
#define DB_RECV_DATETIME(x)
Definition: macros.h:54
#define DB_RECV_DOUBLE(x)
Definition: macros.h:49
void db_error(const char *s)
int db__recv_value(dbValue *value, int Ctype)
Definition: xdrvalue.c:30
int db__send_value(dbValue *value, int Ctype)
Definition: xdrvalue.c:4
#define DB_SEND_DOUBLE(x)
Definition: macros.h:47
#define DB_RECV_CHAR(x)
Definition: macros.h:25
char * value
Definition: env.c:30
#define DB_SEND_STRING(x)
Definition: macros.h:12
#define DB_SEND_DATETIME(x)
Definition: macros.h:52
#define DB_RECV_STRING(x)
Definition: macros.h:18