home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff369.lzh / VaxTerm / src / sendem.c < prev    next >
C/C++ Source or Header  |  1990-08-15  |  4KB  |  138 lines

  1. #include <string.h>
  2. #include <exec/types.h>
  3. #include <exec/io.h>
  4. #include <devices/keymap.h>
  5. #include <hardware/blit.h>
  6. #include <graphics/rastport.h>
  7. #include <graphics/text.h>
  8. #include <libraries/dos.h>
  9. #include <intuition/intuition.h>
  10.  
  11. #include "main.h"
  12.  
  13. #define SETUPBUF    64
  14.  
  15. sendstring(register struct console *con,char *cp)
  16. {
  17. writeserial(con,cp,strlen(cp));
  18. return(0);
  19. }
  20.  
  21. convert(register struct console *con,register char *scp,register LONG len)
  22. {
  23. register USHORT nlen,cnt;
  24. register char   *dcp,*cp;
  25. BPTR            fp;
  26. char            setups[SETUPBUF];
  27.  
  28. dcp = con->conv;
  29. cp = dcp;
  30. nlen = len;
  31. if (con->tstat & CONVERT) {
  32.     cnt = len;
  33.     while(cnt--) {
  34.         if (*scp & 0x80) {
  35.             switch (*scp) {
  36.                 case IND:
  37.                     *dcp++ = ESC;
  38.                     *dcp++ = 'D';
  39.                     scp++;
  40.                     nlen++;
  41.                     break;
  42.                 case NEL:
  43.                     *dcp++ = ESC;
  44.                     *dcp++ = 'E';
  45.                     scp++;
  46.                     nlen++;
  47.                     break;
  48.                 case HTS:
  49.                     *dcp++ = ESC;
  50.                     *dcp++ = 'H';
  51.                     scp++;
  52.                     nlen++;
  53.                     break;
  54.                 case RI:
  55.                     *dcp++ = ESC;
  56.                     *dcp++ = 'M';
  57.                     scp++;
  58.                     nlen++;
  59.                     break;
  60.                 case SS2:
  61.                     *dcp++ = ESC;
  62.                     *dcp++ = 'N';
  63.                     scp++;
  64.                     nlen++;
  65.                     break;
  66.                 case SS3:
  67.                     *dcp++ = ESC;
  68.                     *dcp++ = 'O';
  69.                     scp++;
  70.                     nlen++;
  71.                     break;
  72.                 case DCS:
  73.                     *dcp++ = ESC;
  74.                     *dcp++ = 'P';
  75.                     scp++;
  76.                     nlen++;
  77.                     break;
  78.                 case CSI:
  79.                     *dcp++ = ESC;
  80.                     *dcp++ = '[';
  81.                     scp++;
  82.                     nlen++;
  83.                     break;
  84.                 case ST:
  85.                     *dcp++ = ESC;
  86.                     *dcp++ = '/';
  87.                     scp++;
  88.                     nlen++;
  89.                     break;
  90.                 default:
  91.                     *dcp++ = *scp++;
  92.                     break;
  93.                 }
  94.             }
  95.         else *dcp++ = *scp++;
  96.         }
  97.     }
  98. else memcpy(dcp,scp,len);
  99. while (len--) {
  100.     switch (*cp) {
  101.         case PLD:   if (con->gstat & HOLD) con->gstat &= (MASK - HOLD);
  102.                     else con->gstat |= HOLD;
  103.                     *cp = XON;
  104.                     break;
  105.         case PLU:   if (con->gstat & PRINT) con->gstat &= (MASK - PRINT);
  106.                     else {
  107.                         if (con->prt == NULL) {
  108.                             if (con->prt = OPEN_FOR_WRITING(PRINTERNAME)) {
  109.                                 if (fp = OPEN_FOR_READING(PRINTERSETUP)) {
  110.                                     do {
  111.                                         cnt = READ(fp,setups,SETUPBUF);
  112.                                         WRITE(con->prt,setups,cnt);
  113.                                         } while (cnt == SETUPBUF);
  114.                                     CLOSEFILE(fp);
  115.                                     }
  116.                                 con->gstat |= PRINT;
  117.                                 }
  118.                             }
  119.                         else con->gstat |= PRINT;
  120.                         }
  121.                     *cp = XON;
  122.                     break;
  123.         case STS:   con->gstat |= SETUP;
  124.                     *cp = XON;
  125.                     break;
  126.         case PU1:   con->gstat |= TRANSFER;
  127.                     *cp = XON;
  128.                     break;
  129.         case PU2:   con->gstat |= SEND_BREAK;
  130.                     *cp = XON;
  131.                     break;
  132.         default:    ;
  133.         }
  134.     cp++;
  135.     }
  136. return((LONG)nlen);
  137. }
  138.