From a4cc26155549eee6def832da05a6f641f92cd6ae Mon Sep 17 00:00:00 2001 From: b Date: Mon, 5 Dec 2022 20:49:36 +0000 Subject: [PATCH] newpixbot online --- bluenh-cgi.c | 14 +-- bluenh.1.htm | 4 +- diff-cgi.c | 14 +-- diff.1.htm | 4 +- enhance.1.conf | 7 +- makefile | 15 ++- makefile.1.mak | 15 ++- 503.png => mpb_503.png | Bin npb-cgi.c | 271 ++++++++++++++++++++++++----------------- npb.1.htm | 44 +++---- npb.c | 10 +- settings-release.txt | 1 + settings.txt | 1 + 13 files changed, 231 insertions(+), 169 deletions(-) rename 503.png => mpb_503.png (100%) diff --git a/bluenh-cgi.c b/bluenh-cgi.c index aa431db..b55cc8a 100644 --- a/bluenh-cgi.c +++ b/bluenh-cgi.c @@ -1,7 +1,7 @@ /* bluenh-cgi.c Online interface for npb -04.12.2022 +05.12.2022 Copyright (C) 2013, 2014, 2022 Balthasar Szczepański @@ -141,12 +141,12 @@ int bluenh ( pid_t sub; int r; - snprintf(s_a, 4, "%"SCNuFAST8, a); - snprintf(s_b, 4, "%"SCNuFAST8, b); - snprintf(s_c, 4, "%"SCNuFAST8, c); - snprintf(s_d, 4, "%"SCNuFAST8, d); - snprintf(s_e, 4, "%"SCNuFAST8, e); - snprintf(s_f, 4, "%"SCNuFAST8, f); + snprintf(s_a, 4, "%"PRIuFAST8, a); + snprintf(s_b, 4, "%"PRIuFAST8, b); + snprintf(s_c, 4, "%"PRIuFAST8, c); + snprintf(s_d, 4, "%"PRIuFAST8, d); + snprintf(s_e, 4, "%"PRIuFAST8, e); + snprintf(s_f, 4, "%"PRIuFAST8, f); sub = fork(); if (sub == 0) diff --git a/bluenh.1.htm b/bluenh.1.htm index 12d07c6..c63c6db 100644 --- a/bluenh.1.htm +++ b/bluenh.1.htm @@ -2,8 +2,8 @@
parameter explanation picture

- a=, b=, c=,
- d=, e=, f=.
+ a=, b=, c=,
+ d=, e=, f=.
a < b < c

Enhance by URL
diff --git a/diff-cgi.c b/diff-cgi.c index 2707359..27a3267 100644 --- a/diff-cgi.c +++ b/diff-cgi.c @@ -1,7 +1,7 @@ /* diff-cgi.c The online interface for the differential tool -04.12.2022 +05.12.2022 Copyright (C) 2022 Balthasar Szczepański @@ -161,12 +161,12 @@ int diff ( pid_t sub; int r; - snprintf(s_ra, 4, "%"SCNuFAST8, ra); - snprintf(s_ga, 4, "%"SCNuFAST8, ga); - snprintf(s_ba, 4, "%"SCNuFAST8, ba); - snprintf(s_rb, 4, "%"SCNuFAST8, rb); - snprintf(s_gb, 4, "%"SCNuFAST8, gb); - snprintf(s_bb, 4, "%"SCNuFAST8, bb); + snprintf(s_ra, 4, "%"PRIuFAST8, ra); + snprintf(s_ga, 4, "%"PRIuFAST8, ga); + snprintf(s_ba, 4, "%"PRIuFAST8, ba); + snprintf(s_rb, 4, "%"PRIuFAST8, rb); + snprintf(s_gb, 4, "%"PRIuFAST8, gb); + snprintf(s_bb, 4, "%"PRIuFAST8, bb); sub = fork(); if (sub == 0) diff --git a/diff.1.htm b/diff.1.htm index 054500d..2393a54 100644 --- a/diff.1.htm +++ b/diff.1.htm @@ -9,9 +9,9 @@ File 2:

Color A:
- R=, G=, B=
+ R=, G=, B=
Color B:
- R=, G=, B=
+ R=, G=, B=


\ No newline at end of file diff --git a/enhance.1.conf b/enhance.1.conf index 4a138c7..58eff10 100644 --- a/enhance.1.conf +++ b/enhance.1.conf @@ -3,6 +3,7 @@ ScriptAlias /enhance/bluenh ###CONF_bluenh; ScriptAlias /enhance/diff ###CONF_diff; ScriptAlias /enhance/nofading ###CONF_nofading; +ScriptAlias /enhance/npb ###CONF_npb; ScriptAlias /enhance/reveal ###CONF_reveal; @@ -11,8 +12,8 @@ ScriptAlias /enhance/reveal ###CONF_reveal; # legacy redirections Redirect permanent /pro/npb/npb.htm /enhance/npb.htm -Redirect permanent /pro/npb/403.htm /enhance/403.htm +Redirect permanent /pro/npb/403.htm /enhance/npb.htm Redirect permanent /pro/bluenh/bluenh.htm /enhance/bluenh.htm Redirect permanent /pro/nofading/nofading.htm /enhance/nofading.htm -Redirect permanent /pro/nofading/insertframe.htm /enhance/pal.htm -Redirect permanent /pro http://bicyclesonthemoon.info/git-projects/?p=ott/enhance& \ No newline at end of file +Redirect permanent /pro/insertframe/insertframe.htm /enhance/pal.htm +Redirect permanent /pro /enhance? \ No newline at end of file diff --git a/makefile b/makefile index 6fe3179..8ae88dc 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ # "makefile" is automatically generated from "makefile.1.mak" -# 04.12.2022 +# 05.12.2022 # # Copyright (C) 2022 Balthasar Szczepański # @@ -108,25 +108,30 @@ npb_403.h\ nh.h\ nf.h\ rvl.h\ -df.h +df.h\ +mpb.h\ +mpb_503.h CGI=\ bluenh-cgi\ nofading-cgi\ reveal-cgi\ -diff-cgi +diff-cgi\ +npb-cgi HTM_CGI=\ bluenh.htm\ nofading.htm\ reveal.htm\ -diff.htm +diff.htm\ +npb.htm HTM_CGI_1=\ bluenh.1.htm\ nofading.1.htm\ reveal.1.htm\ -diff.1.htm +diff.1.htm\ +npb.1.htm # keep these 2 lists in the same order!: GENERATE_FROM=\ diff --git a/makefile.1.mak b/makefile.1.mak index 914f0de..0736b7a 100644 --- a/makefile.1.mak +++ b/makefile.1.mak @@ -1,5 +1,5 @@ # "makefile" is automatically generated from "makefile.1.mak" -# 04.12.2022 +# 05.12.2022 # # Copyright (C) 2022 Balthasar Szczepański # @@ -108,25 +108,30 @@ npb_403.h\ nh.h\ nf.h\ rvl.h\ -df.h +df.h\ +mpb.h\ +mpb_503.h CGI=\ bluenh-cgi\ nofading-cgi\ reveal-cgi\ -diff-cgi +diff-cgi\ +npb-cgi HTM_CGI=\ bluenh.htm\ nofading.htm\ reveal.htm\ -diff.htm +diff.htm\ +npb.htm HTM_CGI_1=\ bluenh.1.htm\ nofading.1.htm\ reveal.1.htm\ -diff.1.htm +diff.1.htm\ +npb.1.htm # keep these 2 lists in the same order!: GENERATE_FROM=\ diff --git a/503.png b/mpb_503.png similarity index 100% rename from 503.png rename to mpb_503.png diff --git a/npb-cgi.c b/npb-cgi.c index d155c7a..27049dd 100644 --- a/npb-cgi.c +++ b/npb-cgi.c @@ -1,134 +1,181 @@ -// // //Download images and add - // // Newpixbots to them! (or Megans) - // // - // // Requires cgilib -// // //line 146 of cgi.h - // // must be changed - // // from "extern }" - // // to "}" -// // // - // // ~~bicyclesonthemoon +/* +npb-cgi.c +Download images and add Newpixbots to them! (or Megans) +05.12.2022 + +Copyright (C) 2013, 2014, 2022 Balthasar Szczepański + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . + +Requires cgilib (http://www.infodrom.org/projects/cgilib/) +*/ -#include #include -#include +#include #include -#include +#include #include -#include +#include +#include -#define WGET_PATH "/usr/bin/wget" -#define NPB_PATH "./npb" -#define MEG_PATH "./403" -#define RM_PATH "/bin/rm" -#define LOG_PATH "/eizm/log/npb/npb.log" -#define LOG_PATH2 "/eizm/log/npb/403.log" -#define USERAGENT "NewpixbOTTification\x20(1190.bicyclesonthemoon.dnsd.info/npb/npb.htm)" -#define USERAGENT2 "403fication\x20(1190.bicyclesonthemoon.dnsd.info/npb/403.htm)" -#define MSTD_PATH "/pro/npb/mpb.png" -#define MSTD_PATH2 "/pro/npb/503.png" +#include -int main (int argc, char *argv[]); -void mustard(int mustard); +#include "online-core.h" +#include "mpb.h" +#include "mpb_503.h" -FILE *pix; -unsigned char buf[1024]; -char url[1024]; -char path[256]; -char method[256]; -s_cgi *cgi; -int t; -pid_t sub; -struct stat st; -unsigned long p; -unsigned short q; -char **up; -bool meg=false; + +int npb ( + char *inpix, char *outpix, + uint_fast8_t remove_border, uint_fast32_t remove_border_width, + uint_fast8_t new_border, uint_fast32_t new_border_width, + uint_fast8_t external_border, uint_fast32_t external_border_width, + uint_fast8_t corners, uint_fast8_t ong1, uint8_t t403 +); int main (int argc, char *argv[]) { - cgi=cgiInit(); + s_cgi *cgi; + char in_tmp[256]; + char out_tmp[256]; + char *in_path; + char *t; + uint_fast8_t remove_border, new_border, external_border, corners, ong1; + uint_fast32_t remove_border_width, new_border_width, external_border_width; + uint_fast8_t t403 = 0; - sprintf(path,"%s",(getenv("PATH_INFO")!=NULL)?(getenv("PATH_INFO")):""); - if(strcmp(path,"/403")==0) - { - meg=true; - //mustard(0); - } + int r=0; + int r1=0; + int r2=0; + int r3=0; - up=cgiGetFiles(cgi); - if (up) - { - sprintf(path,"%s",cgiGetFile(cgi,up[0])->tmpfile); - sprintf(url,"%s",cgiGetFile(cgi,up[0])->filename); - } - else - { - sprintf(url,"%s",(cgiGetValue(cgi,"inpix")!=NULL)?(cgiGetValue(cgi,"inpix")):""); - sprintf(path,"/var/tmp/%lu",(unsigned long)getpid()); + do { + make_tmp_path(in_tmp, 256, 0, ""); + make_tmp_path(out_tmp, 256, 1, ".png"); + + cgi=cgiInit(); - //Why is there no spawnl() in linux? - sub=fork(); - if(sub==0) + r = get_file(cgi,"inpix2", in_tmp, &in_path); + if (r) + r = get_file(cgi,"inpix", in_tmp, &in_path); + if (r) + break; + + remove_border = (cgiGetValue(cgi, "r")!=NULL) ? 1 : 0; + external_border = (cgiGetValue(cgi, "e")!=NULL) ? 1 : 0; + new_border = (cgiGetValue(cgi, "b")!=NULL) ? 1 : 0; + corners = (cgiGetValue(cgi, "c")!=NULL) ? 1 : 0; + ong1 = (cgiGetValue(cgi, "o")!=NULL) ? 1 : 0; + t403 = (cgiGetValue(cgi, "4")!=NULL) ? 1 : 0; + + if (remove_border) { - t=execl(WGET_PATH,WGET_PATH,"-q","-t","2","-U",meg?USERAGENT2:USERAGENT,"-O",path,url,(char *)0); - exit(t); + t = cgiGetValue(cgi, "rw"); + if (t != NULL) + sscanf(t,"%"SCNuFAST32, &remove_border_width); + else + remove_border_width = 0; } - waitpid(sub,&t,0); - if(t)mustard(t); - } - - sub=fork(); - if(sub==0) - { - t=execl(meg?MEG_PATH:NPB_PATH,meg?MEG_PATH:NPB_PATH,path,path,"q",(char *)0); - exit(t); - } - waitpid(sub,&t,0); - if(t)mustard(t); - - pix=fopen(path,"rb"); - if(pix==NULL) - mustard(123); - fstat(fileno(pix),&st); - p=st.st_size/1024; - q=st.st_size%1024; - - printf("Content-Length: %lu\n",(unsigned long)(st.st_size)); - printf("Content-type: image/png\n\n"); - for(unsigned long i=0;i - - - It's NewpixbOTTification time! • Bicycles on the Moon - - - - - 1190.bicyclesonthemoon.dnsd.info

