1 // posted.c (1190.bicyclesonthemoon.info/ct-if)
\r
2 // Display the post list
\r
5 // Copyright (C) 2014 Balthasar SzczepaĆski
\r
7 // This program is free software: you can redistribute it and/or modify
\r
8 // it under the terms of the GNU Affero General Public License as
\r
9 // published by the Free Software Foundation, either version 3 of the
\r
10 // License, or (at your option) any later version.
\r
12 // This program is distributed in the hope that it will be useful,
\r
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 // GNU Affero General Public License for more details.
\r
17 // You should have received a copy of the GNU Affero General Public License
\r
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
24 #include <sys/wait.h>
\r
26 #define TEMP_PATH "/eizm/tmp/ong1/posted."
\r
27 #define MPOST_PATH "/eizm/mem/ong1/mpost/"
\r
28 #define WAIT_PATH "/eizm/mem/ong1/mpost/wait/"
\r
29 #define LS_PATH "/bin/ls"
\r
30 #define RM_PATH "/bin/rm"
\r
31 #define MAWK_PATH "/usr/bin/mawk"
\r
32 #define AWK_POSTED "/eizm/pro/ong1/posted.awk"
\r
38 int main(int argc, char **argv)
\r
40 char temppath[256]="";
\r
48 // dup2(fileno(stdout),fileno(stderr));
\r
50 fff=(cgiGetValue(cgi,"fff")!=NULL);
\r
52 sprintf(temppath,"%s%lu",TEMP_PATH,(unsigned long)getpid());
\r
54 printf("Content-type: text/html\n\n");
\r
55 printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"\">\n");
\r
56 printf("<html lang=\"en\"><head>\n");
\r
57 printf("<title>Chronotransponder test interface • Bicycles on the Moon</title>\n");
\r
58 printf("<meta http-equiv=\"Content-type\" content=\"text/html; charset=UTF-8\">\n");
\r
59 printf("<link rel=\"icon\" type=\"image/png\" href=\"/img/favicon.png\">\n");
\r
60 printf("<link rel=\"stylesheet\" href=\"/css/botm.css\">\n");
\r
61 printf("</head><body><a href=\"/\"><img src=\"/img/botmlogo2.png\" alt=\"1190.bicyclesonthemoon.info\" border=\"0\"></a>\n");
\r
62 printf("<h1>Chronotransponder test interface</h1>\n");
\r
68 if(freopen(temppath,"wt",stdout)==NULL)
\r
70 r=execl(LS_PATH,LS_PATH,"-1","--color=never",MPOST_PATH,(char *)0);
\r
75 printf("No messages.<br>\n");
\r
78 printf("<table class=\"pl\"><tr class=\"pls\"><td colspan=\"5\">CT</td></tr>\n");
\r
79 printf("<tr class=\"plt\"><td class=\"plk\">sent</td><td class=\"plk\">received</td><td class=\"plk\">author</td><td class=\"plk\">subject</td><td class=\"plk\">action</td></tr>\n");
\r
81 tempfile=fopen(temppath,"rt");
\r
84 for(i=0; fgets(line,31,tempfile)!=NULL; ++i)
\r
86 sscanf(line,"%s",filename);
\r
87 sprintf(postpath,"%s%s",MPOST_PATH,filename);
\r
93 r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_POSTED,"-v",i&0x1?"r2=1":"r2=0","-v","cat=ct","-v",fff?"fff=fff":"f=f",postpath,(char *)0);
\r
101 printf("</table><br><b><a href=\"/ct-if-p%s\">Send a message</a></b><br>\n",fff?"?fff=fff":"");
\r
111 if(freopen(temppath,"wt",stdout)==NULL)
\r
113 r=execl(LS_PATH,LS_PATH,"-1","--color=never",WAIT_PATH,(char *)0);
\r
118 printf("No messages.<br>\n");
\r
121 printf("<br><table class=\"pl\"><tr class=\"pls\"><td colspan=\"5\">WAIT</td></tr>\n");
\r
122 printf("<tr class=\"plt\"><td class=\"plk\">sent</td><td class=\"plk\">to be received</td><td class=\"plk\">author</td><td class=\"plk\">subject</td><td class=\"plk\">action</td></tr>\n");
\r
124 tempfile=fopen(temppath,"rt");
\r
127 for(i=0; fgets(line,31,tempfile)!=NULL; ++i)
\r
129 sscanf(line,"%s",filename);
\r
130 sprintf(postpath,"%s%s",WAIT_PATH,filename);
\r
136 r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_POSTED,"-v",i&0x1?"r2=1":"r2=0","-v","cat=wt","-v",fff?"fff=fff":"f=f",postpath,(char *)0);
\r
147 printf("</table>%s\n",fff?"<br><b><a href=\"/ct-if-f\">Force delivery</a></b><br>":"");
\r
151 printf("<br><a href=\"/\">1190.bicyclesonthemoon.info</a></body></html>\n");
\r
157 r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0);
\r