Harmonize naming of state variables.
This commit is contained in:
parent
68e58cddd4
commit
c11b63912d
@ -581,15 +581,15 @@ void cli_operation(Arguments *args, Operation *operation) {
|
|||||||
switch (operation->keyPurpose) {
|
switch (operation->keyPurpose) {
|
||||||
case MPKeyPurposeAuthentication: {
|
case MPKeyPurposeAuthentication: {
|
||||||
operation->purposeResult = "password";
|
operation->purposeResult = "password";
|
||||||
operation->resultType = operation->site->type;
|
operation->resultType = operation->site->resultType;
|
||||||
operation->resultState = operation->site->content? mpw_strdup( operation->site->content ): NULL;
|
operation->resultState = operation->site->resultState? mpw_strdup( operation->site->resultState ): NULL;
|
||||||
operation->siteCounter = operation->site->counter;
|
operation->siteCounter = operation->site->counter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MPKeyPurposeIdentification: {
|
case MPKeyPurposeIdentification: {
|
||||||
operation->purposeResult = "login";
|
operation->purposeResult = "login";
|
||||||
operation->resultType = operation->site->loginType;
|
operation->resultType = operation->site->loginType;
|
||||||
operation->resultState = operation->site->loginContent? mpw_strdup( operation->site->loginContent ): NULL;
|
operation->resultState = operation->site->loginState? mpw_strdup( operation->site->loginState ): NULL;
|
||||||
operation->siteCounter = MPCounterValueInitial;
|
operation->siteCounter = MPCounterValueInitial;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -598,7 +598,7 @@ void cli_operation(Arguments *args, Operation *operation) {
|
|||||||
operation->purposeResult = "answer";
|
operation->purposeResult = "answer";
|
||||||
operation->keyContext = operation->question->keyword? mpw_strdup( operation->question->keyword ): NULL;
|
operation->keyContext = operation->question->keyword? mpw_strdup( operation->question->keyword ): NULL;
|
||||||
operation->resultType = operation->question->type;
|
operation->resultType = operation->question->type;
|
||||||
operation->resultState = operation->question->content? mpw_strdup( operation->question->content ): NULL;
|
operation->resultState = operation->question->state? mpw_strdup( operation->question->state ): NULL;
|
||||||
operation->siteCounter = MPCounterValueInitial;
|
operation->siteCounter = MPCounterValueInitial;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -622,7 +622,7 @@ void cli_resultType(Arguments *args, Operation *operation) {
|
|||||||
if (!(operation->resultType & MPSiteFeatureAlternative)) {
|
if (!(operation->resultType & MPSiteFeatureAlternative)) {
|
||||||
switch (operation->keyPurpose) {
|
switch (operation->keyPurpose) {
|
||||||
case MPKeyPurposeAuthentication:
|
case MPKeyPurposeAuthentication:
|
||||||
operation->site->type = operation->resultType;
|
operation->site->resultType = operation->resultType;
|
||||||
break;
|
break;
|
||||||
case MPKeyPurposeIdentification:
|
case MPKeyPurposeIdentification:
|
||||||
operation->site->loginType = operation->resultType;
|
operation->site->loginType = operation->resultType;
|
||||||
@ -725,19 +725,19 @@ void cli_mpw(Arguments *args, Operation *operation) {
|
|||||||
|
|
||||||
switch (operation->keyPurpose) {
|
switch (operation->keyPurpose) {
|
||||||
case MPKeyPurposeAuthentication: {
|
case MPKeyPurposeAuthentication: {
|
||||||
mpw_free_string( &operation->site->content );
|
mpw_free_string( &operation->site->resultState );
|
||||||
operation->site->content = mpw_strdup( operation->resultState );
|
operation->site->resultState = mpw_strdup( operation->resultState );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MPKeyPurposeIdentification: {
|
case MPKeyPurposeIdentification: {
|
||||||
mpw_free_string( &operation->site->loginContent );
|
mpw_free_string( &operation->site->loginState );
|
||||||
operation->site->loginContent = mpw_strdup( operation->resultState );
|
operation->site->loginState = mpw_strdup( operation->resultState );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MPKeyPurposeRecovery: {
|
case MPKeyPurposeRecovery: {
|
||||||
mpw_free_string( &operation->question->content );
|
mpw_free_string( &operation->question->state );
|
||||||
operation->question->content = mpw_strdup( operation->resultState );
|
operation->question->state = mpw_strdup( operation->resultState );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,12 +58,12 @@ MPMarshalledSite *mpw_marshal_site(
|
|||||||
MPMarshalledSite *site = &user->sites[user->sites_count - 1];
|
MPMarshalledSite *site = &user->sites[user->sites_count - 1];
|
||||||
*site = (MPMarshalledSite){
|
*site = (MPMarshalledSite){
|
||||||
.name = mpw_strdup( siteName ),
|
.name = mpw_strdup( siteName ),
|
||||||
.content = NULL,
|
.resultState = NULL,
|
||||||
.type = resultType,
|
.resultType = resultType,
|
||||||
.counter = siteCounter,
|
.counter = siteCounter,
|
||||||
.algorithm = algorithmVersion,
|
.algorithm = algorithmVersion,
|
||||||
|
|
||||||
.loginContent = NULL,
|
.loginState = NULL,
|
||||||
.loginType = MPResultTypeTemplateName,
|
.loginType = MPResultTypeTemplateName,
|
||||||
|
|
||||||
.url = NULL,
|
.url = NULL,
|
||||||
@ -87,7 +87,7 @@ MPMarshalledQuestion *mpw_marshal_question(
|
|||||||
MPMarshalledQuestion *question = &site->questions[site->questions_count - 1];
|
MPMarshalledQuestion *question = &site->questions[site->questions_count - 1];
|
||||||
*question = (MPMarshalledQuestion){
|
*question = (MPMarshalledQuestion){
|
||||||
.keyword = mpw_strdup( keyword ),
|
.keyword = mpw_strdup( keyword ),
|
||||||
.content = NULL,
|
.state = NULL,
|
||||||
.type = MPResultTypeTemplatePhrase,
|
.type = MPResultTypeTemplatePhrase,
|
||||||
};
|
};
|
||||||
return question;
|
return question;
|
||||||
@ -117,11 +117,11 @@ bool mpw_marshal_free(
|
|||||||
|
|
||||||
for (size_t s = 0; s < (*user)->sites_count; ++s) {
|
for (size_t s = 0; s < (*user)->sites_count; ++s) {
|
||||||
MPMarshalledSite *site = &(*user)->sites[s];
|
MPMarshalledSite *site = &(*user)->sites[s];
|
||||||
success &= mpw_free_strings( &site->name, &site->content, &site->loginContent, &site->url, NULL );
|
success &= mpw_free_strings( &site->name, &site->resultState, &site->loginState, &site->url, NULL );
|
||||||
|
|
||||||
for (size_t q = 0; q < site->questions_count; ++q) {
|
for (size_t q = 0; q < site->questions_count; ++q) {
|
||||||
MPMarshalledQuestion *question = &site->questions[q];
|
MPMarshalledQuestion *question = &site->questions[q];
|
||||||
success &= mpw_free_strings( &question->keyword, &question->content, NULL );
|
success &= mpw_free_strings( &question->keyword, &question->state, NULL );
|
||||||
}
|
}
|
||||||
success &= mpw_free( &site->questions, sizeof( MPMarshalledQuestion ) * site->questions_count );
|
success &= mpw_free( &site->questions, sizeof( MPMarshalledQuestion ) * site->questions_count );
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ static bool mpw_marshal_write_flat(
|
|||||||
if (!site->name || !strlen( site->name ))
|
if (!site->name || !strlen( site->name ))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char *content = NULL, *loginContent = NULL;
|
const char *resultState = NULL, *loginState = NULL;
|
||||||
if (!user->redacted) {
|
if (!user->redacted) {
|
||||||
// Clear Text
|
// Clear Text
|
||||||
mpw_free( &masterKey, MPMasterKeySize );
|
mpw_free( &masterKey, MPMasterKeySize );
|
||||||
@ -186,24 +186,24 @@ static bool mpw_marshal_write_flat(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
content = mpw_siteResult( masterKey, site->name, site->counter,
|
resultState = mpw_siteResult( masterKey, site->name, site->counter,
|
||||||
MPKeyPurposeAuthentication, NULL, site->type, site->content, site->algorithm );
|
MPKeyPurposeAuthentication, NULL, site->resultType, site->resultState, site->algorithm );
|
||||||
loginContent = mpw_siteResult( masterKey, site->name, MPCounterValueInitial,
|
loginState = mpw_siteResult( masterKey, site->name, MPCounterValueInitial,
|
||||||
MPKeyPurposeIdentification, NULL, site->loginType, site->loginContent, site->algorithm );
|
MPKeyPurposeIdentification, NULL, site->loginType, site->loginState, site->algorithm );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Redacted
|
// Redacted
|
||||||
if (site->type & MPSiteFeatureExportContent && site->content && strlen( site->content ))
|
if (site->resultType & MPSiteFeatureExportContent && site->resultState && strlen( site->resultState ))
|
||||||
content = mpw_strdup( site->content );
|
resultState = mpw_strdup( site->resultState );
|
||||||
if (site->loginType & MPSiteFeatureExportContent && site->loginContent && strlen( site->loginContent ))
|
if (site->loginType & MPSiteFeatureExportContent && site->loginState && strlen( site->loginState ))
|
||||||
loginContent = mpw_strdup( site->loginContent );
|
loginState = mpw_strdup( site->loginState );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strftime( dateString, sizeof( dateString ), "%FT%TZ", gmtime( &site->lastUsed ) ))
|
if (strftime( dateString, sizeof( dateString ), "%FT%TZ", gmtime( &site->lastUsed ) ))
|
||||||
mpw_string_pushf( out, "%s %8ld %lu:%lu:%lu %25s\t%25s\t%s\n",
|
mpw_string_pushf( out, "%s %8ld %lu:%lu:%lu %25s\t%25s\t%s\n",
|
||||||
dateString, (long)site->uses, (long)site->type, (long)site->algorithm, (long)site->counter,
|
dateString, (long)site->uses, (long)site->resultType, (long)site->algorithm, (long)site->counter,
|
||||||
loginContent? loginContent: "", site->name, content? content: "" );
|
loginState? loginState: "", site->name, resultState? resultState: "" );
|
||||||
mpw_free_strings( &content, &loginContent, NULL );
|
mpw_free_strings( &resultState, &loginState, NULL );
|
||||||
}
|
}
|
||||||
mpw_free( &masterKey, MPMasterKeySize );
|
mpw_free( &masterKey, MPMasterKeySize );
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ static bool mpw_marshal_write_json(
|
|||||||
if (!site->name || !strlen( site->name ))
|
if (!site->name || !strlen( site->name ))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char *content = NULL, *loginContent = NULL;
|
const char *resultState = NULL, *loginState = NULL;
|
||||||
if (!user->redacted) {
|
if (!user->redacted) {
|
||||||
// Clear Text
|
// Clear Text
|
||||||
mpw_free( &masterKey, MPMasterKeySize );
|
mpw_free( &masterKey, MPMasterKeySize );
|
||||||
@ -268,28 +268,28 @@ static bool mpw_marshal_write_json(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
content = mpw_siteResult( masterKey, site->name, site->counter,
|
resultState = mpw_siteResult( masterKey, site->name, site->counter,
|
||||||
MPKeyPurposeAuthentication, NULL, site->type, site->content, site->algorithm );
|
MPKeyPurposeAuthentication, NULL, site->resultType, site->resultState, site->algorithm );
|
||||||
loginContent = mpw_siteResult( masterKey, site->name, MPCounterValueInitial,
|
loginState = mpw_siteResult( masterKey, site->name, MPCounterValueInitial,
|
||||||
MPKeyPurposeIdentification, NULL, site->loginType, site->loginContent, site->algorithm );
|
MPKeyPurposeIdentification, NULL, site->loginType, site->loginState, site->algorithm );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Redacted
|
// Redacted
|
||||||
if (site->type & MPSiteFeatureExportContent && site->content && strlen( site->content ))
|
if (site->resultType & MPSiteFeatureExportContent && site->resultState && strlen( site->resultState ))
|
||||||
content = mpw_strdup( site->content );
|
resultState = mpw_strdup( site->resultState );
|
||||||
if (site->loginType & MPSiteFeatureExportContent && site->loginContent && strlen( site->loginContent ))
|
if (site->loginType & MPSiteFeatureExportContent && site->loginState && strlen( site->loginState ))
|
||||||
loginContent = mpw_strdup( site->loginContent );
|
loginState = mpw_strdup( site->loginState );
|
||||||
}
|
}
|
||||||
|
|
||||||
json_object *json_site = json_object_new_object();
|
json_object *json_site = json_object_new_object();
|
||||||
json_object_object_add( json_sites, site->name, json_site );
|
json_object_object_add( json_sites, site->name, json_site );
|
||||||
json_object_object_add( json_site, "type", json_object_new_int( (int32_t)site->type ) );
|
json_object_object_add( json_site, "type", json_object_new_int( (int32_t)site->resultType ) );
|
||||||
json_object_object_add( json_site, "counter", json_object_new_int( (int32_t)site->counter ) );
|
json_object_object_add( json_site, "counter", json_object_new_int( (int32_t)site->counter ) );
|
||||||
json_object_object_add( json_site, "algorithm", json_object_new_int( (int32_t)site->algorithm ) );
|
json_object_object_add( json_site, "algorithm", json_object_new_int( (int32_t)site->algorithm ) );
|
||||||
if (content)
|
if (resultState)
|
||||||
json_object_object_add( json_site, "password", json_object_new_string( content ) );
|
json_object_object_add( json_site, "password", json_object_new_string( resultState ) );
|
||||||
if (loginContent)
|
if (loginState)
|
||||||
json_object_object_add( json_site, "login_name", json_object_new_string( loginContent ) );
|
json_object_object_add( json_site, "login_name", json_object_new_string( loginState ) );
|
||||||
json_object_object_add( json_site, "login_type", json_object_new_int( (int32_t)site->loginType ) );
|
json_object_object_add( json_site, "login_type", json_object_new_int( (int32_t)site->loginType ) );
|
||||||
|
|
||||||
json_object_object_add( json_site, "uses", json_object_new_int( (int32_t)site->uses ) );
|
json_object_object_add( json_site, "uses", json_object_new_int( (int32_t)site->uses ) );
|
||||||
@ -310,14 +310,14 @@ static bool mpw_marshal_write_json(
|
|||||||
|
|
||||||
if (!user->redacted) {
|
if (!user->redacted) {
|
||||||
// Clear Text
|
// Clear Text
|
||||||
const char *answerContent = mpw_siteResult( masterKey, site->name, MPCounterValueInitial,
|
const char *answerState = mpw_siteResult( masterKey, site->name, MPCounterValueInitial,
|
||||||
MPKeyPurposeRecovery, question->keyword, question->type, question->content, site->algorithm );
|
MPKeyPurposeRecovery, question->keyword, question->type, question->state, site->algorithm );
|
||||||
json_object_object_add( json_site_question, "answer", json_object_new_string( answerContent ) );
|
json_object_object_add( json_site_question, "answer", json_object_new_string( answerState ) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Redacted
|
// Redacted
|
||||||
if (site->type & MPSiteFeatureExportContent && question->content && strlen( question->content ))
|
if (site->resultType & MPSiteFeatureExportContent && question->state && strlen( question->state ))
|
||||||
json_object_object_add( json_site_question, "answer", json_object_new_string( question->content ) );
|
json_object_object_add( json_site_question, "answer", json_object_new_string( question->state ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -328,7 +328,7 @@ static bool mpw_marshal_write_json(
|
|||||||
if (json_object_object_length( json_site_mpw ))
|
if (json_object_object_length( json_site_mpw ))
|
||||||
json_object_object_add( json_site, "_ext_mpw", json_site_mpw );
|
json_object_object_add( json_site, "_ext_mpw", json_site_mpw );
|
||||||
|
|
||||||
mpw_free_strings( &content, &loginContent, NULL );
|
mpw_free_strings( &resultState, &loginState, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
mpw_string_pushf( out, "%s\n", json_object_to_json_string_ext( json_file,
|
mpw_string_pushf( out, "%s\n", json_object_to_json_string_ext( json_file,
|
||||||
@ -512,7 +512,7 @@ static MPMarshalledUser *mpw_marshal_read_flat(
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Site
|
// Site
|
||||||
char *siteLoginName = NULL, *siteName = NULL, *siteContent = NULL;
|
char *siteName = NULL, *siteResultState = NULL, *siteLoginState = NULL;
|
||||||
char *str_lastUsed = NULL, *str_uses = NULL, *str_type = NULL, *str_algorithm = NULL, *str_counter = NULL;
|
char *str_lastUsed = NULL, *str_uses = NULL, *str_type = NULL, *str_algorithm = NULL, *str_counter = NULL;
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case 0: {
|
case 0: {
|
||||||
@ -525,9 +525,9 @@ static MPMarshalledUser *mpw_marshal_read_flat(
|
|||||||
mpw_free_string( &typeAndVersion );
|
mpw_free_string( &typeAndVersion );
|
||||||
}
|
}
|
||||||
str_counter = mpw_strdup( "1" );
|
str_counter = mpw_strdup( "1" );
|
||||||
siteLoginName = NULL;
|
siteLoginState = NULL;
|
||||||
siteName = mpw_get_token( &positionInLine, endOfLine, "\t\n" );
|
siteName = mpw_get_token( &positionInLine, endOfLine, "\t\n" );
|
||||||
siteContent = mpw_get_token( &positionInLine, endOfLine, "\n" );
|
siteResultState = mpw_get_token( &positionInLine, endOfLine, "\n" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
@ -540,9 +540,9 @@ static MPMarshalledUser *mpw_marshal_read_flat(
|
|||||||
str_counter = mpw_strdup( strtok( NULL, "" ) );
|
str_counter = mpw_strdup( strtok( NULL, "" ) );
|
||||||
mpw_free_string( &typeAndVersionAndCounter );
|
mpw_free_string( &typeAndVersionAndCounter );
|
||||||
}
|
}
|
||||||
siteLoginName = mpw_get_token( &positionInLine, endOfLine, "\t\n" );
|
siteLoginState = mpw_get_token( &positionInLine, endOfLine, "\t\n" );
|
||||||
siteName = mpw_get_token( &positionInLine, endOfLine, "\t\n" );
|
siteName = mpw_get_token( &positionInLine, endOfLine, "\t\n" );
|
||||||
siteContent = mpw_get_token( &positionInLine, endOfLine, "\n" );
|
siteResultState = mpw_get_token( &positionInLine, endOfLine, "\n" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -592,31 +592,31 @@ static MPMarshalledUser *mpw_marshal_read_flat(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (siteContent && strlen( siteContent ))
|
if (siteResultState && strlen( siteResultState ))
|
||||||
site->content = mpw_siteState( masterKey, site->name, site->counter,
|
site->resultState = mpw_siteState( masterKey, site->name, site->counter,
|
||||||
MPKeyPurposeAuthentication, NULL, site->type, siteContent, site->algorithm );
|
MPKeyPurposeAuthentication, NULL, site->resultType, siteResultState, site->algorithm );
|
||||||
if (siteLoginName && strlen( siteLoginName ))
|
if (siteLoginState && strlen( siteLoginState ))
|
||||||
site->loginContent = mpw_siteState( masterKey, site->name, MPCounterValueInitial,
|
site->loginState = mpw_siteState( masterKey, site->name, MPCounterValueInitial,
|
||||||
MPKeyPurposeIdentification, NULL, site->loginType, siteLoginName, site->algorithm );
|
MPKeyPurposeIdentification, NULL, site->loginType, siteLoginState, site->algorithm );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Redacted
|
// Redacted
|
||||||
if (siteContent && strlen( siteContent ))
|
if (siteResultState && strlen( siteResultState ))
|
||||||
site->content = mpw_strdup( siteContent );
|
site->resultState = mpw_strdup( siteResultState );
|
||||||
if (siteLoginName && strlen( siteLoginName ))
|
if (siteLoginState && strlen( siteLoginState ))
|
||||||
site->loginContent = mpw_strdup( siteLoginName );
|
site->loginState = mpw_strdup( siteLoginState );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error->type = MPMarshalErrorMissing;
|
error->type = MPMarshalErrorMissing;
|
||||||
error->description = mpw_str(
|
error->description = mpw_str(
|
||||||
"Missing one of: lastUsed=%s, uses=%s, type=%s, version=%s, counter=%s, loginName=%s, siteName=%s",
|
"Missing one of: lastUsed=%s, uses=%s, type=%s, version=%s, counter=%s, loginName=%s, siteName=%s",
|
||||||
str_lastUsed, str_uses, str_type, str_algorithm, str_counter, siteLoginName, siteName );
|
str_lastUsed, str_uses, str_type, str_algorithm, str_counter, siteLoginState, siteName );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mpw_free_strings( &str_lastUsed, &str_uses, &str_type, &str_algorithm, &str_counter, NULL );
|
mpw_free_strings( &str_lastUsed, &str_uses, &str_type, &str_algorithm, &str_counter, NULL );
|
||||||
mpw_free_strings( &siteLoginName, &siteName, &siteContent, NULL );
|
mpw_free_strings( &siteLoginState, &siteName, &siteResultState, NULL );
|
||||||
}
|
}
|
||||||
mpw_free_strings( &fullName, &keyID, NULL );
|
mpw_free_strings( &fullName, &keyID, NULL );
|
||||||
mpw_free( &masterKey, MPMasterKeySize );
|
mpw_free( &masterKey, MPMasterKeySize );
|
||||||
@ -744,8 +744,8 @@ static MPMarshalledUser *mpw_marshal_read_json(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
MPCounterValue siteCounter = (MPCounterValue)value;
|
MPCounterValue siteCounter = (MPCounterValue)value;
|
||||||
const char *siteContent = mpw_get_json_string( json_site.val, "password", NULL );
|
const char *siteResultState = mpw_get_json_string( json_site.val, "password", NULL );
|
||||||
const char *siteLoginName = mpw_get_json_string( json_site.val, "login_name", NULL );
|
const char *siteLoginState = mpw_get_json_string( json_site.val, "login_name", NULL );
|
||||||
MPResultType siteLoginType = (MPResultType)mpw_get_json_int( json_site.val, "login_type", MPResultTypeTemplateName );
|
MPResultType siteLoginType = (MPResultType)mpw_get_json_int( json_site.val, "login_type", MPResultTypeTemplateName );
|
||||||
unsigned int siteUses = (unsigned int)mpw_get_json_int( json_site.val, "uses", 0 );
|
unsigned int siteUses = (unsigned int)mpw_get_json_int( json_site.val, "uses", 0 );
|
||||||
str_lastUsed = mpw_get_json_string( json_site.val, "last_used", NULL );
|
str_lastUsed = mpw_get_json_string( json_site.val, "last_used", NULL );
|
||||||
@ -776,19 +776,19 @@ static MPMarshalledUser *mpw_marshal_read_json(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (siteContent && strlen( siteContent ))
|
if (siteResultState && strlen( siteResultState ))
|
||||||
site->content = mpw_siteState( masterKey, site->name, site->counter,
|
site->resultState = mpw_siteState( masterKey, site->name, site->counter,
|
||||||
MPKeyPurposeAuthentication, NULL, site->type, siteContent, site->algorithm );
|
MPKeyPurposeAuthentication, NULL, site->resultType, siteResultState, site->algorithm );
|
||||||
if (siteLoginName && strlen( siteLoginName ))
|
if (siteLoginState && strlen( siteLoginState ))
|
||||||
site->loginContent = mpw_siteState( masterKey, site->name, MPCounterValueInitial,
|
site->loginState = mpw_siteState( masterKey, site->name, MPCounterValueInitial,
|
||||||
MPKeyPurposeIdentification, NULL, site->loginType, siteLoginName, site->algorithm );
|
MPKeyPurposeIdentification, NULL, site->loginType, siteLoginState, site->algorithm );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Redacted
|
// Redacted
|
||||||
if (siteContent && strlen( siteContent ))
|
if (siteResultState && strlen( siteResultState ))
|
||||||
site->content = mpw_strdup( siteContent );
|
site->resultState = mpw_strdup( siteResultState );
|
||||||
if (siteLoginName && strlen( siteLoginName ))
|
if (siteLoginState && strlen( siteLoginState ))
|
||||||
site->loginContent = mpw_strdup( siteLoginName );
|
site->loginState = mpw_strdup( siteLoginState );
|
||||||
}
|
}
|
||||||
|
|
||||||
json_object *json_site_questions = mpw_get_json_section( json_site.val, "questions" );
|
json_object *json_site_questions = mpw_get_json_section( json_site.val, "questions" );
|
||||||
@ -796,19 +796,19 @@ static MPMarshalledUser *mpw_marshal_read_json(
|
|||||||
json_object_iter json_site_question;
|
json_object_iter json_site_question;
|
||||||
json_object_object_foreachC( json_site_questions, json_site_question ) {
|
json_object_object_foreachC( json_site_questions, json_site_question ) {
|
||||||
MPMarshalledQuestion *question = mpw_marshal_question( site, json_site_question.key );
|
MPMarshalledQuestion *question = mpw_marshal_question( site, json_site_question.key );
|
||||||
const char *answerContent = mpw_get_json_string( json_site_question.val, "answer", NULL );
|
const char *answerState = mpw_get_json_string( json_site_question.val, "answer", NULL );
|
||||||
question->type = (MPResultType)mpw_get_json_int( json_site_question.val, "type", MPResultTypeTemplatePhrase );
|
question->type = (MPResultType)mpw_get_json_int( json_site_question.val, "type", MPResultTypeTemplatePhrase );
|
||||||
|
|
||||||
if (!user->redacted) {
|
if (!user->redacted) {
|
||||||
// Clear Text
|
// Clear Text
|
||||||
if (answerContent && strlen( answerContent ))
|
if (answerState && strlen( answerState ))
|
||||||
question->content = mpw_siteState( masterKey, site->name, MPCounterValueInitial,
|
question->state = mpw_siteState( masterKey, site->name, MPCounterValueInitial,
|
||||||
MPKeyPurposeRecovery, question->keyword, question->type, answerContent, site->algorithm );
|
MPKeyPurposeRecovery, question->keyword, question->type, answerState, site->algorithm );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Redacted
|
// Redacted
|
||||||
if (answerContent && strlen( answerContent ))
|
if (answerState && strlen( answerState ))
|
||||||
question->content = mpw_strdup( answerContent );
|
question->state = mpw_strdup( answerState );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,18 +66,19 @@ typedef struct MPMarshalError {
|
|||||||
|
|
||||||
typedef struct MPMarshalledQuestion {
|
typedef struct MPMarshalledQuestion {
|
||||||
const char *keyword;
|
const char *keyword;
|
||||||
const char *content;
|
const char *state;
|
||||||
MPResultType type;
|
MPResultType type;
|
||||||
} MPMarshalledQuestion;
|
} MPMarshalledQuestion;
|
||||||
|
|
||||||
typedef struct MPMarshalledSite {
|
typedef struct MPMarshalledSite {
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *content;
|
|
||||||
MPResultType type;
|
|
||||||
MPCounterValue counter;
|
|
||||||
MPAlgorithmVersion algorithm;
|
MPAlgorithmVersion algorithm;
|
||||||
|
|
||||||
const char *loginContent;
|
const char *resultState;
|
||||||
|
MPResultType resultType;
|
||||||
|
MPCounterValue counter;
|
||||||
|
|
||||||
|
const char *loginState;
|
||||||
MPResultType loginType;
|
MPResultType loginType;
|
||||||
|
|
||||||
const char *url;
|
const char *url;
|
||||||
|
Loading…
Reference in New Issue
Block a user