1 /*! 2 \file lib/db/dbmi_base/ret_codes.c 3 4 \brief DBMI Library (base) - return codes (internal use only) 5 6 \todo Are we as restrictive here as for vector names? 7 8 (C) 1999-2009, 2011 by the GRASS Development Team 9 10 This program is free software under the GNU General Public License 11 (>=v2). Read the file COPYING that comes with GRASS for details. 12 13 \author Joel Jones (CERL/UIUC), Radim Blazek 14 \author Doxygenized by Martin Landa <landa.martin gmail.com> (2011) 15 */ 16 17 #include <stdlib.h> 18 #include <grass/dbmi.h> 19 #include "macros.h" 20 21 /*! 22 \brief Send success code 23 24 \return DB_OK 25 */ db__send_success()26int db__send_success() 27 { 28 DB_SEND_INT(DB_OK); 29 return DB_OK; 30 } 31 32 /*! 33 \brief Send failure code 34 35 \return DB_OK 36 */ db__send_failure()37int db__send_failure() 38 { 39 DB_SEND_INT(DB_FAILED); 40 DB_SEND_C_STRING(db_get_error_msg()); 41 return DB_OK; 42 } 43 44 /*! 45 \brief Receive return code 46 47 \param[out] ret_code return code 48 49 \return DB_OK on success 50 */ db__recv_return_code(int * ret_code)51int db__recv_return_code(int *ret_code) 52 { 53 dbString err_msg; 54 55 /* get the return code first */ 56 DB_RECV_INT(ret_code); 57 58 /* if OK, we're done here */ 59 if (*ret_code == DB_OK) 60 return DB_OK; 61 62 /* should be DB_FAILED */ 63 if (*ret_code != DB_FAILED) { 64 db_protocol_error(); 65 return DB_PROTOCOL_ERR; 66 } 67 /* get error message from driver */ 68 db_init_string(&err_msg); 69 DB_RECV_STRING(&err_msg); 70 71 db_error(db_get_string(&err_msg)); 72 db_free_string(&err_msg); 73 74 return DB_OK; 75 } 76