diff options
author | Antony Kellermann | 2018-05-29 20:53:07 -0400 |
---|---|---|
committer | Antony Kellermann | 2018-05-29 20:53:07 -0400 |
commit | eedb9c51064050dc7021a97560d7ff8c2f4eb821 (patch) | |
tree | bdfa4add22f56da0d5b5802136e283de4a2ce1d0 /api.h | |
parent | 4638bd317573fa8a8cd9ecebb822196f84c871d0 (diff) | |
download | aur-eedb9c51064050dc7021a97560d7ff8c2f4eb821.tar.gz |
Added News struct to easily store news and moved news API call as a threadable function to api.c
Diffstat (limited to 'api.h')
-rw-r--r-- | api.h | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -14,6 +14,7 @@ #define URL_MAX_LENGTH 2048 #define INFO_TEXT_MAX 2048 #define EMPTY (-999) +#define DEFAULT_NUM_ARTICLES 3 #include <stddef.h> #include <curl/curl.h> @@ -21,6 +22,15 @@ #include <pthread.h> #include "string-tick.h" +typedef struct news_article { + char headline[INFO_TEXT_MAX]; + char source[INFO_TEXT_MAX]; + char date[DATE_MAX_LENGTH]; + char summary[INFO_TEXT_MAX]; + char url[URL_MAX_LENGTH]; + char related[INFO_TEXT_MAX]; +} News; + typedef struct info { /* Company */ char symbol[SYMBOL_MAX_LENGTH]; // ex. AAPL @@ -65,8 +75,14 @@ typedef struct info { double change_7d; // Percent change since 7 days ago double change_30d; // Percent change since 30 days ago double* points; // Array of one price per day, startings five years previously + + /* News */ + News** articles; // Array of News pointers + int num_articles; // Number of News pointers in array } Info; +News* api_news_init(void); + /** * Allocates an Info struct and returns a pointer to it. All numbers are set to EMPTY, all strings are NULL * terminated at length 0, and all pointers are set to NULL. @@ -137,6 +153,8 @@ void* iex_store_earnings(void* vpInfo); */ void* iex_store_chart(void* vpInfo); +void* iex_store_news(void* vpInfo); + /** * Designed for threading * @@ -204,6 +222,8 @@ Info* api_get_check_info(const char* symbol); */ Info* api_get_info(const char* symbol); +void api_news_destroy(News** phNews); + /** * Destroys Info object and frees memory. Sets the pointer to the Info to NULL * @param phInfo the Info to destroy |