Browse Source

* Renamed cucul_buffer to cucul_export. Vanilla rum rules.

tags/v0.99.beta14
Sam Hocevar sam 19 years ago
parent
commit
bb1cedf858
9 changed files with 24 additions and 31 deletions
  1. +5
    -5
      caca/driver_network.c
  2. +4
    -5
      cucul/cucul.c
  3. +6
    -4
      cucul/cucul.h
  4. +1
    -3
      cucul/export_ansi.c
  5. +2
    -6
      cucul/export_html.c
  6. +1
    -3
      cucul/export_irc.c
  7. +1
    -1
      cucul/export_ps.c
  8. +1
    -1
      cucul/export_svg.c
  9. +3
    -3
      test/export.c

+ 5
- 5
caca/driver_network.c View File

@@ -100,7 +100,7 @@ struct driver_private


char prefix[sizeof(INIT_PREFIX)]; char prefix[sizeof(INIT_PREFIX)];


struct cucul_buffer *ex;
struct cucul_export *ex;


int client_count; int client_count;
struct client *clients; struct client *clients;
@@ -219,7 +219,7 @@ static int network_end_graphics(caca_t *kk)
} }


if(kk->drv.p->ex) if(kk->drv.p->ex)
cucul_free(kk->drv.p->ex);
cucul_free_export(kk->drv.p->ex);


/* Restore SIGPIPE handler */ /* Restore SIGPIPE handler */
signal(SIGPIPE, kk->drv.p->sigpipe_handler); signal(SIGPIPE, kk->drv.p->sigpipe_handler);
@@ -252,13 +252,13 @@ static void network_display(caca_t *kk)
/* Free the previous export buffer, if any */ /* Free the previous export buffer, if any */
if(kk->drv.p->ex) if(kk->drv.p->ex)
{ {
cucul_free(kk->drv.p->ex);
cucul_free_export(kk->drv.p->ex);
kk->drv.p->ex = NULL; kk->drv.p->ex = NULL;
} }


/* Get ANSI representation of the image and skip the end-of buffer /* Get ANSI representation of the image and skip the end-of buffer
* linefeed ("\r\n\0", 3 bytes) */ * linefeed ("\r\n\0", 3 bytes) */
kk->drv.p->ex = cucul_export(kk->qq, CUCUL_FORMAT_ANSI);
kk->drv.p->ex = cucul_get_export(kk->qq, CUCUL_FORMAT_ANSI);
kk->drv.p->ex->size -= 3; kk->drv.p->ex->size -= 3;


for(i = 0; i < kk->drv.p->client_count; i++) for(i = 0; i < kk->drv.p->client_count; i++)
@@ -374,7 +374,7 @@ static int send_data(caca_t *kk, struct client *c)
{ {
fprintf(stderr, "client %i said: %.02x %.02x %.02x (%s %s %s)\n", fprintf(stderr, "client %i said: %.02x %.02x %.02x (%s %s %s)\n",
c->fd, c->inbuf[0], c->inbuf[1], c->inbuf[2], c->fd, c->inbuf[0], c->inbuf[1], c->inbuf[2],
COMMAND_NAME(c->inbuf[0]), COMMAND_NAME(c->inbuf[1]), OPTION_NAME(c->inbuf[2]));
COMMAND_NAME(c->inbuf[0]), COMMAND_NAME(c->inbuf[1]), OPTION_NAME(c->inbuf[2]));
/* Just ignore, lol */ /* Just ignore, lol */
c->inbytes = 0; c->inbytes = 0;
} }


+ 4
- 5
cucul/cucul.c View File

@@ -29,7 +29,6 @@
#include "cucul_internals.h" #include "cucul_internals.h"


static void cucul_read_environment(cucul_t *); static void cucul_read_environment(cucul_t *);
void _cucul_set_size(cucul_t *, unsigned int, unsigned int);


