Ejemplo n.º 1
0
int
clip_FCGI_ACCEPT(ClipMachine *mp)
{
	int r;

	if (inited)
	{
		flush_bufs();
		FCGX_Finish();
	}

	r = FCGX_Accept(&in, &out, &err, &envp);
	/*r = FCGI_Accept();*/
	_clip_retl(mp, (r >= 0) ? 1 : 0);

	if (!inited)
	{
		inited = 1;

		init_Buf(&obuf);
		init_Buf(&ebuf);

		mp->obuf = &obuf;
		mp->ebuf = &ebuf;
	}

	return 0;
}
Ejemplo n.º 2
0
/*
 *----------------------------------------------------------------------
 *
 * FCGI_Finish --
 *
 *      Finishes the current request from the HTTP server.
 *
 * Side effects:
 *
 *      Flushes any buffered output to the HTTP server.  Then frees
 *      all storage allocated by the previous call, including all
 *      storage reachable from the value of environ set by the previous
 *      call to FCGI_Accept.
 *
 *      DO NOT use stdin, stdout, stderr, or environ between calling
 *      FCGI_Finish and calling FCGI_Accept.
 *
 *      DO NOT mutate or retain pointers to environ or any values
 *      contained in it (e.g. to the result of calling getenv(3)),
 *      since these are freed by the next call to FCGI_Finish or
 *      FCGI_Accept.  In particular do not use setenv(3) or putenv(3)
 *      in conjunction with FCGI_Accept.
 *
 *----------------------------------------------------------------------
 */
void FCGI_Finish(void)
{
    if(!acceptCalled || isCGI) {
        return;
    }
    FCGX_Finish();
    FCGI_stdin->fcgx_stream = NULL;
    FCGI_stdout->fcgx_stream = NULL;
    FCGI_stderr->fcgx_stream = NULL;
    environ = NULL;
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
	if(argc > 1){
		if(argc == 3){
			// as normal program, not cgi now
			printf("update dns, domain: %s, host: %s\n", argv[1], argv[2]);
			int ret = dns_update(argv[1], argv[2]);
			if(ret < 0){
			        printf("Internal error.\n");
			}else if(ret == 1){
			        printf("Recorde can't find.\n");
			}else if(ret == 2){
			        printf("Recorde still fresh.\n");
			}else if(ret == 0){
			        printf("Recorde refreshed.\n");
			}else{
			        printf("Unknown error.\n");
			}
		}else{
			printf("Usage: %s <domain> <host>\n", argv[0]);
		}
		return 0;
	}

	FCGX_Stream *in;
	FCGX_Stream *out;
	FCGX_Stream *err;
	FCGX_ParamArray envp;

	char *method = NULL;
	while(FCGX_Accept(&in, &out, &err, &envp) >= 0)
	{
		method = FCGX_GetParam("REQUEST_METHOD", envp);
		if(strcmp(method, "POST") == 0){
			//request_post(in, out, &envp);
		}else if(strcmp(method, "GET") == 0){
			request_get(in, out, &envp);
		}

	}

	FCGX_Finish();

	//test();

	return 0;
}