diff options
| author | @syxhe <https://t.me/syxhe> | 2025-03-30 23:13:35 -0500 |
|---|---|---|
| committer | @syxhe <https://t.me/syxhe> | 2025-03-30 23:13:35 -0500 |
| commit | 833cb417608eb138d3a9b99dc995c5c1aeffd1cd (patch) | |
| tree | 9698c034adb7e5124e91ac79b8eb4d68b047a0f9 /src/shared.h | |
| parent | 97713275dc87ea1d0afa4fd6bc49f695ad40efc0 (diff) | |
Create encryption functions that actually work
Diffstat (limited to 'src/shared.h')
| -rw-r--r-- | src/shared.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/shared.h b/src/shared.h index 718bbf2..7d2db27 100644 --- a/src/shared.h +++ b/src/shared.h | |||
| @@ -29,14 +29,16 @@ | |||
| 29 | exit(EXIT_FAILURE); /* Makes gcc happy */\ | 29 | exit(EXIT_FAILURE); /* Makes gcc happy */\ |
| 30 | } while (0) | 30 | } while (0) |
| 31 | 31 | ||
| 32 | #define ERROR(status, errnum, format, ...) do {error((status), (errnum), (format)__VA_ARGS__); exit((status));} while (0) | ||
| 33 | |||
| 32 | // `malloc()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` | 34 | // `malloc()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` |
| 33 | void * xmalloc(size_t size); | 35 | void * xmalloc(size_t size); |
| 34 | 36 | ||
| 35 | // `calloc()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` | 37 | // `calloc()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` |
| 36 | void* xcalloc(size_t nmemb, size_t size); | 38 | void * xcalloc(size_t nmemb, size_t size); |
| 37 | 39 | ||
| 38 | // `reallocarray()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` | 40 | // `reallocarray()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` |
| 39 | void* xreallocarray(void *ptr, size_t nmemb, size_t size); | 41 | void * xreallocarray(void *ptr, size_t nmemb, size_t size); |
| 40 | 42 | ||
| 41 | // Read the entire contents of a file descriptor into a malloc()'ed buffer | 43 | // Read the entire contents of a file descriptor into a malloc()'ed buffer |
| 42 | int rwbuf(char **str, unsigned long int initsize, int fd); | 44 | int rwbuf(char **str, unsigned long int initsize, int fd); |
| @@ -45,6 +47,6 @@ int rwbuf(char **str, unsigned long int initsize, int fd); | |||
| 45 | int wwbuf(int fd, const unsigned char *buf, int len); | 47 | int wwbuf(int fd, const unsigned char *buf, int len); |
| 46 | 48 | ||
| 47 | // `dirname()` reimplementation that returns a malloc()'ed string. According to the `x___` naming scheme, exits/aborts on alloc error. | 49 | // `dirname()` reimplementation that returns a malloc()'ed string. According to the `x___` naming scheme, exits/aborts on alloc error. |
| 48 | char *xdirname(const char * const path); | 50 | char * xdirname(const char * const path); |
| 49 | 51 | ||
| 50 | #endif \ No newline at end of file | 52 | #endif \ No newline at end of file |
