resource_manager.h
Go to the documentation of this file.
1 /**
2  * @file resource_manager.h
3  * @brief Embedded resource management
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.8
27  **/
28 
29 #ifndef _RESOURCE_MANAGER_H
30 #define _RESOURCE_MANAGER_H
31 
32 //Dependencies
33 #include "compiler_port.h"
34 #include "error.h"
35 
36 //C++ guard
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 
42 /**
43  * @brief Resource type
44  **/
45 
46 typedef enum
47 {
50 } ResType;
51 
52 
53 //CodeWarrior or Win32 compiler?
54 #if defined(__CWCC__) || defined(_WIN32)
55  #pragma pack(push, 1)
56 #endif
57 
58 
59 /**
60  * @brief Resource entry
61  **/
62 
63 typedef __start_packed struct
64 {
66  uint32_t dataStart;
67  uint32_t dataLength;
68  uint8_t nameLength;
71 
72 
73 /**
74  * @brief Root entry
75  **/
76 
77 typedef __start_packed struct
78 {
79  char_t type;
80  uint32_t dataStart;
81  uint32_t dataLength;
82  uint8_t nameLength;
84 
85 
86 /**
87  * @brief Resource header
88  **/
89 
90 typedef __start_packed struct
91 {
92  uint32_t totalSize;
95 
96 
97 //CodeWarrior or Win32 compiler?
98 #if defined(__CWCC__) || defined(_WIN32)
99  #pragma pack(pop)
100 #endif
101 
102 
103 typedef struct
104 {
107  uint32_t dataStart;
108  uint32_t dataLength;
109  uint8_t nameLength;
111 } DirEntry;
112 
113 
114 //Resource management
115 error_t resGetData(const char_t *path, const uint8_t **data, size_t *length);
116 
117 error_t resSearchFile(const char_t *path, DirEntry *dirEntry);
118 
119 //error_t resOpenDirectory(Directory *directory, const DirEntry *entry);
120 //error_t resReadDirectory(Directory *directory, DirEntry *entry);
121 
122 #if 0
123 typedef struct
124 {
125  uint_t mode;
126  uint32_t start;
127  uint32_t size;
128  uint32_t offset;
129 } FsFile;
130 
131 error_t resOpenFile(FsFile *file, const DirEntry *dirEntry, uint_t mode);
132 error_t resSeekFile(FsFile *file, uint32_t *position);
133 uint_t resReadFile(FsFile *file, void *data, size_t length);
134 #endif
135 
136 //C++ guard
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif
uint8_t length
Definition: coap_common.h:190
uint8_t data[]
Definition: ethernet.h:209
uint32_t dataStart
uint_t volume
ResRootEntry rootEntry
char_t name[]
uint8_t nameLength
__start_packed struct @2 ResHeader
Resource header.
uint_t type
char_t type
error_t
Error codes.
Definition: error.h:42
__start_packed struct @0 ResEntry
Resource entry.
__start_packed struct _Ipv4Header __end_packed
Error codes description.
uint32_t dataStart
uint32_t dataLength
__start_packed struct @1 ResRootEntry
Root entry.
char char_t
Definition: compiler_port.h:43
ResType
Resource type.
uint8_t file[128]
Definition: dhcp_common.h:213
uint32_t totalSize
uint8_t nameLength
uint32_t dataLength
uint8_t mode
Definition: ntp_common.h:149
unsigned int uint_t
Definition: compiler_port.h:45
error_t resSearchFile(const char_t *path, DirEntry *dirEntry)
Compiler specific definitions.
error_t resGetData(const char_t *path, const uint8_t **data, size_t *length)
void FsFile
File descriptor.
Definition: fs_port_fatfs.h:60