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;
}
#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) {

View File

@ -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;