ReactOS 0.4.16-dev-297-gc569aee
fs.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 * OF SUCH DAMAGE.
26 *
27 * This file is part of the lwIP TCP/IP stack.
28 *
29 * Author: Adam Dunkels <adam@sics.se>
30 *
31 */
32#ifndef LWIP_HDR_APPS_FS_H
33#define LWIP_HDR_APPS_FS_H
34
35#include "httpd_opts.h"
36#include "lwip/err.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42#define FS_READ_EOF -1
43#define FS_READ_DELAYED -2
44
45#if HTTPD_PRECALCULATED_CHECKSUM
46struct fsdata_chksum {
48 u16_t chksum;
49 u16_t len;
50};
51#endif /* HTTPD_PRECALCULATED_CHECKSUM */
52
53#define FS_FILE_FLAGS_HEADER_INCLUDED 0x01
54#define FS_FILE_FLAGS_HEADER_PERSISTENT 0x02
55#define FS_FILE_FLAGS_HEADER_HTTPVER_1_1 0x04
56#define FS_FILE_FLAGS_SSI 0x08
57#define FS_FILE_FLAGS_CUSTOM 0x10
58
62#ifndef FS_FILE_EXTENSION_T_DEFINED
63typedef void fs_file_extension;
64#endif
65
66struct fs_file {
67 const char *data;
68 int len;
69 int index;
70#if LWIP_HTTPD_FILE_EXTENSION
71 /* pextension is free for implementations to hold private (extensional)
72 arbitrary data, e.g. holding some file state or file system handle */
73 fs_file_extension *pextension;
74#endif /* LWIP_HTTPD_FILE_EXTENSION */
75#if HTTPD_PRECALCULATED_CHECKSUM
76 const struct fsdata_chksum *chksum;
77 u16_t chksum_count;
78#endif /* HTTPD_PRECALCULATED_CHECKSUM */
80#if LWIP_HTTPD_FILE_STATE
81 void *state;
82#endif /* LWIP_HTTPD_FILE_STATE */
83};
84
85#if LWIP_HTTPD_FS_ASYNC_READ
86typedef void (*fs_wait_cb)(void *arg);
87#endif /* LWIP_HTTPD_FS_ASYNC_READ */
88
89err_t fs_open(struct fs_file *file, const char *name);
90void fs_close(struct fs_file *file);
91#if LWIP_HTTPD_DYNAMIC_FILE_READ
92#if LWIP_HTTPD_FS_ASYNC_READ
93int fs_read_async(struct fs_file *file, char *buffer, int count, fs_wait_cb callback_fn, void *callback_arg);
94#else /* LWIP_HTTPD_FS_ASYNC_READ */
95int fs_read(struct fs_file *file, char *buffer, int count);
96#endif /* LWIP_HTTPD_FS_ASYNC_READ */
97#endif /* LWIP_HTTPD_DYNAMIC_FILE_READ */
98#if LWIP_HTTPD_FS_ASYNC_READ
99int fs_is_file_ready(struct fs_file *file, fs_wait_cb callback_fn, void *callback_arg);
100#endif /* LWIP_HTTPD_FS_ASYNC_READ */
101int fs_bytes_left(struct fs_file *file);
102
103#if LWIP_HTTPD_FILE_STATE
105void *fs_state_init(struct fs_file *file, const char *name);
107void fs_state_free(struct fs_file *file, void *state);
108#endif /* #if LWIP_HTTPD_FILE_STATE */
109
111 const struct fsdata_file *next;
112 const unsigned char *name;
113 const unsigned char *data;
114 int len;
116#if HTTPD_PRECALCULATED_CHECKSUM
117 u16_t chksum_count;
118 const struct fsdata_chksum *chksum;
119#endif /* HTTPD_PRECALCULATED_CHECKSUM */
120};
121
122#if LWIP_HTTPD_CUSTOM_FILES
123/* Prototypes required to implement custom files as fs addon */
124int fs_open_custom(struct fs_file *file, const char *name);
125void fs_close_custom(struct fs_file *file);
126#if LWIP_HTTPD_FS_ASYNC_READ
127u8_t fs_canread_custom(struct fs_file *file);
128u8_t fs_wait_read_custom(struct fs_file *file, fs_wait_cb callback_fn, void *callback_arg);
129int fs_read_async_custom(struct fs_file *file, char *buffer, int count, fs_wait_cb callback_fn, void *callback_arg);
130#else /* LWIP_HTTPD_FS_ASYNC_READ */
131int fs_read_custom(struct fs_file *file, char *buffer, int count);
132#endif /* LWIP_HTTPD_FS_ASYNC_READ */
133#endif /* LWIP_HTTPD_CUSTOM_FILES */
134
135#ifdef __cplusplus
136}
137#endif
138
139#endif /* LWIP_HDR_APPS_FS_H */
static int state
Definition: maze.c:121
int fs_bytes_left(struct fs_file *file)
Definition: fs.c:158
void fs_file_extension
Definition: fs.h:63
err_t fs_open(struct fs_file *file, const char *name)
Definition: fs.c:43
void fs_close(struct fs_file *file)
Definition: fs.c:83
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
GLintptr offset
Definition: glext.h:5920
uint32_t u32_t
Definition: arch.h:129
uint8_t u8_t
Definition: arch.h:125
uint16_t u16_t
Definition: arch.h:127
s8_t err_t
Definition: err.h:96
void fs_read(off_t pos, int size, void *data)
Definition: io.c:282
Definition: fci.c:127
Definition: fs.h:66
u8_t flags
Definition: fs.h:79
int len
Definition: fs.h:68
const char * data
Definition: fs.h:67
int index
Definition: fs.h:69
const unsigned char * name
Definition: fs.h:112
const struct fsdata_file * next
Definition: fs.h:111
int len
Definition: fs.h:114
u8_t flags
Definition: fs.h:115
const unsigned char * data
Definition: fs.h:113
Definition: name.c:39
void * arg
Definition: msvc.h:10