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

Comparing Bender/Bender.cpp (file contents):
Revision 340 by douglas, 2004-12-14T15:49:53-08:00 vs.
Revision 420 by douglas, 2005-03-09T17:47:41-08:00

# Line 4 | Line 4
4   //
5   // $Id$
6  
7 #include "Bender.hpp"
7   #include "Matcher/Matcher.hpp"
8  
9 < #include <menes-api/exename.hpp>
9 > #include <menes-api/console.hpp>
10 > #include <menes-api/environment.hpp>
11   #include <menes-api/files.hpp>
12   #include <menes-api/process.hpp>
13   #include <menes-app/simple.hpp>
14 + #include <menes-ios/helpers.hpp>
15 + #include <menes-xml/document.hpp>
16 + #include <menes-xml/nodeset.hpp>
17 + #include <menes-xml/parse.hpp>
18 +
19 + class Bender
20 + {
21 + private:
22 +        void bend(const ext::String& path, const ext::String& agent);
23 +        void bend(const ext::String& path);
24 +        void pass(const ext::String& path);
25 + public:
26 +        Bender();
27 + };
28  
29   struct Environment
30   {
# Line 37 | Line 51 | Bender::Bender()
51  
52                          bend(path, env.get("HTTP_USER_AGENT"));
53                  }
54 <                catch (ext::Exception e)
54 >                catch (ext::Exception)
55                  {
56                          api::Cout << "Status: 404\r\n"
57                                  << "Content-Type: text/html; charset=ISO-8859-1\r\n\r\n"
# Line 70 | Line 84 | void Bender::bend(const ext::String& pat
84  
85   void Bender::bend(const ext::String& path)
86   {
87 <        _L<ext::String> args(1, "-a");
87 >        _H<xml::Document> document(xml::Parse("bender.xml"));
88 >        _H<xml::Node> node(*document/"bender");
89 >        ext::String program(*node/"program");
90 >        _L<ext::String> args;
91 >
92 >        _foreach (const xml::NodeSet, arg, *node/"argument") args.InsertLast(**arg);
93  
94          args.InsertLast(path);
95  
96 < #if defined(__FreeBSD__)
97 <        _S<api::Process> xslt("/usr/local/bin/Xalan", args);
79 < #elif defined(_WIN32)
80 <        _S<api::Process> xslt("Xalan.exe", args);
81 < #else
82 <        _S<api::Process> xslt("Xalan", args);
83 < #endif
84 <        ios::String output;
96 >        _S<api::Process> xslt(program, args);
97 >        _S<ios::String> output;
98  
99          ios::ReadToWrite(*xslt.GetReader(), output);
100  
# Line 95 | Line 108 | void Bender::bend(const ext::String& pat
108                  api::Cout << "Content-Type: " << type << "\r\n\r\n" << output;
109          }
110          else pass(path);
98
99        xslt.Join();
111   }
112  
113   void Bender::pass(const ext::String& path)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines