Annotation of 43BSDTahoe/new/X/libis/display.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *     $Source: /u1/X/libis/RCS/display.c,v $
                      3:  *     $Header: display.c,v 1.1 86/11/17 14:33:42 swick Rel $
                      4:  */
                      5: 
                      6: #ifndef lint
                      7: static char *rcsid_display_c = "$Header: display.c,v 1.1 86/11/17 14:33:42 swick Rel $";
                      8: #endif lint
                      9: 
                     10: #include "is-copyright.h"
                     11: 
                     12: /*     display.c - routines to open and close display
                     13:  *
                     14:  *     OpenDisplay
                     15:  *     InitDisplay
                     16:  *     DisplayDead
                     17:  *     AllocateSpace
                     18:  *
                     19:  *     Copyright (c) 1986, Integrated Solutions, Inc.
                     20:  */
                     21: 
                     22: #include "Xis.h"
                     23: #include <sys/file.h>
                     24: #include <errno.h>
                     25: 
                     26: extern int     errno;
                     27: 
                     28: DEVICE *CurrentDevice;
                     29: 
                     30: int    indev;          /* fd of the desktop */
                     31: 
                     32: extern int InputHandler();
                     33: 
                     34: /*
                     35:  *     OpenDisplay
                     36:  */
                     37: OpenDisplay(name)
                     38: char   *name;
                     39: {
                     40:     int ldisc = TWSDISC;
                     41:     short mmode = (VT_MOUSE_DOWN | VT_MOUSE_UP | VT_MOUSE_CONTINUOUS);
                     42:     char       tname[32];
                     43:     extern char *strcpy(), *strcat();
                     44: 
                     45:     strcpy(tname, "/dev/ttyw");
                     46:     strcat(tname, name);
                     47: 
                     48: #ifdef DEBUG
                     49: if (debug & D_Misc)
                     50:     printf("OpenDisplay(name=\"%s\")\n", tname);
                     51: #endif DEBUG
                     52: 
                     53:     indev = GIP_Init();
                     54:     setreuid(-1, -1);       /* don't need to be setuid root anymore */
                     55:     ioctl(indev, TIOCSETD, &ldisc);    /* SetLineDisc */
                     56:     ioctl(indev, TIOVSETMM, &mmode);   /* SetMouseMode */
                     57:     return (indev);
                     58: }
                     59: 
                     60: /*
                     61:  *     InitDisplay
                     62:  */
                     63: InitDisplay(dp)
                     64: register DEVICE        *dp;
                     65: {
                     66:     static vsCursor    vsmouse;
                     67:     static vsBox       vsmbox;
                     68:     static vsEventQueue        vsqueue;
                     69: 
                     70:     struct gconfig gc;
                     71: 
                     72: #ifdef DEBUG
                     73: if (debug & D_Misc)
                     74:     printf("InitDisplay(dp=0x%x)\n", dp);
                     75: #endif DEBUG
                     76: 
                     77:     CurrentDevice = dp;
                     78: 
                     79:     if (indev >= 0) {
                     80:        if (ioctl(indev, TIOVGETHW, &gc)) {     /* GetGraphicsConfig */
                     81:            return (-1);
                     82:        }
                     83: 
                     84:        switch (gc.realcolors) {
                     85:        case 2:
                     86:            dp->id = XDEV_ISIBW;        /* monochrome */
                     87:            break;
                     88:        case 16:
                     89:            dp->id = XDEV_ISICOLOR4;    /* 4 bit plane color */
                     90:            break;
                     91:        default:
                     92:            dp->id = -1;                /* no idea! */
                     93:            break;
                     94:        }
                     95:        dp->width = ScreenPixmap.width;
                     96:        dp->height = ScreenPixmap.height;
                     97:        dp->planes = ScreenPixmap.kind & 0xf;
                     98:        if (dp->planes > 1)
                     99:            dp->entries = gc.lutsize;
                    100:        else
                    101:            dp->entries = 0;            /* no lut! */
                    102:        dp->mouse = &vsmouse;
                    103:        dp->mbox = &vsmbox;
                    104:        dp->queue = &vsqueue;
                    105: 
                    106: 
                    107:        Define_input_handler(InputHandler);
                    108: 
                    109:     } else {
                    110:        return (-1);
                    111:     }
                    112:     return (0);
                    113: }
                    114: 
                    115: /*
                    116:  *     DisplayDead
                    117:  */
                    118: 
                    119: DisplayDead()
                    120: {
                    121: #ifdef DEBUG
                    122: if (debug & D_Misc) {
                    123:     printf("DisplayDead()?\n");
                    124:     fflush(stdout);
                    125: }
                    126: #endif DEBUG
                    127: 
                    128:     GIP_Quit();
                    129: 
                    130:     return (0);
                    131: }
                    132: 
                    133: /*
                    134:  *     AllocateSpace
                    135:  *
                    136:  *     The presumption here is that only one AllocateSpace call is
                    137:  *     made/request
                    138:  */
                    139: 
                    140: #define BUFSIZE 3072   /* arbitrary size for buffer */
                    141: 
                    142: caddr_t AllocateSpace(size)
                    143: int    size;
                    144: {
                    145:     static char buf[BUFSIZE];
                    146: 
                    147: #ifdef DEBUG
                    148: if (debug & D_Misc)
                    149:     printf("AllocateSpace(size=%d)\n", size);
                    150: #endif DEBUG
                    151: 
                    152:     if (size < BUFSIZE) {
                    153:        return (buf);
                    154:     }
                    155:     errno = ENOMEM;
                    156:     return (NULL);
                    157: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.