#ifndef _CERTBCLI_H
#define _CERTBCLI_H

/* Certificate Server backup clipent API definitions */

#ifdef __cplusplus
extern "C" {
#endif

#define RPC_STRING
#define VOID  void

#define CERTBCLI_CALL  __stdcall

#ifndef _CERTBCLI_DEFINED
#define CERTBCLI_API __declspec(dllimport) CERTBCLI_CALL
#else
#define CERTBCLI_API
#endif

#define szBACKUPANNOTATION  "Cert Server Backup Interface"
#define wszBACKUPANNOTATION  TEXT(szBACKUPANNOTATION)

#define szRESTOREANNOTATION  "Cert Server Restore Interface"
#define wszRESTOREANNOTATION TEXT(szRESTOREANNOTATION)

#define CSBACKUP_TYPE_FULL  0x00000001
#define CSBACKUP_TYPE_LOGS_ONLY  0x00000002
#define CSBACKUP_TYPE_MASK  0x00000003

#define CSRESTORE_TYPE_FULL  0x00000001
#define CSRESTORE_TYPE_ONLINE  0x00000002
#define CSRESTORE_TYPE_CATCHUP  0x00000004
#define CSRESTORE_TYPE_MASK  0x00000005

#define CSBACKUP_DISABLE_INCREMENTAL  0xffffffff

#define CSCONTROL_SHUTDOWN  0x000000001
#define CSCONTROL_SUSPEND  0x000000002
#define CSCONTROL_RESTART  0x000000003

typedef WCHAR CSBFT;

#define CSBFT_DIRECTORY  0x80
#define CSBFT_DATABASE_DIRECTORY  0x40
#define CSBFT_LOG_DIRECTORY  0x20

#define CSBFT_LOG  ((CSBFT)(TEXT('\x01')|CSBFT_LOG_DIRECTORY))
#define CSBFT_LOG_DIR  ((CSBFT)(TEXT('\x02')|CSBFT_DIRECTORY))
#define CSBFT_CHECKPOINT_DIR  ((CSBFT)(TEXT('\x03')|CSBFT_DIRECTORY))
#define CSBFT_CERTSERVER_DATABASE ((CSBFT)(TEXT('\x04')|CSBFT_DATABASE_DIRECTORY))
#define CSBFT_PATCH_FILE  ((CSBFT)(TEXT('\x05')|CSBFT_LOG_DIRECTORY))
#define CSBFT_UNKNOWN  ((CSBFT)(TEXT('\x0f')))

typedef void *HCSBC;

#ifndef CSEDB_RSTMAP
typedef struct tagCSEDB_RSTMAPW {
    RPC_STRING WCHAR *pwszDatabaseName;
    RPC_STRING WCHAR *pwszNewDatabaseName;
} CSEDB_RSTMAPW;
#define CSEDB_RSTMAP CSEDB_RSTMAPW
#endif /* CSEDB_RSTMAP */

typedef HRESULT(CERTBCLI_CALL FNCERTSRVISSERVERONLINEW)(WCHAR const*,BOOL*);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVBACKUPGETDYNAMICFILELISTW)(HCSBC,WCHAR**,DWORD*);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVBACKUPPREPAREW)(WCHAR const*,ULONG,ULONG,HCSBC*);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVBACKUPGETDATABASENAMESW)(HCSBC,WCHAR**,DWORD*);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVBACKUPOPENFILEW)(HCSBC,WCHAR const*,DWORD,LARGE_INTEGER*);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVBACKUPREAD)(HCSBC,VOID*,DWORD,DWORD*);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVBACKUPCLOSE)(HCSBC);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVBACKUPGETBACKUPLOGSW)(HCSBC,WCHAR**,DWORD*);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVBACKUPTRUNCATELOGS)(HCSBC);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVBACKUPEND)(HCSBC);
typedef VOID(CERTBCLI_CALL FNCERTSRVBACKUPFREE)(VOID*);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVRESTOREGETDATABASELOCATIONSW)(HCSBC,WCHAR**,DWORD*);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVRESTOREPREPAREW)(WCHAR const*,ULONG,HCSBC*);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVRESTOREREGISTERW)(HCSBC,WCHAR const*,WCHAR const*,CSEDB_RSTMAPW [],LONG,WCHAR const*,ULONG,ULONG);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVRESTOREREGISTERCOMPLETE)(HCSBC,HRESULT);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVRESTOREEND)(HCSBC);
typedef HRESULT(CERTBCLI_CALL FNCERTSRVSERVERCONTROLW)(WCHAR const*,DWORD,DWORD*,BYTE**);

HRESULT CERTBCLI_API CertSrvIsServerOnlineW(WCHAR const*,BOOL*);
HRESULT CERTBCLI_API CertSrvBackupGetDynamicFileListW(HCSBC,WCHAR**,DWORD*);
HRESULT CERTBCLI_API CertSrvBackupPrepareW(WCHAR const*,ULONG,ULONG,HCSBC*);
HRESULT CERTBCLI_API CertSrvBackupGetDatabaseNamesW(HCSBC,WCHAR**,DWORD*);
HRESULT CERTBCLI_API CertSrvBackupOpenFileW(HCSBC,WCHAR const*,DWORD,LARGE_INTEGER*);
HRESULT CERTBCLI_API CertSrvBackupRead(HCSBC,VOID*,DWORD,DWORD*);
HRESULT CERTBCLI_API CertSrvBackupClose(HCSBC);
HRESULT CERTBCLI_API CertSrvBackupGetBackupLogsW(HCSBC,WCHAR**,DWORD*);
HRESULT CERTBCLI_API CertSrvBackupTruncateLogs(HCSBC);
HRESULT CERTBCLI_API CertSrvBackupEnd(HCSBC);
VOID CERTBCLI_API CertSrvBackupFree(VOID*);
HRESULT CERTBCLI_API CertSrvRestoreGetDatabaseLocationsW(HCSBC,WCHAR**,DWORD*);
HRESULT CERTBCLI_API CertSrvRestorePrepareW(WCHAR const*,ULONG,HCSBC*);
HRESULT CERTBCLI_API CertSrvRestoreRegisterW(HCSBC,WCHAR const*,WCHAR const*,CSEDB_RSTMAPW [],LONG,WCHAR const*,ULONG,ULONG);
HRESULT CERTBCLI_API CertSrvRestoreRegisterComplete(HCSBC,HRESULT);
HRESULT CERTBCLI_API CertSrvRestoreEnd(HCSBC);
HRESULT CERTBCLI_API CertSrvServerControlW(WCHAR const*,DWORD,DWORD*,BYTE**);

#define CertSrvIsServerOnline  CertSrvIsServerOnlineW
#define CertSrvBackupGetDynamicFileList CertSrvBackupGetDynamicFileListW
#define CertSrvBackupPrepare  CertSrvBackupPrepareW
#define CertSrvBackupGetDatabaseNames  CertSrvBackupGetDatabaseNamesW
#define CertSrvBackupOpenFile  CertSrvBackupOpenFileW
#define CertSrvBackupGetBackupLogs  CertSrvBackupGetBackupLogsW
#define CertSrvRestoreGetDatabaseLocations CertSrvRestoreGetDatabaseLocationsW
#define CertSrvRestorePrepare  CertSrvRestorePrepareW
#define CertSrvRestoreRegister  CertSrvRestoreRegisterW
#define CertSrvServerControl  CertSrvServerControlW

#ifdef __cplusplus
}
#endif

#endif /* _CERTBCLI_H */
