refactor(methods): change funcs to static
This commit is contained in:
@@ -9,7 +9,6 @@ tgbot_rc tgbot_parse_message(tgbot_s *bot, tgbot_update_s *update, json_object *
|
|||||||
tgbot_rc tgbot_parse_cbquery(tgbot_s *bot, tgbot_cbquery_s *query, json_object *result, Callback query_handler);
|
tgbot_rc tgbot_parse_cbquery(tgbot_s *bot, tgbot_cbquery_s *query, json_object *result, Callback query_handler);
|
||||||
|
|
||||||
/* Request */
|
/* Request */
|
||||||
size_t write_callback(void *ptr, size_t size, size_t nmemb, char **userdata);
|
|
||||||
tgbot_rc tgbot_request(const char *url, struct memory_buffer **mb, json_object *json);
|
tgbot_rc tgbot_request(const char *url, struct memory_buffer **mb, json_object *json);
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|||||||
@@ -4,6 +4,22 @@
|
|||||||
#include "json.h"
|
#include "json.h"
|
||||||
#include "methods.h"
|
#include "methods.h"
|
||||||
|
|
||||||
|
static size_t write_callback(void *ptr, size_t size, size_t nmemb, char **userdata) {
|
||||||
|
size_t real_size = size * nmemb;
|
||||||
|
struct memory_buffer *mem = (struct memory_buffer *)userdata;
|
||||||
|
|
||||||
|
mem->data = realloc(mem->data, mem->size + real_size + 1);
|
||||||
|
memcpy(&(mem->data[mem->size]), ptr, real_size);
|
||||||
|
mem->size += real_size;
|
||||||
|
mem->data[mem->size] = '\0';
|
||||||
|
|
||||||
|
return real_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t discard_callback(char *ptr, size_t size, size_t nmemb, void *userdata) {
|
||||||
|
return size * nmemb;
|
||||||
|
}
|
||||||
|
|
||||||
tgbot_rc tgbot_get_update(tgbot_s *bot, tgbot_update_s *update, Callback cbq_handler) {
|
tgbot_rc tgbot_get_update(tgbot_s *bot, tgbot_update_s *update, Callback cbq_handler) {
|
||||||
char url[1024];
|
char url[1024];
|
||||||
|
|
||||||
@@ -163,22 +179,6 @@ tgbot_rc tgbot_parse_cbquery(tgbot_s *bot, tgbot_cbquery_s *query, json_object *
|
|||||||
return TGBOT_OK;
|
return TGBOT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t write_callback(void *ptr, size_t size, size_t nmemb, char **userdata) {
|
|
||||||
size_t real_size = size * nmemb;
|
|
||||||
struct memory_buffer *mem = (struct memory_buffer *)userdata;
|
|
||||||
|
|
||||||
mem->data = realloc(mem->data, mem->size + real_size + 1);
|
|
||||||
memcpy(&(mem->data[mem->size]), ptr, real_size);
|
|
||||||
mem->size += real_size;
|
|
||||||
mem->data[mem->size] = '\0';
|
|
||||||
|
|
||||||
return real_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t discard_callback(char *ptr, size_t size, size_t nmemb, void *userdata) {
|
|
||||||
return size * nmemb;
|
|
||||||
}
|
|
||||||
|
|
||||||
tgbot_rc tgbot_request(const char *url, struct memory_buffer **mb, json_object *json) {
|
tgbot_rc tgbot_request(const char *url, struct memory_buffer **mb, json_object *json) {
|
||||||
CURL *curl = curl_easy_init();
|
CURL *curl = curl_easy_init();
|
||||||
if (!curl) {
|
if (!curl) {
|
||||||
|
|||||||
@@ -5,8 +5,10 @@
|
|||||||
|
|
||||||
tgbot_inlinekeyboard_s *tgbot_inlinekb_new(size_t rows, size_t columns) {
|
tgbot_inlinekeyboard_s *tgbot_inlinekb_new(size_t rows, size_t columns) {
|
||||||
tgbot_inlinekeyboard_s *keyboard = (tgbot_inlinekeyboard_s *)malloc(sizeof(tgbot_inlinekeyboard_s));
|
tgbot_inlinekeyboard_s *keyboard = (tgbot_inlinekeyboard_s *)malloc(sizeof(tgbot_inlinekeyboard_s));
|
||||||
if (!keyboard)
|
if (!keyboard) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
keyboard->rows = rows;
|
keyboard->rows = rows;
|
||||||
keyboard->columns = columns;
|
keyboard->columns = columns;
|
||||||
keyboard->buttons = (tgbot_inlinekeyboardbutton_s *)malloc(rows * columns * sizeof(tgbot_inlinekeyboardbutton_s));
|
keyboard->buttons = (tgbot_inlinekeyboardbutton_s *)malloc(rows * columns * sizeof(tgbot_inlinekeyboardbutton_s));
|
||||||
|
|||||||
Reference in New Issue
Block a user