From fe4e4e1ad11e2f9b0a257bfacc05296ee228640e Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sat, 20 Apr 2013 14:19:32 +0200 Subject: [PATCH] actions: skeleton --- src/actions.cpp | 26 ++++++++++++++++++++++++++ src/actions.h | 32 ++++++++++++++++++++++++++++++++ src/main.cpp | 36 +++++++++++++++++++++++++++++++++--- 3 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 src/actions.cpp create mode 100644 src/actions.h diff --git a/src/actions.cpp b/src/actions.cpp new file mode 100644 index 0000000..4b5b2cf --- /dev/null +++ b/src/actions.cpp @@ -0,0 +1,26 @@ + +/* + * This file is part of Codecrypt. + * + * Codecrypt is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Codecrypt is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Codecrypt. If not, see . + */ + +#include "actions.h" + +int action_keygen (const std::string& algspec, const std::string&name, + keyring&, algorithm_suite&) +{ + + return 0; +} diff --git a/src/actions.h b/src/actions.h new file mode 100644 index 0000000..468ad03 --- /dev/null +++ b/src/actions.h @@ -0,0 +1,32 @@ + +/* + * This file is part of Codecrypt. + * + * Codecrypt is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Codecrypt is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Codecrypt. If not, see . + */ + +#ifndef _ccr_actions_h_ +#define _ccr_actions_h_ + +/* + * actions = stuff the user can do. main() calls this accordingly to options + */ +#include +#include "keyring.h" +#include "algorithm.h" + +int action_keygen (const std::string& algspec, const std::string&name, + keyring&, algorithm_suite&); + +#endif diff --git a/src/main.cpp b/src/main.cpp index 57163c9..de302f2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -292,7 +292,7 @@ int main (int argc, char**argv) * something will be happening, therefore init everything */ - int exitflag = 0; + int exitval = 0; keyring KR; algorithm_suite AS; @@ -304,7 +304,7 @@ int main (int argc, char**argv) if (!KR.load() ) { err ("could not load keyring!"); - exitflag = 1; + exitval = 1; goto exit_ok; } @@ -320,6 +320,36 @@ int main (int argc, char**argv) goto exit_ok; } + switch (action) { + case 'g': + exitval = action_keygen (action_param, name, KR, AS); + break; + + case 'e': + case 'd': + case 's': + case 'v': + case 'E': + case 'D': + + case 'k': + case 'i': + case 'p': + case 'x': + case 'm': + case 'K': + case 'I': + case 'P': + case 'X': + case 'M': + + default: + progerr ("no action specified, use `--help'"); + exitval = 1; + break; + + } + /* * all done. * keyring is _not_ automatically saved here to prevent frequent @@ -333,6 +363,6 @@ exit_ok: "something weird is going to happen."); } - return exitflag; + return exitval; }