utilities/modwrite.cpp File Reference

#include <fcntl.h>
#include <iostream>
#include <fstream>
#include <io.h>
#include <swmgr.h>
#include <swmodule.h>
#include <stdio.h>
Include dependency graph for modwrite.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 46 of file modwrite.cpp.

00047 {
00048     int action = 0;
00049 
00050     if ((argc < 4) || (argc > 6)) {
00051         cerr << "usage: " << argv[0] << " <mod_name> <key> <key|buf|""-delete> [0(deflt) - normal; 1 - link]\n";
00052         exit(-1);
00053     }
00054 
00055     if (argc > 4)
00056         action = atoi(argv[4]);
00057 
00058     SWMgr mgr;
00059 
00060     ModMap::iterator it = mgr.Modules.find(argv[1]);
00061     if (it == mgr.Modules.end()) {
00062         fprintf(stderr, "error: %s: couldn't find module: %s \n", argv[0], argv[1]);
00063         exit(-2);
00064     }
00065 
00066     SWModule *module = it->second;
00067     module->setKey(argv[2]);
00068 
00069     switch (action) {
00070     case 0:
00071         if (strlen(argv[3]))
00072             (*module) << argv[3];
00073         else module->deleteEntry();
00074         break;
00075     case 1:
00076         (*module) << (SWKey)argv[3];
00077         break;
00078     default:
00079         cerr << "Unknown action " << action << "\n";
00080         exit(-3);
00081     }
00082 }


Generated on 18 Mar 2013 for The SWORD Project by  doxygen 1.6.1