ret_codes.c

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <grass/dbmi.h>
00003 #include "macros.h"
00004 
00005 int db__send_success()
00006 {
00007     DB_SEND_INT(DB_OK);
00008     return DB_OK;
00009 }
00010 
00011 int db__send_failure()
00012 {
00013     DB_SEND_INT(DB_FAILED);
00014     DB_SEND_C_STRING(db_get_error_msg());
00015     return DB_OK;
00016 }
00017 
00018 int db__recv_return_code(int *ret_code)
00019 {
00020     dbString err_msg;
00021 
00022     /* get the return code first */
00023     DB_RECV_INT(ret_code);
00024 
00025     /* if OK, we're done here */
00026     if (*ret_code == DB_OK)
00027         return DB_OK;
00028 
00029     /* should be DB_FAILED */
00030     if (*ret_code != DB_FAILED) {
00031         db_protocol_error();
00032         return DB_PROTOCOL_ERR;
00033     }
00034     /* get error message from driver */
00035     db_init_string(&err_msg);
00036     DB_RECV_STRING(&err_msg);
00037 
00038     db_error(db_get_string(&err_msg));
00039     db_free_string(&err_msg);
00040 
00041     return DB_OK;
00042 }