stasis-bLSM/util/drop_database.cpp

42 lines
862 B
C++
Raw Normal View History

/*
* drop_database.cpp
*
* Created on: Feb 23, 2010
* Author: sears
*/
#include "../tcpclient.h"
#include "../network.h"
#include "../datatuple.h"
void usage(char * argv[]) {
fprintf(stderr, "usage %s [host [port]]\n", argv[0]);
}
int main(int argc, char * argv[]) {
bool ok = true;
int svrport = 32432;
char * svrname = "localhost";
if(argc == 3) {
svrport = atoi(argv[2]);
}
if(argc == 2 || argc == 3) {
svrname = argv[1];
}
if(!ok || argc > 3) {
usage(argv); return 1;
}
logstore_handle_t * l = logstore_client_open(svrname, svrport, 100);
if(l == NULL) { perror("Couldn't open connection"); return 2; }
datatuple * ret = logstore_client_op(l, OP_DBG_DROP_DATABASE);
if(ret == NULL) {
perror("Drop database failed."); return 3;
}
logstore_client_close(l);
printf("Success\n");
return 0;
}