mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 10:03:03 +01:00
simple utility to build public ibase.h
This commit is contained in:
parent
7da2f23ccd
commit
7683ae4b53
69
src/misc/makeHeader.cpp
Normal file
69
src/misc/makeHeader.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
void ProcessFile(FILE *in, bool stripFirstComment)
|
||||
{
|
||||
char s[256];
|
||||
bool striping = false;
|
||||
while(fgets(s, sizeof(s), in)) {
|
||||
if (stripFirstComment) {
|
||||
char *x = strstr(s, "/*");
|
||||
if (x) {
|
||||
striping = true;
|
||||
stripFirstComment = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (striping) {
|
||||
char *x = strstr(s, "*/");
|
||||
if (x) {
|
||||
striping = false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const char* include = "#include";
|
||||
if (memcmp(s, include, strlen(include))) {
|
||||
fputs(s, stdout);
|
||||
continue;
|
||||
}
|
||||
char *p = strchr(s, '"');
|
||||
if (! p) {
|
||||
throw "#include misses \" - start of filename";
|
||||
}
|
||||
++p;
|
||||
char *p2 = strchr(p, '"');
|
||||
if (! p2) {
|
||||
throw "#include misses \" - end of filename";
|
||||
}
|
||||
*p2 = 0;
|
||||
p2 = strrchr(p, '/'); // always open files in current directory
|
||||
if (p2) {
|
||||
p = p2 + 1;
|
||||
}
|
||||
FILE *newIn = fopen(p, "rt");
|
||||
if (! newIn) {
|
||||
continue;
|
||||
}
|
||||
ProcessFile(newIn, true);
|
||||
fclose(newIn);
|
||||
// clean after Makefile's cp
|
||||
unlink(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
try {
|
||||
ProcessFile(stdin, false);
|
||||
}
|
||||
catch(char* x)
|
||||
{
|
||||
fprintf(stderr, "%s\n", x);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user