Ignore:
Timestamp:
Jul 11, 2010, 7:42:10 AM (15 years ago)
Author:
David Azarewicz
Message:

Bring branch up-to-date with trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-2.1.x/lib32/debug.c

    r484 r504  
    2727
    2828#include <string.h>
     29#include <dbgos2.h>
     30
     31#define COMM_DEBUG
    2932
    3033#define CR 0x0d
     
    3437#define SIGNIFICANT_FIELD       0x0007
    3538
    36 BOOL  fLineTerminate=TRUE;
    37 int   DebugLevel = 1;
    38 
    39 extern int wrOffset;
    40 extern char *szprintBuf;
    41 extern int max_buf_size;
     39int DebugLevel;
    4240
    4341char hextab[]="0123456789ABCDEF";
     
    144142}
    145143
    146 #ifdef DEBUG
    147 #define COMM_DEBUG
    148 //------------------------- StringOut --------------------------//
    149 
    150 #define VMDHA_FIXED             0x0002
    151 
    152 extern APIRET VMAlloc(ULONG size, ULONG flags, char NEAR* *pAddr);
    153 
    154144/**
    155145 * Finds the length of a string up to cchMax.
     
    218208#endif
    219209
     210//------------------------- StringOut --------------------------//
    220211void StringOut(char *DbgStr)
    221212{
    222    int len;
     213        int len;
     214
     215        len= _strnlen( DbgStr, 1024 );
     216
    223217#ifdef COMM_DEBUG
    224    int i;
    225 #endif /* DEBUG */
    226 
    227    len= _strnlen( DbgStr, 1024 );
    228 /*
    229    while (*DbgStr)
    230       CharOut(*DbgStr++);
    231       */
    232 #ifdef COMM_DEBUG
    233    if (MAGIC_COMM_PORT)   //PS+++ If have comport - out to it
    234    {
    235        for( i= 0; i < len; i++ )
    236            CharOut( DbgStr[i] );
    237 
    238        if (fLineTerminate)
    239        {
    240            CharOut(CR);                              // append carriage return,
    241            CharOut(LF);                              // linefeed
    242        }
    243    }
     218        if (MAGIC_COMM_PORT) {
     219                int i;
     220
     221                for( i= 0; i < len; i++ ) CharOut( DbgStr[i] );
     222
     223                CharOut(CR);                              // append carriage return,
     224                CharOut(LF);                              // linefeed
     225        }
    244226#endif
    245    if( szprintBuf == 0 )
    246    {
    247       VMAlloc( max_buf_size, VMDHA_FIXED, &szprintBuf );
    248       if( szprintBuf )
    249          memset( szprintBuf, 0, max_buf_size );
    250       wrOffset= 0;
    251    }
    252    if( szprintBuf )
    253    {
    254        if( (len + wrOffset) > max_buf_size )
    255        {
    256           int cntr;
    257           cntr= max_buf_size - wrOffset;
    258           memcpy( szprintBuf +  wrOffset, DbgStr, cntr );
    259           DbgStr+= cntr;
    260           len= len - cntr;
    261           wrOffset= 0;
    262        }
    263        if( len )
    264        {
    265           memcpy( szprintBuf + wrOffset, DbgStr, len );
    266           wrOffset= wrOffset + len;
    267           if( wrOffset >= max_buf_size )
    268               wrOffset= 0;
    269        }
    270        if (fLineTerminate)
    271        {
    272 //           if( (wrOffset+1) >= max_buf_size )
    273 //               wrOffset= 0;
    274            szprintBuf[wrOffset]= CR;
    275            if( ++wrOffset >= max_buf_size )
    276                wrOffset= 0;
    277            szprintBuf[wrOffset]= LF;
    278            if( ++wrOffset >= max_buf_size )
    279                wrOffset= 0;
    280        }
    281    }
    282 }
    283 #endif
    284 
    285 #ifdef  DEBUG
     227
     228        if (szprintBuf == 0) return;
     229
     230        if( (len + wrOffset) > DBG_MAX_BUF_SIZE ) {
     231                int cntr;
     232                cntr = DBG_MAX_BUF_SIZE - wrOffset;
     233                memcpy( szprintBuf +  wrOffset, DbgStr, cntr );
     234                DbgStr += cntr;
     235                len = len - cntr;
     236                wrOffset= 0;
     237        }
     238
     239        if ( len ) {
     240                memcpy( szprintBuf + wrOffset, DbgStr, len );
     241                wrOffset= wrOffset + len;
     242                if( wrOffset >= DBG_MAX_BUF_SIZE ) wrOffset= 0;
     243        }
     244
     245        if ( (wrOffset+1) >= DBG_MAX_BUF_SIZE ) wrOffset= 0;
     246        szprintBuf[wrOffset]= CR;
     247        if ( ++wrOffset >= DBG_MAX_BUF_SIZE ) wrOffset= 0;
     248        szprintBuf[wrOffset]= LF;
     249        if ( ++wrOffset >= DBG_MAX_BUF_SIZE ) wrOffset= 0;
     250}
     251
    286252char BuildString[1024];
    287 #endif          // DEBUG
    288 
     253
     254#if 0
    289255//------------------------- PrintfOut -
    290256void _cdecl DPD(int level, char *DbgStr, ...)
    291257{
    292 #ifdef DEBUG
    293258   char *BuildPtr=BuildString;
    294259   char *pStr=(char *) DbgStr;
     
    398363   *BuildPtr=0;                                 // cauterize the string
    399364   StringOut((char *) BuildString);
    400 #endif                            //DEBUG
    401 }
    402 
     365}
     366#endif
    403367
    404368void _cdecl DPE(char *DbgStr, ...)
    405369{
    406 #ifdef DEBUG
    407370   char *BuildPtr=BuildString;
    408371   char *pStr = (char *) DbgStr;
     
    517480   *BuildPtr=0;                                 // cauterize the string
    518481   StringOut((char *) BuildString);
    519 #endif                            //DEBUG
    520482}
    521483
Note: See TracChangeset for help on using the changeset viewer.