MCPcopy Create free account
hub / github.com/acl-dev/acl / run_cgi

Function run_cgi

app/jaws/plugin/cgi/http_cgi.c:100–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100static 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 ");

Callers 1

http_cgi_threadFunction · 0.85

Calls 15

acl_vstream_popenFunction · 0.85
acl_msg_errorFunction · 0.85
acl_last_serrorFunction · 0.85
http_req_newFunction · 0.85
http_req_body_get_syncFunction · 0.85
acl_vstream_writenFunction · 0.85
acl_vstream_closeFunction · 0.85
acl_argv_allocFunction · 0.85
acl_vstream_gets_nonlFunction · 0.85
acl_msg_warnFunction · 0.85
acl_argv_addFunction · 0.85
acl_vstring_allocFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…