<commit_before>#include "webcam/webcam.h"
#include <trfb.h>
#include <signal.h>

static int quit_now = 0;
static void sigint(int sig)
{
	quit_now = 1;
}

static void draw_image(webcam_t *cam, buffer_t *frame, trfb_server_t *srv)
{
	trfb_server_lock_fb(srv, 1);

	if (srv->fb->width * srv->fb->height * srv->fb->bpp >= frame->length)
		memcpy(srv->fb->pixels, frame->start, frame->length);

	trfb_server_unlock_fb(srv);
}

int main(int argc, char *argv[])
{
	trfb_server_t *srv;
	webcam_t *cam;
	buffer_t frame = { NULL, 0 };
	const unsigned width = 640;
	const unsigned height = 480;
	trfb_event_t event;

	signal(SIGINT, sigint);

	cam = webcam_open("/dev/video0");
	if (!cam) {
		fprintf(stderr, "Error: can't open webcam!\n");
		return 1;
	}
	webcam_resize(cam, width, height);

	srv = trfb_server_create(width, height, 4);
	if (!srv) {
		fprintf(stderr, "Error: can't create server!\n");
		return 1;
	}

	if (trfb_server_bind(srv, "localhost", "5913")) {
		fprintf(stderr, "Error: can't bind!\n");
		return 1;
	}

	if (trfb_server_start(srv)) {
		fprintf(stderr, "Error: can't start server!\n");
		return 1;
	}

	webcam_stream(cam, true);
	for (;;) {
		if (trfb_server_updated(srv)) {
			webcam_grab(cam, &frame);

			if (frame.length > 0) {
				draw_image(cam, &frame, srv);
			}
		}

		while (trfb_server_poll_event(srv, &event)) {
			if (event.type == TRFB_EVENT_KEY && (
						event.event.key.code == 'q' ||
						event.event.key.code == 'Q' ||
						event.event.key.code == 0xff1b)) {
				quit_now = 1;
			}
			printf("EVENT: %d\n", event.type);
			trfb_event_clear(&event);
		}
<commit_msg>test host<commit_after>#include "webcam/webcam.h"
#include <trfb.h>
#include <signal.h>

static int quit_now = 0;
static void sigint(int sig)
{
	quit_now = 1;
}

static void draw_image(webcam_t *cam, buffer_t *frame, trfb_server_t *srv)
{
	trfb_server_lock_fb(srv, 1);

	if (srv->fb->width * srv->fb->height * srv->fb->bpp >= frame->length)
		memcpy(srv->fb->pixels, frame->start, frame->length);

	trfb_server_unlock_fb(srv);
}

int main(int argc, char *argv[])
{
	trfb_server_t *srv;
	webcam_t *cam;
	buffer_t frame = { NULL, 0 };
	const unsigned width = 640;
	const unsigned height = 480;
	trfb_event_t event;

	signal(SIGINT, sigint);

	cam = webcam_open("/dev/video0");
	if (!cam) {
		fprintf(stderr, "Error: can't open webcam!\n");
		return 1;
	}
	webcam_resize(cam, width, height);

	srv = trfb_server_create(width, height, 4);
	if (!srv) {
		fprintf(stderr, "Error: can't create server!\n");
		return 1;
	}

	if (trfb_server_bind(srv, argc > 1? argv[0]: "localhost", "5913")) {
		fprintf(stderr, "Error: can't bind!\n");
		return 1;
	}

	if (trfb_server_start(srv)) {
		fprintf(stderr, "Error: can't start server!\n");
		return 1;
	}

	webcam_stream(cam, true);
	for (;;) {
		if (trfb_server_updated(srv)) {
			webcam_grab(cam, &frame);

			if (frame.length > 0) {
				draw_image(cam, &frame, srv);
			}
		}

		while (trfb_server_poll_event(srv, &event)) {
			if (event.type == TRFB_EVENT_KEY && (
						event.event.key.code == 'q' ||
						event.event.key.code == 'Q' ||
						event.event.key.code == 0xff1b)) {
				quit_now = 1;
			}
			printf("EVENT: %d\n", event.type);
			trfb_event_clear(&event);
		}

{'fraction_non_alphanumeric': 0.17511664074650077, 'fraction_numerical': 0.015552099533437015, 'mean_word_length': 3.8875379939209727, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7610713', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1329, 'n_words': 278}