summaryrefslogtreecommitdiff
path: root/ticket.c
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-25 16:24:39 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-25 16:24:39 +0800
commite39fa22f6896b7b7200229ffba95c56074a17535 (patch)
treeafca923eff622121d60ca20285e5804d2b27f7a1 /ticket.c
parenta2667831d91ca18b9b8d41ad1d52a721103f8750 (diff)
Ticket structure
now containing ID member
Diffstat (limited to 'ticket.c')
-rw-r--r--ticket.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/ticket.c b/ticket.c
index 77da6b2..c97badd 100644
--- a/ticket.c
+++ b/ticket.c
@@ -2,6 +2,7 @@
#include "post.h"
#include "rtclient/ticket.h"
+typedef struct rtclient_ticket rtclient_ticket;
typedef struct rtclient_ticketlist rtclient_ticketlist;
void rtclient_ticket_new(const char *queue
@@ -69,10 +70,13 @@ static size_t search_callback(void *contents, size_t size, size_t nmemb
line = strtok_r(NULL, "\n", &linesaveptr);
char *tokensaveptr = NULL, *token = NULL;
for (unsigned int i = 0; i < list->length; i++) {
+ list->tickets[i] = malloc(sizeof(rtclient_ticket));
+ rtclient_ticket *ticket = list->tickets[i];
token = strtok_r(line, ":", &tokensaveptr);
+ ticket->id = atoi(token);
token = strtok_r(NULL, ":", &tokensaveptr);
- list->tickets[i] = malloc(strlen(token));
- strcpy(list->tickets[i], ++token);
+ ticket->subject = malloc(strlen(token));
+ strcpy(ticket->subject, ++token);
line = strtok_r(NULL, "\n", &linesaveptr);
}
} else {
@@ -101,8 +105,11 @@ void rtclient_ticket_search(rtclient_ticketlist **listptr, const char *query)
void rtclient_ticket_freelist(rtclient_ticketlist *list)
{
- for (unsigned short i = 0; i < list->length; i++)
- free(list->tickets[i]);
+ for (unsigned short i = 0; i < list->length; i++) {
+ rtclient_ticket *ticket = list->tickets[i];
+ free(ticket->subject);
+ free(ticket);
+ }
free(list);
list = NULL;
}