1 // upload.c (1190.bicyclesonthemoon.info/aftertime/upload)
\r
2 // The post upload interface
\r
5 // Copyright (C) 2015 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
26 #include <sys/wait.h>
\r
28 #define RM_PATH "/bin/rm"
\r
29 #define MAWK_PATH "/usr/bin/mawk"
\r
30 #define AWK_UPLOAD "/eizm/pro/aftertime/upload.awk"
\r
31 #define TEMP_PATH "/eizm/tmp/aftertime/upload."
\r
32 #define RM_PATH "/bin/rm"
\r
38 int main(int argc, char **argv)
\r
45 char timenumber[64];
\r
46 char temppath2[247];
\r
47 char temppath3[256];
\r
49 setvbuf(stdout, NULL, _IONBF, 0);
\r
50 dup2(fileno(stdout),fileno(stderr));
\r
54 sprintf(temppath2,"%s%lu",TEMP_PATH,(unsigned long)getpid());
\r
55 sprintf(temppath3,"tempfile=%s",temppath2);
\r
57 printf("Content-type: text\n\n");
\r
58 up=cgiGetFiles(cgi);
\r
61 temppath=cgiGetFile(cgi,up[0])->tmpfile;
\r
63 posttime=time(NULL);
\r
64 nowS=gmtime(&posttime);
\r
66 sprintf(timenumber,"timenumber=%lu",(unsigned long)posttime);
\r
67 sprintf(timetext,"timetext=%04d%02d%02d%02d",nowS->tm_year+1900,nowS->tm_mon+1,nowS->tm_mday,nowS->tm_hour);
\r
69 // printf("%s\n%s\n%s\n",timenumber,timetext,temppath);
\r
74 r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_UPLOAD,"-v",timetext,"-v",timenumber,"-v",temppath3,temppath,(char *)0);
\r
82 r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0);
\r
89 r=execl(RM_PATH,RM_PATH,"-f",temppath2,(char *)0);
\r
96 printf("File missing\n");
\r