Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM gcc:12.3 AS build
RUN apt-get update && apt-get install -y \
catch2 \
cmake \
libcurl4-openssl-dev \
libncurses5-dev \
libncursesw5-dev && \
apt-get autoremove && \
Expand All @@ -24,6 +25,7 @@ ENTRYPOINT [ "/usr/local/bin/4thand5.i.t" ]

FROM ubuntu:latest AS run
RUN apt-get update && apt-get install -y \
libcurl4 \
libncurses6 && \
apt-get autoremove && \
apt-get -y clean && \
Expand Down
5 changes: 3 additions & 2 deletions src/4thand5.m.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
#include <functional>
#include <iostream>
#include <iterator>
#include <ncurses.h>
#include <string>
#include <tuple>
#include <vector>

#include <ncurses.h>

#include "feed.h"
#include "game_data.h"
#include "view.h"
Expand Down Expand Up @@ -90,7 +91,7 @@ int main(int argc, char *argv[])
startY += view.get().nRows;
};

(bufferView(args), ...);
((void)bufferView(args), ...);
}, views);
} else {
(void)wmove(stdscr, minY, minX);
Expand Down
1 change: 1 addition & 0 deletions src/feed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ target_link_libraries(${LIBRARY_NAME}
game_data # local
INTERFACE
PRIVATE
curl
)

target_sources(${LIBRARY_NAME}
Expand Down
48 changes: 33 additions & 15 deletions src/feed/feed.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
#include "feed.h"

#include <curl/curl.h>

#include <cstdlib>
#include <chrono>
#include <memory>
#include <mutex>
#include <string>

namespace fourthandfive {
namespace {

CURLcode ensure_curl_init_cleanup() {
CURLcode rc = CURLE_OK;
static std::once_flag initFlag;
(void)std::call_once(initFlag, [&rc]() {
rc = curl_global_init(CURL_GLOBAL_ALL);
std::atexit(curl_global_cleanup);
});

return rc;
}

} // close namespace unnamed

std::vector<GameData> getGameData(const int gameId) {
return {
{
.homeTeamId = 0,
.awayTeamId = 0,
.homeTeamScore = 0,
.awayTeamScore = 0,
.homeTeamTO = 3,
.awayTeamTO = 3,
.possession = 0,
.down = 0,
.distance = 10,
.yardLine = 0,
.period = 0,
.clock = std::chrono::seconds(900)
std::vector<GameData> gameData;
CURLcode rc = ensure_curl_init_cleanup();
if (rc == CURLE_OK) {
std::unique_ptr<CURL, decltype(&curl_easy_cleanup)> curl(curl_easy_init(), curl_easy_cleanup);
if (curl) {
std::string response;
rc = curl_easy_perform(curl.get());
if (rc == CURLE_OK) {
// parseFeed(&gameData, const& response);
}
}
};
}

return gameData;
}

} // close namespace fourthandfive
Expand Down
2 changes: 2 additions & 0 deletions src/game_data/game_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define FOURTHANDFIVE_GAME_DATA_H

#include <chrono>
#include <string>

namespace fourthandfive {

Expand All @@ -18,6 +19,7 @@ struct GameData {
unsigned int yardLine{0};
unsigned int period{0};
std::chrono::seconds clock{900};
std::string description{};
};

} // close namespace fourthandfive
Expand Down
Loading