| 98 | } |
| 99 | |
| 100 | static void run_cgi(CGI *cgi, ACL_ARGV *env) |
| 101 | { |
| 102 | char *command = cgi->cgi; |
| 103 | ACL_VSTREAM *stream; |
| 104 | ACL_VSTRING *vbuf; |
| 105 | ACL_ARGV *cgi_hdrs; |
| 106 | char buf[4096]; |
| 107 | int ret, errnum = 200; |
| 108 | char **cpp; |
| 109 | |
| 110 | /* ����CGI����Ĺܵ������� */ |
| 111 | stream = acl_vstream_popen(O_RDWR, |
| 112 | ACL_VSTREAM_POPEN_COMMAND, command, |
| 113 | ACL_VSTREAM_POPEN_ENV, env->argv, |
| 114 | ACL_VSTREAM_POPEN_END); |
| 115 | |
| 116 | if (stream == NULL) { |
| 117 | acl_msg_error("%s(%d): open command(%s) error(%s)", |
| 118 | __FUNCTION__, __LINE__, command, acl_last_serror()); |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | cgi->req = http_req_new(cgi->hdr_req); |
| 123 | if (cgi->hdr_req->hdr.content_length > 0) { |
| 124 | while (1) { |
| 125 | ret = (int) http_req_body_get_sync(cgi->req, cgi->client, |
| 126 | buf, sizeof(buf) - 1); |
| 127 | if (ret <= 0) |
| 128 | break; |
| 129 | if (acl_vstream_writen(stream, buf, ret) == ACL_VSTREAM_EOF) { |
| 130 | acl_vstream_close(stream); |
| 131 | return; |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | /* |
| 137 | * http_hdr_set_keepalive(cgi->hdr_req, cgi->hdr_res); |
| 138 | */ |
| 139 | |
| 140 | cgi_hdrs = acl_argv_alloc(10); |
| 141 | |
| 142 | /* ��CGI���͵���Ӧͷ */ |
| 143 | while (1) { |
| 144 | char *pname, *ptr; |
| 145 | |
| 146 | ret = acl_vstream_gets_nonl(stream, buf, sizeof(buf)); |
| 147 | if (ret == ACL_VSTREAM_EOF) { |
| 148 | acl_msg_error("%s(%d): cgi exit exception", |
| 149 | __FUNCTION__, __LINE__); |
| 150 | errnum = 500; |
| 151 | break; |
| 152 | } |
| 153 | if (ret == 0) { |
| 154 | break; |
| 155 | } |
| 156 | ptr = buf; |
| 157 | pname = acl_mystrtok(&ptr, ":\t "); |
no test coverage detected
searching dependent graphs…