Prusa MINI Firmware overview
fs.c File Reference
#include "lwip/apps/httpd_opts.h"
#include "lwip/def.h"
#include "lwip/apps/fs.h"
#include "fsdata.h"
#include <string.h>
#include "fsdata.c"

Functions

err_t fs_open (struct fs_file *file, const char *name)
 
void fs_close (struct fs_file *file)
 
int fs_bytes_left (struct fs_file *file)
 

Function Documentation

◆ fs_open()

err_t fs_open ( struct fs_file file,
const char *  name 
)
63 {
64  const struct fsdata_file *f;
65 
66  if ((file == NULL) || (name == NULL)) {
67  return ERR_ARG;
68  }
69 
70 #if LWIP_HTTPD_CUSTOM_FILES
71  if (fs_open_custom(file, name)) {
72  file->is_custom_file = 1;
73  return ERR_OK;
74  }
75  file->is_custom_file = 0;
76 #endif /* LWIP_HTTPD_CUSTOM_FILES */
77 
78  for (f = FS_ROOT; f != NULL; f = f->next) {
79  if (!strcmp(name, (const char *)f->name)) {
80  file->data = (const char *)f->data;
81  file->len = f->len;
82  file->index = f->len;
83  file->pextension = NULL;
84  file->flags = f->flags;
86  file->chksum_count = f->chksum_count;
87  file->chksum = f->chksum;
88 #endif /* HTTPD_PRECALCULATED_CHECKSUM */
90  file->state = fs_state_init(file, name);
91 #endif /* #if LWIP_HTTPD_FILE_STATE */
92  return ERR_OK;
93  }
94  }
95  /* file not found */
96  return ERR_VAL;
97 }
Here is the call graph for this function:

◆ fs_close()

void fs_close ( struct fs_file file)
102 {
103 #if LWIP_HTTPD_CUSTOM_FILES
104  if (file->is_custom_file) {
105  fs_close_custom(file);
106  }
107 #endif /* LWIP_HTTPD_CUSTOM_FILES */
108 #if LWIP_HTTPD_FILE_STATE
109  fs_state_free(file, file->state);
110 #endif /* #if LWIP_HTTPD_FILE_STATE */
111  LWIP_UNUSED_ARG(file);
112 }
Here is the call graph for this function:

◆ fs_bytes_left()

int fs_bytes_left ( struct fs_file file)
177 {
178  return file->len - file->index;
179 }
fs_file::pextension
void * pextension
Definition: fs.h:60
FS_ROOT
#define FS_ROOT
Definition: fsdata.c:296
fs_file::len
int len
Definition: fs.h:58
HTTPD_PRECALCULATED_CHECKSUM
#define HTTPD_PRECALCULATED_CHECKSUM
Definition: httpd_opts.h:302
fs_file::flags
u8_t flags
Definition: fs.h:65
fsdata_file::flags
u8_t flags
Definition: fsdata.h:43
fsdata_file::data
const unsigned char * data
Definition: fsdata.h:41
fsdata_file::next
const struct fsdata_file * next
Definition: fsdata.h:39
fs_close_custom
void fs_close_custom(struct fs_file *file)
Definition: fs_custom.c:32
NULL
#define NULL
Definition: usbd_def.h:53
fsdata_file::len
int len
Definition: fsdata.h:42
fs_open_custom
int fs_open_custom(struct fs_file *file, const char *name)
Definition: fs_custom.c:13
ERR_ARG
Definition: err.h:96
fs_file::index
int index
Definition: fs.h:59
LWIP_UNUSED_ARG
#define LWIP_UNUSED_ARG(x)
Definition: arch.h:308
fs_file::data
const char * data
Definition: fs.h:57
ERR_OK
Definition: err.h:63
fsdata_file
Definition: fsdata.h:38
fs_file::is_custom_file
u8_t is_custom_file
Definition: fs.h:67
fsdata_file::name
const unsigned char * name
Definition: fsdata.h:40
ERR_VAL
Definition: err.h:75
LWIP_HTTPD_FILE_STATE
#define LWIP_HTTPD_FILE_STATE
Definition: httpd_opts.h:295