Webserver+3d print

Dependents:   Nucleo

Committer:
Sergunb
Date:
Sat Feb 04 18:15:49 2017 +0000
Revision:
0:8918a71cdbe9
nothing else

Who changed what in which revision?

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