rm ingored

This commit is contained in:
2024-11-22 23:26:07 +03:00
parent 5450d1756f
commit 63e4c1382f
65 changed files with 0 additions and 7599 deletions

View File

@@ -1,63 +0,0 @@
#include "net.h"
#include <curl/curl.h>
#include <iostream>
#include <vector>
#include <regex>
struct data {};
size_t write_data(void *buffer, size_t size, size_t nmemb, void *filename) {
FILE *f = fopen(((std::string *)filename)->c_str(), "w");
size_t written = fwrite(buffer, size, nmemb, f);
fclose(f);
return written;
}
Net::Net() {}
void write_modules(void *buffer, size_t size, size_t nmemb, void *modules) {
std::vector<std::string> *modules_vector =
(std::vector<std::string> *)modules;
std::string to_parse = std::string((char*)buffer);
std::regex r("(?!\\\")\\w+\\.json(?!\\\")", std::regex::collate);
std::smatch res;
std::string::const_iterator search(to_parse.cbegin());
while (std::regex_search(search, to_parse.cend(), res, r)) {
modules_vector->push_back(res[0]);
search = res.suffix().first;
}
}
std::vector<std::string> Net::get_all_modules(std::string url) {
CURL *handle = curl_easy_init();
curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_modules);
std::vector<std::string> modules {};
curl_easy_setopt(handle, CURLOPT_WRITEDATA, &modules);
curl_easy_perform(handle);
return modules;
}
std::string Net::get_file(std::string url, std::string filename) {
CURL *handle = curl_easy_init();
curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, &filename);
auto success = curl_easy_perform(handle);
curl_easy_cleanup(handle);
return "";
}

View File

@@ -1,17 +0,0 @@
#ifndef NET_H
#define NET_H
#include <string>
#include <vector>
size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp);
class Net
{
public:
Net();
std::vector<std::string> get_all_modules(std::string url);
std::string get_file(std::string url, std::string filename);
};
#endif // NET_H