From be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 04:57:58 +0200 Subject: Adding upstream version 1.44.3. Signed-off-by: Daniel Baumann --- fluent-bit/lib/monkey/examples/hello.c | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 fluent-bit/lib/monkey/examples/hello.c (limited to 'fluent-bit/lib/monkey/examples/hello.c') diff --git a/fluent-bit/lib/monkey/examples/hello.c b/fluent-bit/lib/monkey/examples/hello.c new file mode 100644 index 00000000..d54c3dde --- /dev/null +++ b/fluent-bit/lib/monkey/examples/hello.c @@ -0,0 +1,68 @@ +/* Monkey HTTP Daemon + * ------------------ + * Copyright (C) 2012, Lauri Kasanen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include + +/* + * This example shows how to start the server, and point it to /tmp. + * It also creates /tmp/index.html. +*/ + +static void write_index() { + + const char *path = "/tmp/index.html"; + + FILE *f = fopen(path, "w"); + if (!f) exit(1); + + fprintf(f, "

Hello Monkey

"); + + fclose(f); +} + +int main() { + + int ret; + + write_index(); + + // All defaults. Bind to all interfaces, port 2001, default plugins, /tmp. + // No callbacks are used. + mklib_ctx ctx = mklib_init(NULL, 0, 0, "/tmp"); + if (!ctx) return 1; + + // The default has no index files, let's set index.html as one. + ret = mklib_config(ctx, MKC_INDEXFILE, "index.html", NULL); + if (!ret) return 1; + + // Start the server. + mklib_start(ctx); + + // I'm now free to do my own things. I'm just going to wait for a keypress. + printf("All set and running! Visit me, I default to localhost:2001.\n"); + printf("Press a key to exit.\n"); + getchar(); + + mklib_stop(ctx); + + return 0; +} -- cgit v1.2.3