3 The online interface for the tools to insert and extract indexed images
\r
6 Copyright (C) 2015, 2022 Balthasar SzczepaĆski
\r
8 This program is free software: you can redistribute it and/or modify
\r
9 it under the terms of the GNU Affero General Public License as
\r
10 published by the Free Software Foundation, either version 3 of the
\r
11 License, or (at your option) any later version.
\r
13 This program is distributed in the hope that it will be useful,
\r
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 GNU Affero General Public License for more details.
\r
18 You should have received a copy of the GNU Affero General Public License
\r
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
21 Requires cgilib (http://www.infodrom.org/projects/cgilib/)
\r
28 #include <sys/wait.h>
\r
30 #include <inttypes.h>
\r
34 #include "online-core.h"
\r
41 #define MAX_ACTION DETECT
\r
44 char *inpix0, char *inpix1, char *outpix,
\r
45 uint_fast8_t r0, uint_fast8_t r1
\r
48 char *inpix, char *outpix0, char *outpix1,
\r
49 uint_fast8_t size_defined,
\r
50 uint_fast8_t p0, uint_fast8_t p1
\r
53 char *inpix, char *outpix,
\r
54 uint_fast8_t size_defined,
\r
55 uint_fast8_t p0, uint_fast8_t p1
\r
58 int main (int argc, char *argv[])
\r
68 uint_fast8_t p0, p1;
\r
69 uint_fast8_t size_defined = 0;
\r
70 uint_fast8_t action;
\r
79 make_tmp_path(tmp0, 256, 0, ".png");
\r
80 make_tmp_path(tmp1, 256, 1, ".png");
\r
81 make_tmp_path(tmp2, 256, 2, ".png");
\r
85 t = cgiGetValue(cgi, "a");
\r
87 sscanf(t,"%"SCNuFAST8, &action);
\r
90 if (action > MAX_ACTION)
\r
93 r = get_file(cgi,"inpixf0", tmp0, &in0_path);
\r
95 r = get_file(cgi,"inpix0", tmp0, &in0_path);
\r
99 if (action == INSERT)
\r
101 r = get_file(cgi,"inpixf1", tmp1, &in1_path);
\r
103 r = get_file(cgi,"inpix1", tmp1, &in1_path);
\r
107 t = cgiGetValue(cgi, "r0");
\r
109 sscanf(t,"%"SCNuFAST8, &p0);
\r
113 t = cgiGetValue(cgi, "r1");
\r
115 sscanf(t,"%"SCNuFAST8, &p1);
\r
121 t = cgiGetValue(cgi, "p0");
\r
124 sscanf(t,"%"SCNuFAST8, &p0);
\r
130 t = cgiGetValue(cgi, "p1");
\r
133 sscanf(t,"%"SCNuFAST8, &p1);
\r
144 in0_path, in1_path, tmp2,
\r
151 in0_path, tmp1, tmp2,
\r
168 (action == EXTRACT_H) ? tmp1 : tmp2,
\r
175 r1 = send_data(nclr, nclr_size, "image/png", 500);
\r
192 char *inpix0, char *inpix1, char *outpix,
\r
193 uint_fast8_t r0, uint_fast8_t r1
\r
202 snprintf(s_r0, 4, "%"PRIuFAST8, r0);
\r
203 snprintf(s_r1, 4, "%"PRIuFAST8, r1);
\r
209 PAL_MIX_PATH, PAL_MIX_PATH,
\r
210 inpix0, inpix1, outpix,
\r
216 waitpid(sub, &r, 0);
\r
221 char *inpix, char *outpix0, char *outpix1,
\r
222 uint_fast8_t size_defined,
\r
223 uint_fast8_t p0, uint_fast8_t p1
\r
234 snprintf(s_p0, 4, "%"PRIuFAST8, p0);
\r
235 snprintf(s_p1, 4, "%"PRIuFAST8, p1);
\r
242 PAL_UNMIX_PATH, PAL_UNMIX_PATH,
\r
243 inpix, outpix0, outpix1,
\r
244 size_defined ? s_p0 : ((char *) 0),
\r
245 size_defined ? s_p1 : ((char *) 0),
\r
250 waitpid(sub, &r, 0);
\r
255 char *inpix, char *outpix,
\r
256 uint_fast8_t size_defined,
\r
257 uint_fast8_t p0, uint_fast8_t p1
\r
268 snprintf(s_p0, 4, "%"PRIuFAST8, p0);
\r
269 snprintf(s_p1, 4, "%"PRIuFAST8, p1);
\r
276 PAL_MIXDIFF_PATH, PAL_MIXDIFF_PATH,
\r
278 size_defined ? s_p0 : ((char *) 0),
\r
279 size_defined ? s_p1 : ((char *) 0),
\r
284 waitpid(sub, &r, 0);
\r