00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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; }
00057 case 'r' : { opt = 4; break; }
00058 case 'u' : { opt = 5; break; }
00059 default: opt=10;
00060
00061 }
00062 }
00063 if (opt == 10) {
00064 printUsage();
00065 return 0;
00066 }
00067
00068
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 }