It's NewpixbOTTification time!

-
+ NewpixbOTTify by URL
URL of image: - - -
-
-
+ +
NewpixbOTTify by file upload
Upload the image: - - + +
+ remove original border, + width: +
+ new border, + width: +
+ external border, + width: +
+ corners +
+ bOTTeriada Newpixbot +
+ Timeframe 403 +
+
+
-
- Source code available at svn://bicyclesonthemoon.dnsd.info/npb (use "e" to login) or http://1190.bicyclesonthemoon.dnsd.info/pro/npb. - - - diff --git a/npb.c b/npb.c index 63bcb00..d315aff 100644 --- a/npb.c +++ b/npb.c @@ -1,7 +1,7 @@ /* npb.c Take a picture and add a newpixbot to it! -30.11.2022 +05.12.2022 Copyright (C) 2013 - 2015, 2022 Balthasar Szczepański @@ -122,7 +122,7 @@ int subtool_npb (int argc, char **argv, int argi, char **err) {"help", no_argument, NULL, 'h'}, {0, 0, 0, 0} }; - char short_options[] = "o4r:b:e:ch"; + char short_options[] = "o4r:b:e:ch0"; int opt; int r; @@ -227,6 +227,7 @@ int subtool_npb (int argc, char **argv, int argi, char **err) space_t = NPB0_T; space_b = NPB0_B; fill_white = 1; + override_new_border = 1; new_border = 0; npb_after = 1; fixed_frame = 1; @@ -240,6 +241,7 @@ int subtool_npb (int argc, char **argv, int argi, char **err) space_t = NPB1_T; space_b = NPB1_B; fill_white = 1; + override_new_border = 1; new_border = 0; npb_after = 1; fixed_frame = 1; @@ -568,8 +570,8 @@ int subtool_npb (int argc, char **argv, int argi, char **err) r = perform_action_1picture( 2, //id - fixed_frame ? space_l : x0_content_global, //x0 - fixed_frame ? space_t : y0_content_global, //y0 + fixed_frame ? space_l + external_border : x0_content_global, //x0 + fixed_frame ? space_t + external_border: y0_content_global, //y0 0, //f0 fixed_frame ? (space_r - space_l + 1) : width_content, //width fixed_frame ? (space_b - space_t + 1) : height_content, //height diff --git a/settings-release.txt b/settings-release.txt index eed7ff2..08fa7da 100644 --- a/settings-release.txt +++ b/settings-release.txt @@ -17,6 +17,7 @@ title_bluenh: ENHANCE! title_diff: See the difference! title_enhance: ENHANCE! title_nofading: No fading! +title_npb: It's NewpixbOTTification time! title_reveal: Reveal hidden detail! bin_path: /botm/bin/enhance diff --git a/settings.txt b/settings.txt index a2294a6..8b0c9cd 100644 --- a/settings.txt +++ b/settings.txt @@ -39,6 +39,7 @@ CONF_bin = $bin_path CONF_bluenh = $_bin_bluenh_cgi_path CONF_diff = $_bin_diff_cgi_path CONF_nofading = $_bin_nofading_cgi_path +CONF_npb = $_bin_npb_cgi_path CONF_reveal = $_bin_reveal_cgi_path -- 2.30.2