diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c6b5688 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +*~ +testjet diff --git a/JetCore.txt b/JetCore.txt index e6ec235..28095bd 100644 --- a/JetCore.txt +++ b/JetCore.txt @@ -8,3 +8,6 @@ modifications. Data contained within the tags may modify their containers before placing any output. The space taken by the tag itself is not passwed to the output and will not appear in the output. +Skip Blank Lines options on containers will skip passing any blank +lines or line containing only whitespace to the output. + diff --git a/Tag.cpp b/Tag.cpp index 974d57d..cc0fc8f 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -7,6 +7,7 @@ #include "__if.h" #include "__read.h" #include "__set.h" +#include "__call.h" #include "__jet.h" #include "__while.h" #include @@ -114,6 +115,9 @@ namespace jet { } else if(ifTagName(in, "set")) { __set _set(in, out, global); continue; + } else if(ifTagName(in, "call")) { + __call _set(in, out, global); + continue; } else if(ifTagName(in, "while")) { __while _while(in, out, global); continue; diff --git a/__call.cpp b/__call.cpp new file mode 100644 index 0000000..622f6a0 --- /dev/null +++ b/__call.cpp @@ -0,0 +1,37 @@ +#include "__call.h" +#include "Exception.h" +#include "MString.h" +#include +#include +#include +#include +#include + +namespace jet { + + __call::__call(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) { + if(hasContainer) + throw coreutils::Exception("call cannot have a container."); + if(!variableDefined(coreutils::ZString("pgm"))) + throw coreutils::Exception("pgm keyword must be specified."); + pipe[fd]; // TODO: Get these pipes to work with name and input keywords. + dup2(0); + if(pid != fork()) { + argv[0] = variables["pgm"]; // TODO: Need to peel off the program name only and pass as argv[0]. + for(ix = 1; ix <= ARG_MAX; ++ix) { + coreutils::MString arg("arg"); + arg << ix; + if(variableDefined(arg)) + argv[ix] = variables[arg].c_str(); + else + break; + } + argv[ix] == NULL; + execve(variables["pgm"].c_str(), argv, NULL); + exit(-1); + } + waitpid(&status); + + } + +} diff --git a/__call.h b/__call.h new file mode 100644 index 0000000..af91741 --- /dev/null +++ b/__call.h @@ -0,0 +1,24 @@ +#ifndef ____call_h__ +#define ____call_h__ + +#include "Tag.h" + +namespace jet { + + class __call : public Tag { + + public: + __call(coreutils::ZString &in, coreutils::MString &out, Global &global); + + private: + int pid; + int status; + int ix; + int fd[2]; + char *argv[25]; + + }; + +} + +#endif diff --git a/__comment.cpp b/__comment.cpp new file mode 100644 index 0000000..685786b --- /dev/null +++ b/__comment.cpp @@ -0,0 +1,12 @@ +#include "__cpmment.h" +#include "Exception.h" + +namespace jet { + + __comment::__comment(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) { + if(!hasContainer) + throw coreutils::Exception("comment must have a container."); + output = false; + } + +} diff --git a/__comment.h b/__comment.h new file mode 100644 index 0000000..2fe6a49 --- /dev/null +++ b/__comment.h @@ -0,0 +1,17 @@ +#ifndef ____comment_h__ +#define ____comment_h__ + +#include "Tag.h" + +namespace jet { + + class __comment : public Tag { + + public: + __comment(coreutils::ZString &in, coreutils::MString &out, Global &global); + + }; + +} + +#endif diff --git a/__read.cpp b/__read.cpp index 76242f6..45d9abb 100644 --- a/__read.cpp +++ b/__read.cpp @@ -1,17 +1,21 @@ #include "__read.h" #include "Exception.h" +#include +#include namespace jet { __read::__read(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) { if(!variableDefined(coreutils::ZString("file"))) throw coreutils::Exception("file keyword must be specified."); - if(hasContainer) - throw coreutils::Exception("Missing / at end of tag definition. Not a container tag."); - - // process file request here. - + throw coreutils::Exception("read tag does not have a container."); + fd = open(variables["file"], O_RDONLY); + while(len = read(fd, &buffer, sizeof(buffer - 1))) { + buffer[len] = 0; + out << buffer; + } + close(fd); } } diff --git a/__read.h b/__read.h index 3bded82..7c026b8 100644 --- a/__read.h +++ b/__read.h @@ -9,7 +9,12 @@ namespace jet { public: __read(coreutils::ZString &in, coreutils::MString &parent, Global &global); - + + private: + int fd; + int len; + char buffer[4096]; + }; } diff --git a/gitignore b/gitignore deleted file mode 100644 index a70237a..0000000 --- a/gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.o -*~