home *** CD-ROM | disk | FTP | other *** search
- /* CHK=0xF436 */
- /*+-------------------------------------------------------------------------
- kmemsio.c
- ...!gatech!emory!tridom!wht
-
- Defined functions:
- kmem_init_tty()
- kmem_read_tty(ttfirst,ttcount)
-
- --------------------------------------------------------------------------*/
- /*+:EDITS:*/
- /*:12-04-1989-16:05-wht-creation */
-
- #include <sys/types.h>
- #include <sys/stat.h>
- #define TERMIO_HACK /* for XENIX termio.h multiple inclusion problem */
- #include <sys/tty.h>
-
- #include "kmemsio.h"
-
- #if defined(M_UNIX)
- #include <nlist.h>
- #define XLIST nlist
- #define XL_name n_name
- #define XL_value n_value
- #define XL_type n_type
- #else
- #include <sys/a.out.h>
- #define XLIST xlist
- #define XL_name xl_name
- #define XL_value xl_value
- #define XL_type xl_type
- #endif
-
- #ifdef M_UNIX
- char *kernel_file = "/unix";
- #else
- char *kernel_file = "/xenix";
- #endif
- char *kmem_file = "/dev/kmem";
-
- int kmemfd;
-
- #if defined(M_UNIX)
- struct XLIST kernel_symbols[] = {
- #define KS_SIO_TTY 0
- { "sio_tty" },
- { (char *)0 }
- };
- #else
- struct XLIST kernel_symbols[] = {
- #define KS_SIO_TTY 0
- {0,0,0, "_sio_tty" },
- {0,0,0, (char *)0 }
- };
- #endif
-
- #define sio_tty_fpos kernel_symbols[KS_SIO_TTY].XL_value
-
- struct tty sio[SIO_NTTY];
-
- static char errmsg[80];
-
- extern int errno;
- extern char *sys_errlist[];
-
- /*+-------------------------------------------------------------------------
- kmem_read_tty(ttfirst,ttcount)
- --------------------------------------------------------------------------*/
- char *
- kmem_read_tty(ttfirst,ttcount)
- int ttfirst;
- int ttcount;
- {
- int len = ttcount * sizeof(struct tty);
-
- if(((unsigned)ttfirst >= SIO_NTTY) ||
- (((unsigned)ttfirst + (unsigned)ttcount) > SIO_NTTY))
- return(" illegal tty ");
-
- if(lseek(kmemfd,sio_tty_fpos + (ttfirst * sizeof(struct tty)),0) == -1)
- {
- sprintf(errmsg,
- " kmem lseek failure: %s ",sys_errlist[errno]);
- return(errmsg);
- }
- errno = 0;
- if(read(kmemfd,(char *)sio,len) != len)
- {
- sprintf(errmsg,
- " kmem read failure: %s ",sys_errlist[errno]);
- return(errmsg);
- }
-
- return((char *)0);
-
- } /* end of kmem_read_tty */
-
- /*+-------------------------------------------------------------------------
- kmem_init_tty()
- --------------------------------------------------------------------------*/
- char *
- kmem_init_tty()
- {
-
- if((kmemfd = open(kmem_file,0)) < 0)
- {
- sprintf(errmsg," %s: %s ",kmem_file,sys_errlist[errno]);
- return(errmsg);
- }
-
- if(XLIST(kernel_file,kernel_symbols))
- {
- sprintf(errmsg," xlist/nlist failure: %s ",kernel_file);
- return(errmsg);
- }
-
- return((char *)0);
-
- } /* end of kmem_init_tty */
-
- /* vi: set tabstop=4 shiftwidth=4: */
- /* end of kmemsio.c */
-