| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- /*
- ** Command & Conquer Red Alert(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include <stdlib.h>
- #include "wdebug.h"
- #include "streamer.h"
- #include "odevice.h"
- static MsgManager *msg_manager=NULL;
- static int debug_enabled=0;
- static ostream *debug_ostream=NULL;
- static Streamer debug_streamer;
- static int info_enabled=0;
- static ostream *info_ostream=NULL;
- static Streamer info_streamer;
- static int warn_enabled=0;
- static ostream *warn_ostream=NULL;
- static Streamer warn_streamer;
- static int error_enabled=0;
- static ostream *error_ostream=NULL;
- static Streamer error_streamer;
- // Don't dare touch this semaphore in application code!
- Sem4 DebugLibSemaphore;
- int MsgManager::setAllStreams(OutputDevice *device)
- {
- if (device==NULL)
- return(1);
- DebugLibSemaphore.Wait();
- debug_streamer.setOutputDevice(device);
- delete(debug_ostream);
- debug_ostream=new ostream(&debug_streamer);
- info_streamer.setOutputDevice(device);
- delete(info_ostream);
- info_ostream=new ostream(&info_streamer);
- warn_streamer.setOutputDevice(device);
- delete(warn_ostream);
- warn_ostream=new ostream(&warn_streamer);
- error_streamer.setOutputDevice(device);
- delete(error_ostream);
- error_ostream=new ostream(&error_streamer);
- DebugLibSemaphore.Post();
- return(0);
- }
- int MsgManager::setDebugStream(OutputDevice *device)
- {
- if (device==NULL)
- return(1);
- DebugLibSemaphore.Wait();
- debug_streamer.setOutputDevice(device);
- delete(debug_ostream);
- debug_ostream=new ostream(&debug_streamer);
- DebugLibSemaphore.Post();
- return(0);
- }
- int MsgManager::setInfoStream(OutputDevice *device)
- {
- if (device==NULL)
- return(1);
- DebugLibSemaphore.Wait();
- info_streamer.setOutputDevice(device);
- delete(info_ostream);
- info_ostream=new ostream(&info_streamer);
- DebugLibSemaphore.Post();
- return(0);
- }
- int MsgManager::setWarnStream(OutputDevice *device)
- {
- if (device==NULL)
- return(1);
- DebugLibSemaphore.Wait();
- warn_streamer.setOutputDevice(device);
- delete(warn_ostream);
- warn_ostream=new ostream(&warn_streamer);
- DebugLibSemaphore.Post();
- return(0);
- }
- int MsgManager::setErrorStream(OutputDevice *device)
- {
- if (device==NULL)
- return(1);
- DebugLibSemaphore.Wait();
- error_streamer.setOutputDevice(device);
- delete(error_ostream);
- error_ostream=new ostream(&error_streamer);
- DebugLibSemaphore.Post();
- return(0);
- }
- ostream *MsgManager::debugStream(void)
- {
- return(debug_ostream);
- }
- ostream *MsgManager::infoStream(void)
- {
- return(info_ostream);
- }
- ostream *MsgManager::warnStream(void)
- {
- return(warn_ostream);
- }
- ostream *MsgManager::errorStream(void)
- {
- return(error_ostream);
- }
|