]> begriffs open source - freertos/blob - FreeRTOS-Plus/Source/Reliance-Edge/include/redtools.h
Minor modification to the WIn32 simple TCP/IP stack example only.
[freertos] / FreeRTOS-Plus / Source / Reliance-Edge / include / redtools.h
1 /*             ----> DO NOT REMOVE THE FOLLOWING NOTICE <----
2
3                    Copyright (c) 2014-2015 Datalight, Inc.
4                        All Rights Reserved Worldwide.
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; use version 2 of the License.
9
10     This program is distributed in the hope that it will be useful,
11     but "AS-IS," WITHOUT ANY WARRANTY; without even the implied warranty
12     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 /*  Businesses and individuals that for commercial or other reasons cannot
20     comply with the terms of the GPLv2 license may obtain a commercial license
21     before incorporating Reliance Edge into proprietary software for
22     distribution in any form.  Visit http://www.datalight.com/reliance-edge for
23     more information.
24 */
25 #ifndef REDTOOLS_H
26 #define REDTOOLS_H
27
28
29 #ifdef _WIN32
30   #include <Windows.h>
31   #define HOST_PATH_MAX MAX_PATH
32 #else
33   #include <linux/limits.h>
34   #define HOST_PATH_MAX PATH_MAX
35 #endif
36
37
38 #if REDCONF_IMAGE_BUILDER == 1
39
40 #define MACRO_NAME_MAX_LEN 32
41
42 typedef struct
43 {
44     uint8_t     bVolNumber;
45     const char *pszInputDir;
46     const char *pszOutputFile;
47   #if REDCONF_API_POSIX == 1
48     const char *pszVolName;
49   #else
50     const char *pszMapFile;
51     const char *pszDefineFile;
52     bool        fNowarn;
53   #endif
54 } IMGBLDPARAM;
55
56
57 void ImgbldParseParams(int argc, char *argv [], IMGBLDPARAM *pParam);
58 int ImgbldStart(IMGBLDPARAM *pParam);
59
60
61 typedef struct
62 {
63   #if REDCONF_API_POSIX == 1
64     char     asOutFilePath[HOST_PATH_MAX];
65   #else
66     uint32_t ulOutFileIndex;
67   #endif
68     char     asInFilePath[HOST_PATH_MAX];
69 } FILEMAPPING;
70
71
72 extern void *gpCopyBuffer;
73 extern uint32_t gulCopyBufferSize;
74
75
76 /*  Implemented in ibposix.c
77 */
78 #if REDCONF_API_POSIX == 1
79 REDSTATUS IbPosixCopyDir(const char *pszVolName, const char *pszInDir);
80 int IbPosixCreateDir(const char *pszVolName, const char *pszFullPath, const char *pszBasePath);
81 int IbConvertPath(const char *pszVolName, const char *pszFullPath, const char *pszBasePath, char *szOutPath);
82 #endif
83
84
85 /*  Implemented in ibfse.c
86 */
87 #if REDCONF_API_FSE == 1
88 typedef struct sFILELISTENTRY FILELISTENTRY;
89 struct sFILELISTENTRY
90 {
91     FILEMAPPING     fileMapping;
92     FILELISTENTRY  *pNext;
93 };
94
95
96 void FreeFileList(FILELISTENTRY **ppsFileList);
97
98 int IbFseGetFileList(const char *pszPath, const char *pszIndirPath, FILELISTENTRY **ppFileListHead);
99 int IbFseOutputDefines(FILELISTENTRY *pFileList, const IMGBLDPARAM *pOptions);
100 int IbFseCopyFiles(int volNum, const FILELISTENTRY *pFileList);
101 #endif
102
103
104 /*  Implemented in os-specific space (ibwin.c and iblinux.c)
105 */
106 #if REDCONF_API_POSIX == 1
107 int IbPosixCopyDirRecursive(const char *pszVolName, const char *pszInDir);
108 #endif
109 #if REDCONF_API_FSE == 1
110 int IbFseBuildFileList(const char *pszDirPath, FILELISTENTRY **ppFileListHead);
111 #endif
112 #if REDCONF_API_FSE == 1
113 int IbSetRelativePath(char *pszPath, const char *pszParentPath);
114 #endif
115 bool IsRegularFile(const char *pszPath);
116
117
118 /*  Implemented in ibcommon.c
119 */
120 int IbCopyFile(int volNum, const FILEMAPPING *pFileMapping);
121 int IbCheckFileExists(const char *pszPath, bool *pfExists);
122
123
124 /*  Implemented separately in ibfse.c and ibposix.c
125 */
126 int IbApiInit(void);
127 int IbApiUninit(void);
128 int IbWriteFile(int volNum, const FILEMAPPING *pFileMapping, uint64_t ullOffset, void *pData, uint32_t ulDataLen);
129
130 #endif /* IMAGE_BUILDER */
131
132 /*  For image copier tool
133 */
134
135 #ifdef _WIN32
136   #define HOST_PSEP '\\'
137   #if !__STDC__
138     #define snprintf _snprintf
139     #define stat _stat
140     #define S_IFDIR _S_IFDIR
141     #define rmdir _rmdir
142   #endif
143 #else
144   #define HOST_PSEP '/'
145 #endif
146
147 typedef struct
148 {
149     uint8_t     bVolNumber;
150     const char *pszOutputDir;
151     const char *pszBDevSpec;
152   #if REDCONF_API_POSIX == 1
153     const char *pszVolName;
154   #endif
155     bool        fNoWarn;
156 } IMGCOPYPARAM;
157
158 typedef struct
159 {
160   #if REDCONF_API_POSIX == 1
161     const char *pszVolume;      /* Volume path prefix. */
162     uint32_t    ulVolPrefixLen; /* strlen(COPIER::pszVolume) */
163   #else
164     uint8_t     bVolNum;        /* Volume number. */
165   #endif
166     const char *pszOutputDir;   /* Output directory path. */
167     bool        fNoWarn;        /* If true, no warning to overwrite. */
168     uint8_t    *pbCopyBuffer;   /* Buffer for copying file data. */
169 } COPIER;
170
171
172 void ImgcopyParseParams(int argc, char *argv [], IMGCOPYPARAM *pParam);
173 int ImgcopyStart(IMGCOPYPARAM *pParam);
174
175 /*  Implemented separately in imgcopywin.c and imgcopylinux.c.  These functions
176     print an error message and abort on failure.
177 */
178 void ImgcopyMkdir(const char *pszDir);
179 void ImgcopyRecursiveRmdir(const char *pszDir);
180
181
182 #endif /* REDTOOLS_H */
183