[asterisk-commits] tilghman: branch tilghman/odbc_tx_support r169478 - in /team/tilghman/odbc_tx...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 19 16:50:52 CST 2009


Author: tilghman
Date: Mon Jan 19 16:50:52 2009
New Revision: 169478

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=169478
Log:
Merged revisions 169438 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r169438 | kpfleming | 2009-01-19 15:42:46 -0600 (Mon, 19 Jan 2009) | 5 lines
  
  ast_str_SQLGetData is *not* part of the ast_str API, it's part of the ast_odbc API and just happens to use an ast_str as the buffer; move all of it to res_odbc.c and res_odbc.h, renaming appropriately
  
  along the way fix some minor coding style issues in strings.h and add some attribute_pure annotations to functions in the ast_str API
........

Modified:
    team/tilghman/odbc_tx_support/   (props changed)
    team/tilghman/odbc_tx_support/funcs/func_odbc.c
    team/tilghman/odbc_tx_support/include/asterisk/res_odbc.h
    team/tilghman/odbc_tx_support/include/asterisk/strings.h
    team/tilghman/odbc_tx_support/res/res_odbc.c

Propchange: team/tilghman/odbc_tx_support/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/tilghman/odbc_tx_support/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jan 19 16:50:52 2009
@@ -1,1 +1,1 @@
-/trunk:1-169427
+/trunk:1-169477

Modified: team/tilghman/odbc_tx_support/funcs/func_odbc.c
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/odbc_tx_support/funcs/func_odbc.c?view=diff&rev=169478&r1=169477&r2=169478
==============================================================================
--- team/tilghman/odbc_tx_support/funcs/func_odbc.c (original)
+++ team/tilghman/odbc_tx_support/funcs/func_odbc.c Mon Jan 19 16:50:52 2009
@@ -31,7 +31,6 @@
 	<depend>res_odbc</depend>
  ***/
 
-#define USE_ODBC
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
@@ -564,7 +563,7 @@
 			}
 
 			buflen = strlen(buf);
-			res = ast_str_SQLGetData(&coldata, -1, stmt, x + 1, SQL_CHAR, &indicator);
+			res = ast_odbc_ast_str_SQLGetData(&coldata, -1, stmt, x + 1, SQL_CHAR, &indicator);
 			if (indicator == SQL_NULL_DATA) {
 				ast_debug(3, "Got NULL data\n");
 				ast_str_reset(coldata);
@@ -1114,7 +1113,7 @@
 						snprintf(colname, sizeof(colname), "field%d", x);
 					}
 
-					res = ast_str_SQLGetData(&coldata, maxcol, stmt, x + 1, SQL_CHAR, &indicator);
+					res = ast_odbc_ast_str_SQLGetData(&coldata, maxcol, stmt, x + 1, SQL_CHAR, &indicator);
 					if (indicator == SQL_NULL_DATA) {
 						ast_str_set(&coldata, 0, "(nil)");
 						res = SQL_SUCCESS;

Modified: team/tilghman/odbc_tx_support/include/asterisk/res_odbc.h
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/odbc_tx_support/include/asterisk/res_odbc.h?view=diff&rev=169478&r1=169477&r2=169478
==============================================================================
--- team/tilghman/odbc_tx_support/include/asterisk/res_odbc.h (original)
+++ team/tilghman/odbc_tx_support/include/asterisk/res_odbc.h Mon Jan 19 16:50:52 2009
@@ -31,6 +31,7 @@
 #include <sqlext.h>
 #include <sqltypes.h>
 #include "asterisk/linkedlists.h"
+#include "asterisk/strings.h"
 
 typedef enum { ODBC_SUCCESS=0, ODBC_FAIL=-1} odbc_status;
 
@@ -207,4 +208,14 @@
  */
 #define ast_odbc_release_table(ptr) if (ptr) { AST_RWLIST_UNLOCK(&(ptr)->columns); }
 
+/*!\brief Wrapper for SQLGetData to use with dynamic strings
+ * \param buf Address of the pointer to the ast_str structure.
+ * \param maxlen The maximum size of the resulting string, or 0 for no limit.
+ * \param StatementHandle The statement handle from which to retrieve data.
+ * \param ColumnNumber Column number (1-based offset) for which to retrieve data.
+ * \param TargetType The SQL constant indicating what kind of data is to be retrieved (usually SQL_CHAR)
+ * \param StrLen_or_Ind A pointer to a length indicator, specifying the total length of data.
+ */
+SQLRETURN ast_odbc_ast_str_SQLGetData(struct ast_str **buf, int pmaxlen, SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, SQLLEN *StrLen_or_Ind);
+
 #endif /* _ASTERISK_RES_ODBC_H */

Modified: team/tilghman/odbc_tx_support/include/asterisk/strings.h
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/odbc_tx_support/include/asterisk/strings.h?view=diff&rev=169478&r1=169477&r2=169478
==============================================================================
--- team/tilghman/odbc_tx_support/include/asterisk/strings.h (original)
+++ team/tilghman/odbc_tx_support/include/asterisk/strings.h Mon Jan 19 16:50:52 2009
@@ -60,7 +60,7 @@
 }
 
 #else
