Static Value-Flow Analysis
Loading...
Searching...
No Matches
Functions
ExtAPI.cpp File Reference
#include "Util/ExtAPI.h"
#include "Util/SVFUtil.h"
#include "Util/Options.h"
#include "Util/config.h"
#include <ostream>
#include <sys/stat.h>
#include "SVFIR/SVFVariables.h"

Go to the source code of this file.

Functions

static std::string GetStdoutFromCommand (const std::string &command)
 
static std::string getFilePath (const std::string &path)
 

Function Documentation

◆ getFilePath()

static std::string getFilePath ( const std::string path)
static

Definition at line 98 of file ExtAPI.cpp.

99{
100 std::string bcFilePath = "";
101 if (path.compare("SVF_DIR") == 0)
102 {
103 char const* svfdir = getenv("SVF_DIR");
104 if (svfdir)
106 }
107 else if (path.compare("npm root") == 0)
108 {
110 bcFilePath.append("/SVF");
111 }
112
113 if (!bcFilePath.empty() && bcFilePath.back() != '/')
114 bcFilePath.push_back('/');
115 bcFilePath.append(SVF_BUILD_TYPE "-build").append("/lib/extapi.bc");
116 return bcFilePath;
117}
static std::string GetStdoutFromCommand(const std::string &command)
Definition ExtAPI.cpp:74
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ GetStdoutFromCommand()

static std::string GetStdoutFromCommand ( const std::string command)
static

Definition at line 74 of file ExtAPI.cpp.

75{
76 char buffer[128];
77 std::string result = "";
78 // Open pipe to file
79 FILE* pipe = popen(command.c_str(), "r");
80 if (!pipe)
81 {
82 return "popen failed!";
83 }
84 // read till end of process:
85 while (!feof(pipe))
86 {
87 // use buffer to read and add to result
88 if (fgets(buffer, 128, pipe) != NULL)
89 result += buffer;
90 }
91 pclose(pipe);
92 // remove "\n"
93 result.erase(remove(result.begin(), result.end(), '\n'), result.end());
94 return result;
95}
char * buffer
Definition cJSON.h:163
#define NULL
Definition extapi.c:2
char * fgets(char *str, int n, void *stream)
Definition extapi.c:746