chore: add meson build and initial stuff
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
BasedOnStyle: LLVM
|
||||
UseTab: Always
|
||||
TabWidth: 4
|
||||
IndentWidth: 4
|
||||
IndentCaseLabels: true
|
||||
ColumnLimit: 120
|
||||
PointerAlignment: Right
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
InsertBraces: true
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef DISCORD_DISCORD_H
|
||||
#define DISCORD_DISCORD_H
|
||||
|
||||
#define DISCORD_BASE_URL "https://discord.com/api"
|
||||
#define DISCORD_API_VERSION "10"
|
||||
|
||||
typedef struct discord_client discord_client;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef DISCORD_ERROR_H
|
||||
#define DISCORD_ERROR_H
|
||||
|
||||
typedef enum discord_error {
|
||||
DISCORD_OK,
|
||||
DISCORD_ERR,
|
||||
DISCORD_AUTH_ERR,
|
||||
} discord_error;
|
||||
|
||||
/**
|
||||
* @brief Retrieves error string.
|
||||
*
|
||||
* @param err Discord error.
|
||||
* @return String of the error.
|
||||
*/
|
||||
const char *discord_err_str(discord_error err);
|
||||
|
||||
#endif
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
project(
|
||||
'discord-c',
|
||||
'c',
|
||||
version: '0.1',
|
||||
default_options: ['warning_level=3', 'c_std=c17'],
|
||||
)
|
||||
|
||||
sources = []
|
||||
headers = []
|
||||
include_directories('src')
|
||||
include_directories('include')
|
||||
incdir = include_directories('include')
|
||||
|
||||
libcurl = dependency('libcurl', required: true)
|
||||
libyyjson = dependency('yyjson', required: true)
|
||||
|
||||
deps = [libcurl, libyyjson]
|
||||
|
||||
libdiscord = static_library(
|
||||
'discord',
|
||||
sources,
|
||||
dependencies: deps,
|
||||
install: true,
|
||||
include_directories: incdir,
|
||||
)
|
||||
install_headers(headers, install_dir: 'discord-c')
|
||||
|
||||
# Test executable
|
||||
exesrc = files('test/test1.c')
|
||||
executable(
|
||||
'dstest',
|
||||
exesrc,
|
||||
build_by_default: false,
|
||||
link_with: libdiscord,
|
||||
include_directories: incdir,
|
||||
)
|
||||
|
||||
# Commands
|
||||
clangformat = find_program('clang-format', required: false)
|
||||
if clangformat.found()
|
||||
all_files = sources + headers + exesrc
|
||||
run_target('format', command: [clangformat, '-i'] + all_files)
|
||||
endif
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "discord.h"
|
||||
|
||||
typedef struct discord_client {
|
||||
char *token_type;
|
||||
char *token_value;
|
||||
} discord_client;
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#include "error.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define ARR_SIZE(X) (sizeof(X) / sizeof(*X))
|
||||
|
||||
typedef struct discord_err {
|
||||
discord_error error;
|
||||
const char *text;
|
||||
} discord_err;
|
||||
|
||||
static discord_err errors[] = {
|
||||
{DISCORD_OK, "OK"},
|
||||
{DISCORD_ERR, "ERR"},
|
||||
{DISCORD_AUTH_ERR, "Authentication error, maybe wrong token"},
|
||||
};
|
||||
|
||||
const char *discord_err_str(discord_error err) {
|
||||
for (size_t i = 0; i < ARR_SIZE(errors); ++i) {
|
||||
if (errors[i].error == err) {
|
||||
return errors[i].text;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
sources += files('main.c')
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
puts("discord.c");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user