GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ret_codes.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <grass/dbmi.h>
3 #include "macros.h"
4 
6 {
7  DB_SEND_INT(DB_OK);
8  return DB_OK;
9 }
10 
12 {
13  DB_SEND_INT(DB_FAILED);
15  return DB_OK;
16 }
17 
18 int db__recv_return_code(int *ret_code)
19 {
20  dbString err_msg;
21 
22  /* get the return code first */
23  DB_RECV_INT(ret_code);
24 
25  /* if OK, we're done here */
26  if (*ret_code == DB_OK)
27  return DB_OK;
28 
29  /* should be DB_FAILED */
30  if (*ret_code != DB_FAILED) {
32  return DB_PROTOCOL_ERR;
33  }
34  /* get error message from driver */
35  db_init_string(&err_msg);
36  DB_RECV_STRING(&err_msg);
37 
38  db_error(db_get_string(&err_msg));
39  db_free_string(&err_msg);
40 
41  return DB_OK;
42 }
const char * db_get_error_msg(void)
#define DB_SEND_INT(x)
Definition: macros.h:37
#define DB_SEND_C_STRING(x)
Definition: macros.h:16
int db__send_success()
Definition: ret_codes.c:5
#define DB_RECV_INT(x)
Definition: macros.h:39
int db__send_failure()
Definition: ret_codes.c:11
void db_protocol_error(void)
void db_error(const char *s)
int db__recv_return_code(int *ret_code)
Definition: ret_codes.c:18
char * db_get_string(dbString *x)
Definition: string.c:131
void db_free_string(dbString *x)
Definition: string.c:142
void db_init_string(dbString *x)
Definition: string.c:11
#define DB_RECV_STRING(x)
Definition: macros.h:18