Changeset 24659
- Timestamp:
- 2011-09-27T12:09:55+13:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/parallel-building/trunk/src/src/gdbmcli-src/gdbmcli.cpp
r24639 r24659 73 73 74 74 void 75 printUsage ( char *program_name)75 printUsage () 76 76 { 77 77 cerr << "===== GDBM Command Line Interface v1.0 =====" << endl << endl; 78 cerr << "usage: " << program_name << " [-removeold] database-name" << endl << endl;79 cerr << " -removeold delete the contents of any existing database with the same name" << endl<< endl;80 cerr << " Once the program is running enter empty key (\"[]\") to exit." << endl<< endl;81 cerr << " examples:" << endl;78 cerr << "usage: gdbmcli <db path>" << endl << endl; 79 cerr << "Once the program is running, the first thing it expects is the" << endl; 80 cerr << "path to the GDBM database to open, after which you can use the" << endl; 81 cerr << "commands below:" << endl; 82 82 cerr << " [key]+<newline>value <= adds the pair key:value" << endl; 83 83 cerr << " [key]<newline>value <= also adds the pair" << endl; 84 84 cerr << " [key]- <= deleted the pair identified by key" << endl; 85 85 cerr << " [key]? <= lookup the value for key" << endl; 86 cerr << " [*] <= retrieve a list of keys" << endl << endl; 86 cerr << " [*] <= retrieve a list of keys" << endl; 87 cerr << " [] <= exit " << endl << endl; 87 88 } 88 89 … … 90 91 main (int argc, char *argv[]) 91 92 { 92 // sanity check 93 if (argc != 2 && argc != 3) 93 if (argc != 2) 94 94 { 95 printUsage( argv[0]);95 printUsage(); 96 96 exit(0); 97 97 } 98 98 99 char *dbname; 100 bool removeold = false; 101 if (argc == 3) 102 { 103 if (strcmp (argv[1], "-removeold") == 0) 104 { 105 removeold = true; 106 dbname = argv[2]; 107 } 108 else 109 { 110 cerr << argv[1] << " is not a valid option." << endl << endl; 111 printUsage (argv[0]); 112 exit(0); 113 } 114 } 115 else 116 { 117 dbname = argv[1]; 118 } 99 char *dbname = argv[1]; 119 100 120 101 // open the database 121 102 // note that GDBM_FAST is obsolete on newer versions of gdbm 122 103 int read_write = GDBM_WRCREAT | GDBM_FAST; 123 if (removeold)124 {125 read_write = GDBM_NEWDB | GDBM_FAST;126 }127 104 int block_size = 0; 128 105 #ifdef __WIN32__ … … 181 158 } 182 159 160 if (key == "?") 161 { 162 cout << "0.1" << endl; 163 gdbm_close (dbf); 164 return 0; 165 } 166 183 167 // retrieve the command token 184 168 if (!cin.eof())
Note:
See TracChangeset
for help on using the changeset viewer.