-static force_inline int ast_strlen_zero(const char *s)
+static force_inline int attribute_pure ast_strlen_zero(const char *s)
 {
 	return (!s || (*s == '\0'));
 }
@@ -83,11 +83,11 @@
   \return a pointer to the first non-whitespace character
  */
 AST_INLINE_API(
-char *ast_skip_blanks(const char *str),
+char * attribute_pure ast_skip_blanks(const char *str),
 {
 	while (*str && ((unsigned char) *str) < 33)
 		str++;
-	return (char *)str;
+	return (char *) str;
 }
 )
 
@@ -122,11 +122,11 @@
   \return a pointer to the first whitespace character
  */
 AST_INLINE_API(
-char *ast_skip_nonblanks(char *str),
+char * attribute_pure ast_skip_nonblanks(const char *str),
 {
 	while (*str && ((unsigned char) *str) > 32)
 		str++;
-	return str;
+	return (char *) str;
 }
 )
   
@@ -142,9 +142,9 @@
 AST_INLINE_API(
 char *ast_strip(char *s),
 {
-	s = ast_skip_blanks(s);
-	if (s)
+	if ((s = ast_skip_blanks(s))) {
 		ast_trim_blanks(s);
+	}
 	return s;
 } 
 )
@@ -257,7 +257,7 @@
  * \retval -1 if "true".
  * \retval 0 otherwise.
  */
-int ast_true(const char *val);
+int attribute_pure ast_true(const char *val);
 
 /*! 
  * \brief Make sure something is false.
@@ -269,7 +269,7 @@
  * \retval -1 if "true".
  * \retval 0 otherwise.
  */
