src/tools/repltable.cxx

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by www.databasecache.com                           *
00003  *   Contact: praba_tuty@databasecache.com                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  ***************************************************************************/
00016 #include <CSql.h>
00017 #include <Network.h>
00018 
00019 void printUsage()
00020 {
00021    printf("Usage: repltable [-U username] [-P passwd] -t tablename \n"
00022           "       [-m TSYNC|ASYNC>][-u] [-r] \n");
00023    printf("       username -> username to connect with csql.\n");
00024    printf("       passwd -> password for the above username to connect with csql.\n");
00025    printf("       tablename -> table name to be replicated in csql with peers.\n");
00026    printf("       u -> unreplicate the table\n");
00027    printf("       r -> replicate and load all the records from peer site\n");
00028    printf("       m -> replication mode for the table\n");
00029    printf("         -> Modes could be one of TSYNC|ASYNC\n");
00030    printf("       no option -> replicates with default mode ASYNC\n");
00031    printf("       Note:Table should not have any records for this command to succeed\n");
00032    return;
00033 }
00034 
00035 int main(int argc, char **argv)
00036 {
00037     char username[IDENTIFIER_LENGTH];
00038     username [0] = '\0';
00039     char password[IDENTIFIER_LENGTH];
00040     password [0] = '\0';
00041     int c = 0, opt = 10;
00042     char tablename[IDENTIFIER_LENGTH];
00043     char syncModeStr[IDENTIFIER_LENGTH];
00044     bool tableNameSpecified = false;
00045     while ((c = getopt(argc, argv, "U:P:t:l:m:u?")) != EOF) 
00046     {
00047         switch (c)
00048         {
00049             case 'U' : { strcpy(username, argv[optind - 1]); opt=10; break; }
00050             case 'P' : { strcpy(password, argv[optind - 1]); opt=10; break; }
00051             case 't' : { strcpy(tablename, argv[optind - 1]); 
00052                          if (opt==10) opt = 2; 
00053                          tableNameSpecified = true; 
00054                          break; 
00055                        }
00056             case '?' : { opt = 10; break; } //print help 
00057             case 'r' : { opt = 4; break; } //replicate the table
00058             case 'u' : { opt = 5; break; } //unreplicate the table
00059             default: opt=10; 
00060 
00061         }
00062     }//while options
00063     if (opt == 10) {
00064         printUsage();
00065         return 0;
00066     }
00067 
00068     //printf("%s %s \n", username, password);
00069     if (username[0] == '\0' )
00070     {
00071         strcpy(username, "root");
00072         strcpy(password, "manager");
00073     }
00074     DbRetVal rv = OK;
00075     if (opt==2) {
00076     }
00077     return 0;
00078 }

Generated on Mon Jun 9 22:37:15 2008 for csql by  doxygen 1.4.7