From 1cb8d025605c27da3dd0971c38e583af3cfbcdf4 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 8 Nov 2006 17:18:23 +0000 Subject: [PATCH] * Set the cucul_import_memory() buffer type to void const * instead of unsigned char const * so that C++ programs won't complain. ___ __ __ ____ ___ ___ ___ / _ \| \/ |/ ___| / _ \ / _ \ / _ \ | | | | |\/| | | _ | (_) | (_) | (_) | | |_| | | | | |_| | \__, |\__, |\__, | \___/|_| |_|\____| /_/ /_/ /_/ --- cucul/cucul.h | 2 +- cucul/import.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cucul/cucul.h b/cucul/cucul.h index c94c110..36bc66c 100644 --- a/cucul/cucul.h +++ b/cucul/cucul.h @@ -216,7 +216,7 @@ int cucul_free_font(cucul_font_t *); * the current canvas to various text formats. * * @{ */ -long int cucul_import_memory(cucul_canvas_t *, unsigned char const *, +long int cucul_import_memory(cucul_canvas_t *, void const *, unsigned long int, char const *); long int cucul_import_file(cucul_canvas_t *, char const *, char const *); char const * const * cucul_get_import_list(void); diff --git a/cucul/import.c b/cucul/import.c index de964cb..25900de 100644 --- a/cucul/import.c +++ b/cucul/import.c @@ -82,7 +82,7 @@ static void ansi_parse_grcm(cucul_canvas_t *, struct ansi_grcm *, * \param format A string describing the input format. * \return The number of bytes read, or -1 if an error occurred. */ -long int cucul_import_memory(cucul_canvas_t *cv, unsigned char const *buf, +long int cucul_import_memory(cucul_canvas_t *cv, void const *buf, unsigned long int len, char const *format) { if(!strcasecmp("caca", format)) @@ -97,16 +97,17 @@ long int cucul_import_memory(cucul_canvas_t *cv, unsigned char const *buf, /* Autodetection */ if(!strcasecmp("", format)) { + unsigned char const *str = buf; unsigned int i; /* If 4 first bytes are 0xcaca + 'CV' */ - if(len >= 4 && buf[0] == 0xca && - buf[1] == 0xca && buf[2] == 'C' && buf[3] == 'V') + if(len >= 4 && str[0] == 0xca && + str[1] == 0xca && str[2] == 'C' && str[3] == 'V') return import_caca(cv, buf, len); /* If we find ESC[ argv, we guess it's an ANSI file */ for(i = 0; i + 1 < len; i++) - if((buf[i] == 0x1b) && (buf[i + 1] == '[')) + if((str[i] == 0x1b) && (str[i + 1] == '[')) return import_ansi(cv, buf, len, 0); /* Otherwise, import it as text */