]>
git.saurik.com Git - apple/security.git/blob - utilities/src/sqlutils.h
5 // Created by Fabrice Gautier on 8/26/11.
6 // Copyright (c) 2011 Apple, Inc. All rights reserved.
10 * sqlutils.h - some wrapper for sql3lite
12 #ifndef _SECURITY_UTILITIES_SQLUTILS_H_
13 #define _SECURITY_UTILITIES_SQLUTILS_H_
17 /* Those are just wrapper around the sqlite3 functions, but they have size_t for some len parameters,
18 and checks for overflow before casting to int */
19 static inline int sqlite3_bind_blob_wrapper(sqlite3_stmt
* pStmt
, int i
, const void* zData
, size_t n
, void(*xDel
)(void*))
21 if(n
>INT_MAX
) return SQLITE_TOOBIG
;
22 return sqlite3_bind_blob(pStmt
, i
, zData
, (int)n
, xDel
);
25 static inline int sqlite3_bind_text_wrapper(sqlite3_stmt
* pStmt
, int i
, const void* zData
, size_t n
, void(*xDel
)(void*))
27 if(n
>INT_MAX
) return SQLITE_TOOBIG
;
28 return sqlite3_bind_text(pStmt
, i
, zData
, (int)n
, xDel
);
31 static inline int sqlite3_prepare_wrapper(sqlite3
*db
, const char *zSql
, size_t nByte
, sqlite3_stmt
**ppStmt
, const char **pzTail
)
33 if(nByte
>INT_MAX
) return SQLITE_TOOBIG
;
34 return sqlite3_prepare(db
, zSql
, (int)nByte
, ppStmt
, pzTail
);