Added ability for call tag to use container as input stream.
This commit is contained in:
parent
bdbae9e397
commit
96302e1d27
17
__call.cpp
17
__call.cpp
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
#include "__call.h"
|
#include "__call.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "MString.h"
|
#include "MString.h"
|
||||||
@ -11,8 +12,8 @@
|
|||||||
namespace jet {
|
namespace jet {
|
||||||
|
|
||||||
__call::__call(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
__call::__call(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||||
if(hasContainer)
|
if(hasContainer && keywordDefined("input"))
|
||||||
throw coreutils::Exception("call tag cannot have a container.");
|
throw coreutils::Exception("call tag cannot have both input keyword and have a container.");
|
||||||
if(!keywordDefined("pgm"))
|
if(!keywordDefined("pgm"))
|
||||||
throw coreutils::Exception("pgm keyword must be specified.");
|
throw coreutils::Exception("pgm keyword must be specified.");
|
||||||
for(ix = 0; ix <= 50; ++ix)
|
for(ix = 0; ix <= 50; ++ix)
|
||||||
@ -31,7 +32,17 @@ namespace jet {
|
|||||||
if(pid == 0) {
|
if(pid == 0) {
|
||||||
close(fdo[0]);
|
close(fdo[0]);
|
||||||
dup2(fdo[1], 1);
|
dup2(fdo[1], 1);
|
||||||
if(keywordDefined("input")) {
|
if(hasContainer) {
|
||||||
|
pipe(fdi);
|
||||||
|
if(fork() == 0) {
|
||||||
|
close(fdi[0]);
|
||||||
|
write(fdi[1], container.getData(), container.getLength());
|
||||||
|
close(fdi[1]);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
close(fdi[1]);
|
||||||
|
dup2(fdi[0], 0);
|
||||||
|
} else if(keywordDefined("input")) {
|
||||||
coreutils::MString input(resolveKeyword("input"));
|
coreutils::MString input(resolveKeyword("input"));
|
||||||
pipe(fdi);
|
pipe(fdi);
|
||||||
if(fork() == 0) {
|
if(fork() == 0) {
|
||||||
|
|||||||
@ -1,11 +1,18 @@
|
|||||||
#!../jet-2.0
|
#!../jet-2.0
|
||||||
<jet name1="localname" filterblanklines="true" trimlines="true">
|
<jet name1="localname" filterblanklines="false" trimlines="true">
|
||||||
<set name="abc" value="abcdefg" />
|
<set name="abc" value="abcdefg" />
|
||||||
<call pgm="cat" error="error" input="$[abc]xyz" name="test1" />
|
<call pgm="cat" error="error" input="$[abc]xyz" name="test1" />
|
||||||
test1=$[test1]
|
test1=$[test1]
|
||||||
name1=$[%name1]
|
name1=$[%name1]
|
||||||
error=$[error]
|
error=$[error]
|
||||||
<call error="rc" pgm="/usr/bin/ls" arg1="-al" />
|
<call error="rc" pgm="ls" arg1="-al" />
|
||||||
$[rc]
|
$[rc]
|
||||||
|
<call pgm="cat" filterblanklines="false">
|
||||||
|
From: barant@barant.com
|
||||||
|
To: brad.arant@gmail.com
|
||||||
|
Subject: This is a test email.
|
||||||
|
|
||||||
|
This is a test email being sent from a jet script with a single
|
||||||
|
call command.
|
||||||
|
</call>
|
||||||
</jet>
|
</jet>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user