From 1c6bfd09a18403777113a561bd3f5fbb0d10cc9b Mon Sep 17 00:00:00 2001 From: Jean-Yves Lamoureux Date: Fri, 10 Mar 2006 14:41:24 +0000 Subject: [PATCH] * Fixed configure script to check for UTF8 enabled slang, removed network driver debug output, added size > 255 in telnet negociation, fixed scrolling bug in network driver --- caca/driver_network.c | 25 ++++++++++++------------- configure.ac | 4 ++-- cucul/cucul_internals.h | 2 ++ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/caca/driver_network.c b/caca/driver_network.c index 5ca8903..d9a616a 100644 --- a/caca/driver_network.c +++ b/caca/driver_network.c @@ -70,7 +70,7 @@ static char codes[] = {0xff, 0xfb, 0x01, // WILL ECHO 0xff, 0xfb, 0x03, // WILL SUPPRESS GO AHEAD 0xff, 253, 31, // DO NAWS 0xff, 254, 31, // DON'T NAWS - 0xff, 31, 250, 0, 30, 0, 0xFF, // to be replaced + 0xff, 31, 250, 0, 30, 0, 0xFF, // Set size, replaced in display 0xff, 240}; @@ -78,14 +78,12 @@ static int network_init_graphics(caca_t *kk) { int yes=1; - printf("Initing network stack.\n"); - kk->drv.p = malloc(sizeof(struct driver_private)); if(kk->drv.p == NULL) return -1; kk->drv.p->width = 80; - kk->drv.p->height = 24; + kk->drv.p->height = 23; // Avoid scrolling kk->drv.p->port = 7575; // 75 75 decimal ASCII -> KK // FIXME, sadly kk->drv.p->client_count = 0; kk->drv.p->fd_list = NULL; @@ -95,12 +93,11 @@ static int network_init_graphics(caca_t *kk) _cucul_set_size(kk->qq, kk->drv.p->width, kk->drv.p->height); - printf("socket\n"); if ((kk->drv.p->sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) { perror("socket"); return -1; } - printf("setsockopt\n"); + if (setsockopt(kk->drv.p->sockfd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int)) == -1) { perror("setsockopt"); return -1; @@ -111,7 +108,6 @@ static int network_init_graphics(caca_t *kk) kk->drv.p->my_addr.sin_addr.s_addr = INADDR_ANY; memset(&(kk->drv.p->my_addr.sin_zero), '\0', 8); - printf("bind\n"); if (bind(kk->drv.p->sockfd, (struct sockaddr *)&kk->drv.p->my_addr, sizeof(struct sockaddr)) == -1) { perror("bind"); @@ -121,15 +117,11 @@ static int network_init_graphics(caca_t *kk) /* Non blocking socket */ fcntl(kk->drv.p->sockfd, F_SETFL, O_NONBLOCK); - - printf("listen\n"); if (listen(kk->drv.p->sockfd, BACKLOG) == -1) { perror("listen"); return -1; } - printf("network ok.\n"); - kk->drv.p->buffer = NULL; return 0; @@ -166,6 +158,7 @@ static void network_display(caca_t *kk) { int i; + /* Get ANSI representation of the image */ kk->drv.p->buffer = cucul_get_ansi(kk->qq, 0, &kk->drv.p->size);; for(i = 0; i < kk->drv.p->client_count; i++) @@ -184,9 +177,12 @@ static void network_handle_resize(caca_t *kk) static unsigned int network_get_event(caca_t *kk) { + /* Manage new connections as this function will be called sometimes + * more often than display + */ manage_connections(kk); - /* Not handled */ + /* Event not handled */ return 0; } @@ -200,7 +196,7 @@ static void manage_connections(caca_t *kk) kk->drv.p->clilen = sizeof(kk->drv.p->remote_addr); fd = accept(kk->drv.p->sockfd, (struct sockaddr *) &kk->drv.p->remote_addr, &kk->drv.p->clilen); - if(fd != -1) + if(fd != -1) /* That's non blocking socket, -1 if no connection received */ { if(kk->drv.p->fd_list == NULL) { @@ -231,7 +227,9 @@ static int send_data(caca_t *kk, int fd) return -1; /* FIXME, handle >255 sizes */ + codes[15] = (unsigned char) (kk->drv.p->width & 0xff00)>>8; codes[16] = (unsigned char) kk->drv.p->width & 0xff; + codes[17] = (unsigned char) (kk->drv.p->height & 0xff00)>>8; codes[18] = (unsigned char) kk->drv.p->height & 0xff; /* Send basic telnet codes */ @@ -242,6 +240,7 @@ static int send_data(caca_t *kk, int fd) if (send(fd, "\033[1,1H", 6, 0) == -1) return -1; + /* Send actual data */ if (send(fd, kk->drv.p->buffer, kk->drv.p->size, 0) == -1) return -1; diff --git a/configure.ac b/configure.ac index be70bd9..5fbcbdc 100644 --- a/configure.ac +++ b/configure.ac @@ -100,9 +100,9 @@ fi if test "${enable_slang}" != "no"; then ac_cv_my_have_slang="no" AC_CHECK_HEADERS(slang.h slang/slang.h, - [AC_CHECK_LIB(slang, SLkp_init, + [AC_CHECK_LIB(slang, SLsmg_utf8_enable, [ac_cv_my_have_slang="yes" - AC_DEFINE(USE_SLANG, 1, Define to activate the slang backend driver) + AC_DEFINE(USE_SLANG, 1, Define to activate the slang backend driver (needs slang-utf8)) CPPFLAGS="${CPPFLAGS} -DOPTIMISE_SLANG_PALETTE=1" CACA_LIBS="${CACA_LIBS} -lslang" CACA_DRIVERS="${CACA_DRIVERS} slang"])]) diff --git a/cucul/cucul_internals.h b/cucul/cucul_internals.h index 0e0405e..5781e01 100644 --- a/cucul/cucul_internals.h +++ b/cucul/cucul_internals.h @@ -61,5 +61,7 @@ struct cucul_context /* Initialisation functions */ extern int _cucul_init_bitmap(void); extern int _cucul_end_bitmap(void); +void _cucul_set_size(cucul_t *qq, unsigned int width, unsigned int height); + #endif /* __CUCUL_INTERNALS_H__ */