Clean up
This commit is contained in:
-21
@@ -1,21 +0,0 @@
|
||||
#include "Telegram/exec.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
std::string exec(const char* cmd) {
|
||||
|
||||
FILE* pipe = popen(cmd, "r");
|
||||
if (!pipe)
|
||||
return "ERROR";
|
||||
|
||||
char buffer[128];
|
||||
std::string result = "";
|
||||
while (!feof(pipe)) {
|
||||
if (fgets(buffer, 128, pipe) != NULL)
|
||||
result += buffer;
|
||||
}
|
||||
pclose(pipe);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
#include "Telegram/explode.h"
|
||||
|
||||
std::vector<std::string> explode( const std::string &delimiter, const std::string &str) {
|
||||
|
||||
std::vector<std::string> arr;
|
||||
|
||||
int strleng = str.length();
|
||||
int delleng = delimiter.length();
|
||||
if (delleng == 0)
|
||||
return arr;//no change
|
||||
|
||||
int i = 0;
|
||||
int k = 0;
|
||||
while(i < strleng) {
|
||||
int j = 0;
|
||||
while ((i+j < strleng) && (j < delleng) && (str[i+j] == delimiter[j]))
|
||||
j++;
|
||||
if (j == delleng) {
|
||||
arr.push_back(str.substr(k, i-k));
|
||||
i += delleng;
|
||||
k = i;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
arr.push_back(str.substr(k, i-k));
|
||||
return arr;
|
||||
}
|
||||
Reference in New Issue
Block a user