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-2024 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.4.4
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 //CC-RX, CodeWarrior or Win32 compiler?
54 #if defined(__CCRX__)
55  #pragma pack
56 #elif defined(__CWCC__) || defined(_WIN32)
57  #pragma pack(push, 1)
58 #endif
59 
60 
61 /**
62  * @brief Resource entry
63  **/
64 
66 {
67  char_t type;
68  uint32_t dataStart;
69  uint32_t dataLength;
70  uint8_t nameLength;
73 
74 
75 /**
76  * @brief Root entry
77  **/
78 
79 typedef __packed_struct
80 {
81  char_t type;
82  uint32_t dataStart;
83  uint32_t dataLength;
84  uint8_t nameLength;
86 
87 
88 /**
89  * @brief Resource header
90  **/
91 
92 typedef __packed_struct
93 {
94  uint32_t totalSize;
97 
98 
99 //CC-RX, CodeWarrior or Win32 compiler?
100 #if defined(__CCRX__)
101  #pragma unpack
102 #elif defined(__CWCC__) || defined(_WIN32)
103  #pragma pack(pop)
104 #endif
105 
106 
107 typedef struct
108 {
111  uint32_t dataStart;
112  uint32_t dataLength;
113  uint8_t nameLength;
115 } DirEntry;
116 
117 
118 //Resource management
119 error_t resGetData(const char_t *path, const uint8_t **data, size_t *length);
120 
121 error_t resSearchFile(const char_t *path, DirEntry *dirEntry);
122 
123 //error_t resOpenDirectory(Directory *directory, const DirEntry *entry);
124 //error_t resReadDirectory(Directory *directory, DirEntry *entry);
125 
126 #if 0
127 typedef struct
128 {
129  uint_t mode;
130  uint32_t start;
131  uint32_t size;
132  uint32_t offset;
133 } FsFile;
134 
135 error_t resOpenFile(FsFile *file, const DirEntry *dirEntry, uint_t mode);
136 error_t resSeekFile(FsFile *file, uint32_t *position);
137 uint_t resReadFile(FsFile *file, void *data, size_t length);
138 #endif
139 
140 //C++ guard
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 #endif
ResEntry
@ RES_TYPE_FILE
@ RES_TYPE_DIR
uint8_t data[]
Definition: ethernet.h:222
uint32_t dataStart
uint8_t type
Definition: coap_common.h:176
uint_t volume
ResRootEntry rootEntry
char_t name[]
uint8_t nameLength
uint_t type
error_t
Error codes.
Definition: error.h:43
ResRootEntry
ResHeader
Error codes description.
uint8_t length
Definition: tcp.h:368
uint32_t dataStart
uint32_t dataLength
char char_t
Definition: compiler_port.h:48
ResType
Resource type.
uint8_t file[128]
Definition: dhcp_common.h:223
uint8_t nameLength
uint32_t dataLength
unsigned int uint_t
Definition: compiler_port.h:50
error_t resSearchFile(const char_t *path, DirEntry *dirEntry)
Compiler specific definitions.
typedef __packed_struct
Resource entry.
error_t resGetData(const char_t *path, const uint8_t **data, size_t *length)
void FsFile
File descriptor.
Definition: fs_port_fatfs.h:60