Changeset 1456 for trunk/src/ddraw


Ignore:
Timestamp:
Oct 26, 1999, 7:53:43 PM (26 years ago)
Author:
sandervl
Message:

log fixes (FS)

Location:
trunk/src/ddraw
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ddraw/initterm.cpp

    r951 r1456  
    1 /* $Id: initterm.cpp,v 1.9 1999-09-15 23:26:06 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.10 1999-10-26 17:52:31 sandervl Exp $ */
    22
    33/*
     
    3535#include <odinlx.h>
    3636#include <misc.h>       /*PLF Wed  98-03-18 23:18:15*/
     37#include "initterm.h"
    3738
    3839extern "C" {
     
    4041void CDECL _ctordtorTerm( void );
    4142}
     43
     44char ddrawPath[CCHMAXPATH] = "";
    4245
    4346/*-------------------------------------------------------------------*/
     
    7275   switch (ulFlag) {
    7376      case 0 :
     77      {
    7478         _ctordtorInit();
     79
     80         DosQueryModuleName(hModule, CCHMAXPATH, ddrawPath);
     81         char *endofpath = strrchr(ddrawPath, '\\');
     82         if(endofpath) *(endofpath+1) = 0;
    7583
    7684         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
     
    8997
    9098         break;
     99      }
    91100      case 1 :
    92101         UnregisterLxDll(hModule);
     
    106115{
    107116   _ctordtorTerm();
     117   CloseLogFile();
    108118   DosExitList(EXLST_EXIT, cleanup);
    109119   return ;
  • trunk/src/ddraw/makefile

    r604 r1456  
    5454    $(PDWIN32_INCLUDE)\win\d3d.h
    5555
    56 misc.obj: misc.cpp
     56misc.obj: misc.cpp initterm.h
    5757
    5858os2palette.obj: os2palette.cpp  \
     
    8484rectangle.obj: rectangle.cpp
    8585
    86 initterm.obj: initterm.cpp
     86initterm.obj: initterm.cpp initterm.h
    8787
    8888clean:
    89   $(RM) *.obj *.lib *.dll *~ *.map *.pch
     89  $(RM) *.obj *.lib *.dll *.map *.pch
    9090  $(RM) $(PDWIN32_BIN)\$(TARGET).dll
    9191  $(RM) $(PDWIN32_LIB)\$(TARGET).lib
  • trunk/src/ddraw/misc.cpp

    r210 r1456  
    88#include <string.h>
    99#include <stdarg.h>
    10 #include "misc.h"
    11 
     10#include <misc.h>
     11#include "initterm.h"
    1212
    1313//#define PMPRINTF
     
    235235
    236236
    237 #if 1   /*PLF Mon  97-09-08 20:04:28*/
     237/*****************************************************************************
     238 * Standard Version                                                          *
     239 *****************************************************************************/
     240
    238241static FILE *flog = NULL;   /*PLF Mon  97-09-08 20:00:15*/
    239242static BOOL init = FALSE;
     243static BOOL fLogging = TRUE;
    240244
    241245int SYSTEM EXPORT WriteLog(char *tekst, ...)
    242246{
     247  USHORT  sel = RestoreOS2FS();
    243248  va_list argptr;
     249
    244250  if(!init)
    245251  {
    246252    init = TRUE;
    247     if(!getenv("NODDRAWLOG"))
    248       flog = fopen("DDRAW.log", "w");
    249   }
    250 
    251   if(flog)
     253
     254    if(!getenv("NODDRAWLOG")) {
     255        char logname[CCHMAXPATH];
     256
     257        flog = fopen("DDRAW.log", "w");
     258        if(flog == NULL) {//probably running exe on readonly device
     259                sprintf(logname, "%sddraw.log", ddrawPath);
     260                flog = fopen(logname, "w");
     261        }
     262    }
     263    else
     264      fLogging = FALSE;
     265  }
     266
     267  if(fLogging && flog)
    252268  {
    253      va_start(argptr, tekst);
    254      vfprintf(flog, tekst, argptr);
    255      va_end(argptr);
    256      fflush(flog);
    257   }
     269    va_start(argptr, tekst);
     270    vfprintf(flog, tekst, argptr);
     271    va_end(argptr);
     272
     273    if(tekst[strlen(tekst)-1] != '\n')
     274      fprintf(flog, "\n");
     275  }
     276
     277  SetFS(sel);
    258278  return 1;
    259279}
    260 #else   /*PLF Mon  97-09-08 20:04:26*/
    261 /******************************************************************************/
    262 static BOOL init = FALSE;
    263 static BOOL fLog = TRUE;
    264 /******************************************************************************/
    265 int SYSTEM EXPORT WriteLog(char *tekst, ...)
    266 {
    267   ULONG Action, Wrote;
    268   HFILE log;
    269   APIRET rc;
    270   char message[4096];
    271   va_list argptr;
    272   ULONG openFlags = OPEN_ACTION_CREATE_IF_NEW;
    273 
    274   if(fLog == FALSE)
    275     return(FALSE);
    276 
    277   if(!init)
    278   {
    279     init = TRUE;
    280     openFlags |= OPEN_ACTION_REPLACE_IF_EXISTS;
    281     if(getenv("NOWIN32LOG"))
    282       fLog = FALSE;
    283   }
    284   else
    285     openFlags |= OPEN_ACTION_OPEN_IF_EXISTS;
    286 
    287   rc = DosOpen( "win32os2.log",
    288                 &log,           /* file handle returned */
    289                 &Action,
    290                 0L,
    291                 FILE_NORMAL,
    292                 openFlags,
    293                 OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYWRITE,
    294                 (PEAOP2)NULL);
    295 
    296    rc = DosSetFilePtr(log, 0, FILE_END, &Wrote);
    297    va_start(argptr, tekst);
    298    vsprintf(message, tekst, argptr);
    299    va_end(argptr);
    300 
    301    rc = DosWrite(log, message, strlen(message), &Wrote);
    302 
    303    DosClose(log);   /*PLF Mon  97-09-08 20:01:43*/
    304    return(TRUE);
     280//******************************************************************************
     281//NOTE: No need to save/restore FS, as our FS selectors have already been
     282//      destroyed and FS == 0x150B.
     283//******************************************************************************
     284void CloseLogFile()
     285{
     286  fclose(flog);
     287  flog = 0;
    305288}
    306 #endif  /*PLF Mon  97-09-08 20:04:23*/
    307 /******************************************************************************/
    308 /******************************************************************************/
    309 
    310 
    311289#endif
Note: See TracChangeset for help on using the changeset viewer.