More work on call tag.
This commit is contained in:
parent
49edce1f34
commit
632e6979ba
32
__call.cpp
32
__call.cpp
@ -13,9 +13,6 @@ namespace jet {
|
|||||||
throw coreutils::Exception("call cannot have a container.");
|
throw coreutils::Exception("call cannot have a container.");
|
||||||
if(!variableDefined(coreutils::ZString("pgm")))
|
if(!variableDefined(coreutils::ZString("pgm")))
|
||||||
throw coreutils::Exception("pgm keyword must be specified.");
|
throw coreutils::Exception("pgm keyword must be specified.");
|
||||||
pipe(fd); // TODO: Get these pipes to work with name and input keywords.
|
|
||||||
dup2(fd[0], 1);
|
|
||||||
if(pid != fork()) {
|
|
||||||
argv[0] = variables["pgm"].c_str(); // TODO: Need to peel off the program name only and pass as argv[0].
|
argv[0] = variables["pgm"].c_str(); // TODO: Need to peel off the program name only and pass as argv[0].
|
||||||
for(ix = 1; ix <= 50; ++ix) {
|
for(ix = 1; ix <= 50; ++ix) {
|
||||||
coreutils::MString arg("arg");
|
coreutils::MString arg("arg");
|
||||||
@ -26,11 +23,34 @@ namespace jet {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
argv[ix] == NULL;
|
argv[ix] == NULL;
|
||||||
execve(variables["pgm"].c_str(), argv, NULL);
|
pipe(fdo);
|
||||||
exit(-1);
|
if(pid != fork()) {
|
||||||
|
close(fdo[0]);
|
||||||
|
dup2(fdo[1], 1);
|
||||||
|
if(variableDefined("input")) {
|
||||||
|
coreutils::ZString input(variables[variables["input"]]);
|
||||||
|
pipe(fdi);
|
||||||
|
if(fork() == 0) {
|
||||||
|
close(fdi[0]);
|
||||||
|
write(fdi[1], input.getData(), input.getLength());
|
||||||
|
close(fdi[1]);
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
close(fdi[0]);
|
||||||
|
dup2(fdi[0], 0);
|
||||||
|
}
|
||||||
|
rc = execve(variables["pgm"].c_str(), argv, NULL);
|
||||||
|
close(fdo[1]);
|
||||||
|
std::cout << "rc: " << rc << std::endl;
|
||||||
|
exit(rc);
|
||||||
|
}
|
||||||
|
close(fdo[1]);
|
||||||
|
if(variableDefined("name"))
|
||||||
|
global.variables[variables["name"]].read(fdo[0]);
|
||||||
|
else
|
||||||
|
out.read(fdo[0]);
|
||||||
waitpid(pid, &status,0);
|
waitpid(pid, &status,0);
|
||||||
|
std::cout << "status: " << status << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
6
__call.h
6
__call.h
@ -14,8 +14,10 @@ namespace jet {
|
|||||||
int pid;
|
int pid;
|
||||||
int status;
|
int status;
|
||||||
int ix;
|
int ix;
|
||||||
int fd[2];
|
int fdi[2];
|
||||||
char *argv[25];
|
int fdo[2];
|
||||||
|
int rc;
|
||||||
|
char *argv[50];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
4
compile
4
compile
@ -5,7 +5,7 @@ do
|
|||||||
filename="${file%.*}"
|
filename="${file%.*}"
|
||||||
list="$list $filename.o"
|
list="$list $filename.o"
|
||||||
echo -n "Compiling $filename..."
|
echo -n "Compiling $filename..."
|
||||||
g++ -g -c -std=c++17 -I../CoreUtils $file &
|
g++ -g -c -std=c++23 -I../CoreUtils $file &
|
||||||
if [ $? = '0' ]
|
if [ $? = '0' ]
|
||||||
then
|
then
|
||||||
echo "OK"
|
echo "OK"
|
||||||
@ -18,7 +18,7 @@ done
|
|||||||
|
|
||||||
wait
|
wait
|
||||||
echo -n "Building executable testjet..."
|
echo -n "Building executable testjet..."
|
||||||
g++ -g -o testjet $list -std=c++17 -L../CoreUtils -lCoreUtils
|
g++ -g -o testjet $list -std=c++23 -L../CoreUtils -lCoreUtils
|
||||||
if [ $? = '0' ]
|
if [ $? = '0' ]
|
||||||
then
|
then
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
@ -26,9 +26,10 @@ int main(int argc, char **argv) {
|
|||||||
" </if>\n"
|
" </if>\n"
|
||||||
" </if>\n"
|
" </if>\n"
|
||||||
" </mysql>\n"
|
" </mysql>\n"
|
||||||
" <for name=\"ix\" start=\"1\" end=\"5\" step=\".1\">\n"
|
" <for name=\"ix\" start=\"1\" end=\"5\" step=\"1\">\n"
|
||||||
" -->#[ix]<--\n"
|
" -->#[ix]<--\n"
|
||||||
" </for>\n"
|
" </for>\n"
|
||||||
|
" <call pgm=\"/usr/bin/ls\" arg1=\"-al\" />"
|
||||||
" </html>\n"
|
" </html>\n"
|
||||||
"</jet>\n");
|
"</jet>\n");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user