mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Disregard that last change. The line endings were messed up.
svn path=/trunk/; revision=11988
This commit is contained in:
parent
79d7258886
commit
698924b5ec
2 changed files with 148 additions and 172 deletions
|
@ -1,153 +1,129 @@
|
||||||
/**
|
//
|
||||||
*
|
// deptool.c
|
||||||
* deptool.c
|
// Copyright (C) 2002 by Brian Palmer <brianp@sginet.com>
|
||||||
* Copyright (C) 2002 by Brian Palmer <brianp@sginet.com>
|
//
|
||||||
*
|
|
||||||
*/
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#define ERROR_SUCCESS 0
|
||||||
|
#define ERROR_NOTENOUGHPARAMS 1
|
||||||
#define ERROR_SUCCESS 0
|
#define ERROR_DEPENDFILENOTFOUND 2
|
||||||
#define ERROR_NOTENOUGHPARAMS 1
|
#define ERROR_OUTOFMEMORY 3
|
||||||
#define ERROR_DEPENDFILENOTFOUND 2
|
#define ERROR_READERROR 4
|
||||||
#define ERROR_OUTOFMEMORY 3
|
#define ERROR_WRITEERROR 5
|
||||||
#define ERROR_READERROR 4
|
|
||||||
#define ERROR_WRITEERROR 5
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
int main(int argc, char *argv[])
|
FILE* DependFile;
|
||||||
{
|
int DependFileSize;
|
||||||
FILE* DependFile;
|
char* DependFileData;
|
||||||
int DependFileSize;
|
char* NewDependFileData;
|
||||||
char* DependFileData;
|
int CurIdx;
|
||||||
char* NewDependFileData;
|
int CurIdx2;
|
||||||
int CurIdx;
|
int RuleDependencySplit = 0;
|
||||||
int CurIdx2;
|
|
||||||
int RuleDependencySplit = 0;
|
// Make sure they passed enough command line parameters
|
||||||
|
if (argc < 2)
|
||||||
/**
|
{
|
||||||
* Make sure they passed enough command line parameters
|
printf("Usage: deptool srcfile.d\n");
|
||||||
*/
|
return ERROR_NOTENOUGHPARAMS;
|
||||||
if (argc < 2)
|
}
|
||||||
{
|
|
||||||
printf("Usage: deptool srcfile.d\n");
|
// Try to open the dependency file
|
||||||
return ERROR_NOTENOUGHPARAMS;
|
DependFile = fopen(argv[1], "r+t");
|
||||||
}
|
if (DependFile == NULL)
|
||||||
|
{
|
||||||
/**
|
printf("deptool: No such dependency file: %s\n", argv[1]);
|
||||||
* Try to open the dependency file
|
return ERROR_DEPENDFILENOTFOUND;
|
||||||
*/
|
}
|
||||||
DependFile = fopen(argv[1], "r+t");
|
|
||||||
if (DependFile == NULL)
|
// Get the file size
|
||||||
{
|
fseek(DependFile, 0, SEEK_END);
|
||||||
printf("deptool: No such dependency file: %s\n", argv[1]);
|
DependFileSize = ftell(DependFile);
|
||||||
return ERROR_DEPENDFILENOTFOUND;
|
rewind(DependFile);
|
||||||
}
|
|
||||||
|
// Allocate memory
|
||||||
/**
|
DependFileData = (char *)malloc(DependFileSize);
|
||||||
* Get the file size
|
NewDependFileData = (char *)malloc(DependFileSize * 3);
|
||||||
*/
|
if (!DependFileData || !NewDependFileData)
|
||||||
fseek(DependFile, 0, SEEK_END);
|
{
|
||||||
DependFileSize = ftell(DependFile);
|
printf("deptool: Out of memory!\n");
|
||||||
rewind(DependFile);
|
fclose(DependFile);
|
||||||
|
return ERROR_OUTOFMEMORY;
|
||||||
/**
|
}
|
||||||
* Allocate memory
|
memset(DependFileData, 0, DependFileSize);
|
||||||
*/
|
memset(NewDependFileData, 0, DependFileSize * 3);
|
||||||
DependFileData = (char *)malloc(DependFileSize);
|
|
||||||
NewDependFileData = (char *)malloc(DependFileSize * 3);
|
// Read in file data
|
||||||
if (!DependFileData || !NewDependFileData)
|
fread(DependFileData, 1, DependFileSize, DependFile);
|
||||||
{
|
if (ferror(DependFile))
|
||||||
printf("deptool: Out of memory!\n");
|
{
|
||||||
fclose(DependFile);
|
printf("deptool: Dependency file read error.\n");
|
||||||
return ERROR_OUTOFMEMORY;
|
fclose(DependFile);
|
||||||
}
|
return ERROR_READERROR;
|
||||||
memset(DependFileData, 0, DependFileSize);
|
}
|
||||||
memset(NewDependFileData, 0, DependFileSize * 3);
|
|
||||||
|
// Loop through the dependency file data and
|
||||||
/**
|
// insert the rule for the dependency file itself
|
||||||
* Read in file data
|
for (CurIdx=0,CurIdx2=0; DependFileData[CurIdx]; CurIdx++,CurIdx2++)
|
||||||
*/
|
{
|
||||||
fread(DependFileData, 1, DependFileSize, DependFile);
|
// Find the first colon ':' in the file and insert
|
||||||
if (ferror(DependFile))
|
// the rule right before it
|
||||||
{
|
if (DependFileData[CurIdx] == ':')
|
||||||
printf("deptool: Dependency file read error.\n");
|
{
|
||||||
fclose(DependFile);
|
NewDependFileData[CurIdx2] = ' ';
|
||||||
return ERROR_READERROR;
|
CurIdx2++;
|
||||||
}
|
strcat(&NewDependFileData[CurIdx2], argv[1]);
|
||||||
|
CurIdx2 += strlen(argv[1]);
|
||||||
/**
|
NewDependFileData[CurIdx2] = ' ';
|
||||||
* Loop through the dependency file data and
|
CurIdx2++;
|
||||||
* insert the rule for the dependency file itself
|
strcat(NewDependFileData, &DependFileData[CurIdx]);
|
||||||
*/
|
CurIdx2 += 2;
|
||||||
for (CurIdx=0,CurIdx2=0; DependFileData[CurIdx]; CurIdx++,CurIdx2++)
|
RuleDependencySplit = CurIdx + 2;
|
||||||
{
|
break;
|
||||||
/**
|
}
|
||||||
* Find the first colon ':' in the file and insert
|
else
|
||||||
* the rule right before it
|
{
|
||||||
*/
|
NewDependFileData[CurIdx2] = DependFileData[CurIdx];
|
||||||
if (DependFileData[CurIdx] == ':')
|
}
|
||||||
{
|
}
|
||||||
NewDependFileData[CurIdx2] = ' ';
|
|
||||||
CurIdx2++;
|
// Now loop through all the rule dependencies and
|
||||||
strcat(&NewDependFileData[CurIdx2], argv[1]);
|
// turn them into rules themselves
|
||||||
CurIdx2 += strlen(argv[1]);
|
strcat(NewDependFileData, "\n\n");
|
||||||
NewDependFileData[CurIdx2] = ' ';
|
CurIdx = RuleDependencySplit;
|
||||||
CurIdx2++;
|
CurIdx2 = strlen(NewDependFileData);
|
||||||
strcat(NewDependFileData, &DependFileData[CurIdx]);
|
for (; DependFileData[CurIdx]; CurIdx++,CurIdx2++)
|
||||||
CurIdx2 += 2;
|
{
|
||||||
RuleDependencySplit = CurIdx + 2;
|
// If it's a line continuation char '\' then skip over it
|
||||||
break;
|
if (DependFileData[CurIdx] == '\\')
|
||||||
}
|
{
|
||||||
else
|
CurIdx2--;
|
||||||
{
|
continue;
|
||||||
NewDependFileData[CurIdx2] = DependFileData[CurIdx];
|
}
|
||||||
}
|
|
||||||
}
|
// If it's a new line char '\n' then insert a colon ':' to make it a rule
|
||||||
|
if (DependFileData[CurIdx] == '\n')
|
||||||
/**
|
{
|
||||||
* Now loop through all the rule dependencies and
|
NewDependFileData[CurIdx2] = ':';
|
||||||
* turn them into rules themselves
|
CurIdx2++;
|
||||||
*/
|
}
|
||||||
strcat(NewDependFileData, "\n\n");
|
|
||||||
CurIdx = RuleDependencySplit;
|
NewDependFileData[CurIdx2] = DependFileData[CurIdx];
|
||||||
CurIdx2 = strlen(NewDependFileData);
|
}
|
||||||
for (; DependFileData[CurIdx]; CurIdx++,CurIdx2++)
|
|
||||||
{
|
// Write out file data
|
||||||
/**
|
rewind(DependFile);
|
||||||
* If it's a line continuation char '\' then skip over it
|
fwrite(NewDependFileData, 1, strlen(NewDependFileData), DependFile);
|
||||||
*/
|
if (ferror(DependFile))
|
||||||
if (DependFileData[CurIdx] == '\\')
|
{
|
||||||
{
|
printf("deptool: Dependency file write error.\n");
|
||||||
CurIdx2--;
|
fclose(DependFile);
|
||||||
continue;
|
return ERROR_WRITEERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
fclose(DependFile);
|
||||||
* If it's a new line char '\n' then insert a colon ':' to make it a rule
|
return ERROR_SUCCESS;
|
||||||
*/
|
}
|
||||||
if (DependFileData[CurIdx] == '\n')
|
|
||||||
{
|
|
||||||
NewDependFileData[CurIdx2] = ':';
|
|
||||||
CurIdx2++;
|
|
||||||
}
|
|
||||||
|
|
||||||
NewDependFileData[CurIdx2] = DependFileData[CurIdx];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write out file data
|
|
||||||
*/
|
|
||||||
rewind(DependFile);
|
|
||||||
fwrite(NewDependFileData, 1, strlen(NewDependFileData), DependFile);
|
|
||||||
if (ferror(DependFile))
|
|
||||||
{
|
|
||||||
printf("deptool: Dependency file write error.\n");
|
|
||||||
fclose(DependFile);
|
|
||||||
return ERROR_WRITEERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(DependFile);
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* hosttype.c
|
* hosttype.c
|
||||||
* Copyright (C) 2002 by Brian Palmer <brianp@sginet.com>
|
* Copyright (C) 2002 by Brian Palmer <brianp@sginet.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
#if defined (__DJGPP__)
|
#if defined (__DJGPP__)
|
||||||
printf("dos\n");
|
printf("dos\n");
|
||||||
#elif defined (__WIN32__)
|
#elif defined (__WIN32__)
|
||||||
printf("win32\n");
|
printf("win32\n");
|
||||||
#else
|
#else
|
||||||
printf("linux\n");
|
printf("linux\n");
|
||||||
#endif // defined __DJGPP__
|
#endif // defined __DJGPP__
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue