Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

libmain.cpp

Go to the documentation of this file.
00001 // libdoomwad: manipulates Doom wad files.
00002 // Copyright (C) 2005  John Gaughan
00003 //
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 //
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 //
00018 // This library is distributed with the full text of the LGPL. Please see
00019 // the accompanying file named COPYING.
00020 // 
00021 // You may contact the author at john@johngaughan.net
00022 
00038 // C++ required.
00039 #if !defined __cplusplus
00040 #error C++ compiler required
00041 #endif
00042 
00043 // Windows header
00044 #if defined WINDOWS
00045 #include <windows.h>
00046 #endif
00047 
00048 // Standard headers
00049 #include <iostream>
00050 
00051 // Doom headers
00052 #include "global.hpp"
00053 #include "eventlog.hpp"
00054 #include "libmain.hpp"
00055 
00056 // This is the cool part. Since Linux uses separate functions instead of one
00057 // with a parameter, I can use the same functions to initialize both versions
00058 // of the library. Most of libdoomwad is OS-independent, so the only thing to
00059 // worry about is how to get into the library.
00060 
00062 void _init (void)
00063 {
00064 
00065   // Log errors to stderr.
00066   Doomwad::EventLog::setStream (&std::cerr);
00067 }
00068 
00070 void _fini (void)
00071 {
00072 
00073   // Detach error log from stream to avoid possible dangling pointer issues as
00074   // this library and libstdc++ both try to unload.
00075   Doomwad::EventLog::setStream (NULL);
00076 }
00077 
00078 #if defined WINDOWS
00079 
00094 EXPORT int WINAPI DllMain (HINSTANCE instance, DWORD reason, PVOID reserved)
00095 {
00096 
00097   // Shut up the compiler about unused variable warnings.
00098   instance = NULL;
00099   reserved = NULL;
00100 
00101   // Only care about attaching/detaching to/from processes. Thread stuff does
00102   // not matter because there is no per-thread crap to worry about here.
00103   switch (reason)
00104   {
00105     case DLL_PROCESS_ATTACH:
00106       _init ();
00107       break;
00108     case DLL_PROCESS_DETACH:
00109       _fini ();
00110       break;
00111     default:
00112       break;
00113   }
00114   return 1;
00115 }
00116 #endif
00117 
00118 //=============================================================================
00119 //=============================================================================
00120 
00179 //=============================================================================
00180 //=============================================================================
00181 
00235 //=============================================================================
00236 //=============================================================================
00237 
00264 //=============================================================================
00265 //=============================================================================
00266 
00367 //=============================================================================
00368 //=============================================================================
00369 
00648 //=============================================================================
00649 //=============================================================================
00650 

Generated on Fri Jun 10 19:38:51 2005 for libdoomwad by  doxygen 1.4.0