int acl_setenv(const char *name, const char *val, int overwrite) { #ifdef ACL_WINDOWS if (overwrite == 0) { if (acl_getenv(name) != NULL) return (0); } if (!SetEnvironmentVariable(name, val)) return (-1); return (0); #else return (setenv(name, val, overwrite)); #endif }
const std::vector<HttpCookie*>& HttpServletRequest::getCookies(void) const { if (cookies_inited_) return cookies_; // 设置标记表明已经分析过cookie了,以便于下次重复调用时节省时间 const_cast<HttpServletRequest*>(this)->cookies_inited_ = true; if (cgi_mode_) { const char* ptr = acl_getenv("HTTP_COOKIE"); if (ptr == NULL || *ptr == 0) return cookies_; ACL_ARGV* argv = acl_argv_split(ptr, ";"); ACL_ITER iter; acl_foreach(iter, argv) { add_cookie(const_cast<HttpServletRequest*> (this)->cookies_, (char*) iter.data); } acl_argv_free(argv); return cookies_; }
static void child(int argc acl_unused, char *argv[] acl_unused) { const char *myname = "child"; const char *env_list; ACL_VSTRING *vbuf = acl_vstring_alloc(256); char buf[1024]; const char *ptr; int ret, i; acl_init(); env_list = acl_getenv_list(); acl_vstring_sprintf(vbuf, "env_list(%s)", env_list); acl_vstring_strcat(vbuf, "), "); ptr = acl_getenv("name1"); if (ptr == NULL) ptr = "null"; acl_vstring_sprintf_append(vbuf, "name1=%s", ptr); ptr = acl_getenv("name2"); if (ptr == NULL) ptr = "null"; acl_vstring_sprintf_append(vbuf, ", name2=%s", ptr); ptr = acl_getenv("name3"); if (ptr == NULL) ptr = "null"; acl_vstring_sprintf_append(vbuf, ", name3=%s", ptr); printf("%s: %s\r\n", myname, acl_vstring_str(vbuf));