host = (nsAutoString(":") + URLName).ToNewCString();
res = MangleUrl(URLName, &host); if (NS_FAILED(res)) return PR_FALSE;
si_RemoveUser(char *URLName, nsAutoString userName, PRBool save, PRBool strip) {  nsresult res;  si_SignonURLStruct * url;  si_SignonUserStruct * user;  si_SignonDataStruct * data;  /* do nothing if signon preference is not enabled */  if (!si_GetSignonRememberingPref()) {    return PR_FALSE;  }  /* convert URLName to a uri so we can parse out the username and hostname */  char* host = nsnull;  if (strip) {    if (URLName) {      nsCOMPtr<nsIURL> uri;      nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, NS_GET_IID(nsIURL), (void **) getter_AddRefs(uri));      uri->SetSpec((char *)URLName);      /* uri is of the form <scheme>://<username>:<password>@<host>:<portnumber>/<pathname>) */      /* get host part of the uri */      res = uri->GetHost(&host);      if (NS_FAILED(res)) {        return PR_FALSE;      }      /* if no username given, extract it from uri -- note: prehost is <username>:<password> */      if (userName.Length() == 0) {        char * userName2 = nsnull;        res = uri->GetPreHost(&userName2);        if (NS_FAILED(res)) {          PR_FREEIF(host);          return PR_FALSE;        }        if (userName2) {          userName = nsAutoString(userName2);          PR_FREEIF(userName2);          PRInt32 colon = userName.FindChar(':');          if (colon != -1) {            userName.Truncate(colon);          }        }      }    }  } else {    host = (nsAutoString(":") + URLName).ToNewCString();  }  si_lock_signon_list();  /* get URL corresponding to host */  url = si_GetURL(host);  if (!url) {    /* URL not found */    si_unlock_signon_list();    PR_FREEIF(host);    return PR_FALSE;  }  /* free the data in each node of the specified user node for this URL */  if (userName.Length() == 0) {    /* no user specified so remove the first one */    user = (si_SignonUserStruct *) (url->signonUser_list->ElementAt(0));  } else {    /* find the specified user */    PRInt32 userCount = LIST_COUNT(url->signonUser_list);    for (PRInt32 i=0; i<userCount; i++) {      user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list->ElementAt(i));      PRInt32 dataCount = LIST_COUNT(user->signonData_list);      for (PRInt32 ii=0; ii<dataCount; ii++) {        data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list->ElementAt(ii));        if (data->value == userName) {          goto foundUser;        }      }    }    si_unlock_signon_list();    PR_FREEIF(host);    return PR_FALSE; /* user not found so nothing to remove */    foundUser: ;  }  /* free the data list */  delete user->signonData_list;  /* free the user node */  url->signonUser_list->RemoveElement(user);  /* remove this URL if it contains no more users */  if (LIST_COUNT(url->signonUser_list) == 0) {    PR_Free(url->URLName);    si_signon_list->RemoveElement(url);  }  /* write out the change to disk */  if (save) {    si_signon_list_changed = PR_TRUE;    si_SaveSignonDataLocked(PR_TRUE);  }  si_unlock_signon_list();  PR_FREEIF(host);  return PR_TRUE;}