19 #include <arpa/inet.h>
22 #include <netinet/in.h>
26 #include <sys/socket.h>
27 #include <sys/types.h>
33 #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
36 #define __PRINTF__ printf
37 #define __COUT__ std::cout << __FILENAME__ << std::dec << " [" << __LINE__ << "]\t"
38 #define __E__ std::endl
44 int main(
int argc,
char** argv)
46 __COUT__ <<
"Starting doxygen main.html editor..." << __E__;
50 __COUT__ <<
"Need 3 arguments: for the full path to main.html AND to "
51 "ARRAY:<html-to-inject>"
55 std::string mainfn = argv[1];
56 std::string injectfn = argv[2];
57 std::string inject2fn = argv[3];
58 __COUT__ <<
"main.html destination full path: " << mainfn << __E__;
59 __COUT__ <<
"main.html source full path: " << mainfn +
".bk" << __E__;
60 __COUT__ <<
"inject.html source full path: " << injectfn << __E__;
61 __COUT__ <<
"inject2.html source full path: " << inject2fn << __E__;
63 FILE* mainSrc = fopen((mainfn +
".bk").c_str(),
"r");
66 __COUT__ <<
"Failed to open... " << mainfn +
".bk" << __E__;
69 FILE* injectSrc = fopen((injectfn).c_str(),
"r");
72 __COUT__ <<
"Failed to open... " << injectfn << __E__;
75 FILE* inject2Src = fopen((inject2fn).c_str(),
"r");
78 __COUT__ <<
"Failed to open... " << inject2fn << __E__;
81 FILE* mainDest = fopen((mainfn).c_str(),
"w");
84 __COUT__ <<
"Failed to open... " << mainfn << __E__;
89 unsigned int countdown = -1;
91 unsigned int injectIndex = 0;
94 while(fgets(line, 1000, mainSrc))
96 fputs(line, mainDest);
97 __COUT__ << line << (line[strlen(line) - 1] ==
'\n' ?
"" :
"\n");
99 if(injected && !strcmp(line,
"<div class=\"contents\">\n"))
106 else if(injected && !strcmp(line,
"<head>\n"))
114 if(!injected && countdown == 0)
136 while(fgets(line, 1000, injectSrc))
138 fputs(line, mainDest);
139 __COUT__ << line << (line[strlen(line) - 1] ==
'\n' ?
"" :
"\n");
150 while(fgets(line, 1000, inject2Src))
152 fputs(line, mainDest);
153 __COUT__ << line << (line[strlen(line) - 1] ==
'\n' ?
"" :
"\n");
158 __COUT__ <<
"Unknown injection!" << __E__;
171 __COUT__ <<
"Doxygen main.html editor complete!" << __E__;