1/* Copyright (c) 2012 Apple Inc. All Rights Reserved. */ 2 3#ifndef _SECURITY_AUTH_AUTHDB_H_ 4#define _SECURITY_AUTH_AUTHDB_H_ 5 6#include <sqlite3.h> 7#include <CoreFoundation/CoreFoundation.h> 8 9enum { 10 AuthDBTransactionNone = 0, 11 AuthDBTransactionImmediate, 12 AuthDBTransactionExclusive, 13 AuthDBTransactionNormal 14}; 15typedef uint32_t AuthDBTransactionType; 16 17#if defined(__cplusplus) 18extern "C" { 19#endif 20 21#pragma mark - 22#pragma mark authdb_t 23 24typedef bool (^authdb_iterator_t)(auth_items_t data); 25 26AUTH_WARN_RESULT AUTH_NONNULL_ALL 27char * authdb_copy_sql_string(sqlite3_stmt*,int32_t); 28 29AUTH_WARN_RESULT AUTH_MALLOC AUTH_RETURNS_RETAINED 30authdb_t authdb_create(void); 31 32AUTH_WARN_RESULT AUTH_NONNULL_ALL 33authdb_connection_t authdb_connection_acquire(authdb_t); 34 35AUTH_NONNULL_ALL 36void authdb_connection_release(authdb_connection_t*); 37 38AUTH_NONNULL_ALL 39bool authdb_maintenance(authdb_connection_t); 40 41AUTH_NONNULL_ALL 42int32_t authdb_exec(authdb_connection_t, const char *); 43 44AUTH_NONNULL_ALL 45bool authdb_transaction(authdb_connection_t, AuthDBTransactionType, bool (^t)(void)); 46 47AUTH_NONNULL1 AUTH_NONNULL2 AUTH_NONNULL3 48bool authdb_step(authdb_connection_t, const char * sql, void (^bind_stmt)(sqlite3_stmt* stmt), authdb_iterator_t iter); 49 50AUTH_NONNULL_ALL 51int32_t authdb_get_key_value(authdb_connection_t, const char * table, auth_items_t * out_items); 52 53AUTH_NONNULL_ALL 54int32_t authdb_set_key_value(authdb_connection_t, const char * table, auth_items_t items); 55 56AUTH_NONNULL_ALL 57void authdb_checkpoint(authdb_connection_t); 58 59AUTH_NONNULL_ALL 60bool authdb_import_plist(authdb_connection_t,CFDictionaryRef,bool); 61 62#pragma mark - 63#pragma mark authdb_connection_t 64 65AUTH_NONNULL_ALL 66authdb_connection_t authdb_connection_create(authdb_t); 67 68#if defined(__cplusplus) 69} 70#endif 71 72#endif /* !_SECURITY_AUTH_AUTHDB_H_ */ 73