tmp.c/main.cpp
Vincent Batts 7628ecc915
main: :ohno: linked to libcurl and did a webconnect
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2025-02-10 17:58:07 -05:00

92 lines
1.9 KiB
C++

// Copyright 2025 Vincent Batts <vbatts@hashbangbash.com>
/*
* =====================================================================================
*
* Filename: main.cpp
*
* Description: learning C++ [again]
*
* Version: 1.0
* Created: 02/08/2025 11:05:02 AM
* Revision: none
* Compiler: g++
*
* Author: Vincent Batts (vbatts@hashbangbash.com)
* Organization: HashBangBash
*
* =====================================================================================
*/
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <curl/curl.h>
#include "./common.h"
#include "./account.h"
#include "./worker.h"
Account* do_account() {
Account* account = new Account(0.0);
assert(account);
if (nullptr == account) {
log_err("failed to allocate account");
return nullptr;
}
account->deposit(100.5); // Add some money
account->deposit(50.25); // Add more money
log_out("Current Balance: " << account->getBalance());
return account;
}
void scoped_account() {
log_out("HERE");
auto account = do_account();
if (nullptr == account) {
log_err("failed to allocate account");
return;
}
log_out("HERE");
account->withdraw(100);
log_out("Current Balance: " << account->getBalance());
log_err("dang");
delete account;
}
void webtest() {
log_out("begin webtest");
CURL* c = curl_easy_init();
if (c) {
CURLcode res;
curl_easy_setopt(c, CURLOPT_URL, "https://hashbangbash.com/");
res = curl_easy_perform(c);
curl_easy_cleanup(c);
if (res==CURLE_OK) {
log_out("connected to hashbangbash.com");
}
}
log_out("end webtest");
}
int main(int argc, char* argv[]) {
int ret;
scoped_account();
webtest();
Dang::Worker worker;
worker.setTimeout(1);
ret = worker.work();
if (ret != 0) {
std::cout << "worker failed" << std::endl;
}
return EXIT_SUCCESS;
}
// vim:set sts=2 sw=2 et: