si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave2, 0, 0, PR_TRUE); si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave2, 0, 0, PR_TRUE);
si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave, 0, 0, PR_TRUE); si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave, 0, 0, PR_TRUE);
si_SaveSignonDataLocked(PRBool fullSave) {  si_SignonURLStruct * url;  si_SignonUserStruct * user;  si_SignonDataStruct * data;  si_Reject * reject;  nsKeyType writeCount = 0;  PRBool fullSave2 = fullSave || si_oldFormat;  /* do nothing if signon list has not changed */  if(!si_signon_list_changed) {    return(-1);  }  if (fullSave2) {    PRUnichar * message = Wallet_Localize("IncorrectKey_TryAgain?");    if (si_KeyTimedOut()) {      SI_RemoveAllSignonData();    }    while (!si_SetKey()) {      if (Wallet_CancelKey() || (Wallet_KeySize() < 0) || !si_ConfirmYN(message)) {        Recycle(message);        return 1;      }    }    Recycle(message);    si_KeyResetTime();    /* do not save signons if user didn't know the key */    if (!si_KeySet()) {      return(-1);    }  }#ifdef APPLE_KEYCHAIN  if (KeychainManagerAvailable()) {    return si_SaveSignonDataInKeychain();  }#endif  /* do nothing if we are unable to open file that contains signon list */  nsFileSpec dirSpec;  nsresult rv = Wallet_ProfileDirectory(dirSpec);  if (NS_FAILED(rv)) {    return 0;  }  if (si_oldFormat) {    /* change name of signonFileNameP from "xxxxxxxx.psw" to "xxxxxxxx.p" */        signonFileNameP[10] = '\0';    SI_SetCharPref(pref_SignonFileNameP, signonFileNameP);    /* create signonFileNameU and set it to "xxxxxxxx.u" */    signonFileNameU = PL_strdup(signonFileNameP); /* set it to "xxxxxxxx.p" */    signonFileNameU[9] = 'u'; /* change .p to .u */    SI_SetCharPref(pref_SignonFileNameU, signonFileNameU);    si_oldFormat = PR_FALSE;  }  nsOutputFileStream strmu(dirSpec + signonFileNameU);  if (!strmu.is_open()) {    return 0;  }  nsOutputFileStream strmp    (fullSave2 ? (dirSpec+signonFileNameP) : dirSpec); // not used if !fullSave  if (fullSave2 && !strmp.is_open()) {    return 0;  }  /* format for head of file shall be:   * format revision number   * unused at present   * saveCount   * unused at present   * writeCount   */  /* write out the header info */  /* format revision number */  si_WriteLine(strmu, strmp, nsAutoString(HEADER_VERSION_1), PR_FALSE, fullSave2, 0, 0, PR_TRUE);  /* saveCount */  nsAutoString buffer;  buffer = "";  saveCountP += 16; /* preserve low order four bits which designate the file type */  buffer.Append(PRInt32(saveCountP),10);  si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave2, 0, 0, PR_TRUE);  si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave2, 0, 0, PR_TRUE);  /* writeCount */  buffer = "";  buffer.Append(PRInt32(writeCount),10);  si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave2, 0, 0, PR_TRUE);  si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave2, 0, 0, PR_TRUE);  Wallet_StreamGeneratorReset();  /* format for next part of file shall be:   * URLName -- first url/username on reject list   * userName   * URLName -- second url/username on reject list   * userName   * ...     -- etc.   * .       -- end of list   */  /* write out reject list */  if (si_reject_list) {    PRInt32 rejectCount = LIST_COUNT(si_reject_list);    for (PRInt32 i=0; i<rejectCount; i++) {      reject = NS_STATIC_CAST(si_Reject*, si_reject_list->ElementAt(i));      si_WriteLine(strmu, strmp, nsAutoString(reject->URLName), PR_FALSE, fullSave2);    }  }  si_WriteLine(strmu, strmp, nsAutoString("."), PR_FALSE, fullSave2);  /* format for cached logins shall be:   * url LINEBREAK {name LINEBREAK value LINEBREAK}*  . LINEBREAK   * if type is password, name is preceded by an asterisk (*)   */  /* write out each URL node */  if((si_signon_list)) {    PRInt32 urlCount = LIST_COUNT(si_signon_list);    for (PRInt32 i2=0; i2<urlCount; i2++) {      url = NS_STATIC_CAST(si_SignonURLStruct*, si_signon_list->ElementAt(i2));      /* write out each user node of the URL node */      PRInt32 userCount = LIST_COUNT(url->signonUser_list);      for (PRInt32 i3=0; i3<userCount; i3++) {        user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list->ElementAt(i3));        si_WriteLine          (strmu, strmp, nsAutoString(url->URLName), PR_FALSE, fullSave2);        /* write out each data node of the user node */        PRInt32 dataCount = LIST_COUNT(user->signonData_list);        for (PRInt32 i4=0; i4<dataCount; i4++) {          data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list->ElementAt(i4));          if (data->isPassword) {            si_WriteChar(strmu, '*');          }          si_WriteLine(strmu, strmp, nsAutoString(data->name), PR_FALSE, fullSave2);          si_WriteLine(strmu, strmp, nsAutoString(data->value), PR_TRUE,            fullSave2, saveCountP, &writeCount);        }        si_WriteLine(strmu, strmp, nsAutoString("."), PR_FALSE, fullSave2);      }    }  }  si_signon_list_changed = PR_FALSE;  strmu.flush();  strmu.close();  if (fullSave2) {    strmp.flush();    strmp.close();  }  return 0;}