Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ mcc(7) — mips UMIPS RISC/os 5.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

streamio(7)

euc(4)



MCC(7)              RISC/os Reference Manual               MCC(7)



NAME
     mcc_open, mcc_close, mcc_rput, mcc_rsrv, mcc_wput, mcc_wsrv,
          mcc_ioctl - code conversion STREAMS module interface

SYNOPSIS
     #include <sys/mcc.h>

     int mccopen(rq, dev, flag, sflag)
     queuet *rq;
     devt dev;
     int flag, sflag;

     mccclose(rq)
     queuet *rq;

     mccrput(rq, bp)
     queuet *rq;
     mblkt *bp;

     mccrsrv(rq)
     queuet *rq;

     mccwput(wq, bp)
     queuet *wq;
     mblkt *bp;

     mccwsrv(wq)
     queuet *wq;

     mccioctl(mp, cmd, data, count)
     struct mccbuf *mp;
     int cmd;
     uchar *data;
     uint *count;

DESCRIPTION
     These routines are queue procedures for the "qinit" struc-
     ture of STREAMS modules.  mccrsrv (mccwsrv) calls the
     mccbuf structure's mccrconv (mccwconv), converts code, and
     sends the result upstream (downstream).  By defining con-
     verters (mccrconv, mccwconv), it is possible to build
     filters to convert between EUC and various codes.

     Also, it is possible to add and remove code set shift
     sequences.  There is a STREAMS ioctl to define code set
     shift sequences.  It is possible to specify a timeout in
     milliseconds for the input shift sequences.  If a negative
     value is specified, the timeout is set to a value calculated
     from the current baud rate.  A zero value deletes the
     current setting.  If a timeout is specified, each byte must
     arrive within the timeout for a sequence to be recognized,
     otherwise it is processed as ordinary data.



                        Printed 11/19/92                   Page 1





MCC(7)              RISC/os Reference Manual               MCC(7)



USAGE

          #include <stropts.h>
          #include <sys/types.h>
          #include <sys/mccioctl.h>

          struct strioctl sb;
          struct mccioc miocb;
          int to;

          /* getting or setting shift strings */
          sb.ic_cmd = MCC_GETSEQ or MCC_SETSEQ;
          sb.ic_len = sizeof(struct mccioc);
          sb.ic_dp = (char *)&miocb;
          sb.ic_timeout = 0;
          ioctl(fd, I_STR, &sb);

          /* getting or setting sequence timeouts */
          sb.ic_cmd = MCC_GETTIMEOUT or MCC_SETTIMEOUT;
          sb.ic_len = sizeof(int);
          sb.ic_dp = (char *)&to;
          sb.ic_timeout = 0;
          ioctl(fd, I_STR, &sb);


          struct mccioc {
               int m_nseq;    /* no. of defined sequences */
               struct mioc_seqs {
                    char str[MCCSEQLEN];     /* sequence string */
                    u_char len;    /* length of seq str */
                    u_char cs;     /* code set (CS0 to CS3) */
                    u_char rw;     /* indicate input/output
                       of this seq (RSEQ, WSEQ) */
               } m_seqs[MCCMAXSEQ];
          };
          #define CS00
          #define CS11
          #define CS22
          #define CS33

          #define RSEQ01
          #define WSEQ02

     mcc_rconv converts from device dependent code to EUC.
     mcc_wconv converts from EUC to device dependent code.

          int read_side_converter(euc, s, nbytes, cs, closure)
          u_char *euc, *s;
          int nbytes;
          u_char cs;
          caddr_t closure;




 Page 2                 Printed 11/19/92





