Litstr must die, episode II.

Esse commit está contido em:
smith
2013-04-16 18:41:55 -07:00
commit de Sara Golemon
commit 89f5f70e42
19 arquivos alterados com 367 adições e 219 exclusões
+3 -1
Ver Arquivo
@@ -295,13 +295,15 @@ Variant ArrayUtil::Range(double low, double high, int64_t step /* = 1 */) {
return ret;
}
static const StaticString s_default("(default)");
Variant ArrayUtil::FromHdf(const Hdf &hdf) {
if (hdf.firstChild().exists()) {
Array ret = Array::Create();
const char *value = hdf.get();
if (value) {
ret.set("(default)", String(value, CopyString));
ret.set(s_default, String(value, CopyString));
}
for (Hdf child = hdf.firstChild(); child.exists(); child = child.next()) {
+23 -12
Ver Arquivo
@@ -306,19 +306,30 @@ bool File::lock(int operation, bool &wouldblock /* = false */) {
return true;
}
static const StaticString s_wrapper_type("wrapper_type");
static const StaticString s_stream_type("stream_type");
static const StaticString s_mode("mode");
static const StaticString s_unread_bytes("unread_bytes");
static const StaticString s_seekable("seekable");
static const StaticString s_uri("uri");
static const StaticString s_timed_out("timed_out");
static const StaticString s_blocked("blocked");
static const StaticString s_eof("eof");
static const StaticString s_wrapper_data("wrapper_data");
Array File::getMetaData() {
Array ret = Array::Create();
ret.set("wrapper_type", o_getClassName());
ret.set("stream_type", getStreamType());
ret.set("mode", String(m_mode));
ret.set("unread_bytes", 0);
ret.set("seekable", seekable());
ret.set("uri", String(m_name));
ret.set("timed_out", false);
ret.set("blocked", true);
ret.set("eof", eof());
ret.set("wrapper_data", getWrapperMetaData());
return ret;
ArrayInit ret(10);
ret.set(s_wrapper_type, o_getClassName());
ret.set(s_stream_type, getStreamType());
ret.set(s_mode, String(m_mode));
ret.set(s_unread_bytes, 0);
ret.set(s_seekable, seekable());
ret.set(s_uri, String(m_name));
ret.set(s_timed_out, false);
ret.set(s_blocked, true);
ret.set(s_eof, eof());
ret.set(s_wrapper_data, getWrapperMetaData());
return ret.create();
}
///////////////////////////////////////////////////////////////////////////////
+5 -2
Ver Arquivo
@@ -200,10 +200,13 @@ bool Socket::eof() {
return m_eof;
}
static const StaticString s_timed_out("timed_out");
static const StaticString s_blocked("blocked");
Array Socket::getMetaData() {
Array ret = File::getMetaData();
ret.set("timed_out", m_timedOut);
ret.set("blocked", (bool)(fcntl(m_fd, F_GETFL, 0) & O_NONBLOCK));
ret.set(s_timed_out, m_timedOut);
ret.set(s_blocked, (bool)(fcntl(m_fd, F_GETFL, 0) & O_NONBLOCK));
return ret;
}
+1
Ver Arquivo
@@ -227,6 +227,7 @@ public:
assert(len >= 0 && len <= capacity() && !isImmutable());
m_data[len] = 0;
m_len = len;
m_hash = 0; // invalidate old hash
return this;
}
+36 -17
Ver Arquivo
@@ -1153,33 +1153,52 @@ static void removeOrphan(XmlNodeSet &orphans, xmlNodePtr node) {
}
}
static Variant php_dom_create_object(xmlNodePtr obj, p_DOMDocument doc,
bool owner = false) {
const char *clsname = NULL;
static const StaticString s_domdocument("domdocument");
static const StaticString s_domdocumenttype("domdocumenttype");
static const StaticString s_domelement("domelement");
static const StaticString s_domattr("domattr");
static const StaticString s_domtext("domtext");
static const StaticString s_domcomment("domcomment");
static const StaticString
s_domprocessinginstruction("domprocessinginstruction");
static const StaticString s_domentityreference("domentityreference");
static const StaticString s_domentity("domentity");
static const StaticString s_domcdatasection("domcdatasection");
static const StaticString s_domdocumentfragment("domdocumentfragment");
static const StaticString s_domnotation("domnotation");
static String domClassname(xmlNodePtr obj) {
switch (obj->type) {
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE: clsname = "domdocument"; break;
case XML_HTML_DOCUMENT_NODE: return s_domdocument;
case XML_DTD_NODE:
case XML_DOCUMENT_TYPE_NODE: clsname = "domdocumenttype"; break;
case XML_ELEMENT_NODE: clsname = "domelement"; break;
case XML_ATTRIBUTE_NODE: clsname = "domattr"; break;
case XML_TEXT_NODE: clsname = "domtext"; break;
case XML_COMMENT_NODE: clsname = "domcomment"; break;
case XML_PI_NODE: clsname = "domprocessinginstruction"; break;
case XML_ENTITY_REF_NODE: clsname = "domentityreference"; break;
case XML_DOCUMENT_TYPE_NODE: return s_domdocumenttype;
case XML_ELEMENT_NODE: return s_domelement;
case XML_ATTRIBUTE_NODE: return s_domattr;
case XML_TEXT_NODE: return s_domtext;
case XML_COMMENT_NODE: return s_domcomment;
case XML_PI_NODE: return s_domprocessinginstruction;
case XML_ENTITY_REF_NODE: return s_domentityreference;
case XML_ENTITY_DECL:
case XML_ELEMENT_DECL: clsname = "domentity"; break;
case XML_CDATA_SECTION_NODE: clsname = "domcdatasection"; break;
case XML_DOCUMENT_FRAG_NODE: clsname = "domdocumentfragment"; break;
case XML_NOTATION_NODE: clsname = "domnotation"; break;
case XML_ELEMENT_DECL: return s_domentity;
case XML_CDATA_SECTION_NODE: return s_domcdatasection;
case XML_DOCUMENT_FRAG_NODE: return s_domdocumentfragment;
case XML_NOTATION_NODE: return s_domnotation;
default:
return String((StringData*)nullptr);
}
}
static Variant php_dom_create_object(xmlNodePtr obj, p_DOMDocument doc,
bool owner = false) {
String clsname = domClassname(obj);
if (!clsname.get()) {
raise_warning("Unsupported node type: %d", obj->type);
return uninit_null();
}
if (doc.get() && doc->m_classmap.exists(clsname)) {
assert(doc->m_classmap[clsname].isString()); // or const char * is not safe
clsname = doc->m_classmap[clsname].toString().data();
clsname = doc->m_classmap[clsname].toString();
}
Object wrapper = create_object_only(clsname);
c_DOMNode *nodeobj = wrapper.getTyped<c_DOMNode>();
+31 -18
Ver Arquivo
@@ -1040,6 +1040,14 @@ static void output_dataset(Array &ret, int affected, DBDataSet &ds,
}
}
static const StaticString s_session_variable("session_variable");
static const StaticString s_ip("ip");
static const StaticString s_db("db");
static const StaticString s_port("port");
static const StaticString s_username("username");
static const StaticString s_password("password");
static const StaticString s_sql("sql");
void f_fb_load_local_databases(CArrRef servers) {
DBConn::ClearLocalDatabases();
for (ArrayIter iter(servers); iter; ++iter) {
@@ -1047,19 +1055,19 @@ void f_fb_load_local_databases(CArrRef servers) {
Array data = iter.second().toArray();
if (!data.empty()) {
std::vector< std::pair<string, string> > sessionVariables;
if (data.exists("session_variable")) {
Array sv = data["session_variable"].toArray();
if (data.exists(s_session_variable)) {
Array sv = data[s_session_variable].toArray();
for (ArrayIter svIter(sv); svIter; ++svIter) {
sessionVariables.push_back(std::pair<string, string>(
svIter.first().toString().data(),
svIter.second().toString().data()));
}
}
DBConn::AddLocalDB(dbId, data["ip"].toString().data(),
data["db"].toString().data(),
data["port"].toInt32(),
data["username"].toString().data(),
data["password"].toString().data(),
DBConn::AddLocalDB(dbId, data[s_ip].toString().data(),
data[s_db].toString().data(),
data[s_port].toInt32(),
data[s_username].toString().data(),
data[s_password].toString().data(),
sessionVariables);
}
}
@@ -1081,8 +1089,8 @@ Array f_fb_parallel_query(CArrRef sql_map, int max_thread /* = 50 */,
Array data = iter.second().toArray();
if (!data.empty()) {
std::vector< std::pair<string, string> > sessionVariables;
if (data.exists("session_variable")) {
Array sv = data["session_variable"].toArray();
if (data.exists(s_session_variable)) {
Array sv = data[s_session_variable].toArray();
for (ArrayIter svIter(sv); svIter; ++svIter) {
sessionVariables.push_back(std::pair<string, string>(
svIter.first().toString().data(),
@@ -1090,13 +1098,13 @@ Array f_fb_parallel_query(CArrRef sql_map, int max_thread /* = 50 */,
}
}
ServerDataPtr server
(new ServerData(data["ip"].toString().data(),
data["db"].toString().data(),
data["port"].toInt32(),
data["username"].toString().data(),
data["password"].toString().data(),
(new ServerData(data[s_ip].toString().data(),
data[s_db].toString().data(),
data[s_port].toInt32(),
data[s_username].toString().data(),
data[s_password].toString().data(),
sessionVariables));
queries.push_back(ServerQuery(server, data["sql"].toString().data()));
queries.push_back(ServerQuery(server, data[s_sql].toString().data()));
} else {
// so we can report errors according to array index
queries.push_back(ServerQuery(ServerDataPtr(), ""));
@@ -1134,6 +1142,8 @@ Array f_fb_parallel_query(CArrRef sql_map, int max_thread /* = 50 */,
return ret;
}
static const StaticString s_error("error");
Array f_fb_crossall_query(CStrRef sql, int max_thread /* = 50 */,
bool retry_query_on_fail /* = true */,
int connect_timeout /* = -1 */,
@@ -1147,18 +1157,21 @@ Array f_fb_crossall_query(CStrRef sql, int max_thread /* = 50 */,
Array ret;
// parameter checking
if (!sql || !*sql) {
ret.set("error", "empty SQL");
static const StaticString s_errstr("empty SQL");
ret.set(s_error, s_errstr);
return ret;
}
// security checking
String ssql = StringUtil::ToLower(sql);
if (ssql.find("where") < 0) {
ret.set("error", "missing where clause");
static const StaticString s_errstr("missing where clause");
ret.set(s_error, s_errstr);
return ret;
}
if (ssql.find("select") < 0) {
ret.set("error", "non-SELECT not supported");
static const StaticString s_errstr("non-SELECT not supported");
ret.set(s_error, s_errstr);
return ret;
}
+9 -6
Ver Arquivo
@@ -1285,14 +1285,17 @@ public:
};
IMPLEMENT_STATIC_REQUEST_LOCAL(DirectoryRequestData, s_directory_data);
static const StaticString s_handle("handle");
static const StaticString s_path("path");
static DIR *get_dir(CObjRef dir_handle) {
Object obj;
if (dir_handle.isNull()) {
obj = s_directory_data->defaultDirectory;
} else {
Array arr = dir_handle.toArray();
if (arr.exists("handle")) {
obj = arr["handle"].toObject();
if (arr.exists(s_handle)) {
obj = arr[s_handle].toObject();
} else {
obj = dir_handle;
}
@@ -1314,8 +1317,8 @@ Variant f_dir(CStrRef directory) {
return false;
}
ObjectData* d = SystemLib::AllocDirectoryObject();
*(d->o_realProp("path", 0)) = directory;
*(d->o_realProp("handle", 0)) = dir;
*(d->o_realProp(s_path, 0)) = directory;
*(d->o_realProp(s_handle, 0)) = dir;
return d;
}
@@ -1394,8 +1397,8 @@ void f_closedir(CObjRef dir_handle) {
if (!dir_handle.isNull()) {
Object obj;
Array arr = dir_handle.toArray();
if (arr.exists("handle")) {
obj = arr["handle"].toObject();
if (arr.exists(s_handle)) {
obj = arr[s_handle].toObject();
} else {
obj = dir_handle;
}
+9 -6
Ver Arquivo
@@ -467,6 +467,9 @@ String c_UConverter::doConvert(CStrRef str,
return destStr.setSize(dest_len);
}
static const StaticString s_from_subst("from_subst");
static const StaticString s_to_subst("to_subst");
Variant c_UConverter::ti_transcode(const char* cls , CStrRef str,
CStrRef toEncoding, CStrRef fromEncoding,
CArrRef options) {
@@ -477,14 +480,14 @@ Variant c_UConverter::ti_transcode(const char* cls , CStrRef str,
if (!setEncoding(toEncoding, &toCnv, s_intl_error->m_error)) {
return uninit_null();
}
if (options.exists("from_subst") &&
!setSubstChars(options["from_subst"].toString(), fromCnv,
s_intl_error->m_error)) {
if (options.exists(s_from_subst) &&
!setSubstChars(options[s_from_subst].toString(), fromCnv,
s_intl_error->m_error)) {
return uninit_null();
}
if (options.exists("to_subst") &&
!setSubstChars(options["to_subst"].toString(), toCnv,
s_intl_error->m_error)) {
if (options.exists(s_to_subst) &&
!setSubstChars(options[s_to_subst].toString(), toCnv,
s_intl_error->m_error)) {
return uninit_null();
}
Variant ret = doConvert(str, toCnv, fromCnv, s_intl_error->m_error);
+3 -1
Ver Arquivo
@@ -4355,6 +4355,8 @@ static int php_iptc_next_marker(File *file, int spool,
return (unsigned int) c;
}
static const StaticString s_size("size");
Variant f_iptcembed(CStrRef iptcdata, CStrRef jpeg_file_name,
int spool /* = 0 */) {
char psheader[] = "\xFF\xED\0\0Photoshop 3.0\08BIM\x04\x04\0\0\0\0";
@@ -4371,7 +4373,7 @@ Variant f_iptcembed(CStrRef iptcdata, CStrRef jpeg_file_name,
}
if (spool < 2) {
Array stat = f_fstat(stream);
int st_size = stat["size"];
int st_size = stat[s_size];
size_t malloc_size = iptcdata_len + sizeof(psheader) + st_size + 1024 + 1;
poi = spoolbuf = (unsigned char *)IM_MALLOC(malloc_size);
CHECK_ALLOC_R(poi, malloc_size, false);
+38 -23
Ver Arquivo
@@ -30,6 +30,15 @@
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
static const StaticString s_padding_top("padding_top");
static const StaticString s_padding_right("padding_right");
static const StaticString s_padding_bottom("padding_bottom");
static const StaticString s_padding_left("padding_left");
static const StaticString s_width("width");
static const StaticString s_height("height");
static const StaticString s_flush_left("flush_left");
static const StaticString s_flush_right("flush_right");
namespace ImageSprite {
// PHP extension gd.c
@@ -243,8 +252,8 @@ void Image::load_data_to_gd(int size, const void* data) {
}
void Image::setOptions(Array options) {
if (options.exists("padding_top")) {
int32_t v = options["padding_top"].toInt32();
if (options.exists(s_padding_top)) {
int32_t v = options[s_padding_top].toInt32();
if (v < 0) {
m_padding[IMAGESPRITE_PAD_TOP] = 0;
} else {
@@ -252,8 +261,8 @@ void Image::setOptions(Array options) {
}
}
if (options.exists("padding_right")) {
int32_t v = options["padding_right"].toInt32();
if (options.exists(s_padding_right)) {
int32_t v = options[s_padding_right].toInt32();
if (v < 0) {
m_padding[IMAGESPRITE_PAD_RIGHT] = 0;
} else {
@@ -261,8 +270,8 @@ void Image::setOptions(Array options) {
}
}
if (options.exists("padding_bottom")) {
int32_t v = options["padding_bottom"].toInt32();
if (options.exists(s_padding_bottom)) {
int32_t v = options[s_padding_bottom].toInt32();
if (v < 0) {
m_padding[IMAGESPRITE_PAD_BOTTOM] = 0;
} else {
@@ -270,8 +279,8 @@ void Image::setOptions(Array options) {
}
}
if (options.exists("padding_left")) {
int32_t v = options["padding_left"].toInt32();
if (options.exists(s_padding_left)) {
int32_t v = options[s_padding_left].toInt32();
if (v < 0) {
m_padding[IMAGESPRITE_PAD_LEFT] = 0;
} else {
@@ -279,19 +288,19 @@ void Image::setOptions(Array options) {
}
}
if (options.exists("width") && options.exists("height")) {
m_width = options["width"].toInt32();
m_height = options["height"].toInt32();
if (options.exists(s_width) && options.exists(s_height)) {
m_width = options[s_width].toInt32();
m_height = options[s_height].toInt32();
m_area = m_width * m_height;
}
if (options.exists("flush_left")) {
bool v = options["flush_left"].toBoolean();
if (options.exists(s_flush_left)) {
bool v = options[s_flush_left].toBoolean();
m_flush[IMAGESPRITE_FLUSH_LEFT] = v;
}
if (options.exists("flush_right")) {
bool v = options["flush_right"].toBoolean();
if (options.exists(s_flush_right)) {
bool v = options[s_flush_right].toBoolean();
m_flush[IMAGESPRITE_FLUSH_RIGHT] = v;
}
}
@@ -1058,6 +1067,9 @@ String c_ImageSprite::t_output(CStrRef output_file /* = null_string*/,
}
}
static const StaticString s_x("x");
static const StaticString s_y("y");
String c_ImageSprite::t_css(CStrRef css_namespace,
CStrRef sprite_file /* = null_string */,
CStrRef output_file /* = null_string */,
@@ -1096,13 +1108,13 @@ String c_ImageSprite::t_css(CStrRef css_namespace,
if (verbose) output += "\n ";
output += "background-position:";
if (more(attr["x"], 0)) {
output += String("-") + attr["x"] + "px";
if (more(attr[s_x], 0)) {
output += String("-") + attr[s_x] + "px";
} else {
output += "0";
}
if (more(attr["y"], 0)) {
output += String(" -") + attr["y"] + "px";
if (more(attr[s_y], 0)) {
output += String(" -") + attr[s_y] + "px";
} else {
output += " 0";
}
@@ -1113,9 +1125,9 @@ String c_ImageSprite::t_css(CStrRef css_namespace,
}
if (verbose) output += "\n ";
output += String("width:") + attr["width"] + "px;";
output += String("width:") + attr[s_width] + "px;";
if (verbose) output += "\n ";
output += String("height:") + attr["height"] + "px";
output += String("height:") + attr[s_height] + "px";
if (verbose) output += "\n";
output += "}";
if (verbose) output += "\n";
@@ -1129,10 +1141,13 @@ String c_ImageSprite::t_css(CStrRef css_namespace,
}
}
static const StaticString s_images("images");
static const StaticString s_sprite("sprite");
Array c_ImageSprite::t_geterrors() {
Array ret = Array::Create();
ret.set("images", m_img_errors);
ret.set("sprite", m_sprite_errors);
ret.set(s_images, m_img_errors);
ret.set(s_sprite, m_sprite_errors);
return ret;
}
+25 -14
Ver Arquivo
@@ -111,6 +111,17 @@ bool f_msg_remove_queue(CObjRef queue) {
return msgctl(q->id, IPC_RMID, NULL) == 0;
}
static const StaticString s_msg_perm_uid("msg_perm.uid");
static const StaticString s_msg_perm_gid("msg_perm.gid");
static const StaticString s_msg_perm_mode("msg_perm.mode");
static const StaticString s_msg_stime("msg_stime");
static const StaticString s_msg_rtime("msg_rtime");
static const StaticString s_msg_ctime("msg_ctime");
static const StaticString s_msg_qnum("msg_qnum");
static const StaticString s_msg_qbytes("msg_qbytes");
static const StaticString s_msg_lspid("msg_lspid");
static const StaticString s_msg_lrpid("msg_lrpid");
bool f_msg_set_queue(CObjRef queue, CArrRef data) {
MessageQueue *q = queue.getTyped<MessageQueue>();
if (!q) {
@@ -121,13 +132,13 @@ bool f_msg_set_queue(CObjRef queue, CArrRef data) {
struct msqid_ds stat;
if (msgctl(q->id, IPC_STAT, &stat) == 0) {
Variant value;
value = data["msg_perm.uid"];
value = data[s_msg_perm_uid];
if (!value.isNull()) stat.msg_perm.uid = (int64_t)value;
value = data["msg_perm.gid"];
value = data[s_msg_perm_gid];
if (!value.isNull()) stat.msg_perm.uid = (int64_t)value;
value = data["msg_perm.mode"];
value = data[s_msg_perm_mode];
if (!value.isNull()) stat.msg_perm.uid = (int64_t)value;
value = data["msg_qbytes"];
value = data[s_msg_qbytes];
if (!value.isNull()) stat.msg_perm.uid = (int64_t)value;
return msgctl(q->id, IPC_SET, &stat) == 0;
@@ -146,16 +157,16 @@ Array f_msg_stat_queue(CObjRef queue) {
struct msqid_ds stat;
if (msgctl(q->id, IPC_STAT, &stat) == 0) {
Array data;
data.set("msg_perm.uid", (int64_t)stat.msg_perm.uid);
data.set("msg_perm.gid", (int64_t)stat.msg_perm.gid);
data.set("msg_perm.mode", stat.msg_perm.mode);
data.set("msg_stime", (int64_t)stat.msg_stime);
data.set("msg_rtime", (int64_t)stat.msg_rtime);
data.set("msg_ctime", (int64_t)stat.msg_ctime);
data.set("msg_qnum", (int64_t)stat.msg_qnum);
data.set("msg_qbytes", (int64_t)stat.msg_qbytes);
data.set("msg_lspid", stat.msg_lspid);
data.set("msg_lrpid", stat.msg_lrpid);
data.set(s_msg_perm_uid, (int64_t)stat.msg_perm.uid);
data.set(s_msg_perm_gid, (int64_t)stat.msg_perm.gid);
data.set(s_msg_perm_mode, stat.msg_perm.mode);
data.set(s_msg_stime, (int64_t)stat.msg_stime);
data.set(s_msg_rtime, (int64_t)stat.msg_rtime);
data.set(s_msg_ctime, (int64_t)stat.msg_ctime);
data.set(s_msg_qnum, (int64_t)stat.msg_qnum);
data.set(s_msg_qbytes, (int64_t)stat.msg_qbytes);
data.set(s_msg_lspid, stat.msg_lspid);
data.set(s_msg_lrpid, stat.msg_lrpid);
return data;
}
+9 -5
Ver Arquivo
@@ -767,6 +767,10 @@ bool f_ldap_get_option(CObjRef link, int option, VRefParam retval) {
return true;
}
static const StaticString s_oid("oid");
static const StaticString s_value("value");
static const StaticString s_iscritical("iscritical");
bool f_ldap_set_option(CVarRef link, int option, CVarRef newval) {
LDAP *ldap = NULL;
if (!link.isNull()) {
@@ -866,17 +870,17 @@ bool f_ldap_set_option(CVarRef link, int option, CVarRef newval) {
break;
}
Array ctrlval = vctrlval.toArray();
if (!ctrlval.exists("oid")) {
if (!ctrlval.exists(s_oid)) {
raise_warning("Control must have an oid key");
error = 1;
break;
}
String val = ctrlval["oid"].toString();
String val = ctrlval[s_oid].toString();
stringHolder.append(val);
ctrl = *ctrlp = (LDAPControl*)malloc(sizeof(**ctrlp));
ctrl->ldctl_oid = (char*)val.data();
if (ctrlval.exists("value")) {
val = ctrlval["value"].toString();
if (ctrlval.exists(s_value)) {
val = ctrlval[s_value].toString();
stringHolder.append(val);
ctrl->ldctl_value.bv_val = (char*)val.data();
ctrl->ldctl_value.bv_len = val.size();
@@ -884,7 +888,7 @@ bool f_ldap_set_option(CVarRef link, int option, CVarRef newval) {
ctrl->ldctl_value.bv_val = NULL;
ctrl->ldctl_value.bv_len = 0;
}
if (ctrlval.exists("iscritical")) {
if (ctrlval.exists(s_iscritical)) {
ctrl->ldctl_iscritical = val.toBoolean() ? 1 : 0;
} else {
ctrl->ldctl_iscritical = 0;
+5 -2
Ver Arquivo
@@ -3939,7 +3939,8 @@ bool f_mb_send_mail(CStrRef to, CStrRef subject, CStrRef message,
int cnt_trans_enc:1;
} suppressed_hdrs = { 0, 0 };
String s = ht_headers["CONTENT-TYPE"];
static const StaticString s_CONTENT_TYPE("CONTENT-TYPE");
String s = ht_headers[s_CONTENT_TYPE];
if (!s.isNull()) {
char *tmp;
char *param_name;
@@ -3975,7 +3976,9 @@ bool f_mb_send_mail(CStrRef to, CStrRef subject, CStrRef message,
suppressed_hdrs.cnt_type = 1;
}
s = ht_headers["CONTENT-TRANSFER-ENCODING"];
static const StaticString
s_CONTENT_TRANSFER_ENCODING("CONTENT-TRANSFER-ENCODING");
s = ht_headers[s_CONTENT_TRANSFER_ENCODING];
if (!s.isNull()) {
mbfl_no_encoding _body_enc = mbfl_name2no_encoding(s.data());
switch (_body_enc) {
+20 -11
Ver Arquivo
@@ -464,7 +464,7 @@ static void add_assoc_name_entry(Array &ret, const char *key,
}
}
static const char *read_string(CArrRef args, const char *key, const char *def,
static const char *read_string(CArrRef args, CStrRef key, const char *def,
vector<String> &strings) {
if (args.exists(key)) {
String value = args[key].toString();
@@ -474,7 +474,7 @@ static const char *read_string(CArrRef args, const char *key, const char *def,
return def;
}
static int64_t read_integer(CArrRef args, const char *key, int64_t def) {
static int64_t read_integer(CArrRef args, CStrRef key, int64_t def) {
if (args.exists(key)) {
return args[key].toInt64();
}
@@ -524,12 +524,21 @@ static inline bool php_openssl_config_check_syntax
return true;
}
static const StaticString s_config("config");
static const StaticString s_config_section_name("config_section_name");
static const StaticString s_digest_alg("digest_alg");
static const StaticString s_x509_extensions("x509_extensions");
static const StaticString s_req_extensions("req_extensions");
static const StaticString s_private_key_bits("private_key_bits");
static const StaticString s_private_key_type("private_key_type");
static const StaticString s_encrypt_key("encrypt_key");
static bool php_openssl_parse_config(struct php_x509_request *req,
CArrRef args, vector<String> &strings) {
req->config_filename =
read_string(args, "config", default_ssl_conf_filename, strings);
read_string(args, s_config, default_ssl_conf_filename, strings);
req->section_name =
read_string(args, "config_section_name", "req", strings);
read_string(args, s_config_section_name, "req", strings);
req->global_config = CONF_load(NULL, default_ssl_conf_filename, NULL);
req->req_config = CONF_load(NULL, req->config_filename, NULL);
if (req->req_config == NULL) {
@@ -550,33 +559,33 @@ static bool php_openssl_parse_config(struct php_x509_request *req,
}
req->digest_name =
read_string(args, "digest_alg",
read_string(args, s_digest_alg,
CONF_get_string(req->req_config, req->section_name,
"default_md"),
strings);
req->extensions_section =
read_string(args, "x509_extensions",
read_string(args, s_x509_extensions,
CONF_get_string(req->req_config, req->section_name,
"x509_extensions"),
strings);
req->request_extensions_section =
read_string(args, "req_extensions",
read_string(args, s_req_extensions,
CONF_get_string(req->req_config, req->section_name,
"req_extensions"),
strings);
req->priv_key_bits =
read_integer(args, "private_key_bits",
read_integer(args, s_private_key_bits,
CONF_get_number(req->req_config, req->section_name,
"default_bits"));
req->priv_key_type =
read_integer(args, "private_key_type", OPENSSL_KEYTYPE_DEFAULT);
read_integer(args, s_private_key_type, OPENSSL_KEYTYPE_DEFAULT);
if (args.exists("encrypt_key")) {
bool value = args["encrypt_key"].toBoolean();
if (args.exists(s_encrypt_key)) {
bool value = args[s_encrypt_key].toBoolean();
req->priv_key_encrypt = value ? 1 : 0;
} else {
str = CONF_get_string(req->req_config, req->section_name,
+81 -54
Ver Arquivo
@@ -1829,6 +1829,33 @@ c_SoapServer::c_SoapServer(VM::Class* cb) :
c_SoapServer::~c_SoapServer() {
}
static const StaticString s_soap_version("soap_version");
static const StaticString s_uri("uri");
static const StaticString s_actor("actor");
static const StaticString s_encoding("encoding");
static const StaticString s_classmap("classmap");
static const StaticString s_typemap("typemap");
static const StaticString s_features("features");
static const StaticString s_cache_wsdl("cache_wsdl");
static const StaticString s_send_errors("send_errors");
static const StaticString s_location("location");
static const StaticString s_style("style");
static const StaticString s_use("use");
static const StaticString s_stream_context("stream_context");
static const StaticString s_login("login");
static const StaticString s_password("password");
static const StaticString s_authentication("authentication");
static const StaticString s_proxy_host("proxy_host");
static const StaticString s_proxy_port("proxy_port");
static const StaticString s_proxy_login("proxy_login");
static const StaticString s_proxy_password("proxy_password");
static const StaticString s_trace("trace");
static const StaticString s_exceptions("exceptions");
static const StaticString s_compression("compression");
static const StaticString s_connection_timeout("connection_timeout");
static const StaticString s_user_agent("user_agent");
static const StaticString s_soapaction("soapaction");
void c_SoapServer::t___construct(CVarRef wsdl,
CArrRef options /* = null_array */) {
USE_SOAP_GLOBAL;
@@ -1847,25 +1874,25 @@ void c_SoapServer::t___construct(CVarRef wsdl,
int version = SOAP_1_1;
Array typemap_ht;
if (!options.empty()) {
if (options["soap_version"].isInteger()) {
int64_t tmp = options["soap_version"].toInt64();
if (options[s_soap_version].isInteger()) {
int64_t tmp = options[s_soap_version].toInt64();
if (tmp == SOAP_1_1 || tmp == SOAP_1_2) {
version = tmp;
}
}
if (options["uri"].isString()) {
m_uri = options["uri"].toString();
if (options[s_uri].isString()) {
m_uri = options[s_uri].toString();
} else if (wsdl.isNull()) {
throw SoapException("'uri' option is required in nonWSDL mode");
}
if (options["actor"].isString()) {
m_actor = options["actor"].toString();
if (options[s_actor].isString()) {
m_actor = options[s_actor].toString();
}
if (options["encoding"].isString()) {
String tmp = options["encoding"].toString();
if (options[s_encoding].isString()) {
String tmp = options[s_encoding].toString();
m_encoding = xmlFindCharEncodingHandler(tmp.data());
if (m_encoding == NULL) {
throw SoapException("Invalid 'encoding' option - '%s'", tmp.data());
@@ -1873,25 +1900,25 @@ void c_SoapServer::t___construct(CVarRef wsdl,
s_soap_data->register_encoding(m_encoding);
}
if (options["classmap"].isArray()) {
m_classmap = options["classmap"].toArray();
if (options[s_classmap].isArray()) {
m_classmap = options[s_classmap].toArray();
}
if (options["typemap"].isArray()) {
typemap_ht = options["typemap"].toArray();
if (options[s_typemap].isArray()) {
typemap_ht = options[s_typemap].toArray();
}
if (options["features"].isInteger()) {
m_features = options["features"].toInt64();
if (options[s_features].isInteger()) {
m_features = options[s_features].toInt64();
}
if (options["cache_wsdl"].isInteger()) {
cache_wsdl = options["cache_wsdl"].toInt64();
if (options[s_cache_wsdl].isInteger()) {
cache_wsdl = options[s_cache_wsdl].toInt64();
}
if (options["send_errors"].isInteger() ||
options["send_errors"].is(KindOfBoolean)) {
m_send_errors = options["send_errors"].toInt64();
if (options[s_send_errors].isInteger() ||
options[s_send_errors].is(KindOfBoolean)) {
m_send_errors = options[s_send_errors].toInt64();
}
} else if (wsdl.isNull()) {
@@ -2301,13 +2328,13 @@ void c_SoapClient::t___construct(CVarRef wsdl,
int64_t cache_wsdl = SOAP_GLOBAL(cache);
if (!options.empty()) {
m_location = options["location"];
m_location = options[s_location];
if (wsdl.isNull()) {
/* Fetching non-WSDL mode options */
m_uri = options["uri"];
m_style = options["style"].toInt32(); // SOAP_RPC || SOAP_DOCUMENT
m_use = options["use" ].toInt32(); // SOAP_LITERAL || SOAP_ENCODED
m_uri = options[s_uri];
m_style = options[s_style].toInt32(); // SOAP_RPC || SOAP_DOCUMENT
m_use = options[s_use].toInt32(); // SOAP_LITERAL || SOAP_ENCODED
if (m_uri.empty()) {
throw SoapException("'uri' option is required in nonWSDL mode");
@@ -2317,10 +2344,10 @@ void c_SoapClient::t___construct(CVarRef wsdl,
}
}
if (options.exists("stream_context")) {
if (options.exists(s_stream_context)) {
StreamContext *sc = NULL;
if (options["stream_context"].isObject()) {
sc = options["stream_context"].toObject()
if (options[s_stream_context].isObject()) {
sc = options[s_stream_context].toObject()
.getTyped<StreamContext>();
}
if (!sc) {
@@ -2329,28 +2356,28 @@ void c_SoapClient::t___construct(CVarRef wsdl,
m_stream_context_options = sc->m_options;
}
if (options.exists("soap_version")) {
m_soap_version = options["soap_version"].toInt32();
if (options.exists(s_soap_version)) {
m_soap_version = options[s_soap_version].toInt32();
}
m_login = options["login"].toString();
m_password = options["password"].toString();
m_authentication = options["authentication"].toInt32();
m_login = options[s_login].toString();
m_password = options[s_password].toString();
m_authentication = options[s_authentication].toInt32();
m_proxy_host = options["proxy_host"].toString();
m_proxy_port = options["proxy_port"].toInt32();
m_proxy_login = options["proxy_login"].toString();
m_proxy_password = options["proxy_password"].toString();
m_proxy_host = options[s_proxy_host].toString();
m_proxy_port = options[s_proxy_port].toInt32();
m_proxy_login = options[s_proxy_login].toString();
m_proxy_password = options[s_proxy_password].toString();
m_trace = options["trace"].toBoolean();
if (options.exists("exceptions")) {
m_exceptions = options["exceptions"].toBoolean();
m_trace = options[s_trace].toBoolean();
if (options.exists(s_exceptions)) {
m_exceptions = options[s_exceptions].toBoolean();
}
if (options.exists("compression")) {
m_compression = options["compression"].toBoolean();
if (options.exists(s_compression)) {
m_compression = options[s_compression].toBoolean();
}
String encoding = options["encoding"].toString();
String encoding = options[s_encoding].toString();
if (!encoding.empty()) {
m_encoding = xmlFindCharEncodingHandler(encoding.data());
if (m_encoding == NULL) {
@@ -2359,13 +2386,13 @@ void c_SoapClient::t___construct(CVarRef wsdl,
}
s_soap_data->register_encoding(m_encoding);
}
m_classmap = options["classmap"].toArray();
m_features = options["features"].toInt32();
m_connection_timeout = options["connection_timeout"].toInt64();
m_user_agent = options["user_agent"].toString();
m_classmap = options[s_classmap].toArray();
m_features = options[s_features].toInt32();
m_connection_timeout = options[s_connection_timeout].toInt64();
m_user_agent = options[s_user_agent].toString();
if (options.exists("cache_wsdl")) {
cache_wsdl = options["cache_wsdl"].toInt64();
if (options.exists(s_cache_wsdl)) {
cache_wsdl = options[s_cache_wsdl].toInt64();
}
} else if (wsdl.isNull()) {
@@ -2394,7 +2421,7 @@ void c_SoapClient::t___construct(CVarRef wsdl,
SOAP_GLOBAL(soap_version) = old_soap_version;
}
Variant v = options["typemap"];
Variant v = options[s_typemap];
if (v.isArray()) {
Array arr = v.toArray();
if (!arr.empty()) {
@@ -2419,17 +2446,17 @@ Variant c_SoapClient::t___soapcall(CStrRef name, CArrRef args,
String location, soap_action, uri;
if (!options.isNull()) {
if (options["location"].isString()) {
location = options["location"].toString();
if (options[s_location].isString()) {
location = options[s_location].toString();
if (location.isNull()) {
location = m_location;
}
}
if (options["soapaction"].isString()) {
soap_action = options["soapaction"].toString();
if (options[s_soapaction].isString()) {
soap_action = options[s_soapaction].toString();
}
if (options["uri"].isString()) {
uri = options["uri"].toString();
if (options[s_uri].isString()) {
uri = options[s_uri].toString();
}
}
+13 -8
Ver Arquivo
@@ -457,6 +457,11 @@ bool f_socket_set_nonblock(CObjRef socket) {
return sock->setBlocking(false);
}
static const StaticString s_l_onoff("l_onoff");
static const StaticString s_l_linger("l_linger");
static const StaticString s_sec("sec");
static const StaticString s_usec("usec");
bool f_socket_set_option(CObjRef socket, int level, int optname,
CVarRef optval) {
Socket *sock = socket.getTyped<Socket>();
@@ -471,17 +476,17 @@ bool f_socket_set_option(CObjRef socket, int level, int optname,
case SO_LINGER:
{
Array value = optval.toArray();
if (!value.exists("l_onoff")) {
if (!value.exists(s_l_onoff)) {
raise_warning("no key \"l_onoff\" passed in optval");
return false;
}
if (!value.exists("l_linger")) {
if (!value.exists(s_l_linger)) {
raise_warning("no key \"l_linger\" passed in optval");
return false;
}
lv.l_onoff = (unsigned short)value["l_onoff"].toInt32();
lv.l_linger = (unsigned short)value["l_linger"].toInt32();
lv.l_onoff = (unsigned short)value[s_l_onoff].toInt32();
lv.l_linger = (unsigned short)value[s_l_linger].toInt32();
optlen = sizeof(lv);
opt_ptr = &lv;
}
@@ -491,17 +496,17 @@ bool f_socket_set_option(CObjRef socket, int level, int optname,
case SO_SNDTIMEO:
{
Array value = optval.toArray();
if (!value.exists("sec")) {
if (!value.exists(s_sec)) {
raise_warning("no key \"sec\" passed in optval");
return false;
}
if (!value.exists("usec")) {
if (!value.exists(s_usec)) {
raise_warning("no key \"usec\" passed in optval");
return false;
}
tv.tv_sec = value["sec"].toInt32();
tv.tv_usec = value["usec"].toInt32();
tv.tv_sec = value[s_sec].toInt32();
tv.tv_usec = value[s_usec].toInt32();
if (tv.tv_usec >= 1000000) {
tv.tv_sec += tv.tv_usec / 1000000;
tv.tv_usec %= 1000000;
+3 -5
Ver Arquivo
@@ -943,7 +943,7 @@ Variant f_strtr(CStrRef str, CVarRef from, CVarRef to /* = null_variant */) {
const char *s = str.data();
int slen = str.size();
char *key = (char *)malloc(maxlen+1);
String key(maxlen, ReserveString);
StringBuffer result(slen);
for (int pos = 0; pos < slen; ) {
@@ -951,9 +951,9 @@ Variant f_strtr(CStrRef str, CVarRef from, CVarRef to /* = null_variant */) {
maxlen = slen - pos;
}
bool found = false;
memcpy(key, s + pos, maxlen);
memcpy(key.mutableSlice().ptr, s + pos, maxlen);
for (int len = maxlen; len >= minlen; len--) {
key[len] = 0;
key.setSize(len);
if (arr.exists(key)) {
String replace = arr[key].toString();
if (!replace.empty()) {
@@ -968,8 +968,6 @@ Variant f_strtr(CStrRef str, CVarRef from, CVarRef to /* = null_variant */) {
result += s[pos++];
}
}
free(key);
return result.detach();
}
+52 -33
Ver Arquivo
@@ -223,10 +223,10 @@ Variant MimePart::MimeHeader::get(const char *attrname) {
return m_attributes[attrname];
}
void MimePart::MimeHeader::getAll(Array &ret, litstr valuelabel,
litstr attrprefix) {
void MimePart::MimeHeader::getAll(Array &ret, CStrRef valuelabel,
CStrRef attrprefix) {
for (ArrayIter iter(m_attributes); iter; ++iter) {
ret.set(String(attrprefix) + iter.first().toString(), iter.second());
ret.set(attrprefix + iter.first().toString(), iter.second());
}
/* do this last so that a bogus set of headers like this:
@@ -497,61 +497,81 @@ MimePart *MimePart::getParent() {
}
static const StaticString s_headers("headers");
static const StaticString s_starting_pos("starting-pos");
static const StaticString s_starting_pos_body("starting-pos-body");
static const StaticString s_ending_pos("ending-pos");
static const StaticString s_ending_pos_body("ending-pos-body");
static const StaticString s_line_count("line-count");
static const StaticString s_body_line_count("body-line-count");
static const StaticString s_charset("charset");
static const StaticString s_transfer_encoding("transfer-encoding");
static const StaticString s_content_type("content-type");
static const StaticString s_content_("content-");
static const StaticString s_text_plain_error("text/plain; (error)");
static const StaticString s_content_disposition("content-disposition");
static const StaticString s_disposition_("disposition-");
static const StaticString s_content_location("content-location");
static const StaticString s_content_base("content-base");
static const StaticString s_content_boundary("content-boundary");
static const StaticString s_content_id("content-id");
static const StaticString s_content_description("content-description");
static const StaticString s_content_language("content-language");
static const StaticString s_content_md5("content-md5");
Variant MimePart::getPartData() {
Array ret = Array::Create();
ret.set(s_headers, m_headers);
ret.set("starting-pos", m_startpos);
ret.set("starting-pos-body", m_bodystart);
ret.set(s_starting_pos, m_startpos);
ret.set(s_starting_pos_body, m_bodystart);
if (m_parent.isNull()) {
ret.set("ending-pos", m_endpos);
ret.set("ending-pos-body", m_bodyend);
ret.set("line-count", m_nlines);
ret.set("body-line-count", m_nbodylines);
ret.set(s_ending_pos, m_endpos);
ret.set(s_ending_pos_body, m_bodyend);
ret.set(s_line_count, m_nlines);
ret.set(s_body_line_count, m_nbodylines);
} else {
ret.set("ending-pos", m_bodyend);
ret.set("ending-pos-body", m_bodyend);
ret.set("line-count", m_nlines ? m_nlines - 1 : m_nlines);
ret.set("body-line-count", m_nbodylines ? m_nbodylines - 1 : m_nbodylines);
ret.set(s_ending_pos, m_bodyend);
ret.set(s_ending_pos_body, m_bodyend);
ret.set(s_line_count, m_nlines ? m_nlines - 1 : m_nlines);
ret.set(s_body_line_count, m_nbodylines ? m_nbodylines - 1 : m_nbodylines);
}
if (!m_charset.empty()) {
ret.set("charset", m_charset);
ret.set(s_charset, m_charset);
} else {
ret.set("charset", "us-ascii");
ret.set(s_charset, "us-ascii");
}
if (!m_content_transfer_encoding.empty()) {
ret.set("transfer-encoding", m_content_transfer_encoding);
ret.set(s_transfer_encoding, m_content_transfer_encoding);
} else {
ret.set("transfer-encoding", "8bit");
ret.set(s_transfer_encoding, "8bit");
}
if (!m_content_type.empty()) {
m_content_type.getAll(ret, "content-type", "content-");
m_content_type.getAll(ret, s_content_type, s_content_);
} else {
ret.set("content-type", "text/plain; (error)");
ret.set(s_content_type, s_text_plain_error);
}
if (!m_content_disposition.empty()) {
m_content_disposition.getAll(ret, "content-disposition", "disposition-");
m_content_disposition.getAll(ret, s_content_disposition, s_disposition_);
}
if (!m_content_location.empty()) {
ret.set("content-location", m_content_location);
ret.set(s_content_location, m_content_location);
}
if (!m_content_base.empty()) {
ret.set("content-base", m_content_base);
ret.set(s_content_base, m_content_base);
} else {
ret.set("content-base", "/");
ret.set(s_content_base, "/");
}
if (!m_boundary.empty()) {
ret.set("content-boundary", m_boundary);
ret.set(s_content_boundary, m_boundary);
}
/* extract the address part of the content-id only */
Variant contentId = m_headers["content-id"];
Variant contentId = m_headers[s_content_id];
if (!contentId.isNull()) {
php_rfc822_tokenized_t *toks =
php_mailparse_rfc822_tokenize((const char*)contentId.toString().data(),
@@ -559,19 +579,18 @@ Variant MimePart::getPartData() {
php_rfc822_addresses_t *addrs =
php_rfc822_parse_address_tokens(toks);
if (addrs->naddrs > 0) {
ret.set("content-id", String(addrs->addrs[0].address, CopyString));
ret.set(s_content_id, String(addrs->addrs[0].address, CopyString));
}
php_rfc822_free_addresses(addrs);
php_rfc822_tokenize_free(toks);
}
const char *key = "content-description";
if (m_headers.exists(key)) ret.set(key, m_headers[key]);
key = "content-language";
if (m_headers.exists(key)) ret.set(key, m_headers[key]);
key = "content-md5";
if (m_headers.exists(key)) ret.set(key, m_headers[key]);
auto copyHeader = [&](CVarRef key) {
if (m_headers.exists(key)) ret.set(key, m_headers[key]);
};
copyHeader(s_content_description);
copyHeader(s_content_language);
copyHeader(s_content_md5);
return ret;
}
+1 -1
Ver Arquivo
@@ -71,7 +71,7 @@ private:
void clear();
Variant get(const char *attrname);
void getAll(Array &ret, litstr valuelabel, litstr attrprefix);
void getAll(Array &ret, CStrRef valuelabel, CStrRef attrprefix);
bool m_empty;
String m_value;