Changeset 2979


Ignore:
Timestamp:
Oct 18, 2008, 11:24:58 PM (9 years ago)
Author:
Sam Hocevar
Message:

Port cacamoo to the unified libcaca 0.99.beta15 API.

Location:
cacamoo/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cacamoo/trunk/configure.ac

    r2441 r2979  
    3636
    3737CACA="no"
    38 PKG_CHECK_MODULES(CUCUL, cucul,
     38PKG_CHECK_MODULES(CACA, caca >= 0.99.beta15,
    3939 [CACA="yes"],
    4040 [AC_MSG_RESULT(no)
    41   AC_MSG_ERROR([you need libcucul version 0.99 or later])])
     41  AC_MSG_ERROR([you need libcaca version 0.99.beta15 or later])])
    4242
    4343# Optimizations
  • cacamoo/trunk/src/Makefile.am

    r1448 r2979  
    33
    44cacamoo_SOURCES = main.c cacamoo.h
    5 cacamoo_CFLAGS = @CUCUL_CFLAGS@
    6 cacamoo_LDADD = @CUCUL_LIBS@
     5cacamoo_CFLAGS = @CACA_CFLAGS@
     6cacamoo_LDADD = @CACA_LIBS@
    77
  • cacamoo/trunk/src/cacamoo.h

    r1457 r2979  
    1313 */
    1414
    15 #ifndef _CACASAY_H_
    16 #define _CACASAY_H_
     15#ifndef _CACAMOO_H_
     16#define _CACAMOO_H_
    1717
    1818#include <stdio.h>
     
    2424
    2525
    26 #include <cucul.h>
     26#include <caca.h>
    2727
    2828static void version(void);
     
    3939#endif
    4040
    41 #endif /* _CACASAY_H_ */
     41#endif /* _CACAMOO_H_ */
  • cacamoo/trunk/src/main.c

    r1457 r2979  
    2727
    2828#include "cacamoo.h"
    29 #include <cucul.h>
     29#include <caca.h>
    3030
    3131char const *cacamoo_export = "utf8";
     
    7373    char *initial = NULL;
    7474    unsigned int no_wrap = 0;
    75     cucul_buffer_t* input_buffer;
    76     cucul_buffer_t* output_buffer;
    77     cucul_canvas_t* canvas;
    78     int buf_size;
     75    caca_canvas_t* canvas;
     76    size_t buf_size;
    7977    char *buf_data;
    8078
     
    251249    }
    252250
    253 
    254251    /* Import our buffer as an ansi (color) one */
    255     input_buffer = cucul_load_memory(buffer, buffer_size-1);
    256     if(input_buffer == NULL)
    257     {
    258         printf("Can't load file in libcucul !\n");
     252    canvas = caca_create_canvas(0, 0);
     253    if(caca_import_memory(canvas, buffer, buffer_size - 1,
     254                          unicode ? "utf8" : "ansi") < 0)
     255    {
     256        printf("Can't load file in libcaca !\n");
    259257        return -1;
    260258    }
    261     canvas = cucul_import_canvas (input_buffer, unicode?"utf8":"ansi");
    262     if(canvas == NULL)
    263     {
    264         printf("Can't load file in libcucul !\n");
    265         return -1;
    266     }
     259
    267260    /* Export given canvas to format we want */
    268     output_buffer = cucul_export_canvas(canvas, "utf8");
    269     if(output_buffer == NULL)
     261    buf_data = caca_export_memory(canvas, "utf8", &buf_size);
     262    if(buf_data == NULL)
    270263    {
    271264        printf("Can't export file to text !\n");
     
    273266    }
    274267
    275     buf_size = cucul_get_buffer_size(output_buffer);
    276     buf_data = cucul_get_buffer_data(output_buffer);
    277 
    278     for(i = 0; i < buf_size; i++)
    279         printf("%c", buf_data[i]);
     268    fwrite(buf_data, buf_size, 1, stdout);
    280269
    281270    if(string)
     
    284273        free(buffer);
    285274
    286     cucul_free_buffer(input_buffer);
    287     cucul_free_buffer(output_buffer);
    288     cucul_free_canvas(canvas);
    289 
     275    free(buf_data);
     276    caca_free_canvas(canvas);
    290277
    291278    return 0;
Note: See TracChangeset for help on using the changeset viewer.