static bool cgi_send_cookies(void) { bool t_success = true; char *t_cookie_header = NULL; MCExecPoint ep; for (uint32_t i = 0; t_success && i < MCservercgicookiecount; i++) { t_success = MCCStringFormat(t_cookie_header, "Set-Cookie: %s=%s", MCservercgicookies[i].name, MCservercgicookies[i].value); if (t_success && MCservercgicookies[i].expires != 0) { ep.setuint(MCservercgicookies[i].expires); t_success = MCD_convert(ep, CF_SECONDS, CF_UNDEFINED, CF_INTERNET_DATE, CF_UNDEFINED); if (t_success) { MCString t_date; t_date = ep.getsvalue(); t_success = MCCStringAppendFormat(t_cookie_header, "; Expires=%.*s", t_date.getlength(), t_date.getstring()); } } if (t_success && MCservercgicookies[i].path != NULL) t_success = MCCStringAppendFormat(t_cookie_header, "; Path=%s", MCservercgicookies[i].path); if (t_success && MCservercgicookies[i].domain != NULL) t_success = MCCStringAppendFormat(t_cookie_header, "; Domain=%s", MCservercgicookies[i].domain); if (t_success && MCservercgicookies[i].secure) t_success = MCCStringAppend(t_cookie_header, "; Secure"); if (t_success && MCservercgicookies[i].http_only) t_success = MCCStringAppend(t_cookie_header, "; HttpOnly"); if (t_success) t_success = MCCStringAppend(t_cookie_header, "\n"); if (t_success) t_success = IO_NORMAL == MCS_write(t_cookie_header, 1, MCCStringLength(t_cookie_header), IO_stdout); MCCStringFree(t_cookie_header); t_cookie_header = NULL; } return t_success; }
Exec_stat MCConvert::exec(MCExecPoint &ep) { MCresult->clear(False); if (container != NULL) { if (container->eval(ep) != ES_NORMAL) { MCeerror->add (EE_CONVERT_CANTGET, line, pos); return ES_ERROR; } } else if (source->eval(ep) != ES_NORMAL) { MCeerror->add (EE_CONVERT_CANTGET, line, pos); return ES_ERROR; } if (!MCD_convert(ep, fform, fsform, pform, sform)) { MCresult->sets("invalid date"); return ES_NORMAL; } Exec_stat stat; if (it != NULL) stat = it->set (ep); else stat = container->set (ep, PT_INTO); if (stat != ES_NORMAL) { MCeerror->add (EE_CONVERT_CANTSET, line, pos, ep.getsvalue()); return ES_ERROR; } return ES_NORMAL; }
void MCSort::additem(MCExecPoint &ep, MCSortnode *&items, uint4 &nitems, Sort_type form, MCString &s, MCExpression *by) { if (by != NULL) { MCerrorlock++; ep.setsvalue(s); MCeach->store(ep, False); if (by->eval(ep) == ES_NORMAL) s = ep.getsvalue(); else s = MCnullmcstring; MCerrorlock--; } switch (form) { case ST_DATETIME: ep.setsvalue(s); if (MCD_convert(ep, CF_UNDEFINED, CF_UNDEFINED, CF_SECONDS, CF_UNDEFINED)) { if (!MCU_stor8(ep.getsvalue(), items[nitems].nvalue)) items[nitems].nvalue = -MAXREAL8; } else items[nitems].nvalue = -MAXREAL8; break; case ST_NUMERIC: { const char *sptr = s.getstring(); uint4 length = s.getlength(); // MW-2013-03-21: [[ Bug ]] Make sure we skip any whitespace before the // number starts - making it consistent with string->number conversions // elsewhere. MCU_skip_spaces(sptr, length); // REVIEW - at the moment the numeric prefix of the string is used to // derive the sort key e.g. 1000abc would get processed as 1000. while (length && (isdigit((uint1)*sptr) || *sptr == '.' || *sptr == '-' || *sptr == '+')) { sptr++; length--; } s.setlength(s.getlength() - length); if (!MCU_stor8(s, items[nitems].nvalue)) items[nitems].nvalue = -MAXREAL8; } break; default: if (ep.getcasesensitive() && by == NULL) items[nitems].svalue = (char *)s.getstring(); else if (ep.getcasesensitive()) items[nitems].svalue = s.clone(); else { #if defined(_MAC_DESKTOP) || defined(_IOS_MOBILE) if (form == ST_INTERNATIONAL) { extern char *MCSystemLowercaseInternational(const MCString& s); items[nitems].svalue = MCSystemLowercaseInternational(s); } else #endif { items[nitems].svalue = new char[s.getlength() + 1]; MCU_lower(items[nitems].svalue, s); items[nitems].svalue[s.getlength()] = '\0'; } } break; } nitems++; }