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-2023 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 2.3.2
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 {
49  RES_TYPE_FILE = 2
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 
64 {
65  char_t type;
66  uint32_t dataStart;
67  uint32_t dataLength;
68  uint8_t nameLength;
71 
72 
73 /**
74  * @brief Root entry
75  **/
76 
77 typedef __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 __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 type
Definition: coap_common.h:174
Compiler specific definitions.
unsigned int uint_t
Definition: compiler_port.h:50
char char_t
Definition: compiler_port.h:48
uint8_t file[128]
Definition: dhcp_common.h:221
Error codes description.
error_t
Error codes.
Definition: error.h:43
uint8_t data[]
Definition: ethernet.h:220
void FsFile
File descriptor.
Definition: fs_port_fatfs.h:60
error_t resGetData(const char_t *path, const uint8_t **data, size_t *length)
char_t name[]
ResRootEntry rootEntry
uint8_t nameLength
ResEntry
ResHeader
uint32_t dataStart
uint32_t dataLength
error_t resSearchFile(const char_t *path, DirEntry *dirEntry)
ResRootEntry
typedef __packed_struct
Resource entry.
ResType
Resource type.
@ RES_TYPE_FILE
@ RES_TYPE_DIR
uint_t type
uint8_t nameLength
uint32_t dataStart
uint32_t dataLength
uint_t volume
uint8_t length
Definition: tcp.h:366