The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 51 of file modwrite.cpp.

52 {
53  int action = 0;
54 
55  if ((argc < 4) || (argc > 6)) {
56  cerr << "usage: " << argv[0] << " <mod_name> <key> <key|buf|""-delete> [0(deflt) - normal; 1 - link]\n";
57  exit(-1);
58  }
59 
60  if (argc > 4)
61  action = atoi(argv[4]);
62 
63  SWMgr mgr;
64 
65  ModMap::iterator it = mgr.Modules.find(argv[1]);
66  if (it == mgr.Modules.end()) {
67  fprintf(stderr, "error: %s: couldn't find module: %s \n", argv[0], argv[1]);
68  exit(-2);
69  }
70 
71  SWModule *module = it->second;
72  module->setKey(argv[2]);
73 
74  switch (action) {
75  case 0:
76  if (strlen(argv[3]))
77  (*module) << argv[3];
78  else module->deleteEntry();
79  break;
80  case 1:
81  (*module) << (SWKey)argv[3];
82  break;
83  default:
84  cerr << "Unknown action " << action << "\n";
85  exit(-3);
86  }
87 }
Definition: swmgr.h:93
virtual void deleteEntry()
Definition: swmodule.h:525
ModMap Modules
Definition: swmgr.h:322
SWText * module
Definition: osis2mod.cpp:105
virtual char setKey(const SWKey *ikey)
Definition: swmodule.cpp:298
Definition: swkey.h:77
SWMgr * mgr
Definition: installmgr.cpp:46