ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Smersh/Smersh.cpp
(Generate patch)

Comparing Smersh/Smersh.cpp (file contents):
Revision 242 by Douglas Thrift, 2004-09-11T21:06:02-07:00 vs.
Revision 253 by Douglas Thrift, 2004-09-13T23:31:24-07:00

# Line 16 | Line 16
16   string program;
17   bool debug(false);
18  
19 < struct SmershCommand : public app::Application
19 > int main(int argc, char* argv[])
20   {
21 <        virtual int Run(const app::ArgumentList& args)
21 >        program = api::GetExecutableName();
22 >
23 >        int port(54321);
24 >        bool daemon(false), redirector(false);
25 >        string redirect, log("smersh.log");
26 >
27 >        for (int index(1); index < argc; ++index)
28          {
29 <                program = api::GetExecutableName();
29 >                string arg(argv[index]);
30 >                Matcher matcher;
31  
32 <                int port(54321);
33 <                bool fork(false), daemon(false), redirector(false);
34 <                string redirect, log("smersh.log");
28 <
29 <                for (size_t index(0); index < args.GetSize(); ++index)
30 <                {
31 <                        string arg(args[index]);
32 <                        Matcher matcher;
33 <
34 <                        if (arg == "-daemon")
35 <                        {
36 <                                if (!daemon) daemon = true;
37 <                        }
38 <                        else if (arg == matcher("^-redirector=(.+)$"))
39 <                        {
40 <                                if (!redirector) redirector = true;
41 <
42 <                                redirect = matcher[1];
43 <                        }
44 <                        else if (arg == matcher("^-port=([0-9]+)$"))
45 <                        {
46 <                                port = lexical_cast<int>(matcher[1]);
47 <                        }
48 <                        else if (arg == "-fork")
49 <                        {
50 <                                if (!fork) fork = true;
51 <                        }
52 <                        else if (arg == matcher("^-log=(.+)$"))
53 <                        {
54 <                                log = matcher[1];
55 <                        }
56 <                        else if (arg == "-D")
57 <                        {
58 <                                if (!debug) debug = true;
59 <                        }
60 <                        else
61 <                        {
62 <                                cout << "Usage: " << program
63 <                                        << " [-daemon|-redirector=redirect] [-port=port] [-fork] "
64 <                                        << "[-log=log] [-D]\n";
65 <
66 <                                return 1;
67 <                        }
32 >                if (arg == "-daemon")
33 >                {
34 >                        if (!daemon) daemon = true;
35                  }
36 +                else if (arg == matcher("^-redirector=(.+)$"))
37 +                {
38 +                        if (!redirector) redirector = true;
39  
40 <                if (daemon)
40 >                        redirect = matcher[1];
41 >                }
42 >                else if (arg == matcher("^-port=([0-9]+)$"))
43 >                {
44 >                        port = lexical_cast<int>(matcher[1]);
45 >                }
46 >                else if (arg == matcher("^-log=(.+)$"))
47                  {
48 <                        Daemon daemon(port, fork, log);
48 >                        log = matcher[1];
49                  }
50 <                else if (redirector)
50 >                else if (arg == "-D")
51                  {
52 <                        Redirector redirector(port, fork, log, redirect);
52 >                        if (!debug) debug = true;
53                  }
54                  else
55                  {
56 <                        Smersh smersh;
56 >                        cout << "Usage: " << program << " [-daemon|-redirector=redirect] "
57 >                                "[-port=port] [-log=log] [-D]\n";
58 >
59 >                        return 1;
60                  }
61 +        }
62  
63 <                return 0;
63 >        if (daemon)
64 >        {
65 >                Daemon daemon(port, log);
66 >        }
67 >        else if (redirector)
68 >        {
69 >                Redirector redirector(port, log, redirect);
70          }
71 < } smersh;
71 >        else
72 >        {
73 >                Smersh smersh;
74 >        }
75 >
76 >        return 0;
77 > }
78  
79   Smersh::Smersh(istream& sin, ostream& sout, const Environment& env)
80   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines