initial commit
This commit is contained in:
commit
584aad56b8
19 changed files with 390 additions and 0 deletions
36
nobotgate-access.c
Normal file
36
nobotgate-access.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include <libowfat/buffer.h>
|
||||
#include <libowfat/errmsg.h>
|
||||
#include <libowfat/str.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define dieusage() die(100, argv0, " PROG ARGS");
|
||||
|
||||
static void consume_headers(void) {
|
||||
char buf[2048];
|
||||
int r;
|
||||
for (;;) {
|
||||
r=buffer_getline(buffer_0, buf, sizeof buf);
|
||||
if (r==0) die(100,"EOF before header end");
|
||||
if (buf[0]=='\r')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *header;
|
||||
(void)argc;
|
||||
errmsg_iam(*argv);
|
||||
|
||||
if (argc<2) dieusage();
|
||||
|
||||
consume_headers();
|
||||
|
||||
header = "HTTP/1.0 200 OK\r\n"
|
||||
"Connection: close\r\n"
|
||||
"\r\n";
|
||||
if (write(1, header, str_len(header)) < 0)
|
||||
diesys(111, "write to stdout");
|
||||
execvp(argv[1], argv+1);
|
||||
diesys(111, "exec ", argv[1]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue