You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Alexei Kosut <ak...@leland.Stanford.EDU> on 1997/11/23 23:54:34 UTC
[PATCH/Win32] Remove main() from ApacheCore.dll
Here's a patch that accomplishes what I discussed earlier:
1) It gets rid of the main() function in http_main.c (for Win32 only) and
replaces it with an apache_main(). This takes main() out of
ApacheCore.dll, which always struck me as a somewhat nasty idea.
This also has the benefit of allowing other programs to link to
it if they want (why? I dunno).
2) Remove main/dummy.c, and replace it with os/win32/main_win32.c,
which just contains a main() function that calls the aforementioned
apache_main(). This has the added benefit of not having to deal with
a silly dummy object file just so link.exe doesn't complain about
not having any object files when linking Apache.exe.
So here's the patch, followed by the contents of main_win32.c:
Index: Apache.dsp
===================================================================
RCS file: /export/home/cvs/apachen/src/Apache.dsp,v
retrieving revision 1.6
diff -u -r1.6 Apache.dsp
--- Apache.dsp 1997/10/20 20:19:07 1.6
+++ Apache.dsp 1997/11/23 22:39:12
@@ -86,7 +86,7 @@
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
# Begin Source File
-SOURCE=.\main\dummy.c
+SOURCE=.\os\win32\main_win32.c
# End Source File
# End Group
# Begin Group "Header Files"
Index: Apache.mak
===================================================================
RCS file: /export/home/cvs/apachen/src/Apache.mak,v
retrieving revision 1.6
diff -u -r1.6 Apache.mak
--- Apache.mak 1997/10/20 20:19:08 1.6
+++ Apache.mak 1997/11/23 22:39:12
@@ -47,7 +47,7 @@
!ENDIF
CLEAN :
- -@erase "$(INTDIR)\dummy.obj"
+ -@erase "$(INTDIR)\main_win32.obj"
-@erase "$(INTDIR)\vc50.idb"
-@erase "$(OUTDIR)\Apache.exe"
@@ -68,7 +68,7 @@
/incremental:no /pdb:"$(OUTDIR)\Apache.pdb" /machine:I386\
/out:"$(OUTDIR)\Apache.exe"
LINK32_OBJS= \
- "$(INTDIR)\dummy.obj"
+ "$(INTDIR)\main_win32.obj"
"$(OUTDIR)\Apache.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
@@ -94,7 +94,7 @@
!ENDIF
CLEAN :
- -@erase "$(INTDIR)\dummy.obj"
+ -@erase "$(INTDIR)\main_win32.obj"
-@erase "$(INTDIR)\vc50.idb"
-@erase "$(INTDIR)\vc50.pdb"
-@erase "$(OUTDIR)\Apache.exe"
@@ -118,7 +118,7 @@
/incremental:yes /pdb:"$(OUTDIR)\Apache.pdb" /debug /machine:I386\
/out:"$(OUTDIR)\Apache.exe"
LINK32_OBJS= \
- "$(INTDIR)\dummy.obj"
+ "$(INTDIR)\main_win32.obj"
"$(OUTDIR)\Apache.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
@@ -159,9 +159,9 @@
!IF "$(CFG)" == "Apache - Win32 Release" || "$(CFG)" == "Apache - Win32 Debug"
-SOURCE=.\main\dummy.c
+SOURCE=.\os\win32\main_win32.c
-"$(INTDIR)\dummy.obj" : $(SOURCE) "$(INTDIR)"
+"$(INTDIR)\main_win32.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
Index: main/http_main.c
===================================================================
RCS file: /export/home/cvs/apachen/src/main/http_main.c,v
retrieving revision 1.253
diff -u -r1.253 http_main.c
--- http_main.c 1997/11/22 02:04:44 1.253
+++ http_main.c 1997/11/23 22:39:14
@@ -4264,8 +4264,12 @@
return (0);
}
+#ifdef WIN32
__declspec(dllexport)
- int main(int argc, char *argv[])
+ int apache_main(int argc, char *argv[])
+#else
+int main(int argc, char *argv[])
+#endif
{
int c;
int child = 0;
New File: os/win32/main_win32.c
===================================================================
/* main_win32.c - Apache executable stub file for Win32
* This file's purpose in life is to load, and call the
* "real" main function, apache_main(), located in ApacheCore.dll
*
* This was done because having the main() function in a DLL,
* although Win32 allows it, seemed wrong. Also, MSVC++ won't
* link an executable without at least one object file. This
* satistifies that requirement.
*/
__declspec(dllexport) int apache_main(int argc, char *argv[]);
int main(int argc, char *argv[])
{
apache_main(argc, argv);
}
-- Alexei Kosut <ak...@stanford.edu> <http://www.stanford.edu/~akosut/>
Stanford University, Class of 2001 * Apache <http://www.apache.org> *
Re: [PATCH/Win32] Remove main() from ApacheCore.dll
Posted by Ben Laurie <be...@algroup.co.uk>.
Alexei Kosut wrote:
>
> Here's a patch that accomplishes what I discussed earlier:
>
> 1) It gets rid of the main() function in http_main.c (for Win32 only) and
> replaces it with an apache_main(). This takes main() out of
> ApacheCore.dll, which always struck me as a somewhat nasty idea.
> This also has the benefit of allowing other programs to link to
> it if they want (why? I dunno).
>
> 2) Remove main/dummy.c, and replace it with os/win32/main_win32.c,
> which just contains a main() function that calls the aforementioned
> apache_main(). This has the added benefit of not having to deal with
> a silly dummy object file just so link.exe doesn't complain about
> not having any object files when linking Apache.exe.
+1.
Cheers,
Ben.
--
Ben Laurie |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant |Fax: +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd, |http://www.algroup.co.uk/Apache-SSL
London, England. |"Apache: TDG" http://www.ora.com/catalog/apache