#ifndef _SECURITYD_SECITEMDB_H_
#define _SECURITYD_SECITEMDB_H_
#include <securityd/SecDbQuery.h>
#include "securityd_client.h"
__BEGIN_DECLS
#if 0
typedef struct SecItemDb *SecItemDbRef;
typedef struct SecItemDbConnection *SecItemDbConnectionRef;
struct SecItemDb {
CFRuntimeBase _base;
SecDbRef db;
CFDictionaryRef classes; };
struct SecItemDbConnection {
SecDbConnectionRef db;
};
SecItemDbRef SecItemDbCreate(SecDbRef db);
SecItemDbRef SecItemDbRegisterClass(SecItemDbRef db, const SecDbClass *class, void(^upgrade)(SecDbItemRef item, uint32_t current_version));
SecItemDbConnectionRef SecItemDbAquireConnection(SecItemDbRef db);
void SecItemDbReleaseConnection(SecItemDbRef db, SecItemDbConnectionRef dbconn);
bool SecItemDbInsert(SecItemDbConnectionRef dbconn, SecDbItemRef item, CFErrorRef *error);
bool SecItemDbDelete(SecItemDbConnectionRef dbconn, SecDbItemRef item, CFErrorRef *error);
bool SecItemDbDoUpdate(SecItemDbConnectionRef dbconn, SecDbItemRef old_item, SecDbItemRef new_item, CFErrorRef *error,
bool (^use_attr_in_where)(const SecDbAttr *attr));
bool SecItemDbUpdate(SecItemDbConnectionRef dbconn, SecDbItemRef old_item, SecDbItemRef new_item, CFErrorRef *error);
bool SecItemDbSelect(SecItemDbConnectionRef dbconn, SecDbQueryRef query, CFErrorRef *error,
bool (^use_attr_in_where)(const SecDbAttr *attr),
bool (^add_where_sql)(CFMutableStringRef sql, bool *needWhere),
bool (^bind_added_where)(sqlite3_stmt *stmt, int col),
void (^handle_row)(SecDbItemRef item, bool *stop));
#endif
bool SecItemDbCreateSchema(SecDbConnectionRef dbt, const SecDbSchema *schema, CFErrorRef *error);
bool SecItemDbDeleteSchema(SecDbConnectionRef dbt, const SecDbSchema *schema, CFErrorRef *error);
CFTypeRef SecDbItemCopyResult(SecDbItemRef item, ReturnTypeMask return_type, CFErrorRef *error);
bool SecDbItemSelect(SecDbQueryRef query, SecDbConnectionRef dbconn, CFErrorRef *error,
bool (^return_attr)(const SecDbAttr *attr),
bool (^use_attr_in_where)(const SecDbAttr *attr),
bool (^add_where_sql)(CFMutableStringRef sql, bool *needWhere),
bool (^bind_added_where)(sqlite3_stmt *stmt, int col),
void (^handle_row)(SecDbItemRef item, bool *stop));
CFStringRef SecDbItemCopySelectSQL(SecDbQueryRef query,
bool (^return_attr)(const SecDbAttr *attr),
bool (^use_attr_in_where)(const SecDbAttr *attr),
bool (^add_where_sql)(CFMutableStringRef sql, bool *needWhere));
bool SecDbItemSelectBind(SecDbQueryRef query, sqlite3_stmt *stmt, CFErrorRef *error,
bool (^use_attr_in_where)(const SecDbAttr *attr),
bool (^bind_added_where)(sqlite3_stmt *stmt, int col));
bool SecDbItemQuery(SecDbQueryRef query, CFArrayRef accessGroups, SecDbConnectionRef dbconn, CFErrorRef *error,
void (^handle_row)(SecDbItemRef item, bool *stop));
void query_pre_add(Query *q, bool force_date);
enum SecItemFilter {
kSecNoItemFilter,
kSecSysBoundItemFilter,
kSecBackupableItemFilter,
};
CFDictionaryRef SecServerCopyKeychainPlist(SecDbConnectionRef dbt,
SecurityClient *client,
keybag_handle_t src_keybag,
keybag_handle_t dest_keybag,
enum SecItemFilter filter,
CFErrorRef *error);
bool SecServerImportKeychainInPlist(SecDbConnectionRef dbt,
SecurityClient *client,
keybag_handle_t src_keybag,
keybag_handle_t dest_keybag,
CFDictionaryRef keychain,
enum SecItemFilter filter,
CFErrorRef *error);
#if TARGET_OS_IPHONE
bool SecServerDeleteAllForUser(SecDbConnectionRef dbt, CFDataRef musrView, CFErrorRef *error);
#endif
bool kc_transaction(SecDbConnectionRef dbt, CFErrorRef *error, bool(^perform)());
bool s3dl_copy_matching(SecDbConnectionRef dbt, Query *q, CFTypeRef *result,
CFArrayRef accessGroups, CFErrorRef *error);
bool s3dl_query_add(SecDbConnectionRef dbt, Query *q, CFTypeRef *result, CFErrorRef *error);
bool s3dl_query_update(SecDbConnectionRef dbt, Query *q,
CFDictionaryRef attributesToUpdate, CFArrayRef accessGroups, CFErrorRef *error);
bool s3dl_query_delete(SecDbConnectionRef dbt, Query *q, CFArrayRef accessGroups, CFErrorRef *error);
const SecDbAttr *SecDbAttrWithKey(const SecDbClass *c, CFTypeRef key, CFErrorRef *error);
bool s3dl_dbt_keys_current(SecDbConnectionRef dbt, uint32_t current_generation, CFErrorRef *error);
bool s3dl_dbt_update_keys(SecDbConnectionRef dbt, SecurityClient *client, CFErrorRef *error);
__END_DECLS
#endif