MCC(7)              RISC/os Reference Manual               MCC(7)



     The result is put in euc. (The size is MCCBUFSIZ.)
     s is the device dependent code array.
     nbytes is the length of s.
     cs is the code set.
     closure is the mcc_cdata field of the mccbuf structure (sys/mcc.h).
     The return value is the length of euc.
     This routine converts from s to euc and returns the length.
     If it cannot be converted, zero is returned, and if there
     was an error, a negative value is returned.

          int write_side_converter(s, euc, nbytes, cs, closure)
          u_char *s, *euc;
          int nbytes;
          u_char cs;
          caddr_t closure;

     The result is put in s. (The size if MCCBUFSIZ.)
     euc is the EUC code array.
     The return value is the length of s.
     This routine converts from euc to s and returns the length.
     The rest is the same as above.

     EUC code strings can contain single shift bytes.  Device
     dependent code strings do not contain shift sequences.

SEE ALSO
     streamio(7).
     euc(4) in the RISC/os Programmer's Reference Manual.
     RISC/os Streams Primer and Programmer's Guide.

APPENDIX
     A JIS (Japanese Industrial Standard) code set filter is pro-
     vided as an example of a code conversion STREAMS module.

     #include "sys/mcc.h"
     static struct module_info jism_info = {
          0,                  /* module ID */
          "jis",                   /* module name */
          0,                  /* minimum packet size */
          INFPSZ,             /* infinite maximum packet size    */
          512,                /* hi-water mark */
          128,                /* lo-water mark */
     };

     static int jis_open(), jis_to_euc(), euc_to_jis();
     static struct qinit jis_rinit = {
          mcc_rput, mcc_rsrv, jis_open, mcc_close, NULL, &jism_info, NULL
     };

     static struct qinit jis_winit = {
          mcc_wput, mcc_wsrv, NULL, NULL, NULL, &jism_info, NULL
     };



                        Printed 11/19/92                   Page 3





MCC(7)              RISC/os Reference Manual               MCC(7)



     struct streamtab jisinfo = {&jis_rinit, &jis_winit, NULL, NULL};

     static int
     jis_open(rq, dev, flag, sflag)
     queue_t *rq;
     dev_t dev;
     int flag;
     int sflag;
     {
          int ret;
          struct mccbuf *mbp;

          if ((ret = mcc_open(rq, dev, flag, sflag)) == 0) {
               mbp = (struct mccbuf *)rq->q_ptr;
               mbp->mcc_rconv = jis_to_euc;
               mbp->mcc_wconv = euc_to_jis;
          }
          return(ret);
     }

     static int
     jis_to_euc(euc, buf, nbytes, cs, closure)
     u_char *euc, *buf;
     int nbytes;
     u_char cs;
     caddr_t closure;
     {
          switch (cs) {
          case CS0:
               *euc = *buf;
               return(1);
          case CS1:
               if (nbytes < 2)
                    return(0);
               euc[0] = buf[0] | 0x80;
               euc[1] = buf[1] | 0x80;
               return(2);
          case CS2:
               euc[0] = SS2;
               euc[1] = *buf | 0x80;
               return(2);
          case CS3:
               if (nbytes < 2)
                    return(0);
               euc[0] = SS3;
               euc[1] = buf[0] | 0x80;
               euc[2] = buf[1] | 0x80;
               return(3);
          }
          return(-1);
     }




 Page 4                 Printed 11/19/92





MCC(7)              RISC/os Reference Manual               MCC(7)



     static int
     euc_to_jis(buf, euc, nbytes, cs, closure)
     u_char *buf, *euc;
     int nbytes;
     u_char cs;
     caddr_t closure;
     {
          switch (cs) {
          case CS0:
               *buf = *euc;
               return(1);
          case CS1:
               if (nbytes < 2)
                    return(0);
               buf[0] = euc[0] & ~0x80;
               buf[1] = euc[1] & ~0x80;
               return(2);
          case CS2:
               if (nbytes < 2)
                    return(0);
               buf[0] = euc[1] & ~0x80;
               return(1);
          case CS3:
               if (nbytes < 3)
                    return(0);
               buf[0] = euc[1] & ~0x80;
               buf[1] = euc[2] & ~0x80;
               return(2);
          }
          return(-1);
     }
























                        Printed 11/19/92                   Page 5



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026