| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
Filesystem Glue logic for reading http files
LPC18xx/43xx HTTP Server dual core example using LWIP ethernet stack

## Detailed Description

The lwIP Filesystem implementation module implements the file system functions required for FAT file system. The webserver uses this function to fetch the files from the appropriate device.

## Data Structures
struct | fs_file

## Macros
#define | LWIP_HTTPD_CUSTOM_FILES 0
#define | LWIP_HTTPD_FILE_STATE 0
#define | HTTPD_PRECALCULATED_CHECKSUM 0

## Functions
int | GetHTTP_Header (const char *fName, char *buff)
| Get HTTP header function.
struct fs_file * | fs_open_default (void)
| Open default HTTP file function.
struct fs_file * | fs_open (const char *name)
| Open a file from the Filesystem function.
void | fs_close (struct fs_file *file)
| Closes/Frees a previously opened file function.
int | fs_read (struct fs_file *file, char *buffer, int count)
| This reads the requested number of bytes from the file function.
int | fs_bytes_left (struct fs_file *file)
| Get number of bytes yet to be read in a file function.

## Macro Definition Documentation

#define HTTPD_PRECALCULATED_CHECKSUM 0

HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for predefined (MSS-sized) chunks of the files to prevent having to calculate the checksums at runtime.

Definition at line 66 of file lwip_fs.h.

#define LWIP_HTTPD_CUSTOM_FILES 0

Set this to 1 and provide the functions:

- "int fs_open_custom(struct fs_file *file, const char *name)" Called first for every opened file to allow opening files that are not included in fsdata(_custom).c
- "void fs_close_custom(struct fs_file *file)" Called to free resources allocated by fs_open_custom().

Definition at line 52 of file lwip_fs.h.

#define LWIP_HTTPD_FILE_STATE 0

Set this to 1 to include an application state argument per file that is opened. This allows to keep a state per connection/file.

Definition at line 59 of file lwip_fs.h.

## Function Documentation

int fs_bytes_left | ( | struct fs_file * | file | ) |

Get number of bytes yet to be read in a file function.

Parameters

  file | : Pointer to File structure of opened file

Returns
  Number of byets yet to be read from the file The function will return the number bytes yet to be read from the file.

Definition at line 356 of file lwip_fs.c.

void fs_close | ( | struct fs_file * | file | ) |

Closes/Frees a previously opened file function.

Parameters

  file | : Pointer to File structure of opened file

Returns
  None The function will close the file & free the resources.

Definition at line 331 of file lwip_fs.c.

struct fs_file* fs_open | ( | const char * | name | ) |
| read

Open a file from the Filesystem function.

Parameters

  name | : Name of the file to be opened

Returns
  Pointer to File structure on success NULL on failure The function will open the file present on the file system.

Definition at line 278 of file lwip_fs.c.

struct fs_file* fs_open_default | ( | void |  | ) |
| read

Open default HTTP file function.

Returns
  Pointer to File structure of default file on success NULL on failure The function will open the default file. The default file will have the HTTP content pointed by http_index_html variable. This function will be called if the HTTP files are not present in the file system.

Definition at line 253 of file lwip_fs.c.

int fs_read | ( | struct fs_file * | file,
|  | char * | buffer,
|  | int | count
| ) |  |

This reads the requested number of bytes from the file function.

Parameters

  file | : Pointer to File structure of opened file
  buffer | : pointer to memroy, where the data be stored
  count | : Number of bytes to be read from the file

Returns
  Number of bytes successfully read The function will read the specified number of bytes from the file.

Definition at line 345 of file lwip_fs.c.

int GetHTTP_Header | ( | const char * | fName,
|  | char * | buff
| ) |  |

Get HTTP header function.

Parameters

  fName | : Filename for which the header be generated
  buff | : buffer to which the generated header be copied

Returns
  Number of bytes in header The function will read the HTTP header from the file & returns with No. of bytes read

Definition at line 247 of file lwip_fs.c.