💾 Archived View for gemini.rmf-dev.com › repo › Vaati › mz › files › 094d35f1abdef0a50b0e432c42ca5a7… captured on 2023-03-20 at 18:36:20. 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 /* Load an xpm image */
18 #define IMAGE(X, Y) backend_load_image(X##_xpm, X##_width, X##_height, \
19 X##_colors, X##_char, Y)
20 #define SELECTED(X) X->entries[X->selected]
21
22 /* Assign the sum of X and Y to X if the sum is lesser than Z, else assign Z */
23 #define ADDMAX(X, Y, Z) X = ((X + Y) > Z ? Z : (X + Y))
24 /* Assign the subtraction of Y and X to X if the subtraction is lesser than Z,
25 * else assign Z */
26 #define SUBMIN(X, Y, Z) X = ((signed)(X - Y) < Z ? Z : (X - Y))
27 #define AZ(X) (X < 1 ? 1 : X) /* if X is above zero return X else return 1 */
28
29 #define RZERO(X) memset(&X, 0, sizeof(X)) /* Zero'd a reference */
30 #define PZERO(X) memset(X, 0, sizeof(*X)) /* Zero'd a pointer */
31
32 #define rev32(num) ( ((num & 0xFF000000) >> 24) | ((num & 0x00FF0000) >> 8) | \
33 ((num & 0x0000FF00) << 8) | ((num & 0x000000FF) << 24) )
34 #define rev24(num) ( (num & 0xFF000000) | ((num & 0x00FF0000) >> 16) | \
35 (num & 0x0000FF00) | ((num & 0x000000FF) << 16) )
36
37 #define INN(X, Y) X ? X : Y /* If not null return X else return Y */
38 #define TOGGLE(X) X = !X
39 #define MAX(X, Y) X > Y ? Y : X /* if X is greater than Y return Y */
40
41 #ifndef DT_REG
42 #define DT_REG 0
43 #endif
44
45 #ifndef DT_DIR
46 #define DT_DIR 1
47 #endif
48
49 #ifndef PATH_MAX
50 #define PATH_MAX 1024
51 #endif
52