💾 Archived View for gemini.rmf-dev.com › repo › Vaati › mz › files › 992edf38395ace5f05c9586f26ba69a… captured on 2023-09-08 at 16:44:34. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
0 /*
1 * Copyright (c) 2023 RMF <rawmonk@firemail.cc>
2 *
3 * Permission to use, copy, modify, and distribute this software for any
4 * purpose with or without fee is hereby granted, provided that the above
5 * copyright notice and this permission notice appear in all copies.
6 *
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 */
15 #define V(X) X, sizeof(X) /* the value and its size */
16 #define VP(X) X, sizeof(*X) /* the pointer and its value size */
17 #define SELECTED(X) X->entries[X->selected]
18 #define EMPTY(X) (X->selected >= X->length)
19
20 /* Assign the sum of X and Y to X if the sum is lesser than Z, else assign Z */
21 #define ADDMAX(X, Y, Z) X = ((X + Y) > Z ? Z : (X + Y))
22 /* Assign the subtraction of Y and X to X if the subtraction is lesser than Z,
23 * else assign Z */
24 #define SUBMIN(X, Y, Z) X = ((signed)(X - Y) < Z ? Z : (X - Y))
25 #define AZ(X) (X < 1 ? 1 : X) /* if X is above zero return X else return 1 */
26
27 #define RZERO(X) memset(&X, 0, sizeof(X)) /* Zero'd a reference */
28 #define PZERO(X) memset(X, 0, sizeof(*X)) /* Zero'd a pointer */
29 #define STRCMP(X, Y) strncmp(X, Y, sizeof(X))
30 #define STRCPY(X, Y) strlcpy(X, Y, sizeof(X))
31
32 #define TOGGLE(X) (X = !X)
33 #define MAX(X, Y) (X > Y ? Y : X) /* if X is greater than Y return Y */
34
35 #ifndef DT_REG
36 #define DT_REG 0
37 #endif
38
39 #ifndef DT_DIR
40 #define DT_DIR 1
41 #endif
42
43 #ifndef PATH_MAX
44 #define PATH_MAX 1024
45 #endif
46