Static Value-Flow Analysis
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>

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 97 of file ExtAPI.cpp.

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

◆ GetStdoutFromCommand()

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

Definition at line 73 of file ExtAPI.cpp.

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