/** \brief Initialise \e libcucul. /** \brief Initialise \e libcucul.
* *
@@ -276,11 +275,11 @@ void cucul_end(cucul_t *qq)
free(qq); free(qq);
} }


struct cucul_buffer * cucul_export(cucul_t *qq, enum cucul_format format)
struct cucul_export * cucul_get_export(cucul_t *qq, enum cucul_format format)
{ {
struct cucul_buffer *ex;
struct cucul_export *ex;


ex = malloc(sizeof(struct cucul_buffer));
ex = malloc(sizeof(struct cucul_export));


switch(format) switch(format)
{ {
@@ -310,7 +309,7 @@ struct cucul_buffer * cucul_export(cucul_t *qq, enum cucul_format format)
return ex; return ex;
} }


void cucul_free(struct cucul_buffer *ex)
void cucul_free_export(struct cucul_export *ex)
{ {
free(ex->buffer); free(ex->buffer);
free(ex); free(ex);


+ 6
- 4
cucul/cucul.h View File

@@ -21,6 +21,8 @@
#ifndef __CUCUL_H__ #ifndef __CUCUL_H__
#define __CUCUL_H__ #define __CUCUL_H__


#define CUCUL_API_VERSION_1

#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
@@ -215,17 +217,17 @@ void cucul_free_bitmap(cucul_t *, struct cucul_bitmap *);
/** \defgroup exporter Exporters to various formats /** \defgroup exporter Exporters to various formats
* *
* These functions export the current canvas to various text formats. It * These functions export the current canvas to various text formats. It
* is necessary to call cucul_free() to dispose of the data.
* is necessary to call cucul_free_export() to dispose of the data.
* *
* @{ */ * @{ */
struct cucul_buffer
struct cucul_export
{ {
unsigned int size; unsigned int size;
char *buffer; char *buffer;
}; };


struct cucul_buffer * cucul_export(cucul_t *, enum cucul_format);
void cucul_free(struct cucul_buffer *);
struct cucul_export * cucul_get_export(cucul_t *, enum cucul_format);
void cucul_free_export(struct cucul_export *);


/* @} */ /* @} */




+ 1
- 3
cucul/export_ansi.c View File

@@ -29,8 +29,6 @@
#include "cucul.h" #include "cucul.h"
#include "cucul_internals.h" #include "cucul_internals.h"




/** \brief Generate ANSI representation of current image. /** \brief Generate ANSI representation of current image.
* *
* This function generates and returns an ANSI representation of * This function generates and returns an ANSI representation of
@@ -39,7 +37,7 @@
* able to cut/paste the result to a function like printf * able to cut/paste the result to a function like printf
* \return buffer containing generated ANSI codes as a big string * \return buffer containing generated ANSI codes as a big string
*/ */
void _cucul_get_ansi(cucul_t *qq, struct cucul_buffer *ex)
void _cucul_get_ansi(cucul_t *qq, struct cucul_export *ex)
{ {
static int const palette[] = static int const palette[] =
{ {


+ 2
- 6
cucul/export_html.c View File

@@ -29,16 +29,12 @@
#include "cucul.h" #include "cucul.h"
#include "cucul_internals.h" #include "cucul_internals.h"




/* HTML */

/** \brief Generate HTML representation of current image. /** \brief Generate HTML representation of current image.
* *
* This function generates and returns the HTML representation of * This function generates and returns the HTML representation of
* the current image. * the current image.
*/ */
void _cucul_get_html(cucul_t *qq, struct cucul_buffer *ex)
void _cucul_get_html(cucul_t *qq, struct cucul_export *ex)
{ {
static int const palette[] = static int const palette[] =
{ {
@@ -116,7 +112,7 @@ void _cucul_get_html(cucul_t *qq, struct cucul_buffer *ex)
* Won't work under gecko (mozilla rendering engine) unless you set * Won't work under gecko (mozilla rendering engine) unless you set
* a correct header. * a correct header.
*/ */
void _cucul_get_html3(cucul_t *qq, struct cucul_buffer *ex)
void _cucul_get_html3(cucul_t *qq, struct cucul_export *ex)
{ {
static int const palette[] = static int const palette[] =
{ {


+ 1
- 3
cucul/export_irc.c View File

@@ -29,14 +29,12 @@
#include "cucul.h" #include "cucul.h"
#include "cucul_internals.h" #include "cucul_internals.h"




/** \brief Generate IRC representation of current image. /** \brief Generate IRC representation of current image.
* *
* This function generates and returns an IRC representation of * This function generates and returns an IRC representation of
* the current image. * the current image.
*/ */
void _cucul_get_irc(cucul_t *qq, struct cucul_buffer *ex)
void _cucul_get_irc(cucul_t *qq, struct cucul_export *ex)
{ {
static int const palette[] = static int const palette[] =
{ {


+ 1
- 1
cucul/export_ps.c View File

@@ -59,7 +59,7 @@ static char const *ps_header =
* This function generates and returns a Postscript representation of * This function generates and returns a Postscript representation of
* the current image. * the current image.
*/ */
void _cucul_get_ps(cucul_t *qq, struct cucul_buffer *ex)
void _cucul_get_ps(cucul_t *qq, struct cucul_export *ex)
{ {
static char const * const palette[] = static char const * const palette[] =
{ {


+ 1
- 1
cucul/export_svg.c View File

@@ -44,7 +44,7 @@ static char const svg_header[] =
* This function generates and returns a SVG representation of * This function generates and returns a SVG representation of
* the current image. * the current image.
*/ */
void _cucul_get_svg(cucul_t *qq, struct cucul_buffer *ex)
void _cucul_get_svg(cucul_t *qq, struct cucul_export *ex)
{ {
static int const palette[] = static int const palette[] =
{ {


+ 3
- 3
test/export.c View File

@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
cucul_t *qq; cucul_t *qq;
enum cucul_format format; enum cucul_format format;
struct cucul_bitmap *bitmap; struct cucul_bitmap *bitmap;
struct cucul_buffer *buffer;
struct cucul_export *buffer;
int x, y; int x, y;


if(argc != 2) if(argc != 2)
@@ -98,9 +98,9 @@ int main(int argc, char *argv[])
cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_LIGHTBLUE); cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_LIGHTBLUE);
cucul_putstr(qq, WIDTH / 2 - 7, HEIGHT / 2, " LIBCACA "); cucul_putstr(qq, WIDTH / 2 - 7, HEIGHT / 2, " LIBCACA ");


buffer = cucul_export(qq, format);
buffer = cucul_get_export(qq, format);
fwrite(buffer->buffer, buffer->size - 1, 1, stdout); fwrite(buffer->buffer, buffer->size - 1, 1, stdout);
cucul_free(buffer);
cucul_free_export(buffer);


cucul_end(qq); cucul_end(qq);




Loading…
Cancel
Save