|
@@ -59,6 +59,9 @@ unsigned int term_width = 40-1; /* Default for cowsay */ |
|
|
/* Think ? */ |
|
|
/* Think ? */ |
|
|
unsigned char think = 0; |
|
|
unsigned char think = 0; |
|
|
|
|
|
|
|
|
|
|
|
/* Unicode */ |
|
|
|
|
|
unsigned char unicode = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main (int argc, char **argv) |
|
|
int main (int argc, char **argv) |
|
|
{ |
|
|
{ |
|
@@ -102,18 +105,20 @@ int main (int argc, char **argv) |
|
|
{ "youth", 1, NULL, 'y' }, |
|
|
{ "youth", 1, NULL, 'y' }, |
|
|
{ "wired", 1, NULL, 'w' }, |
|
|
{ "wired", 1, NULL, 'w' }, |
|
|
{ "think", 1, NULL, 'O' }, |
|
|
{ "think", 1, NULL, 'O' }, |
|
|
|
|
|
{ "unicode", 1, NULL, 'u' }, |
|
|
{ "version", 0, NULL, 'v' }, |
|
|
{ "version", 0, NULL, 'v' }, |
|
|
|
|
|
{ "list-files", 0, NULL, 'l' }, |
|
|
{ "help", 0, NULL, 'h' }, |
|
|
{ "help", 0, NULL, 'h' }, |
|
|
{ NULL, 0, NULL, 0 } |
|
|
{ NULL, 0, NULL, 0 } |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int c = getopt_long(argc, argv, "D:f:W:e:T:hvObtdgpsywn", |
|
|
|
|
|
|
|
|
int c = getopt_long(argc, argv, "D:f:W:e:T:hvObtdgpsylwnu", |
|
|
long_options, &option_index); |
|
|
long_options, &option_index); |
|
|
# else |
|
|
# else |
|
|
# define MOREINFO "Try `%s -h' for more information.\n" |
|
|
# define MOREINFO "Try `%s -h' for more information.\n" |
|
|
int c = getopt(argc, argv, "D:f:W:hvObtdgpsywn"); |
|
|
|
|
|
|
|
|
int c = getopt(argc, argv, "D:f:W:hvObtdgpsylwnu"); |
|
|
# endif |
|
|
# endif |
|
|
if(c == -1) |
|
|
if(c == -1) |
|
|
break; |
|
|
break; |
|
@@ -169,7 +174,15 @@ int main (int argc, char **argv) |
|
|
term_width = strtol(optarg, NULL, 10); |
|
|
term_width = strtol(optarg, NULL, 10); |
|
|
if(term_width && (term_width != 1)) term_width--; |
|
|
if(term_width && (term_width != 1)) term_width--; |
|
|
break; |
|
|
break; |
|
|
case 'n': /* --width */ |
|
|
|
|
|
|
|
|
case 'l': /* --list-files */ |
|
|
|
|
|
list_files("."); |
|
|
|
|
|
list_files(cacamoo_dir); |
|
|
|
|
|
return 0; |
|
|
|
|
|
break; |
|
|
|
|
|
case 'u': /* --unicode */ |
|
|
|
|
|
unicode = 1; |
|
|
|
|
|
break; |
|
|
|
|
|
case 'n': /* --no-wrap */ |
|
|
no_wrap = 1; |
|
|
no_wrap = 1; |
|
|
break; |
|
|
break; |
|
|
case '?': |
|
|
case '?': |
|
@@ -239,9 +252,24 @@ int main (int argc, char **argv) |
|
|
|
|
|
|
|
|
/* Import our buffer as an ansi (color) one */ |
|
|
/* Import our buffer as an ansi (color) one */ |
|
|
input_buffer = cucul_load_memory(buffer, buffer_size); |
|
|
input_buffer = cucul_load_memory(buffer, buffer_size); |
|
|
canvas = cucul_import_canvas (input_buffer, "ansi"); |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
{ |
|
|
|
|
|
printf("Can't load file in libcucul !\n"); |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
/* Export given canvas to format we want */ |
|
|
/* Export given canvas to format we want */ |
|
|
output_buffer = cucul_export_canvas(canvas, "irc"); |
|
|
output_buffer = cucul_export_canvas(canvas, "irc"); |
|
|
|
|
|
if(output_buffer == NULL) |
|
|
|
|
|
{ |
|
|
|
|
|
printf("Can't export file to text !\n"); |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
buf_size = cucul_get_buffer_size(output_buffer); |
|
|
buf_size = cucul_get_buffer_size(output_buffer); |
|
|
buf_data = cucul_get_buffer_data(output_buffer); |
|
|
buf_data = cucul_get_buffer_data(output_buffer); |
|
@@ -258,6 +286,32 @@ int main (int argc, char **argv) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void list_files(const char *directory) |
|
|
|
|
|
{ |
|
|
|
|
|
struct dirent * dp; |
|
|
|
|
|
int count = 0; |
|
|
|
|
|
DIR *dir = opendir(directory); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (dp = readdir(dir); dp != NULL; dp = readdir(dir)) |
|
|
|
|
|
{ |
|
|
|
|
|
if(!strncmp(&dp->d_name[strlen(dp->d_name)-4], ".cow", 4)) |
|
|
|
|
|
{ |
|
|
|
|
|
char name[256]; |
|
|
|
|
|
memcpy(name, dp->d_name, strlen(dp->d_name)-4); |
|
|
|
|
|
name[strlen(dp->d_name)-4] = 0; |
|
|
|
|
|
printf("%s ", name); |
|
|
|
|
|
count++; |
|
|
|
|
|
if(!(count%6)) |
|
|
|
|
|
printf("\n"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
closedir(dir); |
|
|
|
|
|
if(count) |
|
|
|
|
|
printf("\n"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
char * make_caca_from_file(unsigned int *size) |
|
|
char * make_caca_from_file(unsigned int *size) |
|
|
{ |
|
|
{ |
|
|
FILE *fp = NULL; |
|
|
FILE *fp = NULL; |
|
|