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"
#include <dlfcn.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)
 
std::string getCurrentSOPath ()
 

Function Documentation

◆ getCurrentSOPath()

std::string getCurrentSOPath ( )

Definition at line 125 of file ExtAPI.cpp.

126{
128 if (dladdr((void*)&getCurrentSOPath, &info) && info.dli_fname)
129 {
130 return std::string(info.dli_fname);
131 }
132 return "";
133}
std::string getCurrentSOPath()
Definition ExtAPI.cpp:125
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ getFilePath()

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

Definition at line 99 of file ExtAPI.cpp.

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

◆ GetStdoutFromCommand()

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

Definition at line 75 of file ExtAPI.cpp.

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