/*
 *  FBCDatabases.h
 *  FrontBase
 *
 *  Created by Svend Bodilsen on 8/26/10.
 *  Copyright 2010 Frontline Software. All rights reserved.
 *
 */
#ifndef FBCDadabases__H
#define FBCDadabases__H

#ifndef FBVersion
#define FBVersion 7
#elif FBVersion != 7
#error "The headers for FBCAccess version have been mixed"
#endif

#include "FBCMetaData.h"

// If the server needs a encryption key, it will call the keyCallBack if is is set.
// The attempt argument is the number of times this function have been called, if the database is being created then
// attempt is 0.  The keyIdent is the expected identity of the key, 0 is the identity if any is accepted,  key a buffer of size 
// *length, in which the length of the actual key is also returned.  The function should return 1 if a key is returned and 0 to
// prevent further calls.
// 

typedef int (*FBCDGetKeyCallback) ( void* context, unsigned int attempt, unsigned int keyIdent, unsigned char* key, unsigned int* keyLength);  

#ifdef __cplusplus
extern "C" {
#endif

FBCDGetKeyCallback fbcdKeyCallback           ( void );
void               fbcdSetKeyCallback        ( FBCDGetKeyCallback  callback);
void*              fbcdKeyCallbackContext    ( void);
void               fbcdSetKeyCallbackContext ( void* context );

int          fbcdIsStarted ( const char* url );  
int          fbcdIsCreated ( const char* url );

FBCMetaData* fbcdCreate   ( const char* url, const char* options);
FBCMetaData* fbcdStart    ( const char* url, const char* options);

FBCMetaData* fbcdStop     ( const char* url);
FBCMetaData* fbcdDelete   ( const char* url);

FBCMetaData* fbcdGetLogTail ( const char* url, unsigned int count );

#ifdef __cplusplus
}
#endif

#endif
