feat&fix: fix build and add initial authnetication
This commit is contained in:
+16
-1
@@ -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
|
||||
|
||||
@@ -5,6 +5,8 @@ typedef enum discord_error {
|
||||
DISCORD_OK,
|
||||
DISCORD_ERR,
|
||||
DISCORD_AUTH_ERR,
|
||||
DISCORD_NULL_VALUE,
|
||||
DISCORD_AUTH_FAILED,
|
||||
} discord_error;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
headers += files(
|
||||
'discord.h',
|
||||
'error.h',
|
||||
'request.h',
|
||||
)
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user