if (!(net_cookie_permission_list)) {
if(!(net_cookie_permission_list)) { net_unlock_cookie_permission_list(); return; }  if(!(fp = NET_XP_FileOpen(NULL, xpHTTPCookiePermission, XP_FILE_WRITE))) { net_unlock_cookie_permission_list(); return; } len = NET_XP_FileWrite("# Netscape HTTP Cookie Permission File" LINEBREAK "# http: LINEBREAK "# This is a generated file!  Do not edit." LINEBREAK LINEBREAK, -1, fp);  if (len < 0) { NET_XP_FileClose(fp); net_unlock_cookie_permission_list(); return; }  /* format shall be: * host \t permission <optional trust label information > */ while((cookie_permission_s = (net_CookiePermissionStruct *) XP_ListNextObject(list_ptr)) != NULL) { len = NET_XP_FileWrite(cookie_permission_s->host, -1, fp); if (len < 0) { NET_XP_FileClose(fp); net_unlock_cookie_permission_list(); return; }  NET_XP_FileWrite("\t", 1, fp);  if(cookie_permission_s->permission) { NET_XP_FileWrite("TRUE", -1, fp); } else { NET_XP_FileWrite("FALSE", -1, fp); }  len = NET_XP_FileWrite(LINEBREAK, -1, fp); if (len < 0) { NET_XP_FileClose(fp); net_unlock_cookie_permission_list(); return; } }  /* save current state of cookie nag-box's checkmark */ NET_XP_FileWrite("@@@@", -1, fp); NET_XP_FileWrite("\t", 1, fp); if (cookie_remember_checked) { NET_XP_FileWrite("TRUE", -1, fp); } else { NET_XP_FileWrite("FALSE", -1, fp); } NET_XP_FileWrite(LINEBREAK, -1, fp);  cookie_permissions_changed = FALSE; NET_XP_FileClose(fp);
net_SaveCookiePermissions(){  XP_List * list_ptr;  net_CookiePermissionStruct * cookie_permission_s;  if (NET_GetCookieBehaviorPref() == NET_DontUse) {    return;  }  if (!cookie_permissions_changed) {    return;  }  net_lock_cookie_permission_list();  list_ptr = net_cookie_permission_list;  if (!(net_cookie_permission_list)) {    net_unlock_cookie_permission_list();    return;  }  nsFileSpec dirSpec;  nsresult rval = cookie_ProfileDirectory(dirSpec);  if (NS_FAILED(rval)) {    net_unlock_cookie_permission_list();    return;  }  nsOutputFileStream strm(dirSpec + "cookperm.txt");  if (!strm.is_open()) {    net_unlock_cookie_permission_list();    return;  }  cookie_Put(strm, "# Netscape HTTP Cookie Permission File\n");  cookie_Put(strm, "# http://www.netscape.com/newsref/std/cookie_spec.html\n");  cookie_Put(strm, "# This is a generated file!  Do not edit.\n\n");  /* format shall be:   * host \t permission   */  while ((cookie_permission_s = (net_CookiePermissionStruct *)    XP_ListNextObject(list_ptr)) != NULL) {    cookie_Put(strm, cookie_permission_s->host);    if (cookie_permission_s->permission) {      cookie_Put(strm, "\tTRUE\n");    } else {      cookie_Put(strm, "\tFALSE\n");    }  }  /* save current state of cookie nag-box's checkmark */  if (cookie_remember_checked) {    cookie_Put(strm, "@@@@\tTRUE\n");  } else {    cookie_Put(strm, "@@@@\tFALSE\n");  }  cookie_permissions_changed = FALSE;  strm.flush();  strm.close();  net_unlock_cookie_permission_list();}