Dillo v3.1.1-99-gf3103cc4
|
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/un.h>
#include <dirent.h>
#include <fcntl.h>
#include <time.h>
#include <signal.h>
#include <netinet/in.h>
#include "../dpip/dpip.h"
#include "dpiutil.h"
#include "d_size.h"
Go to the source code of this file.
Macros | |
#define | _MSG(...) |
#define | MSG(...) printf("[file dpi]: " __VA_ARGS__) |
#define | _MSG_RAW(...) |
#define | MSG_RAW(...) printf(__VA_ARGS__) |
#define | MAXNAMESIZE 30 |
#define | HIDE_DOTFILES TRUE |
#define | FILE_AUTH_OK 1 /* Authentication done */ |
#define | FILE_READ 2 /* Waiting data */ |
#define | FILE_WRITE 4 /* Sending data */ |
#define | FILE_DONE 8 /* Operation done */ |
#define | FILE_ERR 16 /* Operation error */ |
#define | LBUF 16*1024 |
Enumerations | |
enum | FileState { st_start = 10 , st_dpip , st_http , st_content , st_done , st_err } |
Functions | |
static const char * | File_content_type (const char *filename) |
static void | File_close (int fd) |
static const char * | File_get_content_type_from_data (void *Data, size_t Size) |
static int | File_comp (const FileInfo *f1, const FileInfo *f2) |
static DilloDir * | File_dillodir_new (char *dirname) |
static void | File_dillodir_free (DilloDir *Ddir) |
static void | File_print_parent_dir (ClientInfo *client, const char *dirname) |
static void | File_print_mtime (ClientInfo *client, time_t mtime) |
static void | File_info2html (ClientInfo *client, FileInfo *finfo, int n) |
static void | File_send_dir (ClientInfo *client) |
static const char * | File_ext (const char *filename) |
static void | File_prepare_send_error_page (ClientInfo *client, int res, const char *orig_url) |
static void | File_send_error_page (ClientInfo *client) |
static int | File_prepare_send_dir (ClientInfo *client, const char *DirName, const char *orig_url) |
static int | File_prepare_send_file (ClientInfo *client, const char *filename, const char *orig_url) |
static void | File_get (ClientInfo *client, const char *filename, const char *orig_url) |
static int | File_send_file (ClientInfo *client) |
static int | File_parse_hex_octet (const char *s) |
static char * | File_normalize_path (const char *orig) |
static void | File_toggle_html_style (ClientInfo *client) |
static void | termination_handler (int signum) |
static ClientInfo * | File_add_client (int sock_fd) |
static void | File_remove_client (ClientInfo *client) |
static void | File_serve_client (void *data, int f_write) |
static void | File_serve_clients (void) |
static int | File_check_fds (uint_t seconds) |
int | main (void) |
Variables | |
static int | DPIBYE = 0 |
static int | OLD_STYLE = 0 |
static Dlist * | Clients |
fd_set | read_set |
fd_set | write_set |
#define LBUF 16*1024 |
enum FileState |
|
static |
Definition at line 891 of file file.c.
References a_Dpip_dsh_new(), Clients, dList_append(), dNew, FILE_READ, and OLD_STYLE.
Referenced by main().
|
static |
Definition at line 1027 of file file.c.
References _MSG, Clients, dList_length(), dList_nth_data(), FILE_READ, FILE_WRITE, read_set, and write_set.
Referenced by main().
|
static |
Definition at line 117 of file file.c.
Referenced by File_content_type(), and File_remove_client().
|
static |
Definition at line 188 of file file.c.
Referenced by File_dillodir_new().
|
static |
Definition at line 531 of file file.c.
References _MSG, File_close(), File_ext(), and File_get_content_type_from_data().
Referenced by File_info2html(), and File_send_file().
|
static |
Definition at line 268 of file file.c.
References dFree(), dList_free(), dList_length(), dList_nth_data(), and dReturn_if.
Referenced by File_remove_client().
|
static |
Definition at line 208 of file file.c.
References dFree(), dList_append(), dList_new(), dList_sort(), dNew, dStrconcat(), dStrdup(), File_comp(), and HIDE_DOTFILES.
Referenced by File_prepare_send_dir().
|
static |
Definition at line 497 of file file.c.
References dStrAsciiCasecmp().
Referenced by File_content_type().
|
static |
Definition at line 671 of file file.c.
References File_prepare_send_dir(), File_prepare_send_error_page(), and File_prepare_send_file().
Referenced by File_serve_client().
|
static |
Definition at line 131 of file file.c.
References _MSG, dIsspace, dStrnAsciiCasecmp(), and MIN.
Referenced by File_content_type().
|
static |
Definition at line 337 of file file.c.
References a_Dpip_dsh_printf, a_Dpip_dsh_write_str(), dFree(), Escape_html_str(), Escape_uri_str(), File_content_type(), File_print_mtime(), and MAXNAMESIZE.
Referenced by File_send_dir().
|
static |
Definition at line 801 of file file.c.
References dFree(), dGethomedir(), dStr_erase(), dStr_free(), dStr_sized_new(), dStr_sprintf(), dStr_truncate(), dStrconcat(), dStrnAsciiCasecmp(), File_parse_hex_octet(), and Dstr::str.
Referenced by File_serve_client().
|
static |
Definition at line 780 of file file.c.
Referenced by File_normalize_path().
|
static |
Definition at line 611 of file file.c.
References dStr_append(), dStr_free(), dStr_new(), dStrdup(), File_dillodir_new(), FILE_WRITE, Dstr::len, st_start, Dstr::str, and TRUE.
Referenced by File_get().
|
static |
Definition at line 559 of file file.c.
References dStrdup(), FILE_WRITE, and st_err.
Referenced by File_get().
|
static |
Definition at line 640 of file file.c.
References dStrdup(), FILE_WRITE, and st_start.
Referenced by File_get().
|
static |
Definition at line 314 of file file.c.
References a_Dpip_dsh_printf.
Referenced by File_info2html().
|
static |
Definition at line 289 of file file.c.
References a_Dpip_dsh_printf, dFree(), dStrdup(), Escape_html_str(), and Escape_uri_str().
Referenced by File_send_dir().
|
static |
Definition at line 914 of file file.c.
References _MSG, a_Dpip_dsh_close(), a_Dpip_dsh_free(), Clients, dFree(), dList_remove(), File_close(), and File_dillodir_free().
Referenced by File_serve_clients().
|
static |
Definition at line 410 of file file.c.
References a_Dpip_build_cmd(), a_Dpip_dsh_printf, a_Dpip_dsh_write_str(), dFree(), dList_length(), dList_nth_data(), Escape_html_str(), Escape_uri_str(), FILE_DONE, File_info2html(), File_print_parent_dir(), st_content, st_dpip, st_http, and st_start.
Referenced by File_serve_client().
|
static |
Definition at line 572 of file file.c.
References a_Dpip_build_cmd(), a_Dpip_dsh_printf, a_Dpip_dsh_write_str(), dFree(), dStr_append(), dStr_free(), dStr_sized_new(), dStrerror, FILE_DONE, Dstr::len, Dstr::str, and TRUE.
Referenced by File_serve_client().
|
static |
Definition at line 695 of file file.c.
References a_Dpip_build_cmd(), a_Dpip_dsh_printf, a_Dpip_dsh_tryflush(), a_Dpip_dsh_trywrite(), a_Dpip_dsh_write_str(), dFree(), dStrAsciiCasecmp(), dStrerror, dStrndup(), FALSE, File_content_type(), FILE_DONE, FILE_ERR, LBUF, MSG, st_content, st_dpip, st_http, st_start, and TRUE.
Referenced by File_serve_client().
|
static |
Definition at line 932 of file file.c.
References _MSG, a_Dpip_check_auth(), a_Dpip_dsh_read_token(), a_Dpip_get_attr(), dFree(), DPIBYE, DPIP_EOF, DPIP_ERROR, dStrnAsciiCasecmp(), FILE_AUTH_OK, FILE_DONE, FILE_ERR, File_get(), File_normalize_path(), FILE_READ, File_send_dir(), File_send_error_page(), File_send_file(), File_toggle_html_style(), MSG, path(), and st_err.
Referenced by File_serve_clients().
|
static |
Definition at line 1003 of file file.c.
References Clients, dList_nth_data(), FILE_DONE, FILE_ERR, File_remove_client(), File_serve_client(), read_set, and write_set.
Referenced by main().
|
static |
Definition at line 866 of file file.c.
References a_Dpip_build_cmd(), a_Dpip_dsh_write_str(), dFree(), and OLD_STYLE.
Referenced by File_serve_client().
int main | ( | void | ) |
Definition at line 1067 of file file.c.
References _MSG, Clients, dList_new(), DPIBYE, dStrerror, File_add_client(), File_check_fds(), File_serve_clients(), MSG, read_set, termination_handler(), and write_set.
|
static |
|
static |
Definition at line 109 of file file.c.
Referenced by File_add_client(), File_check_fds(), File_remove_client(), File_serve_clients(), and main().
|
static |
Definition at line 106 of file file.c.
Referenced by File_serve_client(), and main().
|
static |
Definition at line 107 of file file.c.
Referenced by File_add_client(), and File_toggle_html_style().
fd_set read_set |
Definition at line 111 of file file.c.
Referenced by File_check_fds(), File_serve_clients(), and main().
fd_set write_set |
Definition at line 111 of file file.c.
Referenced by File_check_fds(), File_serve_clients(), and main().