10#define ERROR_SUCCESS 0
11#define ERROR_NOTENOUGHPARAMS 1
12#define ERROR_DEPENDFILENOTFOUND 2
13#define ERROR_OUTOFMEMORY 3
14#define ERROR_READERROR 4
15#define ERROR_WRITEERROR 5
22 char* NewDependFileData;
25 int RuleDependencySplit = 0;
30 printf(
"Usage: deptool srcfile.d\n");
36 if (DependFile ==
NULL)
38 printf(
"deptool: No such dependency file: %s\n",
argv[1]);
44 DependFileSize =
ftell(DependFile);
48 DependFileData = (
char *)
malloc(DependFileSize);
49 NewDependFileData = (
char *)
malloc(DependFileSize * 3);
50 if (!DependFileData || !NewDependFileData)
52 printf(
"deptool: Out of memory!\n");
53 if (DependFileData !=
NULL)
55 if (NewDependFileData !=
NULL)
56 free(NewDependFileData);
60 memset(DependFileData, 0, DependFileSize);
61 memset(NewDependFileData, 0, DependFileSize * 3);
64 fread(DependFileData, 1, DependFileSize, DependFile);
67 printf(
"deptool: Dependency file read error.\n");
69 free(NewDependFileData);
76 for (CurIdx=0,CurIdx2=0; DependFileData[CurIdx]; CurIdx++,CurIdx2++)
80 if (DependFileData[CurIdx] ==
':')
82 NewDependFileData[CurIdx2] =
' ';
86 NewDependFileData[CurIdx2] =
' ';
88 strcat(NewDependFileData, &DependFileData[CurIdx]);
90 RuleDependencySplit = CurIdx + 2;
95 NewDependFileData[CurIdx2] = DependFileData[CurIdx];
101 strcat(NewDependFileData,
"\n\n");
102 CurIdx = RuleDependencySplit;
103 CurIdx2 =
strlen(NewDependFileData);
104 for (; DependFileData[CurIdx]; CurIdx++,CurIdx2++)
107 if (DependFileData[CurIdx] ==
'\\')
114 if (DependFileData[CurIdx] ==
'\n')
116 NewDependFileData[CurIdx2] =
':';
120 NewDependFileData[CurIdx2] = DependFileData[CurIdx];
125 fwrite(NewDependFileData, 1,
strlen(NewDependFileData), DependFile);
128 printf(
"deptool: Dependency file write error.\n");
130 free(DependFileData);
131 free(NewDependFileData);
136 free(DependFileData);
137 free(NewDependFileData);
char * strcat(char *DstString, const char *SrcString)
ACPI_SIZE strlen(const char *String)
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
_CRTIMP void __cdecl rewind(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)