summaryrefslogtreecommitdiff
path: root/quotes.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2021-05-31 06:11:22 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2021-05-31 06:11:22 -0700
commit18bde7391efb9c6bd6ea7846891ab5d16276a809 (patch)
tree237cc152edbdf934ed32e4c8c54c5ce97535e57f /quotes.c
downloadstonks-18bde7391efb9c6bd6ea7846891ab5d16276a809.tar.gz
stonks-18bde7391efb9c6bd6ea7846891ab5d16276a809.tar.xz
initial importHEADmaster
A bit messy and missing error handling in some places.
Diffstat (limited to 'quotes.c')
-rw-r--r--quotes.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/quotes.c b/quotes.c
new file mode 100644
index 0000000..5e269e0
--- /dev/null
+++ b/quotes.c
@@ -0,0 +1,23 @@
+#include "quotes.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+void quote_free(struct quote *q)
+{
+ free(q->symbol);
+ free(q->currency);
+ free(q);
+}
+
+struct quote *quote_find(struct quote **quotes, int n_quotes,
+ const char *symbol, const char *currency)
+{
+ for (int i = 0; i < n_quotes; ++i) {
+ if (strcmp(quotes[i]->symbol, symbol) == 0 &&
+ strcmp(quotes[i]->currency, currency) == 0)
+ return quotes[i];
+ }
+
+ return NULL;
+}