added dump tag.

This commit is contained in:
brad Arant 2024-11-24 14:25:39 -08:00
parent a9ce087939
commit 1c7edf3118
5 changed files with 60 additions and 5 deletions

View File

@ -23,6 +23,7 @@
#include "__tag.h"
#include "__dotag.h"
#include "__stream.h"
#include "__dump.h"
#include <iostream>
namespace jet {
@ -178,6 +179,9 @@ namespace jet {
} else if(ifTagName(in, "stream")) {
__stream _stream(in, out, global, this);
continue;
} else if(ifTagName(in, "dump")) {
__dump _dump(in, out, global, this);
continue;
} else if(ifTagName(in, "tag")) {
__tag _tag(in, out, global, this);
continue;

33
__dump.cpp Normal file
View File

@ -0,0 +1,33 @@
#include "__dump.h"
#include "Exception.h"
#include <iostream>
#include <fstream>
namespace jet {
__dump::__dump(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent) : Tag(in, parentOut, global, parent) {
if(!variableDefined("file"))
throw coreutils::Exception("file must be sppecified for dump tag.");
std::ofstream outFile(variables["file"].str());
outFile << "*** CGI VARIABLES ***" << std::endl;
for (auto i = global.cgiVariables.begin(); i != global.cgiVariables.end(); i++)
outFile << i->first << "=[" << i->second << "]" << std::endl;
outFile << "*** GLOBAL VARIABLES ***" << std::endl;
for (auto i = global.variables.begin(); i != global.variables.end(); i++)
outFile << i->first << "=[" << i->second << "]" << std::endl;
outFile << "*** LOCAL VARIABLES ***" << std::endl;
for (auto i = parent->variables.begin(); i != parent->variables.end(); i++)
outFile << i->first << "=[" << i->second << "]" << std::endl;
outFile.close();
}
}

19
__dump.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef ____dump_h__
#define ____dump_h__
#include "Tag.h"
#include "MString.h"
#include "Global.h"
namespace jet {
class __dump : public Tag {
public:
__dump(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent);
};
}
#endif

View File

@ -17,9 +17,7 @@ namespace jet {
std::ofstream outFile("/tmp/output.txt");
coreutils::MString postdata;
postdata.read(0);
outFile << postdata << std::endl;
outFile.close();
postdata.read(0); // TODO: Need to limit the read characters to the CONTENT-LENGTH value;
if(contentType == "multipart/form-data")
global.setupFormData(postdata);

View File

@ -8,4 +8,5 @@ $[:name2]
$[:name:2;tohex]
$[:name:3;tohex]
$[:name2;tohex]
<dump file="/tmp/dump.txt" />
</jet>