home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c004 / 4.ddi / NETBIOS / CTSPRTF.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-18  |  1.6 KB  |  81 lines

  1. /*
  2.  *    c-tree server for netbios
  3.  *     printf and putch implementations that go straight to bios
  4.  *
  5.  *    This program is the CONFIDENTIAL and PROPRIETARY property 
  6.  *    of FairCom(R) Corporation. Any unauthorized use, reproduction or
  7.  *    transfer of this program is strictly prohibited.
  8.  *
  9.  *      Copyright (c) 1987, 1988, 1989 FairCom Corporation
  10.  *    (Subject to limited distribution and
  11.  *     restricted disclosure only.)
  12.  *    *** ALL RIGHTS RESERVED ***
  13.  *
  14.  *    4006 West Broadway
  15.  *    Columbia, MO 65203
  16.  *
  17.  *
  18.  *    c-tree(R)    Version 4.3
  19.  *            Release C
  20.  *            February 7, 1989 17:30
  21.  *
  22.  */
  23.  
  24.  
  25. /* printf and putch
  26.  * these replace library versions of same for the netbios version
  27.  * of c-tree server.  The bios is called directly for character output
  28.  * for following reasons:
  29.  *  - disallow ctl-break of server process during start/stat/fatal-err
  30.  *    reports
  31.  *  - allow debug messages to be issued at any time by server
  32.  */
  33.  
  34. #include <dos.h>    /*     cpu regs structure */
  35.  
  36. static char pfbuf[512];    /* handle pretty long lines */
  37.  
  38. void putch(c)
  39. int c;
  40. {
  41.     union REGS r;
  42.     r.h.ah = 14;
  43.     r.h.al = c;
  44.     r.x.bx = 7;
  45.     int86(0x10, &r, &r);
  46. }
  47.  
  48.  
  49.  
  50. int printf(fmt)
  51. char *fmt;
  52. {
  53.     char *ap;
  54.     register int i;
  55.     register int len;
  56.     static int col = 0;
  57.  
  58.     ap  = (char *)&fmt + sizeof(fmt);
  59.     len = vsprintf(pfbuf, fmt, ap);
  60.     for(i=0; i<len; i++)
  61.     {
  62.         switch(pfbuf[i])
  63.         {
  64.             case '\n':
  65.                 col = 0;
  66.                 putch('\r');
  67.                 putch('\n');
  68.                 break;
  69.             case '\t':
  70.                 do
  71.                     putch(' ');
  72.                 while (7 & ++col);
  73.                 break;
  74.             default:
  75.                 putch(pfbuf[i]);
  76.         }
  77.     }
  78.     return len;
  79. }
  80.  
  81.