Author | Jamozed <[email protected]> |
Date | 2022-02-09 07:04:50 |
Commit | 8a5f06f43d142e99ca2278361a9de4366ada1844 |
Parent | 8914f44396f472c7b971c5cadac552fc1748acc7 |
meta: Add __cplusplus guards
Diffstat
M | README.md | | | 12 | ++++++++---- |
M | src/alloc.c | | | 2 | +- |
M | src/alloc.h | | | 10 | +++++++++- |
M | src/base32.c | | | 2 | +- |
M | src/base32.h | | | 10 | +++++++++- |
M | src/base64.c | | | 2 | +- |
M | src/base64.h | | | 10 | +++++++++- |
M | src/crypt.h | | | 10 | +++++++++- |
M | src/endian.h | | | 10 | +++++++++- |
M | src/error.c | | | 2 | +- |
M | src/error.h | | | 10 | +++++++++- |
M | src/fnv.c | | | 2 | +- |
M | src/fnv.h | | | 10 | +++++++++- |
M | src/map.c | | | 2 | +- |
M | src/map.h | | | 10 | +++++++++- |
M | src/mode.c | | | 2 | +- |
M | src/mode.h | | | 10 | +++++++++- |
M | src/optget.c | | | 2 | +- |
M | src/optget.h | | | 10 | +++++++++- |
M | src/rc2.c | | | 2 | +- |
M | src/rc2.h | | | 10 | +++++++++- |
M | src/strconv.h | | | 10 | +++++++++- |
M | src/strtos.c | | | 2 | +- |
M | src/strtou.c | | | 2 | +- |
M | src/util.h | | | 10 | +++++++++- |
25 files changed, 136 insertions, 28 deletions
diff --git a/README.md b/README.md index 5523322..9535567 100644 --- a/README.md +++ b/README.md @@ -7,22 +7,26 @@ intended to provide common portable extensions to the C standard library. | Component | Description | Standard | | ---------------- | ---------------------------------------- | -------- | +| alloc | Memory allocation wrapper functions | | | base32 | Encode or decode Base32 | | | base64 | Encode or decode Base64 | | -| crypt | Cryptography functions | | +| crypt | General cryptography functions | | | endian | Endianness related functions | | | error | Error reporting functions | | | fnv | FNV hashing algorithms | | -| map | Hashmap data structure | | +| map | Generic hashmap data structure | | | mode | Parse numeric or symbolic POSIX modes | | | optget | Parse command line options | | | rc2 | RC2 encryption algorithm | RFC 2268 | | strconv | String conversion functions | | +| util | Base typedefs and macros | | + +*Note that `util.h` is required by many other **libutil** components.* ## Usage -**libutil** is being developed on x86-64 Linux, and some components may depend -on POSIX provided functionality. +**libutil** is being developed on x86-64 Linux, is untested elsewhere, and some +components may depend on POSIX provided functionality. **libutil** source files are intended to be built directly into projects, rather than being compiled seperately and linked. diff --git a/src/alloc.c b/src/alloc.c index be1ec97..10067ae 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1,4 +1,4 @@ -// util/alloc.h, version 1.0.0 +// util/alloc.h, version 1.0.1 // Memory allocation source file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. diff --git a/src/alloc.h b/src/alloc.h index f58e3ab..7f07d0a 100644 --- a/src/alloc.h +++ b/src/alloc.h @@ -1,4 +1,4 @@ -// util/alloc.h, version 1.0.0 +// util/alloc.h, version 1.0.1 // Memory allocation header file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. @@ -33,10 +33,18 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_ALLOC_H_M0UWQ8LT #define UTIL_ALLOC_H_M0UWQ8LT +#ifdef __cplusplus +extern "C" { +#endif + #include "util.h" extern void *xmalloc(UINT l); extern void *xcalloc(UINT n, UINT l); extern void *xrealloc(void *p, UINT l); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_ALLOC_H_M0UWQ8LT diff --git a/src/base32.c b/src/base32.c index 09af30c..bbf9f9c 100644 --- a/src/base32.c +++ b/src/base32.c @@ -1,4 +1,4 @@ -// util/base32.c, version 1.0.3 +// util/base32.c, version 1.0.4 // Base32 source file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. diff --git a/src/base32.h b/src/base32.h index 98fc671..30ed6b3 100644 --- a/src/base32.h +++ b/src/base32.h @@ -1,4 +1,4 @@ -// util/base32.h, version 1.0.3 +// util/base32.h, version 1.0.4 // Base32 header file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_BASE32_H_2PSMZTB0 #define UTIL_BASE32_H_2PSMZTB0 +#ifdef __cplusplus +extern "C" { +#endif + #include <stdint.h> #include <stdlib.h> @@ -42,4 +46,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. extern size_t b32encode(uint8_t *dst, uint8_t *src, size_t len); extern size_t b32decode(uint8_t *dst, uint8_t *src, size_t len); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_BASE32_H_2PSMZTB0 diff --git a/src/base64.c b/src/base64.c index 91c774e..69cee8f 100644 --- a/src/base64.c +++ b/src/base64.c @@ -1,4 +1,4 @@ -// util/base64.c, version 1.1.4 +// util/base64.c, version 1.1.5 // Base64 source file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. diff --git a/src/base64.h b/src/base64.h index f606ffe..df04fb1 100644 --- a/src/base64.h +++ b/src/base64.h @@ -1,4 +1,4 @@ -// util/base64.h, version 1.1.4 +// util/base64.h, version 1.1.5 // Base64 header file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_BASE64_H_5YQ80JRV #define UTIL_BASE64_H_5YQ80JRV +#ifdef __cplusplus +extern "C" { +#endif + #include <stdint.h> #include <stdlib.h> @@ -42,4 +46,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. extern size_t b64encode(uint8_t *dst, uint8_t *src, size_t len); extern size_t b64decode(uint8_t *dst, uint8_t *src, size_t len); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_BASE64_H_5YQ80JRV diff --git a/src/crypt.h b/src/crypt.h index 29a2cff..c6f3470 100644 --- a/src/crypt.h +++ b/src/crypt.h @@ -1,4 +1,4 @@ -// util/crypt.h, version 0.1.1 +// util/crypt.h, version 0.1.2 // Crypt header file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_CRYPT_H_RDY6J5JV #define UTIL_CRYPT_H_RDY6J5JV +#ifdef __cplusplus +extern "C" { +#endif + #include <stdint.h> /* Circular shift left */ @@ -47,4 +51,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #define ROR32(x, n) (uint32_t)(((x) >> (n)) | ((x) << (32 - (n)))) #define ROR64(x, n) (uint64_t)(((x) >> (n)) | ((x) << (64 - (n)))) +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_CRYPT_H_RDY6J5JV diff --git a/src/endian.h b/src/endian.h index 96b90b3..f715377 100644 --- a/src/endian.h +++ b/src/endian.h @@ -1,4 +1,4 @@ -// util/endian.h, version 1.0.1 +// util/endian.h, version 1.0.2 // Endian header file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_ENDIAN_H_G7AID2RQ #define UTIL_ENDIAN_H_G7AID2RQ +#ifdef __cplusplus +extern "C" { +#endif + #include <stdint.h> /* Byte swap a 16-bit integer */ @@ -150,4 +154,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. ((uint8_t *)(p))[6] = ((uint64_t)(x) >> 8) & 0xFFu; \ ((uint8_t *)(p))[7] = ((uint64_t)(x) >> 0) & 0xFFu +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_ENDIAN_H_G7AID2RQ diff --git a/src/error.c b/src/error.c index 0e306e9..f096704 100644 --- a/src/error.c +++ b/src/error.c @@ -1,4 +1,4 @@ -// util/error.h, version 1.1.1 +// util/error.h, version 1.1.2 // Error source file from libutil // Copyright (C) 2020, Jakob Wakeling // All rights reserved. diff --git a/src/error.h b/src/error.h index 794e5c3..e13c32b 100644 --- a/src/error.h +++ b/src/error.h @@ -1,4 +1,4 @@ -// util/error.h, version 1.1.1 +// util/error.h, version 1.1.2 // Error header file from libutil // Copyright (C) 2020, Jakob Wakeling // All rights reserved. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_ERROR_H_38W06M3W #define UTIL_ERROR_H_38W06M3W +#ifdef __cplusplus +extern "C" { +#endif + #include <errno.h> #include <stdbool.h> #include <stdnoreturn.h> @@ -84,4 +88,8 @@ extern void alert(const char *format, ...); /* Shorthand for strerror(errno). DEPRECIATED, use the SERR macro. */ extern char *serr(void); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_ERROR_H_38W06M3W diff --git a/src/fnv.c b/src/fnv.c index c393e67..0454249 100644 --- a/src/fnv.c +++ b/src/fnv.c @@ -1,4 +1,4 @@ -// util/fnv.c, version 1.0.1 +// util/fnv.c, version 1.0.2 // FNV hash source file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. diff --git a/src/fnv.h b/src/fnv.h index e79e964..0123a2e 100644 --- a/src/fnv.h +++ b/src/fnv.h @@ -1,4 +1,4 @@ -// util/fnv.h, version 1.0.1 +// util/fnv.h, version 1.0.2 // FNV hash header file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_FNV_H_O4TYU6Q1 #define UTIL_FNV_H_O4TYU6Q1 +#ifdef __cplusplus +extern "C" { +#endif + #include "util.h" extern u32 fnv1a32(const char *dat, UINT len); @@ -44,4 +48,8 @@ extern void fnv1a32_hash(u32 *ctx, char *dat, UINT len); extern void fnv1a64_init(u64 *ctx); extern void fnv1a64_hash(u64 *ctx, char *dat, UINT len); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_FNV_H_O4TYU6Q1 diff --git a/src/map.c b/src/map.c index 64b315a..0241488 100644 --- a/src/map.c +++ b/src/map.c @@ -1,4 +1,4 @@ -// util/map.c, version 0.1.1 +// util/map.c, version 0.1.2 // Map utility source file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. diff --git a/src/map.h b/src/map.h index 553cccf..ac42bd9 100644 --- a/src/map.h +++ b/src/map.h @@ -1,4 +1,4 @@ -// util/map.h, version 0.1.1 +// util/map.h, version 0.1.2 // Map utility header file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_MAP_H_NB53CJJ8 #define UTIL_MAP_H_NB53CJJ8 +#ifdef __cplusplus +extern "C" { +#endif + #include "util.h" typedef struct { @@ -56,4 +60,8 @@ extern void *map_remove(map *m, char *k); extern void map_print(map *m); extern void map_debug(map *m); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_MAP_H_NB53CJJ8 diff --git a/src/mode.c b/src/mode.c index 3d235ba..02634c7 100644 --- a/src/mode.c +++ b/src/mode.c @@ -1,4 +1,4 @@ -// util/mode.c, version 1.0.2 +// util/mode.c, version 1.0.3 // Mode source file from libutil // Copyright (C) 2020, Jakob Wakeling // All rights reserved. diff --git a/src/mode.h b/src/mode.h index 09c7dc0..99f4ecb 100644 --- a/src/mode.h +++ b/src/mode.h @@ -1,4 +1,4 @@ -// util/mode.h, version 1.0.2 +// util/mode.h, version 1.0.3 // Mode header file from libutil // Copyright (C) 2020, Jakob Wakeling // All rights reserved. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_MODE_H_0C99POMA #define UTIL_MODE_H_0C99POMA +#ifdef __cplusplus +extern "C" { +#endif + #include <sys/types.h> #define M_USR 05700 @@ -51,4 +55,8 @@ enum { MF_NULL, MF_NORM, MF_XIFX, MF_COPY }; extern chmod_t *strmode(char *str); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_MODE_H_0C99POMA diff --git a/src/optget.c b/src/optget.c index 24d334d..4b46a47 100644 --- a/src/optget.c +++ b/src/optget.c @@ -1,4 +1,4 @@ -// util/optget.h, version 1.6.1 +// util/optget.h, version 1.6.2 // optget source file from libutil // Copyright (C) 2020, Jakob Wakeling // All rights reserved. diff --git a/src/optget.h b/src/optget.h index e3065fb..fffd345 100644 --- a/src/optget.h +++ b/src/optget.h @@ -1,4 +1,4 @@ -// util/optget.h, version 1.6.1 +// util/optget.h, version 1.6.2 // optget header file from libutil // Copyright (C) 2020, Jakob Wakeling // All rights reserved. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_OPTGET_H_W3LIZK1S #define UTIL_OPTGET_H_W3LIZK1S +#ifdef __cplusplus +extern "C" { +#endif + #define ARG_NUL 0 #define ARG_REQ 1 #define ARG_OPT 2 @@ -52,4 +56,8 @@ extern const struct opt OPTGET_INIT; extern int optget(struct opt *opt, char *av[], int flags); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_OPTGET_H_W3LIZK1S diff --git a/src/rc2.c b/src/rc2.c index 104b8c9..469be05 100644 --- a/src/rc2.c +++ b/src/rc2.c @@ -1,4 +1,4 @@ -// util/rc2.c, version 1.0.0 +// util/rc2.c, version 1.0.1 // RC2 source file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. diff --git a/src/rc2.h b/src/rc2.h index ee6ef1e..50473e8 100644 --- a/src/rc2.h +++ b/src/rc2.h @@ -1,4 +1,4 @@ -// util/rc2.h, version 1.0.0 +// util/rc2.h, version 1.0.1 // RC2 header file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_RC2_H_PMXL29JH #define UTIL_RC2_H_PMXL29JH +#ifdef __cplusplus +extern "C" { +#endif + #include <stdint.h> #include <stdlib.h> @@ -42,4 +46,8 @@ extern void rc2expand(struct rc2 *ctx, const uint8_t *key, int len, int ekl); extern void rc2encrypt(struct rc2 *ctx, uint8_t *in, uint8_t *out); extern void rc2decrypt(struct rc2 *ctx, uint8_t *in, uint8_t *out); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_RC2_H_PMXL29JH diff --git a/src/strconv.h b/src/strconv.h index 5901fcb..5d5b102 100644 --- a/src/strconv.h +++ b/src/strconv.h @@ -1,4 +1,4 @@ -// util/strconv.h, version 1.1.2 +// util/strconv.h, version 1.1.3 // String conversion header file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_STRCONV_H_3EQMSZZK #define UTIL_STRCONV_H_3EQMSZZK +#ifdef __cplusplus +extern "C" { +#endif + #include "util.h" s8 strtos8(const char *nptr, char **endptr, register int base); @@ -45,4 +49,8 @@ u16 strtou16(const char *nptr, char **endptr, register int base); u32 strtou32(const char *nptr, char **endptr, register int base); u64 strtou64(const char *nptr, char **endptr, register int base); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_STRCONV_H_3EQMSZZK diff --git a/src/strtos.c b/src/strtos.c index c09c2e3..7c5b1cf 100644 --- a/src/strtos.c +++ b/src/strtos.c @@ -1,4 +1,4 @@ -// util/strtos.c, version 1.1.2 +// util/strtos.c, version 1.1.3 // String conversion source file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. diff --git a/src/strtou.c b/src/strtou.c index e865866..ffccbe7 100644 --- a/src/strtou.c +++ b/src/strtou.c @@ -1,4 +1,4 @@ -// util/strtou.c, version 1.1.2 +// util/strtou.c, version 1.1.3 // String conversion source file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. diff --git a/src/util.h b/src/util.h index 3b3d167..f1ee66a 100644 --- a/src/util.h +++ b/src/util.h @@ -1,4 +1,4 @@ -// util/util.h, version 1.0.0 +// util/util.h, version 1.0.1 // Utility header file from libutil // Copyright (C) 2021, Jakob Wakeling // All rights reserved. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #ifndef UTIL_UTIL_H_KP8NS9DC #define UTIL_UTIL_H_KP8NS9DC +#ifdef __cplusplus +extern "C" { +#endif + #include <assert.h> #include <float.h> #include <stdbool.h> @@ -89,4 +93,8 @@ typedef long double f128; /* Miscellaneous */ #define BIT(x) (1 << (x)) +#ifdef __cplusplus +} // extern "C" +#endif + #endif // UTIL_UTIL_H_KP8NS9DC