Codebase list ansilove / 097f466
Import Debian changes 4.0.3-1 ansilove (4.0.3-1) unstable; urgency=medium * New upstream version. Gürkan Myczko authored 4 years ago root committed 4 years ago
14 changed file(s) with 107 addition(s) and 87 deletion(s). Raw diff Collapse all Expand all
2323 coverity_scan:
2424 project:
2525 name: "ansilove/ansilove"
26 version: 4.0.0
26 version: 4.0.3
2727 description: "ANSi / ASCII art to PNG converter in C"
2828 notification_email: fred@statdns.com
2929 build_command_prepend: cmake .
0 AnsiLove/C 4.0.3 (2019-08-16)
1
2 - Use errx() for displaying error messages
3 - Print information messages on stdout
4 - Introduce a version() function to display version information
5 - Add a -q flag (quiet) to allow silencing output messages
6
7
8
09 AnsiLove/C 4.0.2 (2019-08-13)
110
211 - Remove most examples from the repository, they continue to live on the
1616 - -----------//______|----------------- -
1717 : :
1818 | |
19 | Ansilove/C 4.0.2 |
19 | Ansilove/C 4.0.3 |
2020 | |
2121 | ANSi=>PNG converter & library |
2222 | |
2222 This is a complete rewrite of [AnsiLove/PHP][3] in the C programming
2323 language. It converts ANSi and artscene related file formats into
2424 PNG images. The project is considered as stable, current version
25 is `4.0.2`.
25 is `4.0.3`.
2626
2727 # Specs
2828
8383
8484 pkg install ansilove
8585
86 ### Debian / Ubuntu
87
88 apt install ansilove
89
8690 ### Solus
8791
8892 eopkg install ansilove
120124 ## Synopsis
121125
122126 ```
123 ansilove [-dhirsv] [-b bits] [-c columns] [-f font] [-m mode] [-o file]
127 ansilove [-dhiqrsv] [-b bits] [-c columns] [-f font] [-m mode] [-o file]
124128 [-R factor] file
125129 ```
126130
151155 Use Amiga Workbench palette.
152156
153157 -o file Specify output filename/path.
158
159 -q Suppress output messages (quiet).
154160
155161 -r Create Retina @2x output file.
156162
2323 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2424 .\" POSSIBILITY OF SUCH DAMAGE.
2525 .\"
26 .Dd $Mdocdate: January 16 2019 $
26 .Dd $Mdocdate: August 16 2019 $
2727 .Dt ANSILOVE 1
2828 .Os
2929 .Sh NAME
3131 .Nd ANSI / ASCII art to PNG converter
3232 .Sh SYNOPSIS
3333 .Nm
34 .Op Fl dhirsv
34 .Op Fl dhiqrsv
3535 .Op Fl b Ar bits
3636 .Op Fl c Ar columns
3737 .Op Fl f Ar font
134134 .El
135135 .It Fl o Ar file
136136 Specify output filename/path.
137 .It Fl q
138 Suppress output messages (quiet).
137139 .It Fl r
138140 Create Retina @2x output file.
139141 .It Fl R Ar factor
0 Repackaged, dropping examples/*
0 ansilove (4.0.3-1) unstable; urgency=medium
1
2 * New upstream version.
3
4 -- Gürkan Myczko <gurkan@phys.ethz.ch> Fri, 30 Aug 2019 20:29:08 +0200
5
06 ansilove (4.0.2-1) unstable; urgency=medium
17
28 * New upstream version.
00 /*
11 * ansilove.c
2 * Ansilove 4.0.2
2 * Ansilove 4.0.3
33 * https://www.ansilove.org
44 *
55 * Copyright (c) 2011-2019 Stefan Vogt, Brian Cassidy, and Frederic Cambus
3434
3535 /* prototypes */
3636 static void synopsis(void);
37
38 /* following the IEEE Std 1003.1 for utility conventions */
37 static void version(void);
38
3939 static void
4040 synopsis(void)
4141 {
42 fprintf(stderr, "\nSYNOPSIS\n"
43 " ansilove [-dhirsv] [-b bits] [-c columns] [-f font] [-m mode]"
44 " [-o file]\n"
45 " [-R factor] file\n\n");
42 fprintf(stdout, "SYNOPSIS\n"
43 " ansilove [-dhiqrsv] [-b bits] [-c columns] [-f font]"
44 " [-m mode] [-o file]\n"
45 " [-R factor] file\n");
46 }
47
48 static void
49 version(void)
50 {
51 fprintf(stdout, "AnsiLove/C %s - ANSI / ASCII art to PNG converter\n"
52 "Copyright (c) 2011-2019 Stefan Vogt, Brian Cassidy, and "
53 "Frederic Cambus.\n", VERSION);
4654 }
4755
4856 int
4957 main(int argc, char *argv[])
5058 {
51 fprintf(stderr, "AnsiLove/C %s - ANSI / ASCII art to PNG converter\n"
52 "Copyright (c) 2011-2019 Stefan Vogt, Brian Cassidy, and "
53 "Frederic Cambus.\n", VERSION);
59 FILE *messages = NULL;
5460
5561 /* SAUCE record related bool types */
5662 bool justDisplaySAUCE = false;
7379
7480 const char *errstr;
7581
76 if (ansilove_init(&ctx, &options) == -1) {
77 fprintf(stderr, "\n%s\n", ansilove_error(&ctx));
78 return EXIT_FAILURE;
79 }
80
81 if (pledge("stdio cpath rpath wpath", NULL) == -1) {
82 if (ansilove_init(&ctx, &options) == -1)
83 errx(EXIT_FAILURE, "%s", ansilove_error(&ctx));
84
85 if (pledge("stdio cpath rpath wpath", NULL) == -1)
8286 err(EXIT_FAILURE, "pledge");
83 }
84
85 while ((getoptFlag = getopt(argc, argv, "b:c:df:him:o:rR:sv")) != -1) {
87
88 while ((getoptFlag = getopt(argc, argv, "b:c:df:him:o:qrR:sv")) != -1) {
8689 switch (getoptFlag) {
8790 case 'b':
8891 /* convert numeric command line flags to integer values */
8992 options.bits = strtonum(optarg, 8, 9, &errstr);
9093
91 if (errstr) {
92 fprintf(stderr, "\nInvalid value for bits (must be 8 or 9).\n\n");
93 return EXIT_FAILURE;
94 }
94 if (errstr)
95 errx(EXIT_FAILURE, "Invalid value for bits (must be 8 or 9).");
9596
9697 break;
9798 case 'c':
9899 /* convert numeric command line flags to integer values */
99100 options.columns = strtonum(optarg, 1, 4096, &errstr);
100101
101 if (errstr) {
102 fprintf(stderr, "\nInvalid value for columns (must range from 1 to 4096).\n\n");
103 return EXIT_FAILURE;
104 }
102 if (errstr)
103 errx(EXIT_FAILURE, "\nInvalid value for columns (must range from 1 to 4096).");
105104
106105 break;
107106 case 'd':
134133 case 'o':
135134 output = optarg;
136135 break;
136 case 'q':
137 messages = fopen("/dev/null", "w");
138 break;
137139 case 'r':
138140 options.scale_factor = 2;
139141 break;
141143 /* convert numeric command line flags to integer values */
142144 options.scale_factor = strtonum(optarg, 2, 8, &errstr);
143145
144 if (errstr) {
145 fprintf(stderr, "\nInvalid value for retina scale factor (must range from 2 to 8).\n\n");
146 return EXIT_FAILURE;
147 }
146 if (errstr)
147 errx(EXIT_FAILURE, "Invalid value for retina scale factor (must range from 2 to 8).");
148148
149149 break;
150150 case 's':
151151 justDisplaySAUCE = true;
152152 break;
153153 case 'v':
154 version();
154155 return EXIT_SUCCESS;
155156 }
156157 }
165166 argc -= optind;
166167 argv += optind;
167168
169 /* if -q flag was not set, default to stdout */
170 if (!messages)
171 messages = stdout;
172
168173 /* let's check the file for a valid SAUCE record */
169174 sauce *record = sauceReadFileName(input);
170175
171176 /* record == NULL also means there is no file, we can stop here */
172177 if (record == NULL) {
173 fprintf(stderr, "\nFile %s not found.\n\n", input);
174 return EXIT_FAILURE;
178 errx(EXIT_FAILURE, "File %s not found.", input);
175179 } else {
176180 /* if we find a SAUCE record, update bool flag */
177181 if (!strcmp(record->ID, SAUCE_ID)) {
183187 /* create output file name if output is not specified */
184188 if (!output) {
185189 /* appending ".png" extension to output file name */
186 if (asprintf(&fileName, "%s%s", input, ".png") == -1) {
187 fprintf(stderr, "Memory allocation error.\n\n");
188 return EXIT_FAILURE;
189 }
190 if (asprintf(&fileName, "%s%s", input, ".png") == -1)
191 errx(EXIT_FAILURE, "Memory allocation error.");
190192 } else {
191193 fileName = output;
192194 }
193195
194196 /* display name of input and output files */
195 fprintf(stderr, "\nInput File: %s\n", input);
196 fprintf(stderr, "Output File: %s\n", fileName);
197 fprintf(messages, "Input File: %s\n", input);
198 fprintf(messages, "Output File: %s\n", fileName);
197199
198200 /* get file extension */
199201 char *fext = strrchr(input, '.');
203205 if (!strcmp(fext, "diz"))
204206 options.diz = true;
205207
206 if (ansilove_loadfile(&ctx, input) == -1) {
207 fprintf(stderr, "\n%s\n", ansilove_error(&ctx));
208 return EXIT_FAILURE;
209 }
208 if (ansilove_loadfile(&ctx, input) == -1)
209 errx(EXIT_FAILURE, "%s", ansilove_error(&ctx));
210210
211211 /* adjust the file size if file contains a SAUCE record */
212212 if (fileHasSAUCE) {
237237 fileIsANSi = true;
238238 }
239239
240 if (loader(&ctx, &options) == -1) {
241 fprintf(stderr, "\n%s\n", ansilove_error(&ctx));
242 return EXIT_FAILURE;
243 }
240 if (loader(&ctx, &options) == -1)
241 errx(EXIT_FAILURE, "%s", ansilove_error(&ctx));
244242
245243 /* create the output file */
246 if (ansilove_savefile(&ctx, fileName) == -1) {
247 fprintf(stderr, "\n%s\n", ansilove_error(&ctx));
248 return EXIT_FAILURE;
249 }
244 if (ansilove_savefile(&ctx, fileName) == -1)
245 errx(EXIT_FAILURE, "%s", ansilove_error(&ctx));
250246
251247 /* gather information and report to the command line */
252248 if (fileIsANSi || fileIsBinary ||
253249 fileIsPCBoard || fileIsTundra) {
254 fprintf(stderr, "Font: %s\n", font ? font : "80x25");
255
256 fprintf(stderr, "Bits: %d\n", options.bits);
250 fprintf(messages, "Font: %s\n", font ? font : "80x25");
251
252 fprintf(messages, "Bits: %d\n", options.bits);
257253 }
258254
259255 if (options.icecolors && (fileIsANSi || fileIsBinary))
260 fprintf(stderr, "iCE Colors: enabled\n");
256 fprintf(messages, "iCE Colors: enabled\n");
261257
262258 if (fileIsANSi || fileIsBinary || fileIsTundra)
263 fprintf(stderr, "Columns: %d\n", options.columns);
259 fprintf(messages, "Columns: %d\n", options.columns);
264260
265261 if (options.scale_factor)
266 fprintf(stderr, "Scale factor: %d\n", options.scale_factor);
262 fprintf(messages, "Scale factor: %d\n", options.scale_factor);
267263 }
268264
269265 /* either display SAUCE or tell us if there is no record */
270266 if (!fileHasSAUCE) {
271 fprintf(stderr, "\nFile %s does not have a SAUCE record.\n", input);
267 fprintf(messages, "\nFile %s does not have a SAUCE record.\n", input);
272268 } else {
273 fprintf(stderr, "\nId: %s v%s\n", record->ID, record->version);
274 fprintf(stderr, "Title: %s\n", record->title);
275 fprintf(stderr, "Author: %s\n", record->author);
276 fprintf(stderr, "Group: %s\n", record->group);
277 fprintf(stderr, "Date: %s\n", record->date);
278 fprintf(stderr, "Datatype: %d\n", record->dataType);
279 fprintf(stderr, "Filetype: %d\n", record->fileType);
269 fprintf(messages, "\nId: %s v%s\n", record->ID, record->version);
270 fprintf(messages, "Title: %s\n", record->title);
271 fprintf(messages, "Author: %s\n", record->author);
272 fprintf(messages, "Group: %s\n", record->group);
273 fprintf(messages, "Date: %s\n", record->date);
274 fprintf(messages, "Datatype: %d\n", record->dataType);
275 fprintf(messages, "Filetype: %d\n", record->fileType);
280276 if (record->flags) {
281 fprintf(stderr, "Flags: %d\n", record->flags);
277 fprintf(messages, "Flags: %d\n", record->flags);
282278 }
283279 if (record->tinfo1) {
284 fprintf(stderr, "Tinfo1: %d\n", record->tinfo1);
280 fprintf(messages, "Tinfo1: %d\n", record->tinfo1);
285281 }
286282 if (record->tinfo2) {
287 fprintf(stderr, "Tinfo2: %d\n", record->tinfo2);
283 fprintf(messages, "Tinfo2: %d\n", record->tinfo2);
288284 }
289285 if (record->tinfo3) {
290 fprintf(stderr, "Tinfo3: %d\n", record->tinfo3);
286 fprintf(messages, "Tinfo3: %d\n", record->tinfo3);
291287 }
292288 if (record->tinfo4) {
293 fprintf(stderr, "Tinfo4: %d\n", record->tinfo4);
294 }
295 fprintf(stderr, "Tinfos: %s\n", record->tinfos);
289 fprintf(messages, "Tinfo4: %d\n", record->tinfo4);
290 }
291 fprintf(messages, "Tinfos: %s\n", record->tinfos);
296292 if (record->comments > 0) {
297 fprintf(stderr, "Comments: ");
293 fprintf(messages, "Comments: ");
298294 for (int32_t i = 0; i < record->comments; i++) {
299 fprintf(stderr, "%s\n", record->comment_lines[i]);
295 fprintf(messages, "%s\n", record->comment_lines[i]);
300296 }
301297 }
302298 }
00 /*
11 * config.h
2 * Ansilove 4.0.2
2 * Ansilove 4.0.3
33 * https://www.ansilove.org
44 *
55 * Copyright (c) 2011-2019 Stefan Vogt, Brian Cassidy, and Frederic Cambus
1515 #include <stdint.h>
1616
1717 /* configuration defines */
18 #define VERSION "4.0.2"
18 #define VERSION "4.0.3"
1919
2020 #endif /* CONFIG_H */
00 /*
11 * fonts.h
2 * Ansilove 4.0.2
2 * Ansilove 4.0.3
33 * https://www.ansilove.org
44 *
55 * Copyright (c) 2011-2019 Stefan Vogt, Brian Cassidy, and Frederic Cambus
00 /*
11 * sauce.c
2 * Ansilove 4.0.2
2 * Ansilove 4.0.3
33 * https://www.ansilove.org
44 *
55 * Copyright (c) 2011-2019 Stefan Vogt, Brian Cassidy, and Frederic Cambus
00 /*
11 * sauce.h
2 * Ansilove 4.0.2
2 * Ansilove 4.0.3
33 * https://www.ansilove.org
44 *
55 * Copyright (c) 2011-2019 Stefan Vogt, Brian Cassidy, and Frederic Cambus
00 /*
11 * strtolower.c
2 * Ansilove 4.0.2
2 * Ansilove 4.0.3
33 * https://www.ansilove.org
44 *
55 * Copyright (c) 2011-2019 Stefan Vogt, Brian Cassidy, and Frederic Cambus
00 /*
11 * strtolower.h
2 * Ansilove 4.0.2
2 * Ansilove 4.0.3
33 * https://www.ansilove.org
44 *
55 * Copyright (c) 2011-2019 Stefan Vogt, Brian Cassidy, and Frederic Cambus