Просмотр исходного кода

Port cacamoo to the unified libcaca 0.99.beta15 API.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/cacamoo/trunk@2979 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 16 лет назад
Родитель
Сommit
8b8fa19b7a
4 измененных файлов: 21 добавлений и 34 удалений
  1. +2
    -2
      configure.ac
  2. +2
    -2
      src/Makefile.am
  3. +4
    -4
      src/cacamoo.h
  4. +13
    -26
      src/main.c

+ 2
- 2
configure.ac Просмотреть файл

@@ -35,10 +35,10 @@ AC_CHECK_FUNCS(getopt_long,
AC_SUBST(GETOPT_LIBS)

CACA="no"
PKG_CHECK_MODULES(CUCUL, cucul,
PKG_CHECK_MODULES(CACA, caca >= 0.99.beta15,
[CACA="yes"],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([you need libcucul version 0.99 or later])])
AC_MSG_ERROR([you need libcaca version 0.99.beta15 or later])])

# Optimizations
CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"


+ 2
- 2
src/Makefile.am Просмотреть файл

@@ -2,6 +2,6 @@
bin_PROGRAMS = cacamoo

cacamoo_SOURCES = main.c cacamoo.h
cacamoo_CFLAGS = @CUCUL_CFLAGS@
cacamoo_LDADD = @CUCUL_LIBS@
cacamoo_CFLAGS = @CACA_CFLAGS@
cacamoo_LDADD = @CACA_LIBS@


+ 4
- 4
src/cacamoo.h Просмотреть файл

@@ -12,8 +12,8 @@
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

#ifndef _CACASAY_H_
#define _CACASAY_H_
#ifndef _CACAMOO_H_
#define _CACAMOO_H_

#include <stdio.h>
#include <string.h>
@@ -23,7 +23,7 @@
#include <dirent.h>


#include <cucul.h>
#include <caca.h>

static void version(void);
char *construct_balloon(char *buffer, unsigned int termwidth);
@@ -38,4 +38,4 @@ void list_files(const char *directory);
static void usage(void);
#endif

#endif /* _CACASAY_H_ */
#endif /* _CACAMOO_H_ */

+ 13
- 26
src/main.c Просмотреть файл

@@ -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;
}


Загрузка…
Отмена
Сохранить