From 1c2911f5a1affb71f41cf68cb53292eb5901f295 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Mon, 19 Jan 2009 21:42:46 +0000 Subject: 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 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@169438 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_odbc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'res') diff --git a/res/res_odbc.c b/res/res_odbc.c index 165cf872b..3a9b8eea6 100644 --- a/res/res_odbc.c +++ b/res/res_odbc.c @@ -48,6 +48,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/res_odbc.h" #include "asterisk/time.h" #include "asterisk/astobj2.h" +#include "asterisk/strings.h" struct odbc_class { @@ -366,6 +367,22 @@ int ast_odbc_smart_execute(struct odbc_obj *obj, SQLHSTMT stmt) 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) { -- cgit v1.2.3