Merge pull request #4948 from ldir-EDB0/remwireguard
[feed/packages.git] / libs / qrencode / patches / 001-disable-png.patch
1 --- a/qrenc.c
2 +++ b/qrenc.c
3 @@ -25,7 +25,6 @@
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 -#include <png.h>
8 #include <getopt.h>
9
10 #include "qrencode.h"
11 @@ -49,7 +48,6 @@
12 static int verbose = 0;
13
14 enum imageType {
15 - PNG_TYPE,
16 EPS_TYPE,
17 SVG_TYPE,
18 ANSI_TYPE,
19 @@ -60,7 +58,7 @@
20 ANSIUTF8_TYPE
21 };
22
23 -static enum imageType image_type = PNG_TYPE;
24 +static enum imageType image_type = SVG_TYPE;
25
26 static const struct option options[] = {
27 {"help" , no_argument , NULL, 'h'},
28 @@ -96,13 +94,13 @@
29 if(longopt) {
30 fprintf(stderr,
31 "Usage: qrencode [OPTION]... [STRING]\n"
32 -"Encode input data in a QR Code and save as a PNG or EPS image.\n\n"
33 +"Encode input data in a QR Code and save as a SVG or EPS image.\n\n"
34 " -h, --help display the help message. -h displays only the help of short\n"
35 " options.\n\n"
36 " -o FILENAME, --output=FILENAME\n"
37 " write image to FILENAME. If '-' is specified, the result\n"
38 " will be output to standard output. If -S is given, structured\n"
39 -" symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n"
40 +" symbols are written to FILENAME-01.svg, FILENAME-02.svg, ...\n"
41 " (suffix is removed from FILENAME, if specified)\n"
42 " -s NUMBER, --size=NUMBER\n"
43 " specify module size in dots (pixels). (default=3)\n\n"
44 @@ -116,9 +114,9 @@
45 " specify the width of the margins. (default=4 (2 for Micro QR)))\n\n"
46 " -d NUMBER, --dpi=NUMBER\n"
47 " specify the DPI of the generated PNG. (default=72)\n\n"
48 -" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={PNG,EPS,\n"
49 +" -t {EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={EPS,\n"
50 " SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n"
51 -" specify the type of the generated image. (default=PNG)\n\n"
52 +" specify the type of the generated image. (default=SVG)\n\n"
53 " -S, --structured\n"
54 " make structured symbols. Version must be specified.\n\n"
55 " -k, --kanji assume that the input text contains kanji (shift-jis).\n\n"
56 @@ -133,7 +131,7 @@
57 " --background=RRGGBB[AA]\n"
58 " specify foreground/background color in hexadecimal notation.\n"
59 " 6-digit (RGB) or 8-digit (RGBA) form are supported.\n"
60 -" Color output support available only in PNG and SVG.\n"
61 +" Color output support available only in SVG.\n"
62 " -V, --version\n"
63 " display the version number and copyrights of the qrencode.\n\n"
64 " --verbose\n"
65 @@ -153,12 +151,12 @@
66 } else {
67 fprintf(stderr,
68 "Usage: qrencode [OPTION]... [STRING]\n"
69 -"Encode input data in a QR Code and save as a PNG or EPS image.\n\n"
70 +"Encode input data in a QR Code and save as a SVG or EPS image.\n\n"
71 " -h display this message.\n"
72 " --help display the usage of long options.\n"
73 " -o FILENAME write image to FILENAME. If '-' is specified, the result\n"
74 " will be output to standard output. If -S is given, structured\n"
75 -" symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n"
76 +" symbols are written to FILENAME-01.svg, FILENAME-02.svg, ...\n"
77 " (suffix is removed from FILENAME, if specified)\n"
78 " -s NUMBER specify module size in dots (pixels). (default=3)\n"
79 " -l {LMQH} specify error correction level from L (lowest) to H (highest).\n"
80 @@ -166,8 +164,8 @@
81 " -v NUMBER specify the version of the symbol. (default=auto)\n"
82 " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n"
83 " -d NUMBER specify the DPI of the generated PNG. (default=72)\n"
84 -" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n"
85 -" specify the type of the generated image. (default=PNG)\n"
86 +" -t {EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n"
87 +" specify the type of the generated image. (default=SVG)\n"
88 " -S make structured symbols. Version must be specified.\n"
89 " -k assume that the input text contains kanji (shift-jis).\n"
90 " -c encode lower-case alphabet characters in 8-bit mode. (default)\n"
91 @@ -178,7 +176,7 @@
92 " --background=RRGGBB[AA]\n"
93 " specify foreground/background color in hexadecimal notation.\n"
94 " 6-digit (RGB) or 8-digit (RGBA) form are supported.\n"
95 -" Color output support available only in PNG and SVG.\n"
96 +" Color output support available only in SVG.\n"
97 " -V display the version number and copyrights of the qrencode.\n"
98 " [STRING] input data. If it is not specified, data will be taken from\n"
99 " standard input.\n"
100 @@ -253,128 +251,6 @@
101 return fp;
102 }
103
104 -static int writePNG(QRcode *qrcode, const char *outfile)
105 -{
106 - static FILE *fp; // avoid clobbering by setjmp.
107 - png_structp png_ptr;
108 - png_infop info_ptr;
109 - png_colorp palette;
110 - png_byte alpha_values[2];
111 - unsigned char *row, *p, *q;
112 - int x, y, xx, yy, bit;
113 - int realwidth;
114 -
115 - realwidth = (qrcode->width + margin * 2) * size;
116 - row = (unsigned char *)malloc((realwidth + 7) / 8);
117 - if(row == NULL) {
118 - fprintf(stderr, "Failed to allocate memory.\n");
119 - exit(EXIT_FAILURE);
120 - }
121 -
122 - if(outfile[0] == '-' && outfile[1] == '\0') {
123 - fp = stdout;
124 - } else {
125 - fp = fopen(outfile, "wb");
126 - if(fp == NULL) {
127 - fprintf(stderr, "Failed to create file: %s\n", outfile);
128 - perror(NULL);
129 - exit(EXIT_FAILURE);
130 - }
131 - }
132 -
133 - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
134 - if(png_ptr == NULL) {
135 - fprintf(stderr, "Failed to initialize PNG writer.\n");
136 - exit(EXIT_FAILURE);
137 - }
138 -
139 - info_ptr = png_create_info_struct(png_ptr);
140 - if(info_ptr == NULL) {
141 - fprintf(stderr, "Failed to initialize PNG write.\n");
142 - exit(EXIT_FAILURE);
143 - }
144 -
145 - if(setjmp(png_jmpbuf(png_ptr))) {
146 - png_destroy_write_struct(&png_ptr, &info_ptr);
147 - fprintf(stderr, "Failed to write PNG image.\n");
148 - exit(EXIT_FAILURE);
149 - }
150 -
151 - palette = (png_colorp) malloc(sizeof(png_color) * 2);
152 - if(palette == NULL) {
153 - fprintf(stderr, "Failed to allocate memory.\n");
154 - exit(EXIT_FAILURE);
155 - }
156 - palette[0].red = fg_color[0];
157 - palette[0].green = fg_color[1];
158 - palette[0].blue = fg_color[2];
159 - palette[1].red = bg_color[0];
160 - palette[1].green = bg_color[1];
161 - palette[1].blue = bg_color[2];
162 - alpha_values[0] = fg_color[3];
163 - alpha_values[1] = bg_color[3];
164 - png_set_PLTE(png_ptr, info_ptr, palette, 2);
165 - png_set_tRNS(png_ptr, info_ptr, alpha_values, 2, NULL);
166 -
167 - png_init_io(png_ptr, fp);
168 - png_set_IHDR(png_ptr, info_ptr,
169 - realwidth, realwidth,
170 - 1,
171 - PNG_COLOR_TYPE_PALETTE,
172 - PNG_INTERLACE_NONE,
173 - PNG_COMPRESSION_TYPE_DEFAULT,
174 - PNG_FILTER_TYPE_DEFAULT);
175 - png_set_pHYs(png_ptr, info_ptr,
176 - dpi * INCHES_PER_METER,
177 - dpi * INCHES_PER_METER,
178 - PNG_RESOLUTION_METER);
179 - png_write_info(png_ptr, info_ptr);
180 -
181 - /* top margin */
182 - memset(row, 0xff, (realwidth + 7) / 8);
183 - for(y=0; y<margin * size; y++) {
184 - png_write_row(png_ptr, row);
185 - }
186 -
187 - /* data */
188 - p = qrcode->data;
189 - for(y=0; y<qrcode->width; y++) {
190 - bit = 7;
191 - memset(row, 0xff, (realwidth + 7) / 8);
192 - q = row;
193 - q += margin * size / 8;
194 - bit = 7 - (margin * size % 8);
195 - for(x=0; x<qrcode->width; x++) {
196 - for(xx=0; xx<size; xx++) {
197 - *q ^= (*p & 1) << bit;
198 - bit--;
199 - if(bit < 0) {
200 - q++;
201 - bit = 7;
202 - }
203 - }
204 - p++;
205 - }
206 - for(yy=0; yy<size; yy++) {
207 - png_write_row(png_ptr, row);
208 - }
209 - }
210 - /* bottom margin */
211 - memset(row, 0xff, (realwidth + 7) / 8);
212 - for(y=0; y<margin * size; y++) {
213 - png_write_row(png_ptr, row);
214 - }
215 -
216 - png_write_end(png_ptr, info_ptr);
217 - png_destroy_write_struct(&png_ptr, &info_ptr);
218 -
219 - fclose(fp);
220 - free(row);
221 - free(palette);
222 -
223 - return 0;
224 -}
225 -
226 static int writeEPS(QRcode *qrcode, const char *outfile)
227 {
228 FILE *fp;
229 @@ -831,9 +707,6 @@
230 }
231
232 switch(image_type) {
233 - case PNG_TYPE:
234 - writePNG(qrcode, outfile);
235 - break;
236 case EPS_TYPE:
237 writeEPS(qrcode, outfile);
238 break;
239 @@ -887,9 +760,6 @@
240 size_t suffix_size;
241
242 switch(image_type) {
243 - case PNG_TYPE:
244 - type_suffix = ".png";
245 - break;
246 case EPS_TYPE:
247 type_suffix = ".eps";
248 break;
249 @@ -948,9 +818,6 @@
250 }
251
252 switch(image_type) {
253 - case PNG_TYPE:
254 - writePNG(p->code, filename);
255 - break;
256 case EPS_TYPE:
257 writeEPS(p->code, filename);
258 break;
259 @@ -1062,9 +929,7 @@
260 }
261 break;
262 case 't':
263 - if(strcasecmp(optarg, "png") == 0) {
264 - image_type = PNG_TYPE;
265 - } else if(strcasecmp(optarg, "eps") == 0) {
266 + if(strcasecmp(optarg, "eps") == 0) {
267 image_type = EPS_TYPE;
268 } else if(strcasecmp(optarg, "svg") == 0) {
269 image_type = SVG_TYPE;
270 @@ -1133,11 +998,6 @@
271 exit(EXIT_SUCCESS);
272 }
273
274 - if(outfile == NULL && image_type == PNG_TYPE) {
275 - fprintf(stderr, "No output filename is given.\n");
276 - exit(EXIT_FAILURE);
277 - }
278 -
279 if(optind < argc) {
280 intext = (unsigned char *)argv[optind];
281 length = strlen((char *)intext);
282 --- a/configure.ac
283 +++ b/configure.ac
284 @@ -58,9 +58,6 @@
285 [build_tools=$withval], [build_tools=yes])
286
287 AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ])
288 -if test x$build_tools = xyes ; then
289 - PKG_CHECK_MODULES(png, "libpng")
290 -fi
291
292 dnl --with-tests
293 AC_ARG_WITH([tests], [AS_HELP_STRING([--with-tests], [build tests [default=no]])],
294 @@ -80,12 +77,6 @@
295 echo "/* #undef WITH_TESTS */" >>confdefs.h
296 fi
297
298 -if test x$build_tests = xyes ; then
299 - SDL_REQUIRED_VERSION=1.2.0
300 - AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_WARN([*** SDL $SDL_REQUIRED_VERSION or better is required.]))
301 - AC_MSG_NOTICE([SDL check done.])
302 - AM_ICONV_LINK
303 -fi
304 AM_CONDITIONAL(HAVE_SDL, [test "x$SDL_CFLAGS" != "x" ])
305
306