summaryrefslogtreecommitdiff
path: root/ticket.c
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-10-02 14:35:07 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-10-02 14:35:07 +0800
commit8cff9b9d5a49e4c1a9364fd55f4887700ef2a4ae (patch)
tree8a5f2ad8fba5cb49873ac7119c286ac1a9113cfc /ticket.c
parent9fd7e32936b96cdcd5329077662e2fcc546d2bdd (diff)
There are only 2 formats for ticket history return
Diffstat (limited to 'ticket.c')
-rw-r--r--ticket.c38
1 files changed, 8 insertions, 30 deletions
diff --git a/ticket.c b/ticket.c
index 795e750..31a208f 100644
--- a/ticket.c
+++ b/ticket.c
@@ -40,18 +40,7 @@ void rtclient_ticket_new(const char *queue
}, 28);
}
-static size_t history_i_handler(void *contents, size_t size, size_t nmemb
- , void *writedata)
-{
- size_t realsize = size * nmemb;
- char response[realsize + 1];
- memcpy(response, contents, realsize);
- response[realsize] = '\0';
-
- return realsize;
-}
-
-static size_t history_s_handler(void *contents, size_t size, size_t nmemb
+static size_t history_handler(void *contents, size_t size, size_t nmemb
, void *writedata)
{
size_t realsize = size * nmemb;
@@ -294,27 +283,16 @@ static size_t history_l_handler(void *contents, size_t size, size_t nmemb
}
void rtclient_ticket_history(rtclient_ticket_history_list **listptr
- , unsigned int id
- , enum rtclient_ticket_format result_format)
+ , unsigned int id, bool long_format)
{
*listptr = malloc(sizeof(rtclient_ticket_history_list));
(*listptr)->length = 0;
- size_t (*handler)(void *, size_t, size_t, void *) = history_s_handler;
- char format = 's';
- switch (result_format) {
- case RTCLIENT_TICKET_FORMAT_I:
- handler = history_i_handler;
- format = 'i';
- break;
- case RTCLIENT_TICKET_FORMAT_L:
- handler = history_l_handler;
- format = 'l';
- break;
- default:
- break;
- }
- request(handler, (void *)listptr, NULL, "%s%u%s%c", "REST/1.0/ticket/", id
- , "/history?format=", format);
+ if (long_format)
+ request(history_l_handler, (void *)listptr, NULL, "%s%u%s"
+ , "REST/1.0/ticket/", id, "/history?format=l");
+ else
+ request(history_handler, (void *)listptr, NULL, "%s%u%s"
+ , "REST/1.0/ticket/", id, "/history");
}
void rtclient_ticket_history_free(struct rtclient_ticket_history *history)