~ubuntu-branches/debian/squeeze/sword/squeeze

« back to all changes in this revision

Viewing changes to examples/classes/ciphercng.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Glassey
  • Date: 2004-01-15 15:50:07 UTC
  • Revision ID: james.westby@ubuntu.com-20040115155007-n9mz4x0zxrs1isd3
Tags: upstream-1.5.7
ImportĀ upstreamĀ versionĀ 1.5.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 *
 
3
 * This example demonstrates how to change the cipher key of a module
 
4
 *      The change is only in effect for this run.  This DOES NOT change the
 
5
 *      cipherkey in the module's .conf file.
 
6
 *
 
7
 */
 
8
 
 
9
#include <swmgr.h>
 
10
 
 
11
int main(int argc, char **argv) {
 
12
 
 
13
        if (argc != 2) {
 
14
                fprintf(stderr, "usage: %s <modName>\n", *argv);
 
15
                exit(-1);
 
16
        }
 
17
 
 
18
        SWMgr manager;          // create a default manager that looks in the current directory for mods.conf
 
19
        ModMap::iterator it;
 
20
        it = manager.Modules.find(argv[1]);
 
21
 
 
22
        if (it == manager.Modules.end()) {
 
23
                fprintf(stderr, "%s: couldn't find module: %s\n", *argv, argv[1]);
 
24
                exit(-1);
 
25
        }
 
26
 
 
27
        SWModule *module = (*it).second;
 
28
        string key;
 
29
 
 
30
        cout << "\nPress [CTRL-C] to end\n\n";
 
31
        while (true) {
 
32
                cout << "\nModule text:\n";
 
33
                module->setKey("1jn 1:9");
 
34
                cout << "[ " << module->KeyText() << " ]\n";
 
35
                cout << (const char *)*module;
 
36
                cout << "\n\nEnter new cipher key: ";
 
37
                cin >> key;
 
38
                cout << "\nSetting key to: " << key;
 
39
                manager.setCipherKey(argv[1], (unsigned char *)key.c_str());
 
40
        }
 
41
 
 
42
 
 
43
}