]> granicus.if.org Git - apache/blob - os/win32/MakeModuleMak.cpp
This patch corrects the issues from the AP_EXPORT and linkage
[apache] / os / win32 / MakeModuleMak.cpp
1 #include <fstream.h>
2 #include <assert.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <stdlib.h>
6
7 void MakeMake(const char *szModule,const char *szSource)
8     {
9     ifstream ifs("Module.mak.tmpl",ios::nocreate);
10     assert(ifs.good());
11     
12     char buf[1024];
13     sprintf(buf,"%s.mak",szModule);
14     ofstream ofs(buf,ios::trunc);
15     for( ; ; )
16         {
17         ifs.getline(buf,sizeof buf);
18         if(ifs.eof())
19             break;
20         for(char *s=buf ; *s ; )
21             {
22             char *p=strchr(s,'%');
23             if(!p)
24                 {
25                 ofs << s << '\n';
26                 break;
27                 }
28             if(!strncmp(p,"%Module%",8))
29                 {
30                 ofs.write(s,p-s);
31                 ofs << szModule;
32                 s=p+8;
33                 }
34             else if(!strncmp(p,"%Source%",8))
35                 {
36                 ofs.write(s,p-s);
37                 ofs << szSource;
38                 s=p+8;
39                 }
40             else
41                 {
42                 ofs.write(s,p-s+1);
43                 s=p+1;
44                 }
45             }
46         }
47     }
48
49 void main(int argc,char **argv)
50     {
51     if(argc < 2 || (argc%2) != 1)
52         {
53         cerr << argv[0] << " [<module name> <source file>]+\n";
54         exit(1);
55         }
56     for(int n=1 ; n < argc ; n+=2)
57         MakeMake(argv[n],argv[n+1]);
58     }
59