GNU libmicrohttpd
0.9.70
response_from_callback.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
27
45
struct
MHD_Response
*
46
MHD_response_from_callback
(
enum
MHD_HTTP_StatusCode sc,
47
uint64_t size,
48
size_t
block_size,
49
MHD_ContentReaderCallback
crc
,
50
void
*
crc_cls
,
51
MHD_ContentReaderFreeCallback
crfc
)
52
{
53
struct
MHD_Response
*response;
54
55
mhd_assert
(
NULL
!=
crc
);
56
mhd_assert
(0 != block_size);
57
if
(
NULL
==
58
(response =
MHD_calloc_
(1,
59
sizeof
(
struct
MHD_Response
)
60
+ block_size)))
61
return
NULL
;
62
response->
fd
= -1;
63
response->
status_code
= sc;
64
response->
data
= (
void
*) &response[1];
65
response->
data_buffer_size
= block_size;
66
if
(! MHD_mutex_init_ (&response->
mutex
))
67
{
68
free (response);
69
return
NULL
;
70
}
71
response->
crc
=
crc
;
72
response->
crfc
=
crfc
;
73
response->
crc_cls
=
crc_cls
;
74
response->
reference_count
= 1;
75
response->
total_size
= size;
76
return
response;
77
}
78
79
80
/* end of response_from_callback.c */
MHD_ContentReaderFreeCallback
void(* MHD_ContentReaderFreeCallback)(void *cls)
Definition:
microhttpd.h:2331
MHD_Response::crfc
MHD_ContentReaderFreeCallback crfc
Definition:
internal.h:1606
internal.h
internal shared structures
MHD_calloc_
void * MHD_calloc_(size_t nelem, size_t elsize)
Definition:
mhd_compat.c:98
MHD_Response::status_code
enum MHD_HTTP_StatusCode status_code
Definition:
internal.h:1669
MHD_Response::crc
MHD_ContentReaderCallback crc
Definition:
internal.h:1600
MHD_Response::reference_count
unsigned int reference_count
Definition:
internal.h:1675
MHD_Response::data_buffer_size
size_t data_buffer_size
Definition:
internal.h:1664
MHD_Response::total_size
uint64_t total_size
Definition:
internal.h:1642
NULL
#define NULL
Definition:
reason_phrase.c:30
MHD_Response::fd
int fd
Definition:
internal.h:1680
MHD_ContentReaderCallback
ssize_t(* MHD_ContentReaderCallback)(void *cls, uint64_t pos, char *buf, size_t max)
Definition:
microhttpd.h:2315
MHD_Response::mutex
MHD_mutex_ mutex
Definition:
internal.h:1637
mhd_assert
#define mhd_assert(CHK)
Definition:
mhd_assert.h:39
MHD_Response
Definition:
internal.h:1567
MHD_Response::crc_cls
void * crc_cls
Definition:
internal.h:1594
MHD_Response::data
char * data
Definition:
internal.h:1588
MHD_response_from_callback
struct MHD_Response * MHD_response_from_callback(enum MHD_HTTP_StatusCode sc, uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc)
Definition:
response_from_callback.c:46
src
lib
response_from_callback.c
Generated by
1.8.17