2001-07-30 01:43:24 +02:00
|
|
|
|
|
|
|
#include "firebird.h"
|
|
|
|
|
2001-07-12 08:32:05 +02:00
|
|
|
#include "../jrd/ibase.h"
|
2002-12-03 12:48:03 +01:00
|
|
|
#include "../jrd/common.h"
|
2004-12-09 20:19:47 +01:00
|
|
|
#include "../common/classes/ClumpletWriter.h"
|
2001-07-12 08:32:05 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2003-12-03 09:19:24 +01:00
|
|
|
int main(int argc, char** argv)
|
2001-07-12 08:32:05 +02:00
|
|
|
{
|
2003-12-03 09:19:24 +01:00
|
|
|
if (argc != 2)
|
|
|
|
{
|
|
|
|
printf("Usage: %s <new db name>\n", argv[0]);
|
|
|
|
return -1;
|
|
|
|
}
|
2001-07-12 08:32:05 +02:00
|
|
|
|
2003-12-03 09:19:24 +01:00
|
|
|
ISC_STATUS_ARRAY sv;
|
|
|
|
isc_db_handle db = 0;
|
|
|
|
isc_tr_handle tr = 0;
|
2001-07-12 08:32:05 +02:00
|
|
|
|
|
|
|
|
2003-12-03 09:19:24 +01:00
|
|
|
isc_create_database(sv, 0, argv[1], &db, 0, 0, 0);
|
|
|
|
if (sv[0] == 1 && sv[1] > 0)
|
|
|
|
{
|
|
|
|
isc_print_status(sv);
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
isc_start_transaction(sv, &tr, 1, &db, 0, 0);
|
|
|
|
if (sv[0] == 1 && sv[1] > 0)
|
|
|
|
{
|
|
|
|
isc_print_status(sv);
|
|
|
|
return -3;
|
|
|
|
}
|
|
|
|
isc_commit_transaction(sv, &tr);
|
|
|
|
if (sv[0] == 1 && sv[1] > 0)
|
|
|
|
{
|
|
|
|
isc_print_status(sv);
|
|
|
|
return -3;
|
|
|
|
}
|
|
|
|
isc_detach_database(sv, &db);
|
|
|
|
if (sv[0] == 1 && sv[1] > 0)
|
|
|
|
{
|
|
|
|
isc_print_status(sv);
|
|
|
|
return -3;
|
|
|
|
}
|
2004-12-09 20:19:47 +01:00
|
|
|
|
2005-11-27 21:53:09 +01:00
|
|
|
Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::Tagged,
|
|
|
|
MAX_DPB_SIZE, isc_dpb_version1);
|
2004-12-09 20:19:47 +01:00
|
|
|
dpb.insertByte(isc_dpb_set_db_readonly, TRUE);
|
|
|
|
isc_attach_database(sv, 0, argv[1], &db, dpb.getBufferLength(),
|
|
|
|
reinterpret_cast<const char*>(dpb.getBuffer()));
|
2003-12-03 09:19:24 +01:00
|
|
|
if (sv[0] == 1 && sv[1] > 0)
|
|
|
|
{
|
|
|
|
isc_print_status(sv);
|
|
|
|
return -4;
|
|
|
|
}
|
|
|
|
isc_detach_database(sv, &db);
|
|
|
|
if (sv[0] == 1 && sv[1] > 0)
|
|
|
|
{
|
|
|
|
isc_print_status(sv);
|
|
|
|
return -5;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2001-07-12 08:32:05 +02:00
|
|
|
}
|
2003-12-03 09:19:24 +01:00
|
|
|
|
|
|
|
|