|
|
@@ -26,7 +26,7 @@ |
|
|
|
#endif |
|
|
|
|
|
|
|
#include "cacamoo.h" |
|
|
|
#include <cucul.h> |
|
|
|
#include <caca.h> |
|
|
|
|
|
|
|
char const *cacamoo_export = "utf8"; |
|
|
|
char const *cacamoo_file = "default"; |
|
|
@@ -72,10 +72,8 @@ int main (int argc, char **argv) |
|
|
|
unsigned int new_width = 0; |
|
|
|
char *initial = NULL; |
|
|
|
unsigned int no_wrap = 0; |
|
|
|
cucul_buffer_t* input_buffer; |
|
|
|
cucul_buffer_t* output_buffer; |
|
|
|
cucul_canvas_t* canvas; |
|
|
|
int buf_size; |
|
|
|
caca_canvas_t* canvas; |
|
|
|
size_t buf_size; |
|
|
|
char *buf_data; |
|
|
|
|
|
|
|
if ((strstr(argv[0], "cacathink")) != NULL) { |
|
|
@@ -250,43 +248,32 @@ int main (int argc, char **argv) |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Import our buffer as an ansi (color) one */ |
|
|
|
input_buffer = cucul_load_memory(buffer, buffer_size-1); |
|
|
|
if(input_buffer == NULL) |
|
|
|
{ |
|
|
|
printf("Can't load file in libcucul !\n"); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
canvas = cucul_import_canvas (input_buffer, unicode?"utf8":"ansi"); |
|
|
|
if(canvas == NULL) |
|
|
|
canvas = caca_create_canvas(0, 0); |
|
|
|
if(caca_import_memory(canvas, buffer, buffer_size - 1, |
|
|
|
unicode ? "utf8" : "ansi") < 0) |
|
|
|
{ |
|
|
|
printf("Can't load file in libcucul !\n"); |
|
|
|
printf("Can't load file in libcaca !\n"); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
/* Export given canvas to format we want */ |
|
|
|
output_buffer = cucul_export_canvas(canvas, "utf8"); |
|
|
|
if(output_buffer == NULL) |
|
|
|
buf_data = caca_export_memory(canvas, "utf8", &buf_size); |
|
|
|
if(buf_data == NULL) |
|
|
|
{ |
|
|
|
printf("Can't export file to text !\n"); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
buf_size = cucul_get_buffer_size(output_buffer); |
|
|
|
buf_data = cucul_get_buffer_data(output_buffer); |
|
|
|
|
|
|
|
for(i = 0; i < buf_size; i++) |
|
|
|
printf("%c", buf_data[i]); |
|
|
|
fwrite(buf_data, buf_size, 1, stdout); |
|
|
|
|
|
|
|
if(string) |
|
|
|
free(string); |
|
|
|
if(buffer) |
|
|
|
free(buffer); |
|
|
|
|
|
|
|
cucul_free_buffer(input_buffer); |
|
|
|
cucul_free_buffer(output_buffer); |
|
|
|
cucul_free_canvas(canvas); |
|
|
|
|
|
|
|
free(buf_data); |
|
|
|
caca_free_canvas(canvas); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|