Merge remote-tracking branch 'origin/fastpath'

* origin/fastpath:
  Normalize Notice::Type identifiers per convention. (closes #484)
  Another fix to the default-loaded-scripts test.
  Add new piped_exec BiF.
  Revert "Fixes for email_notice_to() function."
  Fixes for email_notice_to() function.
This commit is contained in:
Robin Sommer 2011-07-28 17:05:21 -07:00
commit 4baf344278
12 changed files with 65 additions and 43 deletions

View file

@ -9,6 +9,7 @@
#include <algorithm>
#include <cmath>
#include <sys/stat.h>
#include <cstdio>
#include "Reporter.h"
@ -3613,3 +3614,24 @@ function NFS3::mode2string%(mode: count%): string
return new StringVal(str);
%}
## Opens a program with popen() and writes a given string to the returned
## stream to send it to the opened process's stdin.
## program: a string naming the program to execute
## to_write: a string to pipe to the opened program's process over stdin
## Returns: F if popen'ing the program failed, else T
function piped_exec%(program: string, to_write: string%): bool
%{
const char* prog = program->CheckString();
FILE* f = popen(prog, "w");
if ( ! f )
{
reporter->Error("Failed to popen %s", prog);
return new Val(false, TYPE_BOOL);
}
fprintf(f, "%s", to_write->CheckString());
pclose(f);
return new Val(true, TYPE_BOOL);
%}