mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 11:25:45 +01:00
Compare commits
3 Commits
7df20e9aa1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e8f5958c7 | |||
| bc0743a72b | |||
| 81b21ff7ce |
35
src/io/conf.c
Normal file
35
src/io/conf.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include "conf.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../types.h"
|
||||||
|
#include "../util/atrb.h"
|
||||||
|
|
||||||
|
/* Matches s1 with s2, returns a pointer to s1 where the match stopped. */
|
||||||
|
static const char *strmat(const char *s1, const char *s2) PURE NONNULL((1, 2));
|
||||||
|
static const char *strmat(const char *s1, const char *s2)
|
||||||
|
{
|
||||||
|
while ((*s1 == *s2) & !!*s1)
|
||||||
|
s1++, s2++;
|
||||||
|
return s1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int conf_getkeyval(const char *restrict buf, const char *const restrict *restrict keys, int klen, const char *restrict *restrict out)
|
||||||
|
{
|
||||||
|
const char *tmp = NULL;
|
||||||
|
|
||||||
|
ASSUME((klen > 0));
|
||||||
|
int i = 0;
|
||||||
|
for (; i < klen && !tmp; i++) {
|
||||||
|
tmp = strmat(buf, keys[i]);
|
||||||
|
tmp = keys[i][buf - tmp] ? tmp : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tmp || *tmp != '=')
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
*out = tmp + 1;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int conf_val(int);
|
||||||
12
src/io/conf.h
Normal file
12
src/io/conf.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../types.h"
|
||||||
|
#include "../util/atrb.h"
|
||||||
|
|
||||||
|
/* Gets the key and value, if present. Writes the pointer for the value to `out`.
|
||||||
|
* Returns the key index, or <0 upon failure. */
|
||||||
|
int conf_getkeyval(const char *restrict buf, const char *const restrict *restrict keys, int klen,
|
||||||
|
const char *restrict *restrict out) NONNULL((1, 2, 4));
|
||||||
|
|
||||||
|
/* Processes the value of `type` in `val`. Outputs to `out`.
|
||||||
|
* Returns non-zero on failure. */
|
||||||
|
int conf_procval(u8 type, const char *restrict val, void *restrict out) NONNULL((2, 3));
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "../types.h"
|
#include "../../types.h"
|
||||||
#include "../util/error.h"
|
#include "../../util/error.h"
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
|
|
||||||
#define VERTC 3
|
#define VERTC 3
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "../util/error.h"
|
#include "../../util/error.h"
|
||||||
|
|
||||||
|
|
||||||
// NOTE: we are currently just sucking up the memory costs for ease. We can either include the source files themselves. Or use compression, where I'd prefer the latter for ease of installation.
|
// NOTE: we are currently just sucking up the memory costs for ease. We can either include the source files themselves. Or use compression, where I'd prefer the latter for ease of installation.
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
|
||||||
#include "../types.h"
|
#include "../../types.h"
|
||||||
#include "../util/error.h"
|
#include "../../util/error.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "io/window.h"
|
#include "io/win/window.h"
|
||||||
#include "util/error.h"
|
#include "util/error.h"
|
||||||
|
|
||||||
/* reroutes GLFW errors to our logging system. */
|
/* reroutes GLFW errors to our logging system. */
|
||||||
|
|||||||
@@ -57,4 +57,8 @@
|
|||||||
#else
|
#else
|
||||||
#define NONNULL(args)
|
#define NONNULL(args)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if __has_attribute(__assume__)
|
||||||
|
#define ASSUME(args) __attribute__((__assume__ args))
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user