From 195da3f08f62ee160e20eb619f6ae25bbadd77d6 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 15 Mar 2006 10:01:14 +0000 Subject: [PATCH] * Support CACA_GEOMETRY in the network driver. Still defaults to 80x24. * Use RETSIGTYPE for signal handler return values. --- caca/caca.h | 2 +- caca/driver_network.c | 28 +++++++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/caca/caca.h b/caca/caca.h index 974c98c..8f1bfa0 100644 --- a/caca/caca.h +++ b/caca/caca.h @@ -87,7 +87,7 @@ * * \li \b CACA_GEOMETRY: set the video display size. The format of this * variable must be XxY, with X and Y being integer values. This option - * currently only works with the X11 and the GL driver. + * currently works with the network, X11 and GL drivers. * * \li \b CACA_FONT: set the rendered font. The format of this variable is * implementation dependent, but since it currently only works with the diff --git a/caca/driver_network.c b/caca/driver_network.c index 52a70cd..12a526e 100644 --- a/caca/driver_network.c +++ b/caca/driver_network.c @@ -90,7 +90,7 @@ struct driver_private int client_count; struct client *clients; - void (*sigpipe_handler)(int); + RETSIGTYPE (*sigpipe_handler)(int); }; static void manage_connections(caca_t *kk); @@ -101,24 +101,38 @@ static int network_init_graphics(caca_t *kk) { int yes = 1, flags; int port = 0xCACA; /* 51914 */ - char *network_port, *tmp; + unsigned int width = 0, height = 0; + char *tmp; kk->drv.p = malloc(sizeof(struct driver_private)); if(kk->drv.p == NULL) return -1; #if defined(HAVE_GETENV) - network_port = getenv("CACA_PORT"); - if(network_port && *network_port) + tmp = getenv("CACA_PORT"); + if(tmp && *tmp) { - int new_port = atoi(network_port); + int new_port = atoi(tmp); if(new_port) port = new_port; } + + tmp = getenv("CACA_GEOMETRY"); + if(tmp && *tmp) + sscanf(tmp, "%ux%u", &width, &height); #endif - kk->drv.p->width = 80; - kk->drv.p->height = 24; + if(width && height) + { + kk->drv.p->width = width; + kk->drv.p->height = height; + } + else + { + kk->drv.p->width = 80; + kk->drv.p->height = 24; + } + kk->drv.p->client_count = 0; kk->drv.p->clients = NULL; kk->drv.p->port = port;