feat&fix: fix build and add initial authnetication

This commit is contained in:
2026-05-29 13:39:57 +02:00
parent 89787b36cc
commit c29b4bb008
12 changed files with 190 additions and 11 deletions
+16 -1
View File
@@ -1,9 +1,24 @@
#ifndef DISCORD_DISCORD_H
#define DISCORD_DISCORD_H
#include "error.h"
// @TODO: use opaque pointer
#include <curl/curl.h>
#define DISCORD_BASE_URL "https://discord.com/api"
#define DISCORD_API_VERSION "10"
#define DISCORD_MAX_API_URL 256
#define DISCORD_MAX_TOKEN_VALUE 128
typedef struct discord_client discord_client;
typedef struct discord_client {
// char *token_type; // Bot or Bearer
char token_value[DISCORD_MAX_TOKEN_VALUE];
char api_url[DISCORD_MAX_API_URL];
CURL *curl;
} discord_client;
// remember to call curl_global_cleanup()
discord_error discord_init(discord_client *client, const char *token);
#endif
+2
View File
@@ -5,6 +5,8 @@ typedef enum discord_error {
DISCORD_OK,
DISCORD_ERR,
DISCORD_AUTH_ERR,
DISCORD_NULL_VALUE,
DISCORD_AUTH_FAILED,
} discord_error;
/**
+5
View File
@@ -0,0 +1,5 @@
headers += files(
'discord.h',
'error.h',
'request.h',
)
+8
View File
@@ -0,0 +1,8 @@
#ifndef DISCORD_REQUEST_H
#define DISCORD_REQUEST_H
#include <curl/curl.h>
int request_auth(CURL *curl, const char *token, const char *api_url);
#endif