Browse Source

* Updated README for network driver, fixed remaining exporters

tags/v0.99.beta14
Jean-Yves Lamoureux jylam 19 years ago
parent
commit
5a09b684fe
4 changed files with 46 additions and 19 deletions
  1. +1
    -0
      README
  2. +10
    -0
      cucul/cucul.c
  3. +6
    -1
      cucul/cucul_internals.h
  4. +29
    -18
      cucul/export.c

+ 1
- 0
README View File

@@ -10,6 +10,7 @@ Building libcaca
--enable-x11: support for native X11 rendering
--enable-gl: support for OpenGL rendering
--enable-win32: support for the Windows console
--enable-network: support for network output

--disable-imlib2: remove Imlib2 support in cacaview



+ 10
- 0
cucul/cucul.c View File

@@ -75,6 +75,9 @@ cucul_t * cucul_init(void)
}

qq->ansi_buffer = NULL;
qq->irc_buffer = NULL;
qq->html3_buffer = NULL;
qq->html_buffer = NULL;
return qq;
}
@@ -276,6 +279,13 @@ void cucul_end(cucul_t *qq)

if(qq->ansi_buffer)
free(qq->ansi_buffer);
if(qq->irc_buffer)
free(qq->irc_buffer);
if(qq->html3_buffer)
free(qq->html3_buffer);
if(qq->html_buffer)
free(qq->html_buffer);


free(qq);
}


+ 6
- 1
cucul/cucul_internals.h View File

@@ -47,7 +47,12 @@ struct cucul_context
unsigned int refcount;

/* Exporters facilities */
unsigned char *ansi_buffer;
char *ansi_buffer;
char *irc_buffer;
char *html3_buffer;
char *html_buffer;


};



+ 29
- 18
cucul/export.c View File

@@ -44,14 +44,17 @@ char* cucul_get_html(cucul_t *qq, int *size)
0x000, 0x008, 0x080, 0x088, 0x800, 0x808, 0x880, 0x888,
0x444, 0x44f, 0x4f4, 0x4ff, 0xf44, 0xf4f, 0xff4, 0xfff,
};
char *buffer, *cur;
char *cur;
unsigned int x, y, len;

/* 13000 -> css palette
* 40 -> max size used for a pixel (plus 10, never know)*/
/* FIXME: Check this value */
buffer = malloc((13000 + ((qq->width*qq->height) * 40)) * sizeof(char));
cur = buffer;
if(qq->html_buffer)
free(qq->html_buffer);

qq->html_buffer = malloc((13000 + ((qq->width*qq->height) * 40)) * sizeof(char));
cur = qq->html_buffer;

/* HTML header */
cur += sprintf(cur, "<html>\n<head>\n<title>Generated by libcaca %s</title>\n", VERSION);
@@ -96,10 +99,10 @@ char* cucul_get_html(cucul_t *qq, int *size)
cur += sprintf(cur, "</div></body></html>\n");

/* Crop to really used size */
*size = (strlen(buffer) + 1) * sizeof(char);
buffer = realloc(buffer, *size);
*size = (strlen(qq->html_buffer) + 1) * sizeof(char);
qq->html_buffer = realloc(qq->html_buffer, *size);

return buffer;
return qq->html_buffer;
}

/** \brief Generate HTML3 representation of current image.
@@ -119,13 +122,17 @@ char* cucul_get_html3(cucul_t *qq, int *size)
0x444444, 0x4444ff, 0x44ff44, 0x44ffff,
0xff4444, 0xff44ff, 0xffff44, 0xffffff,
};
char *buffer, *cur;
char *cur;
unsigned int x, y, len;

/* 13000 -> css palette
* 40 -> max size used for a pixel (plus 10, never know) */
buffer = malloc((13000 + ((qq->width*qq->height)*40))*sizeof(char));
cur = buffer;

if(qq->html3_buffer)
free(qq->html3_buffer);

qq->html3_buffer = malloc((13000 + ((qq->width*qq->height)*40))*sizeof(char));
cur = qq->html3_buffer;

/* Table */
cur += sprintf(cur, "<table cols='%d' cellpadding='0' cellspacing='0'>\n",
@@ -173,10 +180,10 @@ char* cucul_get_html3(cucul_t *qq, int *size)
cur += sprintf(cur, "</table>\n");

/* Crop to really used size */
*size = (strlen(buffer) + 1) * sizeof(char);
buffer = realloc(buffer, *size);
*size = (strlen(qq->html3_buffer) + 1) * sizeof(char);
qq->html3_buffer = realloc(qq->html3_buffer, *size);
return buffer;
return qq->html3_buffer;
}

/** \brief Generate IRC representation of current image.
@@ -192,7 +199,7 @@ char* cucul_get_irc(cucul_t *qq, int *size)
14, 12, 9, 11, 4, 13, 8, 0, /* Light */
};

char *buffer, *cur;
char *cur;
unsigned int x, y;

/* 11 bytes assumed for max length per pixel. Worst case scenario:
@@ -202,8 +209,12 @@ char* cucul_get_irc(cucul_t *qq, int *size)
* \r\n 2 bytes
* In real life, the average bytes per pixel value will be around 5.
*/
buffer = malloc((2 + (qq->width * qq->height * 11)) * sizeof(char));
cur = buffer;

if(qq->irc_buffer)
free(qq->irc_buffer);

qq->irc_buffer = malloc((2 + (qq->width * qq->height * 11)) * sizeof(char));
cur = qq->irc_buffer;

*cur++ = '\x0f';

@@ -255,10 +266,10 @@ char* cucul_get_irc(cucul_t *qq, int *size)
*cur++ = '\x0f';

/* Crop to really used size */
*size = (strlen(buffer) + 1) * sizeof(char);
buffer = realloc(buffer, *size);
*size = (strlen(qq->irc_buffer) + 1) * sizeof(char);
qq->irc_buffer = realloc(qq->irc_buffer, *size);

return buffer;
return qq->irc_buffer;
}

/** \brief Generate ANSI representation of current image.


Loading…
Cancel
Save