diff --git a/core/c/mpw-marshall-util.c b/core/c/mpw-marshal-util.c similarity index 99% rename from core/c/mpw-marshall-util.c rename to core/c/mpw-marshal-util.c index 1449c41d..d5f47944 100644 --- a/core/c/mpw-marshall-util.c +++ b/core/c/mpw-marshal-util.c @@ -18,7 +18,7 @@ #include -#include "mpw-marshall-util.h" +#include "mpw-marshal-util.h" #include "mpw-util.h" char *mpw_get_token(const char **in, const char *eol, char *delim) { diff --git a/core/c/mpw-marshall-util.h b/core/c/mpw-marshal-util.h similarity index 97% rename from core/c/mpw-marshall-util.h rename to core/c/mpw-marshal-util.h index b3972a1a..3afbfb07 100644 --- a/core/c/mpw-marshall-util.h +++ b/core/c/mpw-marshal-util.h @@ -16,8 +16,8 @@ // LICENSE file. Alternatively, see . //============================================================================== -#ifndef _MPW_MARSHALL_UTIL_H -#define _MPW_MARSHALL_UTIL_H +#ifndef _MPW_MARSHAL_UTIL_H +#define _MPW_MARSHAL_UTIL_H #include #if MPW_JSON @@ -70,4 +70,4 @@ bool mpw_update_masterKey( MPMasterKey *masterKey, MPAlgorithmVersion *masterKeyAlgorithm, MPAlgorithmVersion targetKeyAlgorithm, const char *fullName, const char *masterPassword); -#endif // _MPW_MARSHALL_UTIL_H +#endif // _MPW_MARSHAL_UTIL_H diff --git a/core/c/mpw-marshal.c b/core/c/mpw-marshal.c index 6dc7fd4b..1c2008ea 100644 --- a/core/c/mpw-marshal.c +++ b/core/c/mpw-marshal.c @@ -23,9 +23,9 @@ #include "mpw-marshal.h" #include "mpw-util.h" -#include "mpw-marshall-util.h" +#include "mpw-marshal-util.h" -MPMarshalledUser *mpw_marshall_user( +MPMarshalledUser *mpw_marshal_user( const char *fullName, const char *masterPassword, const MPAlgorithmVersion algorithmVersion) { MPMarshalledUser *user; @@ -48,7 +48,7 @@ MPMarshalledUser *mpw_marshall_user( return user; }; -MPMarshalledSite *mpw_marshall_site( +MPMarshalledSite *mpw_marshal_site( MPMarshalledUser *user, const char *siteName, const MPResultType resultType, const MPCounterValue siteCounter, const MPAlgorithmVersion algorithmVersion) { @@ -132,7 +132,7 @@ bool mpw_marshal_free( return success; } -static bool mpw_marshall_write_flat( +static bool mpw_marshal_write_flat( char **out, const MPMarshalledUser *user, MPMarshalError *error) { *error = (MPMarshalError){ MPMarshalErrorInternal, "Unexpected internal error." }; @@ -216,7 +216,7 @@ static bool mpw_marshall_write_flat( } #if MPW_JSON -static bool mpw_marshall_write_json( +static bool mpw_marshal_write_json( char **out, const MPMarshalledUser *user, MPMarshalError *error) { *error = (MPMarshalError){ MPMarshalErrorInternal, "Unexpected internal error." }; @@ -345,7 +345,7 @@ static bool mpw_marshall_write_json( } #endif -bool mpw_marshall_write( +bool mpw_marshal_write( char **out, const MPMarshalFormat outFormat, const MPMarshalledUser *user, MPMarshalError *error) { switch (outFormat) { @@ -353,10 +353,10 @@ bool mpw_marshall_write( *error = (MPMarshalError){ .type = MPMarshalSuccess }; return false; case MPMarshalFormatFlat: - return mpw_marshall_write_flat( out, user, error ); + return mpw_marshal_write_flat( out, user, error ); #if MPW_JSON case MPMarshalFormatJSON: - return mpw_marshall_write_json( out, user, error ); + return mpw_marshal_write_json( out, user, error ); #endif default: *error = (MPMarshalError){ MPMarshalErrorFormat, mpw_str( "Unsupported output format: %u", outFormat ) }; @@ -364,7 +364,7 @@ bool mpw_marshall_write( } } -static void mpw_marshall_read_flat_info( +static void mpw_marshal_read_flat_info( const char *in, MPMarshalInfo *info) { info->algorithm = MPAlgorithmVersionCurrent; @@ -411,7 +411,7 @@ static void mpw_marshall_read_flat_info( } } -static MPMarshalledUser *mpw_marshall_read_flat( +static MPMarshalledUser *mpw_marshal_read_flat( const char *in, const char *masterPassword, MPMarshalError *error) { *error = (MPMarshalError){ MPMarshalErrorInternal, "Unexpected internal error." }; @@ -508,7 +508,7 @@ static MPMarshalledUser *mpw_marshall_read_flat( *error = (MPMarshalError){ MPMarshalErrorMasterPassword, "Master password doesn't match key ID." }; return NULL; } - if (!(user = mpw_marshall_user( fullName, masterPassword, algorithm ))) { + if (!(user = mpw_marshal_user( fullName, masterPassword, algorithm ))) { *error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate a new user." }; return NULL; } @@ -582,7 +582,7 @@ static MPMarshalledUser *mpw_marshall_read_flat( return NULL; } - MPMarshalledSite *site = mpw_marshall_site( + MPMarshalledSite *site = mpw_marshal_site( user, siteName, siteType, siteCounter, siteAlgorithm ); if (!site) { *error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate a new site." }; @@ -632,7 +632,7 @@ static MPMarshalledUser *mpw_marshall_read_flat( } #if MPW_JSON -static void mpw_marshall_read_json_info( +static void mpw_marshal_read_json_info( const char *in, MPMarshalInfo *info) { // Parse JSON. @@ -656,7 +656,7 @@ static void mpw_marshall_read_json_info( json_object_put( json_file ); } -static MPMarshalledUser *mpw_marshall_read_json( +static MPMarshalledUser *mpw_marshal_read_json( const char *in, const char *masterPassword, MPMarshalError *error) { *error = (MPMarshalError){ MPMarshalErrorInternal, "Unexpected internal error." }; @@ -720,7 +720,7 @@ static MPMarshalledUser *mpw_marshall_read_json( *error = (MPMarshalError){ MPMarshalErrorMasterPassword, "Master password doesn't match key ID." }; return NULL; } - if (!(user = mpw_marshall_user( fullName, masterPassword, algorithm ))) { + if (!(user = mpw_marshal_user( fullName, masterPassword, algorithm ))) { *error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate a new user." }; return NULL; } @@ -765,7 +765,7 @@ static MPMarshalledUser *mpw_marshall_read_json( json_object *json_site_mpw = mpw_get_json_section( json_site.val, "_ext_mpw" ); const char *siteURL = mpw_get_json_string( json_site_mpw, "url", NULL ); - MPMarshalledSite *site = mpw_marshall_site( user, siteName, siteType, siteCounter, siteAlgorithm ); + MPMarshalledSite *site = mpw_marshal_site( user, siteName, siteType, siteCounter, siteAlgorithm ); if (!site) { *error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate a new site." }; return NULL; @@ -824,7 +824,7 @@ static MPMarshalledUser *mpw_marshall_read_json( } #endif -MPMarshalInfo *mpw_marshall_read_info( +MPMarshalInfo *mpw_marshal_read_info( const char *in) { MPMarshalInfo *info = malloc( sizeof( MPMarshalInfo ) ); @@ -833,12 +833,12 @@ MPMarshalInfo *mpw_marshall_read_info( if (in && strlen( in )) { if (in[0] == '#') { *info = (MPMarshalInfo){ .format = MPMarshalFormatFlat }; - mpw_marshall_read_flat_info( in, info ); + mpw_marshal_read_flat_info( in, info ); } else if (in[0] == '{') { *info = (MPMarshalInfo){ .format = MPMarshalFormatJSON }; #if MPW_JSON - mpw_marshall_read_json_info( in, info ); + mpw_marshal_read_json_info( in, info ); #endif } } @@ -846,7 +846,7 @@ MPMarshalInfo *mpw_marshall_read_info( return info; } -MPMarshalledUser *mpw_marshall_read( +MPMarshalledUser *mpw_marshal_read( const char *in, const MPMarshalFormat inFormat, const char *masterPassword, MPMarshalError *error) { switch (inFormat) { @@ -854,10 +854,10 @@ MPMarshalledUser *mpw_marshall_read( *error = (MPMarshalError){ .type = MPMarshalSuccess }; return false; case MPMarshalFormatFlat: - return mpw_marshall_read_flat( in, masterPassword, error ); + return mpw_marshal_read_flat( in, masterPassword, error ); #if MPW_JSON case MPMarshalFormatJSON: - return mpw_marshall_read_json( in, masterPassword, error ); + return mpw_marshal_read_json( in, masterPassword, error ); #endif default: *error = (MPMarshalError){ MPMarshalErrorFormat, mpw_str( "Unsupported input format: %u", inFormat ) }; @@ -906,7 +906,7 @@ const char *mpw_nameForFormat( } } -const char *mpw_marshall_format_extension( +const char *mpw_marshal_format_extension( const MPMarshalFormat format) { switch (format) { diff --git a/core/c/mpw-marshal.h b/core/c/mpw-marshal.h index 63f859eb..3a75d8a7 100644 --- a/core/c/mpw-marshal.h +++ b/core/c/mpw-marshal.h @@ -16,8 +16,8 @@ // LICENSE file. Alternatively, see . //============================================================================== -#ifndef _MPW_MARSHALL_H -#define _MPW_MARSHALL_H +#ifndef _MPW_MARSHAL_H +#define _MPW_MARSHAL_H #include @@ -111,22 +111,22 @@ typedef struct MPMarshalInfo { //// Marshalling. /** Write the user and all associated data out to the given output buffer using the given marshalling format. */ -bool mpw_marshall_write( +bool mpw_marshal_write( char **out, const MPMarshalFormat outFormat, const MPMarshalledUser *user, MPMarshalError *error); /** Try to read metadata on the sites in the input buffer. */ -MPMarshalInfo *mpw_marshall_read_info( +MPMarshalInfo *mpw_marshal_read_info( const char *in); /** Unmarshall sites in the given input buffer by parsing it using the given marshalling format. */ -MPMarshalledUser *mpw_marshall_read( +MPMarshalledUser *mpw_marshal_read( const char *in, const MPMarshalFormat inFormat, const char *masterPassword, MPMarshalError *error); //// Utilities. /** Create a new user object ready for marshalling. */ -MPMarshalledUser *mpw_marshall_user( +MPMarshalledUser *mpw_marshal_user( const char *fullName, const char *masterPassword, const MPAlgorithmVersion algorithmVersion); /** Create a new site attached to the given user object, ready for marshalling. */ -MPMarshalledSite *mpw_marshall_site( +MPMarshalledSite *mpw_marshal_site( MPMarshalledUser *user, const char *siteName, const MPResultType resultType, const MPCounterValue siteCounter, const MPAlgorithmVersion algorithmVersion); /** Create a new question attached to the given site object, ready for marshalling. */ @@ -153,7 +153,7 @@ const char *mpw_nameForFormat( /** * @return The file extension that's recommended for files that use the given marshalling format. */ -const char *mpw_marshall_format_extension( +const char *mpw_marshal_format_extension( const MPMarshalFormat format); -#endif // _MPW_MARSHALL_H +#endif // _MPW_MARSHAL_H diff --git a/platform-darwin/MasterPassword-iOS.xcodeproj/project.pbxproj b/platform-darwin/MasterPassword-iOS.xcodeproj/project.pbxproj index 1b41ceac..83a19d4e 100644 --- a/platform-darwin/MasterPassword-iOS.xcodeproj/project.pbxproj +++ b/platform-darwin/MasterPassword-iOS.xcodeproj/project.pbxproj @@ -253,7 +253,7 @@ DAADBFE01A68763B00F7A756 /* mpw-algorithm.c in Sources */ = {isa = PBXBuildFile; fileRef = 93D3969393A3A46BD27D7078 /* mpw-algorithm.c */; }; DAB7AE5D1F3D752900C856B1 /* libjson-c.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAB7AE5C1F3D752900C856B1 /* libjson-c.a */; }; DAB7AE771F3D755B00C856B1 /* libjson-c.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAB7AE761F3D755B00C856B1 /* libjson-c.a */; }; - DAB7AE991F3DDEE000C856B1 /* mpw-marshall-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DAB7AE981F3DDEE000C856B1 /* mpw-marshall-util.c */; }; + DAB7AE991F3DDEE000C856B1 /* mpw-marshal-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DAB7AE981F3DDEE000C856B1 /* mpw-marshal-util.c */; }; DABB981615100B4000B05417 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DABB981515100B4000B05417 /* SystemConfiguration.framework */; }; DABD39371711E29700CF925C /* avatar-0.png in Resources */ = {isa = PBXBuildFile; fileRef = DABD366C1711E29400CF925C /* avatar-0.png */; }; DABD39381711E29700CF925C /* avatar-0@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DABD366D1711E29400CF925C /* avatar-0@2x.png */; }; @@ -896,8 +896,8 @@ DAB7AE731F3D755B00C856B1 /* strdup_compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strdup_compat.h; sourceTree = ""; }; DAB7AE741F3D755B00C856B1 /* vasprintf_compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vasprintf_compat.h; sourceTree = ""; }; DAB7AE761F3D755B00C856B1 /* libjson-c.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libjson-c.a"; sourceTree = ""; }; - DAB7AE971F3DDEE000C856B1 /* mpw-marshall-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mpw-marshall-util.h"; sourceTree = ""; }; - DAB7AE981F3DDEE000C856B1 /* mpw-marshall-util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "mpw-marshall-util.c"; sourceTree = ""; }; + DAB7AE971F3DDEE000C856B1 /* mpw-marshal-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mpw-marshal-util.h"; sourceTree = ""; }; + DAB7AE981F3DDEE000C856B1 /* mpw-marshal-util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "mpw-marshal-util.c"; sourceTree = ""; }; DABB981515100B4000B05417 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; DABD360F1711E29400CF925C /* ui_background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ui_background.png; sourceTree = ""; }; DABD36101711E29400CF925C /* ui_background@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ui_background@2x.png"; sourceTree = ""; }; @@ -1759,8 +1759,8 @@ 93D39D4E713564B7654341B0 /* mpw-algorithm_v3.c */, 93D3969393A3A46BD27D7078 /* mpw-algorithm.c */, 93D3990D850D76A94C6B7A4D /* mpw-algorithm.h */, - DAB7AE981F3DDEE000C856B1 /* mpw-marshall-util.c */, - DAB7AE971F3DDEE000C856B1 /* mpw-marshall-util.h */, + DAB7AE981F3DDEE000C856B1 /* mpw-marshal-util.c */, + DAB7AE971F3DDEE000C856B1 /* mpw-marshal-util.h */, DAA449D01EEC4B5800E7BDD5 /* mpw-marshal.c */, DAA449D11EEC4B5800E7BDD5 /* mpw-marshal.h */, 93D392C5A6572DB0EB5B82C8 /* mpw-types.c */, @@ -3988,7 +3988,7 @@ DA0CC58E1EB6B030009A8ED9 /* MPSiteQuestionEntity+CoreDataClass.m in Sources */, 93D39A5FF670957C0AF8298D /* MPSiteCell.m in Sources */, 93D398ECD7D1A0DEDDADF516 /* MPEmergencyViewController.m in Sources */, - DAB7AE991F3DDEE000C856B1 /* mpw-marshall-util.c in Sources */, + DAB7AE991F3DDEE000C856B1 /* mpw-marshal-util.c in Sources */, DA95B50F1C4776F00067F5EF /* NSMutableSet+Pearl.m in Sources */, 93D394B5036C882B33C71872 /* MPSitesSegue.m in Sources */, DA0CC5911EB6B030009A8ED9 /* MPStoredSiteEntity+CoreDataProperties.m in Sources */, diff --git a/platform-darwin/MasterPassword-macOS.xcodeproj/project.pbxproj b/platform-darwin/MasterPassword-macOS.xcodeproj/project.pbxproj index fd59e6f0..2cbf63d2 100644 --- a/platform-darwin/MasterPassword-macOS.xcodeproj/project.pbxproj +++ b/platform-darwin/MasterPassword-macOS.xcodeproj/project.pbxproj @@ -110,8 +110,8 @@ DA6774431A474A3B004F356A /* mpw-algorithm.c in Sources */ = {isa = PBXBuildFile; fileRef = DA6773BB1A4746AF004F356A /* mpw-algorithm.c */; }; DA6774451A474A3B004F356A /* mpw-types.c in Sources */ = {isa = PBXBuildFile; fileRef = DA6773C21A4746AF004F356A /* mpw-types.c */; }; DA6774461A474A3B004F356A /* mpw-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DA6773C51A4746AF004F356A /* mpw-util.c */; }; - DA7471A31F2B71AE005F3468 /* mpw-marshall-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DA7471A01F2B71A9005F3468 /* mpw-marshall-util.c */; }; - DA7471A61F2B71B9005F3468 /* mpw-marshall-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DA7471A01F2B71A9005F3468 /* mpw-marshall-util.c */; }; + DA7471A31F2B71AE005F3468 /* mpw-marshal-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DA7471A01F2B71A9005F3468 /* mpw-marshal-util.c */; }; + DA7471A61F2B71B9005F3468 /* mpw-marshal-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DA7471A01F2B71A9005F3468 /* mpw-marshal-util.c */; }; DA89D4EC1A51EABD00AC64D7 /* Pearl-Cocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = DA89D4EA1A51EABD00AC64D7 /* Pearl-Cocoa.h */; }; DA89D4ED1A51EABD00AC64D7 /* Pearl-Cocoa.m in Sources */ = {isa = PBXBuildFile; fileRef = DA89D4EB1A51EABD00AC64D7 /* Pearl-Cocoa.m */; }; DA8ED895192906920099B726 /* PearlTween.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8ED891192906920099B726 /* PearlTween.m */; }; @@ -950,8 +950,8 @@ DA6773C51A4746AF004F356A /* mpw-util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "mpw-util.c"; sourceTree = ""; }; DA6773C61A4746AF004F356A /* mpw-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mpw-util.h"; sourceTree = ""; }; DA67743B1A474A03004F356A /* mpw-test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "mpw-test"; sourceTree = BUILT_PRODUCTS_DIR; }; - DA7471A01F2B71A9005F3468 /* mpw-marshall-util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "mpw-marshall-util.c"; sourceTree = ""; }; - DA7471A11F2B71A9005F3468 /* mpw-marshall-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mpw-marshall-util.h"; sourceTree = ""; }; + DA7471A01F2B71A9005F3468 /* mpw-marshal-util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "mpw-marshal-util.c"; sourceTree = ""; }; + DA7471A11F2B71A9005F3468 /* mpw-marshal-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mpw-marshal-util.h"; sourceTree = ""; }; DA771FE51E6E15A1004D7EDE /* MasterPassword-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MasterPassword-Prefix.pch"; sourceTree = ""; }; DA831A271A6E1146000AC234 /* mpw-algorithm_v0.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "mpw-algorithm_v0.c"; sourceTree = ""; }; DA831A281A6E1146000AC234 /* mpw-algorithm_v1.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "mpw-algorithm_v1.c"; sourceTree = ""; }; @@ -1887,8 +1887,8 @@ DA831A2A1A6E1146000AC234 /* mpw-algorithm_v3.c */, DA6773BB1A4746AF004F356A /* mpw-algorithm.c */, DA6773BC1A4746AF004F356A /* mpw-algorithm.h */, - DA7471A01F2B71A9005F3468 /* mpw-marshall-util.c */, - DA7471A11F2B71A9005F3468 /* mpw-marshall-util.h */, + DA7471A01F2B71A9005F3468 /* mpw-marshal-util.c */, + DA7471A11F2B71A9005F3468 /* mpw-marshal-util.h */, DAA449D31EEC4B6B00E7BDD5 /* mpw-marshal.c */, DAA449D41EEC4B6B00E7BDD5 /* mpw-marshal.h */, DA6773C21A4746AF004F356A /* mpw-types.c */, @@ -2676,7 +2676,7 @@ DAAF16661F5CA3240013B8AE /* mpw-cli-util.c in Sources */, DA1C7AAC1F1A8F24009A3551 /* mpw-util.c in Sources */, DA1C7AC31F1A8FBA009A3551 /* mpw-cli.c in Sources */, - DA7471A31F2B71AE005F3468 /* mpw-marshall-util.c in Sources */, + DA7471A31F2B71AE005F3468 /* mpw-marshal-util.c in Sources */, DA1C7AAD1F1A8F24009A3551 /* mpw-algorithm.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2738,7 +2738,7 @@ DA4DAE941A7D8117003E5423 /* MPAlgorithmV3.m in Sources */, DA4DAE951A7D8117003E5423 /* MPTypes.m in Sources */, 93D393A1646430FAAC73E7FE /* MPMacApplication.m in Sources */, - DA7471A61F2B71B9005F3468 /* mpw-marshall-util.c in Sources */, + DA7471A61F2B71B9005F3468 /* mpw-marshal-util.c in Sources */, 93D398D1F5D8CD5A22AF6929 /* MPGradientView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/platform-darwin/Source/MPAppDelegate_Store.m b/platform-darwin/Source/MPAppDelegate_Store.m index 3d0805fa..8f7f245e 100644 --- a/platform-darwin/Source/MPAppDelegate_Store.m +++ b/platform-darwin/Source/MPAppDelegate_Store.m @@ -566,7 +566,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted ); saveInContext:(NSManagedObjectContext *)context { // Read metadata for the import file. - MPMarshalInfo *info = mpw_marshall_read_info( importData.UTF8String ); + MPMarshalInfo *info = mpw_marshal_read_info( importData.UTF8String ); if (info->format == MPMarshalFormatNone) return MPError( ([NSError errorWithDomain:MPErrorDomain code:MPErrorMarshalCode userInfo:@{ @"type" : @(MPMarshalErrorFormat), @@ -590,7 +590,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted ); // Parse import data. MPMarshalError importError = { .type = MPMarshalSuccess }; - MPMarshalledUser *importUser = mpw_marshall_read( importData.UTF8String, info->format, importMasterPassword.UTF8String, &importError ); + MPMarshalledUser *importUser = mpw_marshal_read( importData.UTF8String, info->format, importMasterPassword.UTF8String, &importError ); mpw_marshal_info_free( &info ); @try { @@ -707,7 +707,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted ); NSString *masterPassword = askImportPassword( user.name ); inf( @"Exporting sites, %@, for user: %@", revealPasswords? @"revealing passwords": @"omitting passwords", user.userID ); - MPMarshalledUser *exportUser = mpw_marshall_user( user.name.UTF8String, masterPassword.UTF8String, user.algorithm.version ); + MPMarshalledUser *exportUser = mpw_marshal_user( user.name.UTF8String, masterPassword.UTF8String, user.algorithm.version ); exportUser->redacted = !revealPasswords; exportUser->avatar = (unsigned int)user.avatar; exportUser->defaultType = user.defaultType; @@ -721,7 +721,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted ); ? [site.algorithm exportPasswordForSite:site usingKey:self.key] : [site.algorithm resolvePasswordForSite:site usingKey:self.key]; - MPMarshalledSite *exportSite = mpw_marshall_site( exportUser, + MPMarshalledSite *exportSite = mpw_marshal_site( exportUser, site.name.UTF8String, site.type, counter, site.algorithm.version ); exportSite->content = content.UTF8String; exportSite->loginContent = site.loginName.UTF8String; @@ -736,7 +736,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted ); char *export = NULL; MPMarshalError exportError = (MPMarshalError){ .type= MPMarshalSuccess }; - mpw_marshall_write( &export, MPMarshalFormatFlat, exportUser, &exportError ); + mpw_marshal_write( &export, MPMarshalFormatFlat, exportUser, &exportError ); NSString *mpsites = nil; if (export && exportError.type == MPMarshalSuccess) mpsites = [NSString stringWithCString:export encoding:NSUTF8StringEncoding]; diff --git a/platform-darwin/Source/iOS/MPiOSAppDelegate.m b/platform-darwin/Source/iOS/MPiOSAppDelegate.m index 19d71d91..68f451a7 100644 --- a/platform-darwin/Source/iOS/MPiOSAppDelegate.m +++ b/platform-darwin/Source/iOS/MPiOSAppDelegate.m @@ -236,7 +236,7 @@ PearlNotMainQueue( ^{ NSString *importData = [UIPasteboard generalPasteboard].string; - MPMarshalInfo *importInfo = mpw_marshall_read_info( importData.UTF8String ); + MPMarshalInfo *importInfo = mpw_marshal_read_info( importData.UTF8String ); if (importInfo->format != MPMarshalFormatNone) [PearlAlert showAlertWithTitle:@"Import Sites?" message: @"We've detected Master Password import sites on your pasteboard, would you like to import them?" diff --git a/platform-independent/cli-c/CMakeLists.txt b/platform-independent/cli-c/CMakeLists.txt index a59ff372..4b0fd6b5 100644 --- a/platform-independent/cli-c/CMakeLists.txt +++ b/platform-independent/cli-c/CMakeLists.txt @@ -99,7 +99,7 @@ endfunction() ### TARGET: MPW if( BUILD_MPW ) # target - add_executable( mpw "core/base64.c" "core/mpw-algorithm.c" "core/mpw-types.c" "core/mpw-util.c" "core/mpw-marshall-util.c" "core/mpw-marshall.c" + add_executable( mpw "core/base64.c" "core/mpw-algorithm.c" "core/mpw-types.c" "core/mpw-util.c" "core/mpw-marshal-util.c" "core/mpw-marshal.c" "cli/mpw-cli-util.c" "cli/mpw-cli.c" ) target_include_directories( mpw PUBLIC core cli ) diff --git a/platform-independent/cli-c/cli/mpw-cli.c b/platform-independent/cli-c/cli/mpw-cli.c index f3e013dc..2b9701b1 100644 --- a/platform-independent/cli-c/cli/mpw-cli.c +++ b/platform-independent/cli-c/cli/mpw-cli.c @@ -97,7 +97,7 @@ static void usage() { " n, none | No file\n" " f, flat | ~/.mpw.d/Full Name.%s\n" " j, json | ~/.mpw.d/Full Name.%s\n\n", - MP_ENV_format, mpw_marshall_format_extension( MPMarshalFormatFlat ), mpw_marshall_format_extension( MPMarshalFormatJSON ) ); + MP_ENV_format, mpw_marshal_format_extension( MPMarshalFormatFlat ), mpw_marshal_format_extension( MPMarshalFormatJSON ) ); inf( "" " -R redacted Whether to save the mpsites in redacted format or not.\n" " Redaction omits or encrypts any secrets, making the file safe\n" @@ -446,14 +446,14 @@ void cli_user(Arguments *args, Operation *operation) { // Find mpsites file from parameters. FILE *sitesFile = NULL; mpw_free_string( &operation->sitesPath ); - operation->sitesPath = mpw_path( operation->fullName, mpw_marshall_format_extension( operation->sitesFormat ) ); + operation->sitesPath = mpw_path( operation->fullName, mpw_marshal_format_extension( operation->sitesFormat ) ); if (!operation->sitesPath || !(sitesFile = fopen( operation->sitesPath, "r" ))) { dbg( "Couldn't open configuration file:\n %s: %s\n", operation->sitesPath, strerror( errno ) ); // Try to fall back to the flat format. if (!operation->sitesFormatFixed) { mpw_free_string( &operation->sitesPath ); - operation->sitesPath = mpw_path( operation->fullName, mpw_marshall_format_extension( MPMarshalFormatFlat ) ); + operation->sitesPath = mpw_path( operation->fullName, mpw_marshal_format_extension( MPMarshalFormatFlat ) ); if (operation->sitesPath && (sitesFile = fopen( operation->sitesPath, "r" ))) operation->sitesFormat = MPMarshalFormatFlat; else @@ -473,14 +473,14 @@ void cli_user(Arguments *args, Operation *operation) { fclose( sitesFile ); // Parse file. - MPMarshalInfo *sitesInputInfo = mpw_marshall_read_info( sitesInputData ); + MPMarshalInfo *sitesInputInfo = mpw_marshal_read_info( sitesInputData ); MPMarshalFormat sitesInputFormat = args->sitesFormat? operation->sitesFormat: sitesInputInfo->format; - MPMarshalError marshallError = { .type = MPMarshalSuccess }; + MPMarshalError marshalError = { .type = MPMarshalSuccess }; mpw_marshal_info_free( &sitesInputInfo ); - operation->user = mpw_marshall_read( sitesInputData, sitesInputFormat, operation->masterPassword, &marshallError ); - if (marshallError.type == MPMarshalErrorMasterPassword && operation->allowPasswordUpdate) { + operation->user = mpw_marshal_read( sitesInputData, sitesInputFormat, operation->masterPassword, &marshalError ); + if (marshalError.type == MPMarshalErrorMasterPassword && operation->allowPasswordUpdate) { // Update master password in mpsites. - while (marshallError.type == MPMarshalErrorMasterPassword) { + while (marshalError.type == MPMarshalErrorMasterPassword) { inf( "Given master password does not match configuration.\n" ); inf( "To update the configuration with this new master password, first confirm the old master password.\n" ); @@ -489,7 +489,7 @@ void cli_user(Arguments *args, Operation *operation) { importMasterPassword = mpw_getpass( "Old master password: " ); mpw_marshal_free( &operation->user ); - operation->user = mpw_marshall_read( sitesInputData, sitesInputFormat, importMasterPassword, &marshallError ); + operation->user = mpw_marshal_read( sitesInputData, sitesInputFormat, importMasterPassword, &marshalError ); mpw_free_string( &importMasterPassword ); } if (operation->user) { @@ -500,15 +500,15 @@ void cli_user(Arguments *args, Operation *operation) { mpw_free_string( &sitesInputData ); // Incorrect master password. - if (marshallError.type == MPMarshalErrorMasterPassword) { - ftl( "Incorrect master password according to configuration:\n %s: %s\n", operation->sitesPath, marshallError.description ); + if (marshalError.type == MPMarshalErrorMasterPassword) { + ftl( "Incorrect master password according to configuration:\n %s: %s\n", operation->sitesPath, marshalError.description ); cli_free( args, operation ); exit( EX_DATAERR ); } // Any other parse error. - if (!operation->user || marshallError.type != MPMarshalSuccess) { - err( "Couldn't parse configuration file:\n %s: %s\n", operation->sitesPath, marshallError.description ); + if (!operation->user || marshalError.type != MPMarshalSuccess) { + err( "Couldn't parse configuration file:\n %s: %s\n", operation->sitesPath, marshalError.description ); cli_free( args, operation ); exit( EX_DATAERR ); } @@ -516,7 +516,7 @@ void cli_user(Arguments *args, Operation *operation) { // If no user from mpsites, create a new one. if (!operation->user) - operation->user = mpw_marshall_user( + operation->user = mpw_marshal_user( operation->fullName, operation->masterPassword, MPAlgorithmVersionCurrent ); } @@ -532,7 +532,7 @@ void cli_site(Arguments __unused *args, Operation *operation) { // If no site from mpsites, create a new one. if (!operation->site) - operation->site = mpw_marshall_site( + operation->site = mpw_marshal_site( operation->user, operation->siteName, MPResultTypeDefault, MPCounterValueDefault, operation->user->algorithm ); } @@ -762,7 +762,7 @@ void cli_save(Arguments __unused *args, Operation *operation) { if (!operation->sitesFormatFixed) operation->sitesFormat = MPMarshalFormatDefault; - operation->sitesPath = mpw_path( operation->user->fullName, mpw_marshall_format_extension( operation->sitesFormat ) ); + operation->sitesPath = mpw_path( operation->user->fullName, mpw_marshal_format_extension( operation->sitesFormat ) ); dbg( "Updating: %s (%s)\n", operation->sitesPath, mpw_nameForFormat( operation->sitesFormat ) ); FILE *sitesFile = NULL; @@ -772,9 +772,9 @@ void cli_save(Arguments __unused *args, Operation *operation) { } char *buf = NULL; - MPMarshalError marshallError = { .type = MPMarshalSuccess }; - if (!mpw_marshall_write( &buf, operation->sitesFormat, operation->user, &marshallError ) || marshallError.type != MPMarshalSuccess) - wrn( "Couldn't encode updated configuration file:\n %s: %s\n", operation->sitesPath, marshallError.description ); + MPMarshalError marshalError = { .type = MPMarshalSuccess }; + if (!mpw_marshal_write( &buf, operation->sitesFormat, operation->user, &marshalError ) || marshalError.type != MPMarshalSuccess) + wrn( "Couldn't encode updated configuration file:\n %s: %s\n", operation->sitesPath, marshalError.description ); else if (fwrite( buf, sizeof( char ), strlen( buf ), sitesFile ) != strlen( buf )) wrn( "Error while writing updated configuration file:\n %s: %d\n", operation->sitesPath, ferror( sitesFile ) );