From a19df80a034831de7d4ecc2f6f588ee45474ade4 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Thu, 23 Jan 2020 16:03:40 -0500 Subject: [PATCH] Enable annotation of library imports. --- platform-independent/c/core/src/aes.c | 6 ++++-- platform-independent/c/core/src/aes.h | 4 ++++ platform-independent/c/core/src/base64.h | 4 ++++ platform-independent/c/core/src/mpw-algorithm.h | 5 ++--- platform-independent/c/core/src/mpw-algorithm_v0.c | 8 +++++--- platform-independent/c/core/src/mpw-algorithm_v1.c | 6 ++++-- platform-independent/c/core/src/mpw-algorithm_v2.c | 6 ++++-- platform-independent/c/core/src/mpw-algorithm_v3.c | 6 ++++-- platform-independent/c/core/src/mpw-marshal-util.c | 6 ++++-- platform-independent/c/core/src/mpw-marshal-util.h | 8 +++++--- platform-independent/c/core/src/mpw-marshal.c | 10 ++++++---- platform-independent/c/core/src/mpw-marshal.h | 6 ++++-- platform-independent/c/core/src/mpw-types.c | 8 +++++--- platform-independent/c/core/src/mpw-types.h | 7 +++++++ platform-independent/c/core/src/mpw-util.c | 6 ++++-- platform-independent/c/core/src/mpw-util.h | 6 ++++-- 16 files changed, 70 insertions(+), 32 deletions(-) diff --git a/platform-independent/c/core/src/aes.c b/platform-independent/c/core/src/aes.c index 7148ad5e..1df3eda0 100644 --- a/platform-independent/c/core/src/aes.c +++ b/platform-independent/c/core/src/aes.c @@ -37,9 +37,11 @@ NOTE: String length must be evenly divisible by 16byte (str_len % 16 == 0) /*****************************************************************************/ /* Includes: */ /*****************************************************************************/ -#include #include "aes.h" -#include "mpw-util.h" + +MP_LIBS_BEGIN +#include +MP_LIBS_END /*****************************************************************************/ /* Defines: */ diff --git a/platform-independent/c/core/src/aes.h b/platform-independent/c/core/src/aes.h index 462302b1..5b384deb 100644 --- a/platform-independent/c/core/src/aes.h +++ b/platform-independent/c/core/src/aes.h @@ -9,7 +9,11 @@ This is an implementation of the AES algorithm, specifically ECB and CBC mode. #ifndef _AES_H_ #define _AES_H_ +#include "mpw-util.h" + +MP_LIBS_BEGIN #include +MP_LIBS_END // #define the macros below to 1/0 to enable/disable the mode of operation. diff --git a/platform-independent/c/core/src/base64.h b/platform-independent/c/core/src/base64.h index fdbfc58a..1c5b38c4 100644 --- a/platform-independent/c/core/src/base64.h +++ b/platform-independent/c/core/src/base64.h @@ -54,8 +54,12 @@ * project, please see . */ +#include "mpw-util.h" + +MP_LIBS_BEGIN #include #include +MP_LIBS_END /** * @return The amount of bytes needed to decode the given b64Text. diff --git a/platform-independent/c/core/src/mpw-algorithm.h b/platform-independent/c/core/src/mpw-algorithm.h index e0bac8fe..0a82b2d0 100644 --- a/platform-independent/c/core/src/mpw-algorithm.h +++ b/platform-independent/c/core/src/mpw-algorithm.h @@ -16,12 +16,11 @@ // LICENSE file. Alternatively, see . //============================================================================== -// NOTE: mpw is currently NOT thread-safe. -#include "mpw-types.h" - #ifndef _MPW_ALGORITHM_H #define _MPW_ALGORITHM_H +#include "mpw-types.h" + typedef mpw_enum( unsigned int, MPAlgorithmVersion ) { /** V0 did math with chars whose signedness was platform-dependent. */ MPAlgorithmVersion0, diff --git a/platform-independent/c/core/src/mpw-algorithm_v0.c b/platform-independent/c/core/src/mpw-algorithm_v0.c index 4781b923..a994e056 100644 --- a/platform-independent/c/core/src/mpw-algorithm_v0.c +++ b/platform-independent/c/core/src/mpw-algorithm_v0.c @@ -16,12 +16,14 @@ // LICENSE file. Alternatively, see . //============================================================================== +#include "mpw-util.h" +#include "base64.h" + +MP_LIBS_BEGIN #include #include #include - -#include "mpw-util.h" -#include "base64.h" +MP_LIBS_END #define MP_N 32768LU #define MP_r 8U diff --git a/platform-independent/c/core/src/mpw-algorithm_v1.c b/platform-independent/c/core/src/mpw-algorithm_v1.c index 62553559..ccbd0ec3 100644 --- a/platform-independent/c/core/src/mpw-algorithm_v1.c +++ b/platform-independent/c/core/src/mpw-algorithm_v1.c @@ -16,10 +16,12 @@ // LICENSE file. Alternatively, see . //============================================================================== -#include - #include "mpw-util.h" +MP_LIBS_BEGIN +#include +MP_LIBS_END + #define MP_N 32768LU #define MP_r 8U #define MP_p 2U diff --git a/platform-independent/c/core/src/mpw-algorithm_v2.c b/platform-independent/c/core/src/mpw-algorithm_v2.c index 6cf519ea..4d9b6451 100644 --- a/platform-independent/c/core/src/mpw-algorithm_v2.c +++ b/platform-independent/c/core/src/mpw-algorithm_v2.c @@ -16,11 +16,13 @@ // LICENSE file. Alternatively, see . //============================================================================== +#include "mpw-util.h" + +MP_LIBS_BEGIN #include #include #include - -#include "mpw-util.h" +MP_LIBS_END #define MP_N 32768LU #define MP_r 8U diff --git a/platform-independent/c/core/src/mpw-algorithm_v3.c b/platform-independent/c/core/src/mpw-algorithm_v3.c index 1afea1d5..a4489247 100644 --- a/platform-independent/c/core/src/mpw-algorithm_v3.c +++ b/platform-independent/c/core/src/mpw-algorithm_v3.c @@ -16,10 +16,12 @@ // LICENSE file. Alternatively, see . //============================================================================== +#include "mpw-util.h" + +MP_LIBS_BEGIN #include #include - -#include "mpw-util.h" +MP_LIBS_END #define MP_N 32768LU #define MP_r 8U diff --git a/platform-independent/c/core/src/mpw-marshal-util.c b/platform-independent/c/core/src/mpw-marshal-util.c index 4be950e1..3df86cd6 100644 --- a/platform-independent/c/core/src/mpw-marshal-util.c +++ b/platform-independent/c/core/src/mpw-marshal-util.c @@ -16,11 +16,13 @@ // LICENSE file. Alternatively, see . //============================================================================== -#include - #include "mpw-marshal-util.h" #include "mpw-util.h" +MP_LIBS_BEGIN +#include +MP_LIBS_END + char *mpw_get_token(const char **in, const char *eol, char *delim) { // Skip leading spaces. diff --git a/platform-independent/c/core/src/mpw-marshal-util.h b/platform-independent/c/core/src/mpw-marshal-util.h index 3f10e383..533c1e01 100644 --- a/platform-independent/c/core/src/mpw-marshal-util.h +++ b/platform-independent/c/core/src/mpw-marshal-util.h @@ -19,12 +19,14 @@ #ifndef _MPW_MARSHAL_UTIL_H #define _MPW_MARSHAL_UTIL_H +#include "mpw-algorithm.h" + +MP_LIBS_BEGIN #include #if MPW_JSON -#include "json-c/json.h" +#include #endif - -#include "mpw-algorithm.h" +MP_LIBS_END /// Type parsing. diff --git a/platform-independent/c/core/src/mpw-marshal.c b/platform-independent/c/core/src/mpw-marshal.c index 7acfb9ef..ddaa1dbf 100644 --- a/platform-independent/c/core/src/mpw-marshal.c +++ b/platform-independent/c/core/src/mpw-marshal.c @@ -17,14 +17,16 @@ //============================================================================== -#include -#include -#include - #include "mpw-marshal.h" #include "mpw-util.h" #include "mpw-marshal-util.h" +MP_LIBS_BEGIN +#include +#include +#include +MP_LIBS_END + MPMarshalledUser *mpw_marshal_user( const char *fullName, MPMasterKeyProvider masterKeyProvider, const MPAlgorithmVersion algorithmVersion) { diff --git a/platform-independent/c/core/src/mpw-marshal.h b/platform-independent/c/core/src/mpw-marshal.h index 42196203..947ef5ad 100644 --- a/platform-independent/c/core/src/mpw-marshal.h +++ b/platform-independent/c/core/src/mpw-marshal.h @@ -19,10 +19,12 @@ #ifndef _MPW_MARSHAL_H #define _MPW_MARSHAL_H -#include - #include "mpw-algorithm.h" +MP_LIBS_BEGIN +#include +MP_LIBS_END + //// Types. typedef mpw_enum( unsigned int, MPMarshalFormat ) { diff --git a/platform-independent/c/core/src/mpw-types.c b/platform-independent/c/core/src/mpw-types.c index a3efbaee..c2247e7f 100644 --- a/platform-independent/c/core/src/mpw-types.c +++ b/platform-independent/c/core/src/mpw-types.c @@ -16,12 +16,14 @@ // LICENSE file. Alternatively, see . //============================================================================== -#include -#include - #include "mpw-types.h" #include "mpw-util.h" +MP_LIBS_BEGIN +#include +#include +MP_LIBS_END + const size_t MPMasterKeySize = 64; const size_t MPSiteKeySize = 256 / 8; // Size of HMAC-SHA-256 const MPIdenticon MPIdenticonUnset = { diff --git a/platform-independent/c/core/src/mpw-types.h b/platform-independent/c/core/src/mpw-types.h index 3ed50398..f4e25020 100644 --- a/platform-independent/c/core/src/mpw-types.h +++ b/platform-independent/c/core/src/mpw-types.h @@ -19,9 +19,16 @@ #ifndef _MPW_TYPES_H #define _MPW_TYPES_H +#ifndef MP_LIBS_BEGIN +#define MP_LIBS_BEGIN +#define MP_LIBS_END +#endif + +MP_LIBS_BEGIN #include #include #include +MP_LIBS_END #ifdef NS_ENUM #define mpw_enum(_type, _name) NS_ENUM(_type, _name) diff --git a/platform-independent/c/core/src/mpw-util.c b/platform-independent/c/core/src/mpw-util.c index a80603b3..40a8b48a 100644 --- a/platform-independent/c/core/src/mpw-util.c +++ b/platform-independent/c/core/src/mpw-util.c @@ -16,6 +16,9 @@ // LICENSE file. Alternatively, see . //============================================================================== +#include "mpw-util.h" + +MP_LIBS_BEGIN #include #include #include @@ -29,8 +32,7 @@ #define AES_ECB 0 #define AES_CBC 1 #include "aes.h" - -#include "mpw-util.h" +MP_LIBS_END #ifdef inf_level int mpw_verbosity = inf_level; diff --git a/platform-independent/c/core/src/mpw-util.h b/platform-independent/c/core/src/mpw-util.h index 3db7a753..e8bfe866 100644 --- a/platform-independent/c/core/src/mpw-util.h +++ b/platform-independent/c/core/src/mpw-util.h @@ -19,10 +19,12 @@ #ifndef _MPW_UTIL_H #define _MPW_UTIL_H +#include "mpw-types.h" + +MP_LIBS_BEGIN #include #include - -#include "mpw-types.h" +MP_LIBS_END //// Logging. #ifndef trc