-int ast_false(const char *val);
+int attribute_pure ast_false(const char *val);
 
 /*
  *  \brief Join an array of strings into a single string.
@@ -397,8 +397,9 @@
 {
 	if (buf) {
 		buf->__AST_STR_USED = 0;
-		if (buf->__AST_STR_LEN)
+		if (buf->__AST_STR_LEN) {
 			buf->__AST_STR_STR[0] = '\0';
+		}
 	}
 }
 )
@@ -432,7 +433,7 @@
  * \param A pointer to the ast_str string.
  */
 AST_INLINE_API(
-size_t ast_str_strlen(struct ast_str *buf),
+size_t attribute_pure ast_str_strlen(struct ast_str *buf),
 {
 	return buf->__AST_STR_USED;
 }
@@ -442,7 +443,7 @@
  * \param A pointer to the ast_str string.
  */
 AST_INLINE_API(
-size_t ast_str_size(struct ast_str *buf),
+size_t attribute_pure ast_str_size(struct ast_str *buf),
 {
 	return buf->__AST_STR_LEN;
 }
@@ -452,7 +453,7 @@
  * \param A pointer to the ast_str string.
  */
 AST_INLINE_API(
-attribute_pure char *ast_str_buffer(struct ast_str *buf),
+char * attribute_pure ast_str_buffer(struct ast_str *buf),
 {
 	return buf->__AST_STR_STR;
 }
@@ -752,39 +753,6 @@
 }
 )
 
-/*!\brief Wrapper for SQLGetData to use with dynamic strings
- * \param buf Address of the pointer to the ast_str structure.
- * \param maxlen The maximum size of the resulting string, or 0 for no limit.
- * \param StatementHandle The statement handle from which to retrieve data.
- * \param ColumnNumber Column number (1-based offset) for which to retrieve data.
- * \param TargetType The SQL constant indicating what kind of data is to be retrieved (usually SQL_CHAR)
- * \param StrLen_or_Ind A pointer to a length indicator, specifying the total length of data.
- */
-#ifdef USE_ODBC
-#include <sql.h>
-#include <sqlext.h>
-#include <sqltypes.h>
-
-AST_INLINE_API(SQLRETURN ast_str_SQLGetData(struct ast_str **buf, int pmaxlen, SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, SQLLEN *StrLen_or_Ind),
-{
-	SQLRETURN res;
-	size_t maxlen;
-	if (pmaxlen == 0) {
-		if (SQLGetData(StatementHandle, ColumnNumber, TargetType, (*buf)->__AST_STR_STR, 0, StrLen_or_Ind) == SQL_SUCCESS_WITH_INFO) {
-			ast_str_make_space(buf, *StrLen_or_Ind + 1);
-		}
-	} else if (pmaxlen > 0) {
-		ast_str_make_space(buf, pmaxlen);
-	}
-	maxlen = (*buf)->__AST_STR_LEN;
-	res = SQLGetData(StatementHandle, ColumnNumber, TargetType, (*buf)->__AST_STR_STR, maxlen, StrLen_or_Ind);
-	(*buf)->__AST_STR_USED = *StrLen_or_Ind;
-	return res;
-}
-)
-#endif /* defined(USE_ODBC) */
-
-
 /*!
  * \brief Set a dynamic string using variable arguments
  *
@@ -846,7 +814,7 @@
  *
  * http://www.cse.yorku.ca/~oz/hash.html
  */
-static force_inline int ast_str_hash(const char *str)
+static force_inline int attribute_pure ast_str_hash(const char *str)
 {
 	int hash = 5381;
 
@@ -863,7 +831,7 @@
  * all characters to lowercase prior to computing a hash. This
  * allows for easy case-insensitive lookups in a hash table.
  */
-static force_inline int ast_str_case_hash(const char *str)
+static force_inline int attribute_pure ast_str_case_hash(const char *str)
 {
 	int hash = 5381;
 

Modified: team/tilghman/odbc_tx_support/res/res_odbc.c
URL: http://svn.digium.com/svn-view/asterisk/team/tilghman/odbc_tx_support/res/res_odbc.c?view=diff&rev=169478&r1=169477&r2=169478
==============================================================================
--- team/tilghman/odbc_tx_support/res/res_odbc.c (original)
+++ team/tilghman/odbc_tx_support/res/res_odbc.c Mon Jan 19 16:50:52 2009
@@ -672,6 +672,22 @@
 	return res;
 }
 
+SQLRETURN ast_odbc_ast_str_SQLGetData(struct ast_str **buf, int pmaxlen, SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, SQLLEN *StrLen_or_Ind)
+{
+	SQLRETURN res;
+
+	if (pmaxlen == 0) {
+		if (SQLGetData(StatementHandle, ColumnNumber, TargetType, ast_str_buffer(*buf), 0, StrLen_or_Ind) == SQL_SUCCESS_WITH_INFO) {
+			ast_str_make_space(buf, *StrLen_or_Ind + 1);
+		}
+	} else if (pmaxlen > 0) {
+		ast_str_make_space(buf, pmaxlen);
+	}
+	res = SQLGetData(StatementHandle, ColumnNumber, TargetType, ast_str_buffer(*buf), ast_str_size(*buf), StrLen_or_Ind);
+	ast_str_update(*buf);
+
+	return res;
+}
 
 int ast_odbc_sanity_check(struct odbc_obj *obj) 
 {




More information about the asterisk-commits mailing list