Python integration with c++ binary (not totally working yet)
This commit is contained in:
28
backend/nfqueue/utils.hpp
Normal file
28
backend/nfqueue/utils.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef UTILS_HPP
|
||||
#define UTILS_HPP
|
||||
|
||||
bool unhexlify(std::string const &hex, std::string &newString) {
|
||||
try{
|
||||
int len = hex.length();
|
||||
for(int i=0; i< len; i+=2)
|
||||
{
|
||||
std::string byte = hex.substr(i,2);
|
||||
char chr = (char) (int)strtol(byte.c_str(), NULL, 16);
|
||||
newString.push_back(chr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (...){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool is_sudo(){
|
||||
return getuid() == 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user