diff options
author | turret <turret@duck.com> | 2023-12-18 16:13:36 -0600 |
---|---|---|
committer | turret <turret@duck.com> | 2023-12-18 16:13:36 -0600 |
commit | 54b308af97b91ceabb0a482f325d3a8595b01aa3 (patch) | |
tree | adbe345bca29943f02f54c86dc1ec17d5aa3528a /net | |
parent | 22cacb4dc96faae8814a9696805314c0fcc455ba (diff) | |
download | discord-bot-skeleton-54b308af97b91ceabb0a482f325d3a8595b01aa3.tar.gz discord-bot-skeleton-54b308af97b91ceabb0a482f325d3a8595b01aa3.tar.bz2 discord-bot-skeleton-54b308af97b91ceabb0a482f325d3a8595b01aa3.zip |
*: enforce 78 char line limit
Diffstat (limited to 'net')
-rw-r--r-- | net/api.c | 3 | ||||
-rw-r--r-- | net/net.c | 18 |
2 files changed, 14 insertions, 7 deletions
@@ -26,7 +26,8 @@ int http_get(char *url) curl_easy_setopt(job, CURLOPT_URL, url); curl_easy_setopt(job, CURLOPT_WRITEDATA, write_end); - curl_easy_setopt(job, CURLOPT_HTTPHEADER, curl_slist_append(NULL, token)); + curl_easy_setopt(job, CURLOPT_HTTPHEADER, + curl_slist_append(NULL, token)); CURLcode res = curl_easy_perform(job); if(res > 0) { @@ -21,7 +21,8 @@ int net_subsystem(void) void net_get_gateway_url() { - curl_version_info_data *curl_version = curl_version_info(CURLVERSION_NOW); + curl_version_info_data *curl_version = + curl_version_info(CURLVERSION_NOW); const char * const* curl_protocols = curl_version->protocols; int wss_supported = 0; for(int i = 0; curl_protocols[i]; ++i) { @@ -43,14 +44,18 @@ void net_get_gateway_url() close(fd); cJSON *gateway_info = cJSON_ParseWithLength(buf, buf_length); - cJSON *gateway_url_json = cJSON_GetObjectItemCaseSensitive(gateway_info, "url"); - if(!cJSON_IsString(gateway_url_json) || gateway_url_json->valuestring == NULL) { - print(LOG_ERR "net: cannot get gateway url from api (token invalid?)"); + cJSON *gateway_url_json = + cJSON_GetObjectItemCaseSensitive(gateway_info, "url"); + if(!cJSON_IsString(gateway_url_json) || + gateway_url_json->valuestring == NULL) { + print(LOG_ERR "net: cannot get gateway url from api " + "(token invalid?)"); cJSON_Delete(gateway_info); goto assume; } - char *gateway_url = calloc(strlen(gateway_url_json->valuestring) + 1, sizeof(char)); + char *gateway_url = calloc(strlen(gateway_url_json->valuestring) + 1, + sizeof(char)); strcpy(gateway_url, gateway_url_json->valuestring); print(LOG_DEBUG "net: using gateway url %s", gateway_url); @@ -60,7 +65,8 @@ void net_get_gateway_url() assume: print(LOG_DEBUG "net: assuming gateway url wss://gateway.discord.gg"); - gateway_url = calloc(strlen("wss://gateway.discord.gg") + 1, sizeof(char)); + gateway_url = calloc(strlen("wss://gateway.discord.gg") + 1, + sizeof(char)); strcpy(gateway_url, "wss://gateway.discord.gg"); return; } |