11
11
// - the copyright holder be liable for any direct, indirect, incidental or -
12
12
// - special damages arising in any way out of the use of this software. -
13
13
// ---------------------------------------------------------------------------
14
// - copyright (c) 1999-2007 amaury darsch -
14
// - copyright (c) 1999-2011 amaury darsch -
15
15
// ---------------------------------------------------------------------------
17
17
#include "System.hpp"
36
36
static const String S_OPT_MSG = " [s] \t short librarian list";
37
37
static const String T_OPT_MSG = " [t] \t print librarian list";
38
38
static const String F_OPT_MSG = " [f name] \t set librarian file name";
39
static const String M_OPT_MSG = " [m name] \t set start module name";
40
41
// this procedure returns the libarian option object
41
static Options* get_options (Output& os,const long argc,const char** argv) {
42
static Options* get_options (OutputStream& os,
43
const long argc, const char** argv) {
42
44
// create the option class
43
45
Options* opts = new Options (U_CLS_MSG);
44
46
// add the string options
47
opts->add (Options::SOPT, 'm', M_OPT_MSG);
45
48
opts->add (Options::SOPT, 'f', F_OPT_MSG);
46
49
// add the uniq options
47
50
opts->add (Options::UNIQ, 't', T_OPT_MSG);
77
80
os << "fatal: both create and extract flags are set" << eolc;
83
// make sure that the module flag is only set in create mode
84
if ((opts->getoflg ('m') == true) && (opts->getoflg ('c') == false)) {
85
os << "fatal: start module flag in non create mode" << eolc;
103
112
// this procedure extract a file from the librarian
104
113
static void axl_extract (const Librarian& axl, const String& name) {
105
Input* is = axl.extract (name);
114
InputStream* is = axl.extract (name);
106
115
if (is == nilp) return;
107
OutputFile os (name);
108
while (is->iseof () == false) os.write (is->read ());
117
OutputFile os (name);
118
while (is->iseos () == false) os.write (is->read ());
111
126
// this procedure process the options
112
static void run_options (Options* opts) {
127
static void run_options (const Options& opts) {
128
// preset the afnix system
129
System::preset (opts.getpgmn (), false);
113
130
// get the options value
114
bool cflg = opts->getoflg ('c');
115
bool xflg = opts->getoflg ('x');
116
bool sflg = opts->getoflg ('s');
117
bool tflg = opts->getoflg ('t') || sflg;
118
String name = opts->getopts ('f');
119
Strvec args = opts->getargs ();
131
bool cflg = opts.getoflg ('c');
132
bool xflg = opts.getoflg ('x');
133
bool mflg = opts.getoflg ('m');
134
bool sflg = opts.getoflg ('s');
135
bool tflg = opts.getoflg ('t') || sflg;
136
String name = opts.getopts ('f');
137
Strvec args = opts.getargs ();
121
139
// process the create flag
122
140
if (cflg == true) {
169
189
// main processing loop
171
// register the program name
172
System::initialize (argv[0]);
173
191
// get the options
174
192
Options* opts = get_options (terr, argc, argv);
175
193
// process the options
177
195
// clean everything
179
197
} catch (const Exception& e) {