X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=libs%2Fshttpd%2Fcompat_unix.c;fp=libs%2Fshttpd%2Fcompat_unix.c;h=0000000000000000000000000000000000000000;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hp=b0777e94bdcd35c7e8b52ec2166e7dbeec61d646;hpb=9b22dd53fe62e312c1647310b7ec43aa127090af;p=fms.git diff --git a/libs/shttpd/compat_unix.c b/libs/shttpd/compat_unix.c deleted file mode 100644 index b0777e9..0000000 --- a/libs/shttpd/compat_unix.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2004-2005 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" - -void -set_close_on_exec(int fd) -{ - (void) fcntl(fd, F_SETFD, FD_CLOEXEC); -} - -int -my_stat(const char *path, struct stat *stp) -{ - return (stat(path, stp)); -} - -int -my_open(const char *path, int flags, int mode) -{ - return (open(path, flags, mode)); -} - -int -my_remove(const char *path) -{ - return (remove(path)); -} - -int -my_rename(const char *path1, const char *path2) -{ - return (rename(path1, path2)); -} - -int -my_mkdir(const char *path, int mode) -{ - return (mkdir(path, mode)); -} - -char * -my_getcwd(char *buffer, int maxlen) -{ - return (getcwd(buffer, maxlen)); -} - -int -set_non_blocking_mode(int fd) -{ - int ret = -1; - int flags; - - if ((flags = fcntl(fd, F_GETFL, 0)) == -1) { - DBG(("nonblock: fcntl(F_GETFL): %d", ERRNO)); - } else if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) != 0) { - DBG(("nonblock: fcntl(F_SETFL): %d", ERRNO)); - } else { - ret = 0; /* Success */ - } - - return (ret); -} - -#ifndef NO_CGI -int -spawn_process(struct conn *c, const char *prog, char *envblk, - char *envp[], int sock, const char *dir) -{ - int ret; - pid_t pid; - const char *p, *interp = c->ctx->options[OPT_CGI_INTERPRETER]; - - envblk = NULL; /* unused */ - - if ((pid = vfork()) == -1) { - - ret = -1; - elog(E_LOG, c, "redirect: fork: %s", strerror(errno)); - - } else if (pid == 0) { - - /* Child */ - - (void) chdir(dir); - (void) dup2(sock, 0); - (void) dup2(sock, 1); - (void) closesocket(sock); - - /* If error file is specified, send errors there */ - if (c->ctx->error_log) - (void) dup2(fileno(c->ctx->error_log), 2); - - if ((p = strrchr(prog, '/')) != NULL) - p++; - else - p = prog; - - /* Execute CGI program */ - if (interp == NULL) { - (void) execle(p, p, NULL, envp); - elog(E_FATAL, c, "redirect: exec(%s)", prog); - } else { - (void) execle(interp, interp, p, NULL, envp); - elog(E_FATAL, c, "redirect: exec(%s %s)", - interp, prog); - } - - /* UNREACHED */ - exit(EXIT_FAILURE); - - } else { - - /* Parent */ - ret = 0; - (void) closesocket(sock); - } - - return (ret); -} -#endif /* !NO_CGI */