if (!username) { char * s = (char*) PL_strchr(urlname, '@'); if (s) {  *s = '\0'; StrAllocCopy(username, urlname); *s = '@'; } else {  StrAllocCopy(username, urlname); } }
SINGSIGN_PromptPassword    (const PRUnichar *text, PRUnichar **pwd, PRBool *returnValue, char* urlname) {  nsresult res;  NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &res);  if (NS_FAILED(res)) {    return res;  }  /* do only the dialog if signon preference is not enabled */  if (!si_GetSignonRememberingPref()){    return dialog->PromptPassword(text, pwd, returnValue);  }  /* get host part of URL which is of form user@host */  char * host = (char*) PL_strchr(urlname, '@');  if (host) {    /* @ found, host is URL part following the @ */    host++; /* host is part of URL after the @ */  } else {    host = urlname;  }  /* get previous password used with this username */  char *password=0, *username=0;  si_RestoreOldSignonDataFromBrowser(host, PR_TRUE, &username, &password);  /* return if a password was found */  if (password) {    *pwd = nsAutoString(password).ToNewUnicode();    *returnValue = PR_TRUE;    return NS_OK;  }  /* if no password found, get new password from user */  res = dialog->PromptPassword(text, pwd, returnValue);  if (NS_FAILED(res) || !(*returnValue)) {    /* user pressed Cancel */    return res;  }          /* extract username from URLName */  if (!username) {    char * s = (char*) PL_strchr(urlname, '@');    if (s) {      /* @ found, username is URL part preceding the @ */      *s = '\0';      StrAllocCopy(username, urlname);      *s = '@';    } else {      /* no @ found, use entire URL as username */      StrAllocCopy(username, urlname);    }  }  /* remember these values for next time */  password = nsString(*pwd).ToNewCString();  if (password && PL_strlen(password) && si_OkToSave(host, username)) {    si_RememberSignonDataFromBrowser (host, username, password);  }  /* cleanup and return */  PR_FREEIF(username);  return NS_OK;}