2001-05-23 15:26:42 +02:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Interbase Public
|
|
|
|
* License Version 1.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy
|
|
|
|
* of the License at http://www.Inprise.com/IPL.html
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an
|
|
|
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
|
|
|
* or implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Inprise Corporation
|
|
|
|
* and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
* Copyright (C) Inprise Corporation.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
|
|
|
*/
|
2001-07-30 01:43:24 +02:00
|
|
|
#include "firebird.h"
|
2004-04-29 00:36:29 +02:00
|
|
|
#include <stdio.h>
|
2001-05-23 15:26:42 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include "../jrd/common.h"
|
|
|
|
#include "../jrd/ibase.h"
|
|
|
|
#include "../jrd/svc_undoc.h"
|
2004-05-24 13:03:54 +02:00
|
|
|
#include "../common/stuff.h"
|
2009-05-25 09:32:39 +02:00
|
|
|
#include "../common/utils_proto.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
int CLIB_ROUTINE main( int argc, char **argv)
|
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* m a i n
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
*Functional Description
|
2007-02-11 10:04:54 +01:00
|
|
|
* This utility uses the Firebird service api to inform the server
|
2001-05-23 15:26:42 +02:00
|
|
|
* to print out the memory pool information into a specified file.
|
2009-05-25 09:32:39 +02:00
|
|
|
* This utilitiy is for WIN_NT only, In case of UNIX ibmgr utility will
|
2001-05-23 15:26:42 +02:00
|
|
|
* should be used.
|
|
|
|
*
|
|
|
|
*************************************************************************/
|
|
|
|
char fname[512];
|
|
|
|
|
2009-07-03 12:44:55 +02:00
|
|
|
if (argc != 2 && argc != 1)
|
|
|
|
{
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("Usage %s \n %s filename\n");
|
2001-05-23 15:26:42 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
2009-05-25 09:32:39 +02:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2004-04-29 00:36:29 +02:00
|
|
|
printf(" Filename : ");
|
2009-05-25 09:32:39 +02:00
|
|
|
if (!fgets(fname, sizeof(fname), stdin))
|
|
|
|
return 1;
|
|
|
|
const size_t len = strlen(fname);
|
|
|
|
if (!len)
|
|
|
|
return 1;
|
|
|
|
if (fname[len - 1] == '\n')
|
|
|
|
{
|
|
|
|
fname[len - 1] = 0;
|
|
|
|
if (len == 1)
|
|
|
|
return 1;
|
|
|
|
}
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
else
|
2009-05-25 09:32:39 +02:00
|
|
|
{
|
|
|
|
fb_utils::copy_terminate(fname, argv[1], sizeof(fname));
|
|
|
|
if (!fname[0])
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Filename to dump pool info = %s \n", fname);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2009-05-25 09:32:39 +02:00
|
|
|
ISC_STATUS_ARRAY status;
|
2009-05-17 13:20:43 +02:00
|
|
|
|
2009-05-25 09:32:39 +02:00
|
|
|
const char svc_name[] = "localhost:anonymous";
|
2009-05-17 13:20:43 +02:00
|
|
|
isc_svc_handle svc_handle = NULL;
|
2009-07-03 12:44:55 +02:00
|
|
|
if (isc_service_attach(status, 0, svc_name, &svc_handle, 0, NULL))
|
|
|
|
{
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("Failed to attach service\n");
|
2009-05-25 09:32:39 +02:00
|
|
|
return 1;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:32:39 +02:00
|
|
|
const unsigned short path_length = strlen(fname);
|
2004-11-17 06:19:37 +01:00
|
|
|
|
2009-05-25 09:32:39 +02:00
|
|
|
char sendbuf[520]; // 512 + tag + length_word
|
2004-11-17 06:19:37 +01:00
|
|
|
char* sptr = sendbuf;
|
2001-05-23 15:26:42 +02:00
|
|
|
*sptr = isc_info_svc_dump_pool_info;
|
|
|
|
++sptr;
|
2004-05-24 13:03:54 +02:00
|
|
|
add_word(sptr, path_length);
|
2009-05-25 09:32:39 +02:00
|
|
|
strcpy(sptr, fname);
|
2001-05-23 15:26:42 +02:00
|
|
|
sptr += path_length;
|
2004-11-17 06:19:37 +01:00
|
|
|
|
|
|
|
char respbuf[256];
|
2009-05-25 09:32:39 +02:00
|
|
|
if (isc_service_query(status, &svc_handle, NULL, 0, NULL,
|
|
|
|
sptr - sendbuf, sendbuf, sizeof(respbuf), respbuf))
|
2003-11-28 07:48:34 +01:00
|
|
|
{
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("Failed to query service\n");
|
2001-05-23 15:26:42 +02:00
|
|
|
isc_service_detach(status, &svc_handle);
|
2009-05-25 09:32:39 +02:00
|
|
|
return 1;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
isc_service_detach(status, &svc_handle);
|
2009-05-25 09:32:39 +02:00
|
|
|
return 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|