X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=libs%2Fshttpd%2Fio_ssi.c;fp=libs%2Fshttpd%2Fio_ssi.c;h=84176e1e6c0a1fee62858de524b8e9d800a9ac63;hb=d8ccfe2b3944adf07d35534459cdda19d15217c8;hp=0000000000000000000000000000000000000000;hpb=21f835f30b4e092c847bf4569a00995774f7330e;p=fms.git diff --git a/libs/shttpd/io_ssi.c b/libs/shttpd/io_ssi.c new file mode 100644 index 0000000..84176e1 --- /dev/null +++ b/libs/shttpd/io_ssi.c @@ -0,0 +1,467 @@ +/* + * Copyright (c) 2006,2007 Steven Johnson + * Copyright (c) 2007 Sergey Lyubka + * All rights reserved + * + * "THE BEER-WARE LICENSE" (Revision 42): + * Sergey Lyubka wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. + */ + +#include "defs.h" + +#if !defined(NO_SSI) + +#define CMDBUFSIZ 512 /* SSI command buffer size */ +#define NEST_MAX 6 /* Maximum nesting level */ + +struct ssi_func { + struct llhead link; + void *user_data; + char *name; + shttpd_callback_t func; +}; + +struct ssi_inc { + int state; /* Buffering state */ + int cond; /* Conditional state */ + FILE *fp; /* Icluded file stream */ + char buf[CMDBUFSIZ]; /* SSI command buffer */ + size_t nbuf; /* Bytes in a command buffer */ + FILE *pipe; /* #exec stream */ + struct ssi_func func; /* #call function */ +}; + +struct ssi { + struct conn *conn; /* Connection we belong to */ + int nest; /* Current nesting level */ + struct ssi_inc incs[NEST_MAX]; /* Nested includes */ +}; + +enum { SSI_PASS, SSI_BUF, SSI_EXEC, SSI_CALL }; +enum { SSI_GO, SSI_STOP }; /* Conditional states */ + +static const struct vec st = {"