GNU libmicrohttpd 0.9.77
Loading...
Searching...
No Matches
daemon_create.c
Go to the documentation of this file.
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
25#include "internal.h"
26#include "init.h"
27
28
39static void
40file_logger (void *cls,
41 enum MHD_StatusCode sc,
42 const char *fm,
43 va_list ap)
44{
45 FILE *f = cls;
46
47 (void) sc;
48 (void) vfprintf (f,
49 fm,
50 ap);
51}
52
53
65static size_t
67 struct MHD_Request *req,
68 char *val)
69{
70 (void) cls; /* Mute compiler warning. */
71 (void) req; /* Mute compiler warning. */
72 return MHD_http_unescape (val);
73}
74
75
85struct MHD_Daemon *
86MHD_daemon_create (MHD_RequestCallback cb,
87 void *cb_cls)
88{
89 struct MHD_Daemon *daemon;
90
92 if (NULL == (daemon = malloc (sizeof (struct MHD_Daemon))))
93 return NULL;
94 memset (daemon,
95 0,
96 sizeof (struct MHD_Daemon));
97#ifdef EPOLL_SUPPORT
98 daemon->epoll_itc_marker = "itc_marker";
99#endif
100 daemon->rc = cb;
101 daemon->rc_cls = cb_cls;
102 daemon->logger = &file_logger;
103 daemon->logger_cls = stderr;
104 daemon->unescape_cb = &unescape_wrapper;
107#if ENABLE_DAUTH
108 daemon->digest_nc_length = DIGEST_NC_LENGTH_DEFAULT;
109#endif
113
115 {
116 free (daemon);
117 return NULL;
118 }
120 {
122 free (daemon);
123 return NULL;
124 }
125#ifdef DAUTH_SUPPORT
126 if (! MHD_mutex_init_ (&daemon->nnc_lock))
127 {
130 free (daemon);
131 return NULL;
132 }
133#endif
134 return daemon;
135}
136
137
138/* end of daemon_create.c */
struct MHD_Daemon * MHD_daemon_create(MHD_RequestCallback cb, void *cb_cls)
static size_t unescape_wrapper(void *cls, struct MHD_Request *req, char *val)
static void file_logger(void *cls, enum MHD_StatusCode sc, const char *fm, va_list ap)
void MHD_check_global_init_(void)
Definition init.c:136
functions to initialize library
#define BUF_INC_SIZE_DEFAULT
Definition internal.h:1290
#define LISTEN_BACKLOG_DEFAULT
Definition internal.h:1329
#define FO_QUEUE_LENGTH_DEFAULT
Definition internal.h:1341
#define POOL_SIZE_DEFAULT
Definition internal.h:1276
#define NULL
MHD internal shared structures.
#define MHD_mutex_destroy_(ignore)
Definition mhd_locks.h:192
#define MHD_mutex_init_(ignore)
Definition mhd_locks.h:191
_MHD_EXTERN size_t MHD_http_unescape(char *val)
Definition internal.c:142
#define MHD_INVALID_SOCKET
Definition microhttpd.h:208
MHD_mutex_ per_ip_connection_mutex
Definition internal.h:1259
MHD_mutex_ cleanup_connection_mutex
Definition internal.h:1265
int listen_backlog
Definition internal.h:1336
MHD_RequestCallback rc
Definition internal.h:1005
size_t connection_memory_increment_b
Definition internal.h:1296
MHD_LoggingCallback logger
Definition internal.h:1015
void * rc_cls
Definition internal.h:1010
MHD_socket listen_socket
Definition internal.h:1377
size_t connection_memory_limit_b
Definition internal.h:1281
void * logger_cls
Definition internal.h:1020
MHD_UnescapeCallback unescape_cb
Definition internal.h:1058
unsigned int fo_queue_length
Definition internal.h:1346