aboutsummaryrefslogtreecommitdiff
path: root/src/common.h
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2021-05-27 23:37:23 +0200
committerJan200101 <sentrycraft123@gmail.com>2021-05-27 23:37:23 +0200
commitdf1df2929646abd77955b80e3ded3574ac005179 (patch)
tree9704901455843d41180a9402ed4c0012a1d67f04 /src/common.h
parent68c20667ca775a4d4a7d1cfc3c9ec5c30f275084 (diff)
downloadpolecat-df1df2929646abd77955b80e3ded3574ac005179.tar.gz
polecat-df1df2929646abd77955b80e3ded3574ac005179.zip
allow flags to exit prematurely, move defines, add no networking flag
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h53
1 files changed, 5 insertions, 48 deletions
diff --git a/src/common.h b/src/common.h
index 17b372c..21bd727 100644
--- a/src/common.h
+++ b/src/common.h
@@ -6,57 +6,11 @@
#include <stdint.h>
#include <sys/stat.h>
-#define ARRAY_LEN(arr) sizeof(arr) / sizeof(arr[0])
-
-#define GITHUB_API "https://api.github.com"
-#define LUTRIS_API "https://lutris.net/api"
-#define WINE_API LUTRIS_API "/runners/wine"
-#define DXVK_API GITHUB_API"/repos/lutris/dxvk/releases"
-#define INSTALLER_API LUTRIS_API "/installers/"
-#define GAME_API LUTRIS_API "/games"
-#define GAME_SEARCH_API GAME_API "?search=%s"
-#define GAME_INSTALLER_API GAME_API "/%s/installers"
-
-
-#ifndef NAME
-#warning "no name specified, setting it to \"polecat\""
-#define NAME "polecat"
-#endif
-
-#ifndef VERSION
-#warning "no version specified, setting it to \"0.0.0\""
-#define VERSION "0.0.0"
-#endif
-
-#define USER_AGENT NAME "/" VERSION
-
-#define USAGE_STR "Usage: " NAME
-
-#ifdef DEBUG
-#define UNREACHABLE printf("unreachable code reached\n" __FILE__ ":L%i\n", __LINE__); exit(0);
-#else
-#define UNREACHABLE
-#endif
-
-#ifdef __GNUC__
-#define UNUSED __attribute__((__unused__))
-#else
-#define UNUSED
-#endif
+#include "defines.h"
#include <json.h>
-// since json-c 0.13 json_object_array_length returns a size_t
-#if defined(JSON_C_MINOR_VERSION) && JSON_C_MINOR_VERSION >= 13
-#define JSON_LENGTH_TYPE size_t
-#else
-#define JSON_LENGTH_TYPE int
-#endif
-
-#ifdef _WIN32
-#define mkdir(path, perm) mkdir(path)
-#endif
-
+extern uint8_t no_net;
struct MemoryStruct {
uint8_t* memory;
@@ -78,10 +32,13 @@ enum flag_variants {
struct Flag {
char* name;
enum flag_variants variant;
+ uint8_t returns;
int (*func)(int, char**);
char* description;
};
+int set_no_net(UNUSED int argc, UNUSED char** argv);
+
void print_help(const struct Command*, size_t, const struct Flag*, size_t);
struct stat getStat(const char* path);