feat: v1.3-konforme API, HTTP-Fixes, Base64, Example erweitert; Makefile & README Setup
This commit is contained in:
@@ -31,7 +31,41 @@ int main() {
|
||||
std::cout << "Paste created successfully!" << std::endl;
|
||||
std::cout << "URL: " << paste_url << std::endl;
|
||||
std::cout << "Delete token: " << delete_token << std::endl;
|
||||
|
||||
|
||||
// Parse paste_id and key from URL (format: "/?{pasteID}#{key}")
|
||||
std::string full_url = paste_url ? paste_url : "";
|
||||
std::string paste_id;
|
||||
std::string key;
|
||||
auto qpos = full_url.find('?');
|
||||
auto hpos = full_url.find('#');
|
||||
if (qpos != std::string::npos) {
|
||||
if (hpos != std::string::npos && hpos > qpos + 1) {
|
||||
paste_id = full_url.substr(qpos + 1, hpos - (qpos + 1));
|
||||
key = full_url.substr(hpos + 1);
|
||||
} else if (qpos + 1 < full_url.size()) {
|
||||
paste_id = full_url.substr(qpos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Try to fetch paste content back
|
||||
if (!paste_id.empty() && !key.empty()) {
|
||||
std::cout << "Fetching paste..." << std::endl;
|
||||
char* content = nullptr;
|
||||
int gr = get_paste("https://privatebin.medisoftware.org", paste_id.c_str(), key.c_str(), &content);
|
||||
std::cout << "get_paste returned: " << gr << std::endl;
|
||||
if (gr == 0 && content) {
|
||||
std::cout << "Content: " << content << std::endl;
|
||||
free_string(content);
|
||||
}
|
||||
}
|
||||
|
||||
// Try to delete paste
|
||||
if (!paste_id.empty() && delete_token) {
|
||||
std::cout << "Deleting paste..." << std::endl;
|
||||
int dr = delete_paste("https://privatebin.medisoftware.org", paste_id.c_str(), delete_token);
|
||||
std::cout << "delete_paste returned: " << dr << std::endl;
|
||||
}
|
||||
|
||||
// Clean up allocated memory
|
||||
free_string(paste_url);
|
||||
free_string(delete_token);
|
||||
|
||||
Reference in New Issue
Block a user