|
|
@@ -59,6 +59,9 @@ unsigned int term_width = 40-1; /* Default for cowsay */ |
|
|
|
/* Think ? */ |
|
|
|
unsigned char think = 0; |
|
|
|
|
|
|
|
/* Unicode */ |
|
|
|
unsigned char unicode = 0; |
|
|
|
|
|
|
|
|
|
|
|
int main (int argc, char **argv) |
|
|
|
{ |
|
|
@@ -102,18 +105,20 @@ int main (int argc, char **argv) |
|
|
|
{ "youth", 1, NULL, 'y' }, |
|
|
|
{ "wired", 1, NULL, 'w' }, |
|
|
|
{ "think", 1, NULL, 'O' }, |
|
|
|
{ "unicode", 1, NULL, 'u' }, |
|
|
|
{ "version", 0, NULL, 'v' }, |
|
|
|
{ "list-files", 0, NULL, 'l' }, |
|
|
|
{ "help", 0, NULL, 'h' }, |
|
|
|
{ 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); |
|
|
|
# else |
|
|
|
# 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 |
|
|
|
if(c == -1) |
|
|
|
break; |
|
|
@@ -169,7 +174,15 @@ int main (int argc, char **argv) |
|
|
|
term_width = strtol(optarg, NULL, 10); |
|
|
|
if(term_width && (term_width != 1)) term_width--; |
|
|
|
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; |
|
|
|
break; |
|
|
|
case '?': |
|
|
@@ -239,9 +252,24 @@ int main (int argc, char **argv) |
|
|
|
|
|
|
|
/* Import our buffer as an ansi (color) one */ |
|
|
|
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 */ |
|
|
|
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_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) |
|
|
|
{ |
|
|
|
FILE *fp = NULL; |
|
|
|