Initial commit: PrivateBin API C++ DLL implementation
This commit is contained in:
25
example/CMakeLists.txt
Normal file
25
example/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(PrivateBinAPIExample)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# Find the privatebinapi library
|
||||
find_library(PRIVATEBINAPI_LIB privatebinapi
|
||||
PATHS ${CMAKE_CURRENT_SOURCE_DIR}/../build)
|
||||
|
||||
# If not found, build it as part of the project
|
||||
if(NOT PRIVATEBINAPI_LIB)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/privatebinapi)
|
||||
set(PRIVATEBINAPI_LIB privatebinapi)
|
||||
endif()
|
||||
|
||||
# Create example executable
|
||||
add_executable(example example.cpp)
|
||||
|
||||
# Link with the privatebinapi library
|
||||
target_link_libraries(example ${PRIVATEBINAPI_LIB})
|
||||
|
||||
# Include directories
|
||||
target_include_directories(example PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../include
|
||||
)
|
||||
45
example/example.cpp
Normal file
45
example/example.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include "privatebinapi.h"
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
int main() {
|
||||
std::cout << "PrivateBin API C++ DLL Example" << std::endl;
|
||||
std::cout << "===============================" << std::endl;
|
||||
|
||||
// Example of how to use the API
|
||||
char* paste_url = nullptr;
|
||||
char* delete_token = nullptr;
|
||||
|
||||
// Note: This is a demonstration only. In a real application,
|
||||
// you would use actual server URLs and handle errors appropriately.
|
||||
|
||||
/*
|
||||
int result = create_paste(
|
||||
"https://privatebin.net", // Server URL
|
||||
"Hello, PrivateBin!", // Content
|
||||
nullptr, // No password
|
||||
"1hour", // Expire in 1 hour
|
||||
"plaintext", // Plain text format
|
||||
0, // Don't burn after reading
|
||||
0, // No discussion
|
||||
&paste_url, // Output: paste URL
|
||||
&delete_token // Output: delete token
|
||||
);
|
||||
|
||||
if (result == 0) {
|
||||
std::cout << "Paste created successfully!" << std::endl;
|
||||
std::cout << "URL: " << paste_url << std::endl;
|
||||
std::cout << "Delete token: " << delete_token << std::endl;
|
||||
|
||||
// Clean up allocated memory
|
||||
free_string(paste_url);
|
||||
free_string(delete_token);
|
||||
} else {
|
||||
std::cout << "Failed to create paste. Error code: " << result << std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
std::cout << "Example completed." << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user