char buffer[BUFFER_SIZE+1];
nsAutoString buffer;
SI_LoadSignonData(PRBool fullLoad) {  /*   * This routine is called initially with fullLoad set to PR_FALSE.  That will cause   * the main file (consisting of URLs and usernames but having dummy passwords) to   * be read in.  Later, when a password is needed for the first time, the internal   * table is flushed and this routine is called again to read in the main file   * along with the file containing the real passwords.   *   * This is done because the reading of the password file requires the user to   * give a password to unlock the file.  We don't want to bother the user until   * we absolutely have to.  So if he never goes to fill out a password form, he   * should never have to give his password to unlock the password file   */  char * URLName;  LO_FormSubmitData submit;  char* name_array[MAX_ARRAY_SIZE];  char* value_array[MAX_ARRAY_SIZE];  uint8 type_array[MAX_ARRAY_SIZE];  char buffer[BUFFER_SIZE+1];  PRBool badInput;  int i;  if (si_FullyLoaded && fullLoad) {    return 0;  }#ifdef APPLE_KEYCHAIN  if (KeychainManagerAvailable()) {    si_RemoveAllSignonData();    return si_LoadSignonDataFromKeychain();  }#endif  /* open the signon file */  nsFileSpec dirSpec;  nsresult rv = Wallet_ProfileDirectory(dirSpec);  if (NS_FAILED(rv)) {    return -1;  }  nsInputFileStream strm(dirSpec + "signon.tbl");  if (!strm.is_open()) {    return -1;  }  si_RemoveAllSignonData();  if (fullLoad) {    si_RestartKey();    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();  }  nsInputFileStream strmx(fullLoad ? (dirSpec+signonFileName) : dirSpec); // not used if !fullLoad  if (fullLoad && !strmx.is_open()) {    return -1;  }  /* read the reject list */  si_lock_signon_list();  while(!NS_FAILED(si_ReadLine(strm, strmx, buffer, PR_FALSE))) {    if (buffer[0] == '.') {      break; /* end of reject list */    }    si_StripLF(buffer);    URLName = NULL;    StrAllocCopy(URLName, buffer);    if (NS_FAILED(si_ReadLine(strm, strmx, buffer, PR_FALSE))) {      /* error in input file so give up */      badInput = PR_TRUE;      break;    }    si_StripLF(buffer);    si_PutReject(URLName, buffer, PR_FALSE);    PR_Free (URLName);  }  /* initialize the submit structure */  submit.name_array = (PA_Block)name_array;  submit.value_array = (PA_Block)value_array;  submit.type_array = (PA_Block)type_array;  /* read the URL line */  while(!NS_FAILED(si_ReadLine(strm, strmx, buffer, PR_FALSE))) {    si_StripLF(buffer);    URLName = NULL;    StrAllocCopy(URLName, buffer);    /* prepare to read the name/value pairs */    submit.value_cnt = 0;    badInput = PR_FALSE;    while(!NS_FAILED(si_ReadLine(strm, strmx, buffer, PR_FALSE))) {      /* line starting with . terminates the pairs for this URL entry */      if (buffer[0] == '.') {        break; /* end of URL entry */      }      /* line just read is the name part */      /* save the name part and determine if it is a password */      PRBool ret;      si_StripLF(buffer);      name_array[submit.value_cnt] = NULL;      if (buffer[0] == '*') {        type_array[submit.value_cnt] = FORM_TYPE_PASSWORD;        StrAllocCopy(name_array[submit.value_cnt], buffer+1);        ret = si_ReadLine(strm, strmx, buffer, fullLoad);      } else {        type_array[submit.value_cnt] = FORM_TYPE_TEXT;        StrAllocCopy(name_array[submit.value_cnt], buffer);        ret = si_ReadLine(strm, strmx, buffer, PR_FALSE);      }      /* read in and save the value part */      if(NS_FAILED(ret)) {        /* error in input file so give up */        badInput = PR_TRUE;        break;      }      si_StripLF(buffer);      value_array[submit.value_cnt] = NULL;      StrAllocCopy(value_array[submit.value_cnt++], buffer);      /* check for overruning of the arrays */      if (submit.value_cnt >= MAX_ARRAY_SIZE) {        break;      }    }    /* store the info for this URL into memory-resident data structure */    if (!URLName || PL_strlen(URLName) == 0) {      badInput = PR_TRUE;    }    if (!badInput) {      si_PutData(URLName, &submit, PR_FALSE);    }    /* free up all the allocations done for processing this URL */    PR_Free(URLName);    for (i=0; i<submit.value_cnt; i++) {      PR_Free(name_array[i]);      PR_Free(value_array[i]);    }    if (badInput) {      si_unlock_signon_list();      return (1);    }  }  si_unlock_signon_list();  si_PartiallyLoaded = PR_TRUE;  si_FullyLoaded = fullLoad;  return(0);}