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