refactor: move common to internal and update public api

This commit is contained in:
2026-03-17 00:30:38 +01:00
parent 6ca04a9392
commit bb31304614
17 changed files with 284 additions and 272 deletions
+45
View File
@@ -0,0 +1,45 @@
#ifndef TGBOT_INTERNAL_COMMON_H
#define TGBOT_INTERNAL_COMMON_H
#include "types.h"
#include <curl/curl.h>
#include <stdint.h>
#define TOKEN_SIZE 128
#define API_SIZE 512
#define URL_LEN 1024
/**
* @brief A structure used to get curl response.
*/
struct memory_buffer {
char *data;
size_t size;
};
/**
* @brief A structure to represent bot object.
*/
typedef struct tgbot {
char token[TOKEN_SIZE]; /**< Bot token. */
char api[API_SIZE]; /**< Bot API url. */
int32_t offset; /**< Bot offset. */
} tgbot_s;
enum tgbot_opt_type {
tgbot_opt_int,
tgbot_opt_int64,
tgbot_opt_string,
tgbot_opt_inlinekeyboard,
tgbot_opt_null,
};
typedef enum tgbot_opt_type tgbot_opt_type_e;
struct tgbot_option {
char key[32];
void *value;
tgbot_opt_type_e type;
};
typedef struct tgbot_option tgbot_option_s;
#endif
+13
View File
@@ -0,0 +1,13 @@
#ifndef TGBOT_INTERNAL_JSON_H
#define TGBOT_INTERNAL_JSON_H
#include "types.h"
#include <json-c/json.h>
typedef struct tgbot_option tgbot_option_s;
json_object *json_builder(tgbot_option_s *options, size_t optionslen);
json_object *json_ikb_new(tgbot_inlinekeyboard_s *keyboard);
#endif
+11
View File
@@ -0,0 +1,11 @@
#ifndef TGBOT_INTERNAL_PARSE_H
#define TGBOT_INTERNAL_PARSE_H
#include "types.h"
#include <json-c/json.h>
int tgbot_parse_message(tgbot_s *bot, tgbot_update_s *update, json_object *result);
int tgbot_parse_cbquery(tgbot_s *bot, tgbot_cbquery_s *query, json_object *result, Callback cbq_handler);
#endif