Ignore:
Timestamp:
Aug 6, 1999, 11:03:04 AM (26 years ago)
Author:
phaller
Message:

Fix: WriteLog requires to be bracketed in RestoreFS / SetFS, too. The VAC runtime accesses FS directly here!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/misc.cpp

    r120 r433  
    1 /* $Id: misc.cpp,v 1.3 1999-06-19 10:54:42 sandervl Exp $ */
     1/* $Id: misc.cpp,v 1.4 1999-08-06 09:03:04 phaller Exp $ */
    22
    33/*
    4  *
    54 * Project Odin Software License can be found in LICENSE.TXT
    6  *
    7  */
    8 /*
    95 * Logging procedures
    106 *
     
    1410 *
    1511 */
     12
     13
     14/*****************************************************************************
     15 * Includes                                                                  *
     16 *****************************************************************************/
     17
    1618#define INCL_BASE
    1719#define INCL_WIN
    1820#define INCL_WINERRORS
    1921#define INCL_DOSFILEMGR
    20 #include <os2wrap.h>    //Odin32 OS/2 api wrappers
     22#include <os2wrap.h>                     //Odin32 OS/2 api wrappers
    2123#include <stdio.h>
    2224#include <stdlib.h>
     
    2729
    2830
    29 //#define PMPRINTF
     31/*****************************************************************************
     32 * PMPRINTF Version                                                          *
     33 *****************************************************************************/
     34
    3035#ifdef PMPRINTF
    3136
     
    4651#define PRINTFIDSIZE sizeof(PRINTFID)
    4752#define PRINTFMAXBUF PRINTFIDSIZE+PRINTFLINELEN
     53
     54
     55/*****************************************************************************
     56 * Structures                                                                *
     57 *****************************************************************************/
    4858
    4959/* ----- Per-thread output buffer and current indices into line ---- */
     
    6373/* ----- Local subroutine ----- */
    6474static int printf_(struct perthread *);
     75
    6576
    6677/* ----------------------------------------------------------------- */
     
    220231  return 0;                        /* success! */
    221232  } /* printf_ */
    222 #else
    223 
     233#endif
     234
     235
     236
     237/*****************************************************************************
     238 * Standard Version                                                          *
     239 *****************************************************************************/
    224240
    225241#if 1   /*PLF Mon  97-09-08 20:04:28*/
     
    230246int SYSTEM EXPORT WriteLog(char *tekst, ...)
    231247{
    232     va_list argptr;
    233     if(!init){
    234         init = TRUE;
    235         if(!getenv("NOWIN32LOG")) {
    236              flog = fopen("win32os2.log", "w");
    237     }
    238     else fLogging = FALSE;
    239     }
    240 
    241     if(fLogging && flog){
    242         va_start(argptr, tekst);
    243         vfprintf(flog, tekst, argptr);
    244         va_end(argptr);
     248  USHORT  sel = RestoreOS2FS();
     249  va_list argptr;
     250
     251  if(!init)
     252  {
     253    init = TRUE;
     254
     255    if(!getenv("NOWIN32LOG"))
     256      flog = fopen("win32os2.log", "w");
     257    else
     258      fLogging = FALSE;
     259  }
     260
     261  if(fLogging && flog)
     262  {
     263    va_start(argptr, tekst);
     264    vfprintf(flog, tekst, argptr);
     265    va_end(argptr);
     266
    245267    if(tekst[strlen(tekst)-1] != '\n')
    246         fprintf(flog, "\n");
    247     }
    248     return 1;
     268      fprintf(flog, "\n");
     269  }
     270
     271  SetFS(sel);
     272  return 1;
    249273}
    250274
    251275int SYSTEM EXPORT WriteLogError(char *tekst, ...)
    252276{
    253     va_list argptr;
    254 
    255     va_start(argptr, tekst);
    256     printf("ERROR: ");
    257     vprintf(tekst, argptr);
    258     va_end(argptr);
    259     if(tekst[strlen(tekst)-1] != '\n') {
     277  USHORT  sel = RestoreOS2FS();
     278  va_list argptr;
     279
     280  va_start(argptr, tekst);
     281  printf("ERROR: ");
     282  vprintf(tekst, argptr);
     283  va_end(argptr);
     284  if(tekst[strlen(tekst)-1] != '\n')
    260285    printf("\n");
    261     }
    262 
    263     return 1;
     286
     287  SetFS(sel);
     288  return 1;
    264289}
    265 
    266 #else   /*PLF Mon  97-09-08 20:04:26*/
     290#endif
     291
     292
     293/*****************************************************************************
     294 * Modified Standard Version                                                 *
     295 *****************************************************************************/
     296
     297#if 0   /*PLF Mon  97-09-08 20:04:26*/
    267298/******************************************************************************/
    268299static BOOL init = FALSE;
     
    310341}
    311342#endif  /*PLF Mon  97-09-08 20:04:23*/
    312 /******************************************************************************/
    313 /******************************************************************************/
    314 
    315 
    316 #endif
     343
Note: See TracChangeset for help on using the changeset viewer.