main: enhancement, minor stuff

This commit is contained in:
Mirek Kratochvil 2013-01-13 23:37:58 +01:00
parent bbbd4bd8bd
commit fea48c77b3
2 changed files with 32 additions and 3 deletions

View file

@ -19,7 +19,7 @@
#include <iostream> #include <iostream>
/* /*
* main module. Parse options, fire up stuff, pass commands to it. * output helpers
*/ */
#define out(x) std::cout << x << std::endl #define out(x) std::cout << x << std::endl
@ -39,16 +39,31 @@ void print_help (char*pname)
out ("Usage: " << pname << " [options]"); out ("Usage: " << pname << " [options]");
outeol; outeol;
out ("Options consist of:"); out ("Options consist of:");
out (" -h, --help display this help"); out (" -h, --help display this help");
out (" -V,--version display version information"); out (" -V,--version display version information");
out (" -T perform some testing stuff");
} }
/*
* testing
*/
void test()
{
//stuff gets tested here.
}
/*
* main module. Parse options, fire up stuff, pass commands to it.
*/
#include <getopt.h> #include <getopt.h>
int main (int argc, char**argv) int main (int argc, char**argv)
{ {
bool do_help = false; bool do_help = false;
bool do_version = false; bool do_version = false;
bool do_test = false;
bool has_opt = false; bool has_opt = false;
//process options //process options
@ -60,7 +75,7 @@ int main (int argc, char**argv)
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
c = getopt_long (argc, argv, "hV", long_opts, &option_index); c = getopt_long (argc, argv, "hVT", long_opts, &option_index);
if (c == -1) break; if (c == -1) break;
has_opt = true; has_opt = true;
@ -73,6 +88,9 @@ int main (int argc, char**argv)
case 'V': case 'V':
do_version = true; do_version = true;
break; break;
case 'T':
do_test = true;
break;
default: //which doesn't just happen. default: //which doesn't just happen.
break; break;
} }
@ -92,6 +110,12 @@ int main (int argc, char**argv)
print_version(); print_version();
return 0; return 0;
} }
if (do_test) {
test();
return 0;
}
return 0; return 0;
} }

View file

@ -151,6 +151,11 @@ bool polynomial::unserialize (sencode* s)
return unserialize_uint_vector (this, s); return unserialize_uint_vector (this, s);
} }
/*
* TODO -- all keys should have some kind of identification stored with them,
* so they don't get mistaken with other key types. Do it.
*/
sencode* mce::privkey::serialize() sencode* mce::privkey::serialize()
{ {
sencode_list*l = new sencode_list; sencode_list*l = new sencode_list;