#### db_mysql: coherent indentation and whitespacing

Daniel-Constantin Mierla authored on 09/11/2017 06:03:02
Showing 1 changed files
 ... ... @@ -1,4 +1,4 @@ 1 -/*  1 +/* 2 2  * MySQL module row related functions 3 3  * 4 4  * Copyright (C) 2001-2003 FhG Fokus ... ... @@ -16,8 +16,8 @@ 16 16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 17  * GNU General Public License for more details. 18 18  * 19 - * You should have received a copy of the GNU General Public License  20 - * along with this program; if not, write to the Free Software  19 + * You should have received a copy of the GNU General Public License 20 + * along with this program; if not, write to the Free Software 21 21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 22  */ 23 23   ... ... @@ -57,12 +57,12 @@ int db_mysql_convert_row(const db1_con_t* _h, db1_res_t* _res, db_row_t* _r) 57 57  LM_ERR("could not allocate row"); 58 58  return -2; 59 59  } 60 -  60 + 61 61  lengths = mysql_fetch_lengths(RES_RESULT(_res)); 62 62   63 63  for(i = 0; i < RES_COL_N(_res); i++) { 64 64  if (db_str2val(RES_TYPES(_res)[i], &(ROW_VALUES(_r)[i]), 65 - ((MYSQL_ROW)RES_ROW(_res))[i], lengths[i], 0) < 0) { 65 + ((MYSQL_ROW)RES_ROW(_res))[i], lengths[i], 0) < 0) { 66 66  LM_ERR("failed to convert value\n"); 67 67  LM_DBG("free row at %p\n", _r); 68 68  db_free_row(_r);

#### core, lib, modules: updated include paths for header files

Daniel-Constantin Mierla authored on 07/12/2016 11:07:22
Showing 1 changed files
 ... ... @@ -27,8 +27,8 @@ 27 27  * Module: \ref db_mysql 28 28  */ 29 29   30 -#include "../../dprint.h" 31 -#include "../../mem/mem.h" 30 +#include "../../core/dprint.h" 31 +#include "../../core/mem/mem.h" 32 32  #include "../../lib/srdb1/db_row.h" 33 33  #include "../../lib/srdb1/db_val.h" 34 34  #include "km_my_con.h"

#### core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
 1 1 new file mode 100644 ... ... @@ -0,0 +1,73 @@ 1 +/*  2 + * MySQL module row related functions 3 + * 4 + * Copyright (C) 2001-2003 FhG Fokus 5 + * Copyright (C) 2008 1&1 Internet AG 6 + * 7 + * This file is part of Kamailio, a free SIP server. 8 + * 9 + * Kamailio is free software; you can redistribute it and/or modify 10 + * it under the terms of the GNU General Public License as published by 11 + * the Free Software Foundation; either version 2 of the License, or 12 + * (at your option) any later version 13 + * 14 + * Kamailio is distributed in the hope that it will be useful, 15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 + * GNU General Public License for more details. 18 + * 19 + * You should have received a copy of the GNU General Public License  20 + * along with this program; if not, write to the Free Software  21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 + */ 23 + 24 +/*! \file 25 + * \brief DB_MYSQL :: Row related functions 26 + * \ingroup db_mysql 27 + * Module: \ref db_mysql 28 + */ 29 + 30 +#include "../../dprint.h" 31 +#include "../../mem/mem.h" 32 +#include "../../lib/srdb1/db_row.h" 33 +#include "../../lib/srdb1/db_val.h" 34 +#include "km_my_con.h" 35 +#include "km_val.h" 36 +#include "km_row.h" 37 +#include "km_res.h" 38 + 39 +/*! 40 + * \brief Convert a row from result into DB API representation 41 + * \param _h database connection 42 + * \param _res database result in the DB API representation 43 + * \param _r database result row 44 + * \return 0 on success, -1 on failure 45 + */ 46 +int db_mysql_convert_row(const db1_con_t* _h, db1_res_t* _res, db_row_t* _r) 47 +{ 48 + unsigned long* lengths; 49 + int i; 50 + 51 + if ((!_h) || (!_res) || (!_r)) { 52 + LM_ERR("invalid parameter value\n"); 53 + return -1; 54 + } 55 + 56 + if (db_allocate_row(_res, _r) != 0) { 57 + LM_ERR("could not allocate row"); 58 + return -2; 59 + } 60 +  61 + lengths = mysql_fetch_lengths(RES_RESULT(_res)); 62 + 63 + for(i = 0; i < RES_COL_N(_res); i++) { 64 + if (db_str2val(RES_TYPES(_res)[i], &(ROW_VALUES(_r)[i]), 65 + ((MYSQL_ROW)RES_ROW(_res))[i], lengths[i], 0) < 0) { 66 + LM_ERR("failed to convert value\n"); 67 + LM_DBG("free row at %p\n", _r); 68 + db_free_row(_r); 69 + return -3; 70 + } 71 + } 72 + return 0; 73 +}