コード例 #1
0
ファイル: rest_server.cpp プロジェクト: kermitas/intellihome
/********************************************************
 RESPONSE METHODS
 ********************************************************/
void RestServer::send_response(Stream &_client) {
	if (server_state == RESPOND) {
		// Serial.println("__START__");

		// handle resource info/description requests
		if ((request_options & RESOURCE_REQ) == RESOURCE_REQ) {
			print_resource_description(_client);

		// handle standard GET and POST requests
		} else {
			// handle requests in JSON format
			if ((request_options & JSON_FORMAT) == JSON_FORMAT) {
				print_json(_client);
			}
			// handle HTML requests
			else if (((request_options & JSON_FORMAT) == 0)) {
				print_html(_client);
			}
		}

		// Serial.println("__END__");

		server_state = RESET;
	}
}
コード例 #2
0
ファイル: graph-html.c プロジェクト: NethServer/duc
static void br_html_draw_text(duc_graph *g, double x, double y, double size, char *text)
{
	struct html_backend_data *bd = g->backend_data;
	FILE *f = bd->fout;

	fprintf(f, "t('"); 
	print_html(text, f); 
	fprintf(f, "',%.0f,%.0f,%.0f);\n", size, x, y);
}
コード例 #3
0
ファイル: fcgi-utils.c プロジェクト: michals/sx
void send_error(int errnum, const char *message) {
    if(!message || !*message)
	message = http_err_str(errnum);

    if(!is_sky()) {
        print_html(errnum, "Error", errnum, message);
    } else {
	CGI_PRINTF("Status: %d\r\nContent-Type: application/json\r\n", errnum);
        if (verb == VERB_HEAD) {
            /* workaround for old curl: it would close (instead of reusing)
             * the connection if a HEAD doesn't have Content-Length/chunked
             * encoding. And then we run out of ports due to too many
             * TIME_WAIT connections */
            CGI_PUTS("Content-Length: 0\r\n\r\n");
        } else {
            CGI_PUTS("\r\n");
            send_error_helper('{',errnum,message);
        }
    }
}
コード例 #4
0
ファイル: testing.c プロジェクト: dzavalishin/exceptions4c
static void generate_report(/*@notnull@*/ test_runner * runner)
/*@globals
	fileSystem,
	internalState
@*/
/*@modifies
	fileSystem,
	internalState
@*/
{

	FILE * report;

	report = fopen(runner->report, "w");

	if(report == NULL){
		exit( cannot_write(runner->report) );
	}

	print_html(runner, report);

	(void)fclose(report);
}
コード例 #5
0
ファイル: fcgi-utils.c プロジェクト: s3v3ns/sx
void send_home(void) {
    print_html(0, SERVER_NAME, 0, NULL);
    sxi_hmac_sha1_cleanup(&hmac_ctx);
    sxi_md_cleanup(&body_ctx);
}
コード例 #6
0
ファイル: fcgi-utils.c プロジェクト: michals/sx
void send_home(void) {
    print_html(0, SERVER_NAME, 0, NULL);
}