home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / t / tel2305s.zip / NET14 / TEST14.C < prev    next >
C/C++ Source or Header  |  1980-01-13  |  4KB  |  128 lines

  1. #ifdef __TURBOC__
  2. #include "turboc.h"
  3. #endif
  4. #include <stdio.h>
  5. #include <conio.h>
  6. #include <string.h>
  7. #include <stdlib.h>
  8. #include <malloc.h>
  9. #include <dos.h>
  10. #include <ctype.h>
  11. #ifdef MSC
  12. #include <signal.h>
  13. #include <time.h>
  14. #endif
  15.  
  16.  
  17. /* #define DEBUG */
  18.  
  19. /*
  20. *    Global variables
  21. */
  22.  
  23. #define SERIAL  0x14
  24. #define PORT    1
  25.  
  26. /*
  27. *    main ( argc, argv )
  28. *
  29. *    Entry : 
  30. *
  31. *        parameter 1 : machine name
  32. *
  33. */
  34.  
  35. int main(argc,argv)
  36. int argc;
  37. char *argv[];
  38. {
  39.     union REGS inregs;      /* register set going into the interrupt */
  40.     union REGS outregs;     /* register set going out of the interrupt */
  41.     int i,cnt,ev,what,dat;
  42.     unsigned int str_length;
  43.     char *errmsg,
  44.         *str;
  45.     char c;
  46.  
  47.     if(argc<2)
  48.         exit(1);
  49.  
  50. printf("int14h vector=%p\n",_dos_getvect(0x14));
  51. printf("int1Ch vector=%p\n",_dos_getvect(0x1C));
  52.  
  53. #ifdef QAK
  54.     inregs.h.ah=3;          /* set to initialize the comm. port */
  55.     inregs.x.dx=PORT;          /* use port two */
  56.     int86(SERIAL,&inregs,&outregs);     /* call to initialize the interrupt */
  57. printf("ax=%X\n",outregs.x.ax);     /* print the return value */
  58. #endif
  59.  
  60.     inregs.h.ah=0;          /* set to initialize the comm. port */
  61.     inregs.x.dx=PORT;          /* use port two */
  62.     int86(SERIAL,&inregs,&outregs);     /* call to initialize the interrupt */
  63. printf("ax=%X\n",outregs.x.ax);     /* print the return value */
  64.  
  65.     inregs.h.ah=1;          /* set to send a character */
  66.     inregs.h.al=2;          /* send initialization character */
  67.     inregs.x.dx=PORT;          /* use port two */
  68.     int86(SERIAL,&inregs,&outregs);     /* call to initialize the interrupt */
  69. printf("ax=%X\n",outregs.x.ax);     /* print the return value */
  70.  
  71.     str=argv[1];
  72.     str_length=strlen(str);
  73.     for(i=0; i<(int)str_length; i++,str++) {
  74.         inregs.h.ah=1;          /* set to send a character */
  75.         inregs.h.al=*str;       /* send name character */
  76.         inregs.x.dx=PORT;          /* use port two */
  77.         int86(SERIAL,&inregs,&outregs);     /* call to initialize the interrupt */
  78. printf("ax=%X\n",outregs.x.ax);     /* print the return value */
  79.       } /* end for */
  80.  
  81. puts("right before opening a connection");
  82.     inregs.h.ah=1;          /* set to send a character */
  83.     inregs.h.al=3;          /* send initialization character */
  84.     inregs.x.dx=PORT;          /* use port two */
  85.     int86(SERIAL,&inregs,&outregs);     /* call to initialize the interrupt */
  86. printf("ax=%X\n",outregs.x.ax);     /* print the return value */
  87.  
  88. puts("after opening a connection");
  89.     c = 0;
  90. puts("before dropping into the do loop");
  91.     do {
  92.         if(kbhit()) {               /* has key been pressed */
  93.             c=(char)getch();
  94. if(c==16)
  95.     break;
  96.             inregs.h.ah=1;          /* set to send a character */
  97.             inregs.h.al=c;          /* send character */
  98.             inregs.x.dx=PORT;          /* use port two */
  99.             int86(SERIAL,&inregs,&outregs);     /* call to initialize the interrupt */
  100.           }
  101. #ifdef QAK
  102. puts("before int14check() call");
  103. #endif
  104.         dat=int14check();
  105. #ifdef QAK
  106. printf("after int14check() call, dat=%X\n",dat);
  107. #endif
  108.         if(dat&0x0100) {        /* check for data being ready */
  109. #ifdef QAK
  110. printf("data ready, dat=%x",dat);
  111. #endif
  112.             c=int14receive();
  113. #ifdef QAK
  114. printf("c=%x:%d:%c\n",(unsigned)c,(unsigned)c,(char)c);
  115. #endif
  116.             putchar(c);
  117.           } /* end if */
  118.       } while(c!=16);            /* Ctrl-P, arbitrary escape */
  119. #ifdef QAK
  120.     timedeinst();   /* remove the timer interrupt handler */
  121.     int14deinst();  /* remove the int 14h handler */
  122.     netclose(pnum[2]);
  123.     netshut();
  124. #endif
  125.     exit(0);
  126. }
  127.  
  128.