#include <iostream>
#include <string>
using namespace std;

#include "STAF.h" #include "STAFString.h"

int main(int argc, char **argv) { STAFString name("foo"); STAFHandlePtr handle;

int rc = STAFHandle::create(name, handle); if (rc != 0) { cerr << "Could not create STAF handle; error code: " << rc << endl; return 1; }

STAFResultPtr result = handle->submit("127.0.0.1", "VAR", "RESOLVE STRING {STAF/Env/DUMMY}"); if (result->rc != 0) { cerr << "Could not run STAF command; error code: " << rc << endl; return 1; }

STAFString output = result->result; cout << "Output: " << output.buffer() << endl; }

Output:
C:\MixedBag\debug>echo
%DUMMY%
Why__does__it__break

C:\MixedBag\debug>STAFExperiments.exe Output: Why__does__it__break/Env/DUMMY}}

The '/Env/DUMMY' at the end is garbage. The results are not '\0'-terminated in the result-buffer. The correct way to get the output is as follows:
cout << "Output: " << string(output.buffer(), output.length()) << endl;

No comments

Post a comment

RSS