add files

This commit is contained in:
PoliEcho 2024-11-07 16:36:24 +01:00
parent 0471e8de25
commit 2ed6176f38
4 changed files with 83 additions and 0 deletions

20
Makefile Normal file
View File

@ -0,0 +1,20 @@
CC = g++
CC_FLAGS = -s -O3 -lncurses -lcurl -Wall -Wextra
#debug flags:
#CC_FLAGS = -ggdb `pkg-config --cflags --libs gtkmm-4.0` -Wall -Wextra
all: build/bin/pupes-slots
build/bin/pupes-slots: build/obj/main.o build/obj/baka-api.o
$(CC) $(CC_FLAGS) build/obj/main.o build/obj/baka-api.o -o build/bin/bakatui
build/obj/main.o: src/main.cpp
mkdir -p build/obj
mkdir -p build/bin
$(CC) $(CC_FLAGS) -c src/main.cpp -o build/obj/main.o
build/obj/baka-api.o: src/baka-api.cpp
$(CC) $(CC_FLAGS) -c src/baka-api.cpp -o build/obj/baka-api.o
clean:
rm -fr build

33
src/baka-api.cpp Normal file
View File

@ -0,0 +1,33 @@
#include <curl/curl.h>
#include <string>
#include <iostream>
namespace bakaapi {
// Callback function to write data into a std::string
size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* userp) {
size_t totalSize = size * nmemb;
userp->append((char*)contents, totalSize);
return totalSize;
}
void login() {
CURL* curl;
std::string response;
char url[] = "https://c-for-dummies.com/curl_test.txt";
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
curl_easy_perform(curl); // Perform the request
std::cout << "this is responce: "<< response << std::endl; // Output the result
curl_easy_cleanup(curl); // Cleanup
}
}
}

3
src/baka-api.h Normal file
View File

@ -0,0 +1,3 @@
namespace bakaapi {
void login();
}

27
src/main.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <curses.h>
#include "baka-api.h"
int main(int argc, char ** argv) {
/*initscr();
// creating a window;
// with height = 15 and width = 10
// also with start x axis 10 and start y axis = 20
WINDOW *win = newwin(15, 17, 2, 10);
refresh();
// making box border with default border styles
box(win, 0, 0);
// move and print in window
mvwprintw(win, 0, 1, "Greeter");
mvwprintw(win, 1, 1, "Hello");
// refreshing the window
wrefresh(win);
getch();
endwin(); */
bakaapi::login();
return 0;
}