• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef HCS_COMPILER_FILE_H
10 #define HCS_COMPILER_FILE_H
11 
12 #include <stdio.h>
13 #include "hcs_types.h"
14 
15 #define HCS_SOURCE_FILE_SUFFIX ".hcs"
16 #define HCS_OUTPUT_FILE_SUFFIX ".hcb"
17 #define HCS_DECOMPILE_OUTPUT_FILE_SUFFIX ".d.hcs"
18 
19 struct HcsFile {
20     const char *name;
21     const char *fullPath;
22     FILE *file;
23     uint64_t pos;
24     struct HcsFile *next;
25 };
26 
27 struct HcsFileQueue {
28     struct HcsFile *head;
29     uint32_t count;
30 };
31 
32 struct HcsSourceName {
33     const char *name;
34     struct HcsSourceName *next;
35 };
36 
37 const char *HcsGetInputFileName(void);
38 
39 void HcsSetInputFileName(const char *name);
40 
41 int32_t HcsOpenSourceFile(const char *path, struct HcsFile **file, const char *flag);
42 
43 void HcsCloseFile(struct HcsFile *file);
44 
45 int32_t HcsSetOutPutName(const char *name);
46 
47 int32_t HcsSetOutPutNameWithCurrentWorkPath(const char *name);
48 
49 const char *HcsGetOutPutFilePath(void);
50 
51 char *HcsGetOutputFileNameWithoutSuffix(void);
52 
53 const char *HcsGetOutputFileName(void);
54 
55 struct HcsFile *HcsOpenOutputFile(const char *suffix);
56 
57 void HcsCloseOutput(struct HcsFile *output);
58 
59 int32_t HcsOutputWrite(const void *buffer, uint32_t length);
60 
61 int32_t HcsFormatOutputWrite(const char *format, ...);
62 
63 int32_t HcsOutputWriteAlign(const void *buffer, uint32_t length);
64 
65 void HcsMockOutPut(bool dummyOutput);
66 
67 uint32_t HcsGetOutputCurrentCount(void);
68 
69 void HcsResetOutputCurrentCount(void);
70 
71 void HcsSourceQueuePush(struct HcsFile *sourceFile);
72 
73 void HcsSourceQueuePop(void);
74 
75 struct HcsFile *HcsSourceQueueTop(void);
76 
77 uint32_t HcsSourceQueueSize(void);
78 
79 const char *HcsGetCurrentSourceName(void);
80 
81 int32_t HcsSourceNameSetPush(const char *name);
82 
83 void HcsSourceNameSetClean(void);
84 
85 bool HcsFileCopyDir(char *dst, uint32_t dstBufferSize, const char *fullPath);
86 
87 uint64_t HcsSourceFileGetSize(struct HcsFile *file);
88 
89 int32_t HcsSourceFileRead(struct HcsFile *file, uint8_t *out, uint32_t readSize);
90 
91 uint32_t HcsGetSourceFilePos(struct HcsFile *file);
92 
93 #endif // HCS_COMPILER_FILE_H
94