if (NET_GetCookieBehaviorPref() == NET_DontUse) {
if(NET_GetCookieBehaviorPref() == NET_DontUse) return;  if(!cookies_changed) return;  net_lock_cookie_list(); list_ptr = net_cookie_list; if(!(list_ptr)) { net_unlock_cookie_list(); return; }  if(!(fp = NET_XP_FileOpen(NULL, xpHTTPCookie, XP_FILE_WRITE))) { net_unlock_cookie_list(); return; }  len = NET_XP_FileWrite("# Netscape HTTP Cookie 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_list(); return; }  /* format shall be: * * host \t is_domain \t path \t secure \t expires \t name \t cookie * * is_domain is TRUE or FALSE * secure is TRUE or FALSE * expires is a time_t integer * cookie can have tabs */ while((cookie_s = (net_CookieStruct *) XP_ListNextObject(list_ptr)) != NULL) { if(cookie_s->expires < cur_date) continue;  /* don't write entry if cookie has expired * or has no expiration date */  len = NET_XP_FileWrite(cookie_s->host, -1, fp); if (len < 0) { NET_XP_FileClose(fp); net_unlock_cookie_list(); return; } NET_XP_FileWrite("\t", 1, fp);  if(cookie_s->is_domain) NET_XP_FileWrite("TRUE", -1, fp); else NET_XP_FileWrite("FALSE", -1, fp); NET_XP_FileWrite("\t", 1, fp);  NET_XP_FileWrite(cookie_s->path, -1, fp); NET_XP_FileWrite("\t", 1, fp);  HG74640 NET_XP_FileWrite("FALSE", -1, fp); NET_XP_FileWrite("\t", 1, fp);  PR_snprintf(date_string, sizeof(date_string), "%lu", cookie_s->expires); NET_XP_FileWrite(date_string, -1, fp); NET_XP_FileWrite("\t", 1, fp);  NET_XP_FileWrite(cookie_s->name, -1, fp); NET_XP_FileWrite("\t", 1, fp);  NET_XP_FileWrite(cookie_s->cookie, -1, fp); len = NET_XP_FileWrite(LINEBREAK, -1, fp); if (len < 0) { NET_XP_FileClose(fp); net_unlock_cookie_list(); return; } }  cookies_changed = FALSE;  NET_XP_FileClose(fp); net_unlock_cookie_list();
net_SaveCookies(){  XP_List * list_ptr;  net_CookieStruct * cookie_s;  time_t cur_date = time(NULL);  char date_string[36];  if (NET_GetCookieBehaviorPref() == NET_DontUse) {    return;  }  if (!cookies_changed) {    return;  }  net_lock_cookie_list();  list_ptr = net_cookie_list;  if (!(list_ptr)) {    net_unlock_cookie_list();    return;  }  nsFileSpec dirSpec;  nsresult rv = cookie_ProfileDirectory(dirSpec);  if (NS_FAILED(rv)) {    net_unlock_cookie_list();    return;  }  nsOutputFileStream strm(dirSpec + "cookies.txt");  if (!strm.is_open()) {    /* file doesn't exist -- that's not an error */    net_unlock_cookie_list();    return;  }  cookie_Put(strm, "# Netscape HTTP Cookie 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 is_domain \t path \t secure \t expires \t name \t cookie   *   * is_domain is TRUE or FALSE   * xxx is TRUE or FALSE     * expires is a time_t integer   * cookie can have tabs   */  while((cookie_s = (net_CookieStruct *) XP_ListNextObject(list_ptr)) != NULL) {    if (cookie_s->expires < cur_date) {      /* don't write entry if cookie has expired or has no expiration date */      continue;    }    cookie_Put(strm, cookie_s->host);		    if (cookie_s->is_domain) {      cookie_Put(strm, "\tTRUE\t");    } else {      cookie_Put(strm, "\tFALSE\t");    }    cookie_Put(strm, cookie_s->path);    if (cookie_s->xxx) {      cookie_Put(strm, "\tTRUE\t");    } else {      cookie_Put(strm, "\tFALSE\t");    }    PR_snprintf(date_string, sizeof(date_string), "%lu", cookie_s->expires);    cookie_Put(strm, date_string);    cookie_Put(strm, "\t");    cookie_Put(strm, cookie_s->name);    cookie_Put(strm, "\t");    cookie_Put(strm, cookie_s->cookie);    cookie_Put(strm, "\n");  }  cookies_changed = FALSE;  strm.flush();  strm.close();  net_unlock_cookie_list();}