From 627144b583050204fdcf3ec6171f0ccc4df6b11e Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Thu, 31 Aug 2017 11:48:10 -0400 Subject: [PATCH] Make MPW_JSON optional as documented. --- core/c/mpw-marshall-util.c | 2 ++ core/c/mpw-marshall.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/core/c/mpw-marshall-util.c b/core/c/mpw-marshall-util.c index 60485158..1449c41d 100644 --- a/core/c/mpw-marshall-util.c +++ b/core/c/mpw-marshall-util.c @@ -50,6 +50,7 @@ time_t mpw_mktime( return false; } +#if MPW_JSON json_object *mpw_get_json_section( json_object *obj, const char *section) { @@ -95,6 +96,7 @@ bool mpw_get_json_boolean( return json_object_get_boolean( json_value ) == TRUE; } +#endif bool mpw_update_masterKey(MPMasterKey *masterKey, MPAlgorithmVersion *masterKeyAlgorithm, MPAlgorithmVersion targetKeyAlgorithm, const char *fullName, const char *masterPassword) { diff --git a/core/c/mpw-marshall.c b/core/c/mpw-marshall.c index 7a24b6da..92199600 100644 --- a/core/c/mpw-marshall.c +++ b/core/c/mpw-marshall.c @@ -215,6 +215,7 @@ static bool mpw_marshall_write_flat( return true; } +#if MPW_JSON static bool mpw_marshall_write_json( char **out, const MPMarshalledUser *user, MPMarshallError *error) { @@ -342,6 +343,7 @@ static bool mpw_marshall_write_json( *error = (MPMarshallError){ .type = MPMarshallSuccess }; return true; } +#endif bool mpw_marshall_write( char **out, const MPMarshallFormat outFormat, const MPMarshalledUser *user, MPMarshallError *error) { @@ -352,8 +354,10 @@ bool mpw_marshall_write( return false; case MPMarshallFormatFlat: return mpw_marshall_write_flat( out, user, error ); +#if MPW_JSON case MPMarshallFormatJSON: return mpw_marshall_write_json( out, user, error ); +#endif default: *error = (MPMarshallError){ MPMarshallErrorFormat, mpw_str( "Unsupported output format: %u", outFormat ) }; return false; @@ -627,6 +631,7 @@ static MPMarshalledUser *mpw_marshall_read_flat( return user; } +#if MPW_JSON static void mpw_marshall_read_json_info( const char *in, MPMarshallInfo *info) { @@ -817,6 +822,7 @@ static MPMarshalledUser *mpw_marshall_read_json( *error = (MPMarshallError){ .type = MPMarshallSuccess }; return user; } +#endif MPMarshallInfo *mpw_marshall_read_info( const char *in) { @@ -831,7 +837,9 @@ MPMarshallInfo *mpw_marshall_read_info( } else if (in[0] == '{') { *info = (MPMarshallInfo){ .format = MPMarshallFormatJSON }; +#if MPW_JSON mpw_marshall_read_json_info( in, info ); +#endif } } @@ -847,8 +855,10 @@ MPMarshalledUser *mpw_marshall_read( return false; case MPMarshallFormatFlat: return mpw_marshall_read_flat( in, masterPassword, error ); +#if MPW_JSON case MPMarshallFormatJSON: return mpw_marshall_read_json( in, masterPassword, error ); +#endif default: *error = (MPMarshallError){ MPMarshallErrorFormat, mpw_str( "Unsupported input format: %u", inFormat ) }; return NULL;