2
0

Make MPW_JSON optional as documented.

This commit is contained in:
Maarten Billemont 2017-08-31 11:48:10 -04:00
parent fad0f5e5dd
commit 627144b583
2 changed files with 12 additions and 0 deletions

View File

@ -50,6 +50,7 @@ time_t mpw_mktime(
return false; return false;
} }
#if MPW_JSON
json_object *mpw_get_json_section( json_object *mpw_get_json_section(
json_object *obj, const char *section) { json_object *obj, const char *section) {
@ -95,6 +96,7 @@ bool mpw_get_json_boolean(
return json_object_get_boolean( json_value ) == TRUE; return json_object_get_boolean( json_value ) == TRUE;
} }
#endif
bool mpw_update_masterKey(MPMasterKey *masterKey, MPAlgorithmVersion *masterKeyAlgorithm, MPAlgorithmVersion targetKeyAlgorithm, bool mpw_update_masterKey(MPMasterKey *masterKey, MPAlgorithmVersion *masterKeyAlgorithm, MPAlgorithmVersion targetKeyAlgorithm,
const char *fullName, const char *masterPassword) { const char *fullName, const char *masterPassword) {

View File

@ -215,6 +215,7 @@ static bool mpw_marshall_write_flat(
return true; return true;
} }
#if MPW_JSON
static bool mpw_marshall_write_json( static bool mpw_marshall_write_json(
char **out, const MPMarshalledUser *user, MPMarshallError *error) { char **out, const MPMarshalledUser *user, MPMarshallError *error) {
@ -342,6 +343,7 @@ static bool mpw_marshall_write_json(
*error = (MPMarshallError){ .type = MPMarshallSuccess }; *error = (MPMarshallError){ .type = MPMarshallSuccess };
return true; return true;
} }
#endif
bool mpw_marshall_write( bool mpw_marshall_write(
char **out, const MPMarshallFormat outFormat, const MPMarshalledUser *user, MPMarshallError *error) { char **out, const MPMarshallFormat outFormat, const MPMarshalledUser *user, MPMarshallError *error) {
@ -352,8 +354,10 @@ bool mpw_marshall_write(
return false; return false;
case MPMarshallFormatFlat: case MPMarshallFormatFlat:
return mpw_marshall_write_flat( out, user, error ); return mpw_marshall_write_flat( out, user, error );
#if MPW_JSON
case MPMarshallFormatJSON: case MPMarshallFormatJSON:
return mpw_marshall_write_json( out, user, error ); return mpw_marshall_write_json( out, user, error );
#endif
default: default:
*error = (MPMarshallError){ MPMarshallErrorFormat, mpw_str( "Unsupported output format: %u", outFormat ) }; *error = (MPMarshallError){ MPMarshallErrorFormat, mpw_str( "Unsupported output format: %u", outFormat ) };
return false; return false;
@ -627,6 +631,7 @@ static MPMarshalledUser *mpw_marshall_read_flat(
return user; return user;
} }
#if MPW_JSON
static void mpw_marshall_read_json_info( static void mpw_marshall_read_json_info(
const char *in, MPMarshallInfo *info) { const char *in, MPMarshallInfo *info) {
@ -817,6 +822,7 @@ static MPMarshalledUser *mpw_marshall_read_json(
*error = (MPMarshallError){ .type = MPMarshallSuccess }; *error = (MPMarshallError){ .type = MPMarshallSuccess };
return user; return user;
} }
#endif
MPMarshallInfo *mpw_marshall_read_info( MPMarshallInfo *mpw_marshall_read_info(
const char *in) { const char *in) {
@ -831,7 +837,9 @@ MPMarshallInfo *mpw_marshall_read_info(
} }
else if (in[0] == '{') { else if (in[0] == '{') {
*info = (MPMarshallInfo){ .format = MPMarshallFormatJSON }; *info = (MPMarshallInfo){ .format = MPMarshallFormatJSON };
#if MPW_JSON
mpw_marshall_read_json_info( in, info ); mpw_marshall_read_json_info( in, info );
#endif
} }
} }
@ -847,8 +855,10 @@ MPMarshalledUser *mpw_marshall_read(
return false; return false;
case MPMarshallFormatFlat: case MPMarshallFormatFlat:
return mpw_marshall_read_flat( in, masterPassword, error ); return mpw_marshall_read_flat( in, masterPassword, error );
#if MPW_JSON
case MPMarshallFormatJSON: case MPMarshallFormatJSON:
return mpw_marshall_read_json( in, masterPassword, error ); return mpw_marshall_read_json( in, masterPassword, error );
#endif
default: default:
*error = (MPMarshallError){ MPMarshallErrorFormat, mpw_str( "Unsupported input format: %u", inFormat ) }; *error = (MPMarshallError){ MPMarshallErrorFormat, mpw_str( "Unsupported input format: %u", inFormat ) };
return NULL; return NULL;