GRASS Programmer's Manual  6.4.3(2013)-r
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 }