From 21856cf4149973fbd6bd6b63bdedfbd7647b625e Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 10 Nov 2006 15:38:09 +0000 Subject: [PATCH] * Wrote manual pages for img2irc, cacaplay and cacaserver. --- doc/Makefile.am | 2 +- doc/cacaplay.1 | 26 ++++++++++++++++++++++++++ doc/cacaserver.1 | 30 ++++++++++++++++++++++++++++++ doc/cacaview.1 | 2 ++ doc/img2irc.1 | 27 +++++++++++++++++++++++++++ src/img2irc.c | 21 +++++++++++++++++++-- 6 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 doc/cacaplay.1 create mode 100644 doc/cacaserver.1 create mode 100644 doc/img2irc.1 diff --git a/doc/Makefile.am b/doc/Makefile.am index f61d3ba..1de9433 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -3,7 +3,7 @@ EXTRA_DIST = doxygen.cfg.in footer.html header.html $(man_MANS) $(doxygen_DOX) doxygen_DOX = libcaca.dox user.dox migrating.dox tutorial.dox style.dox -man_MANS = caca-config.1 cacafire.1 cacaview.1 +man_MANS = caca-config.1 cacafire.1 cacaview.1 cacaserver.1 img2irc.1 cacaplay.1 if BUILD_DOCUMENTATION htmldoc_DATA = html/doxygen.css diff --git a/doc/cacaplay.1 b/doc/cacaplay.1 new file mode 100644 index 0000000..befd7d9 --- /dev/null +++ b/doc/cacaplay.1 @@ -0,0 +1,26 @@ +.TH cacaplay 1 "2006-11-10" "libcaca" +.SH NAME +cacaplay \- play libcaca files +.SH SYNOPSIS +.B cacaplay [FILE] +.RI +.SH DESCRIPTION +.B cacaplay +plays libcaca animation files. These files can be created by any libcaca +program by setting the +.B CACA_DRIVER +environment variable to +.B "raw" +and storing the program's standard output. +.SH EXAMPLE +cacaplay file.caca +.SH BUGS +As of now, +.B cacaplay +can only play single-image canvases, rendering it pretty useless. See +.B cacaserver +for a more usable alternative. +.SH SEE ALSO +cacaserver(1) +.SH AUTHOR +This manual page was written by Sam Hocevar . diff --git a/doc/cacaserver.1 b/doc/cacaserver.1 new file mode 100644 index 0000000..3e08d07 --- /dev/null +++ b/doc/cacaserver.1 @@ -0,0 +1,30 @@ +.TH cacaserver 1 "2006-11-10" "libcaca" +.SH NAME +cacaserver \- telnet server for libcaca +.SH SYNOPSIS +.B cacaserver +.RI +.SH DESCRIPTION +.B cacaserver +reads libcaca animation files in its standard input and serves them as ANSI +art on network port 51914. These animations can be created by any libcaca +program by setting the +.B CACA_DRIVER +environment variable to +.B "raw" +and piping the program's standard output to +.B cacaserver. + +Clients can then connect to port 51914 using +.B telnet +or +.B netcat +to see the output. +.SH EXAMPLE +CACA_DRIVER=raw cacademo | cacaserver + +telnet localhost 51914 +.SH SEE ALSO +cacaplay(1) +.SH AUTHOR +This manual page was written by Sam Hocevar . diff --git a/doc/cacaview.1 b/doc/cacaview.1 index eabd657..07b1469 100644 --- a/doc/cacaview.1 +++ b/doc/cacaview.1 @@ -50,5 +50,7 @@ There is no support for aspect ratio yet. Also, since there is no way yet to load an image from .B cacaview it is completely useless when run without an argument. +.SH SEE ALSO +img2irc(1) .SH AUTHOR This manual page was written by Sam Hocevar . diff --git a/doc/img2irc.1 b/doc/img2irc.1 new file mode 100644 index 0000000..455adea --- /dev/null +++ b/doc/img2irc.1 @@ -0,0 +1,27 @@ +.TH img2irc 1 "2006-11-10" "libcaca" +.SH NAME +img2irc \- convert images to IRC coloured files +.SH SYNOPSIS +.B img2irc IMAGE [COLUMNS] +.RI +.SH DESCRIPTION +.B img2irc +convert images to colour ASCII characters and outputs them to text using +mIRC colour codes. +.PP +.B img2irc +can load the most widespread image formats: PNG, JPEG, GIF, PNG, BMP etc. +By default the output text is 60 columns wide; this value can be changed +by appending a second argument to the commandline. +.SH EXAMPLES +img2irc hello.jpg > hello.txt + +img2irc hello.jpg 40 > tinyhello.txt +.SH BUGS +This program could be merged into +.B cacaview +or expanded to support multiple output formats. +.SH SEE ALSO +cacaview(1) +.SH AUTHOR +This manual page was written by Sam Hocevar . diff --git a/src/img2irc.c b/src/img2irc.c index b0a41c9..2d01a66 100644 --- a/src/img2irc.c +++ b/src/img2irc.c @@ -23,6 +23,13 @@ #include "cucul.h" #include "common-image.h" +static void usage(int argc, char **argv) +{ + fprintf(stderr, "Usage: %s \n", argv[0]); + fprintf(stderr, " %s \n", argv[0]); + fprintf(stderr, " %s [-h|--help]\n", argv[0]); +} + int main(int argc, char **argv) { /* libcucul context */ @@ -30,14 +37,22 @@ int main(int argc, char **argv) void *export; unsigned long int len; struct image *i; - int cols = 56, lines; + int cols, lines; - if(argc != 2) + if(argc < 2 || argc > 3) { fprintf(stderr, "%s: wrong argument count\n", argv[0]); + usage(argc, argv); return 1; } + if(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) + { + fprintf(stderr, "%s: convert images to IRC file data\n", argv[0]); + usage(argc, argv); + return 0; + } + cv = cucul_create_canvas(0, 0); if(!cv) { @@ -54,6 +69,8 @@ int main(int argc, char **argv) } /* Assume a 6×10 font */ + cols = argc == 3 ? atoi(argv[2]) : 0; + cols = cols ? cols : 60; lines = cols * i->h * 6 / i->w / 10; cucul_set_canvas_size(cv, cols, lines);