Ignore:
Timestamp:
Oct 27, 1999, 4:03:01 AM (26 years ago)
Author:
bird
Message:

Corrections to make win32k work.
(And now it does work, at least at my test machine...)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/misc/vprintf.c

    r1271 r1467  
    1 /* $Id: vprintf.c,v 1.1 1999-10-14 01:19:22 bird Exp $
     1/* $Id: vprintf.c,v 1.2 1999-10-27 02:03:00 bird Exp $
    22 *
    33 * vprintf and printf
     
    3131#include <stdarg.h>
    3232
     33#include "dev32.h"
     34#include "vprintf.h"
    3335#ifdef RING0
    34     #include "dev32.h"
    35 #else
    36     #define SSToDS(a) (a)
     36    #include <builtin.h>
     37    #include "options.h"
    3738#endif
    38 #include "vprintf.h"
    39 
     39
     40
     41/*******************************************************************************
     42*   Global Variables                                                           *
     43*******************************************************************************/
     44static char chNewLine = '\n';
     45static char chReturn  = '\r';
    4046
    4147/*******************************************************************************
     
    4450static int       _atoi_skip(const char **ppsz);
    4551static unsigned  _strnlen(const char *psz, unsigned cchMax);
    46 _Inline void     chout(int ch);
     52static void      chout(int ch);
     53static char *    strout(char *psz, signed cchMax);
    4754
    4855
     
    162169    #if 0
    163170    else if (!(fFlags & NTSF_LEFT) && cchWidth > 0)
    164     {   /* not supported! */
     171    {   /* not yet supported! */
    165172        /*
    166173        for (j = i-1; j >= 0; j--)
     
    207214int vprintf(const char *pszFormat, va_list args)
    208215{
     216    #ifdef RING0
     217        if (options.fQuiet)
     218            return 0;
     219    #else
     220        int cch = 0;
     221    #endif
     222
    209223    while (*pszFormat != '\0')
    210224    {
    211225        if (*pszFormat == '%')
    212226        {
     227            #ifndef RING0
     228                if (cch > 0)
     229                {
     230                    strout((char*)(pszFormat - cch), cch);
     231                    cch = 0;
     232                }
     233            #endif
     234
    213235            pszFormat++;  /* skip '%' */
    214236            if (*pszFormat == '%')    /* '%%'-> '%' */
     
    306328                    case 's':   /* string */
    307329                    {
    308                         int   i;
    309330                        int   cchStr;
    310331                        char *pszStr = va_arg(args, char*);
     
    316337                            while (--cchWidth >= cchStr)
    317338                                 chout(' ');
    318                         for (i = cchStr; i > 0; i--)
    319                             chout(*pszStr++);
     339
     340                        pszStr = strout(pszStr, cchStr);
    320341
    321342                        while (--cchWidth >= cchStr)
     
    352373        }
    353374        else
    354             chout(*pszFormat++);
    355     }
     375        {
     376            #ifdef RING0
     377                chout(*pszFormat++);
     378            #else
     379                cch++;
     380                pszFormat++;
     381            #endif
     382        }
     383    }
     384
     385    #ifndef RING0
     386        if (cch > 0)
     387        {
     388            strout((char*)(pszFormat - cch), cch);
     389            cch = 0;
     390        }
     391    #endif
    356392
    357393    return 0UL;
     
    376412    va_list arguments;
    377413
     414    #ifdef RING0
     415        if (options.fQuiet)
     416            return 0;
     417    #endif
     418
    378419    va_start(arguments, pszFormat);
    379420    cch = vprintf(pszFormat, arguments);
     
    390431    va_list arguments;
    391432
     433    #ifdef RING0
     434        if (options.fQuiet)
     435            return 0;
     436    #endif
     437
    392438    va_start(arguments, pszFormat);
    393439    cch = vprintf(pszFormat, arguments);
     
    402448    int     cch;
    403449    va_list arguments;
     450
     451    #ifdef RING0
     452        if (options.fQuiet)
     453            return 0;
     454    #endif
    404455
    405456    va_start(arguments, pszFormat);
     
    419470 * @author    knut st. osmundsen
    420471 */
    421 _Inline void  chout(int ch)
    422 {
    423     #ifdef RING0
    424 
    425     #else
     472static void chout(int ch)
     473{
     474    #ifndef RING0
    426475        ULONG ulWrote;
    427476    #endif
     
    431480        if (ch == '\n')
    432481        {
    433             static char chReturn = '\r';
    434482            #ifdef RING0
    435 
     483                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     484                _outp(options.usCom, chReturn);             /* Put the char. */
    436485            #else
    437486                DosWrite(1, (void*)&chReturn, 1, &ulWrote);
     
    439488        }
    440489        #ifdef RING0
    441 
     490            while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     491            _outp(options.usCom, ch);                   /* Put the char. */
    442492        #else
    443493            DosWrite(1, (void*)&ch, 1, &ulWrote);
     
    446496}
    447497
     498
     499/**
     500 * Write a string to the output device.
     501 * @returns   pointer end of string.
     502 * @param     psz     Pointer to the string to write.
     503 * @param     cchMax  Max count of chars to write. (or until '\0')
     504 * @status    completely implemented.
     505 * @author    knut st. osmundsen
     506 */
     507static char *strout(char *psz, signed cchMax)
     508{
     509    while (cchMax > 0 && *psz != '\0')
     510    {
     511        ULONG cch = 0;
     512        ULONG ul;
     513
     514        while (cchMax - cch > 0 && psz[cch] != '\0' && psz[cch] != '\r' && psz[cch] != '\n')
     515            cch++;
     516
     517        /* write string part */
     518        #ifdef RING0
     519            for (ul = 0; ul < cch; ul++)
     520            {
     521                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     522                _outp(options.usCom, psz[ul]);              /* Put the char. */
     523            }
     524        #else
     525            DosWrite(1, (void*)psz, cch, &ul);
     526        #endif
     527
     528        /* cr and lf check + skip */
     529        if (psz[cch] == '\n' || psz[cch] == '\r')
     530        {
     531            if (psz[cch] == '\n')
     532            {
     533            #ifdef RING0
     534                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     535                _outp(options.usCom, chReturn);             /* Put the char. */
     536                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     537                _outp(options.usCom, chNewLine);            /* Put the char. */
     538            #else
     539                DosWrite(1, (void*)&chReturn, 1, &ul);
     540                DosWrite(1, (void*)&chNewLine, 1, &ul);
     541            #endif
     542
     543            }
     544
     545            while (cchMax - cch > 0 && (psz[cch] == '\r' || psz[cch] == '\n'))
     546                cch++;
     547        }
     548
     549        /* next */
     550        psz += cch;
     551        cchMax -= cch;
     552    }
     553    return psz;
     554}
     555
Note: See TracChangeset for help on using the changeset viewer.