Annotation of 43BSDTahoe/new/X/libsun/util.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char *rcsid_util_c = "$Header: util.c,v 10.4 86/11/29 13:49:21 jg Rel $";
        !             3: #endif lint
        !             4: #ifdef sun
        !             5: /*
        !             6:  * The Sun X drivers are a product of Sun Microsystems, Inc. and are provided
        !             7:  * for unrestricted use provided that this legend is included on all tape
        !             8:  * media and as a part of the software program in whole or part.  Users
        !             9:  * may copy or modify these drivers without charge, but are not authorized
        !            10:  * to license or distribute them to anyone else except as part of a product or
        !            11:  * program developed by the user.
        !            12:  * 
        !            13:  * THE SUN X DRIVERS ARE PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND
        !            14:  * INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A
        !            15:  * PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE
        !            16:  * PRACTICE.
        !            17:  *
        !            18:  * The Sun X Drivers are provided with no support and without any obligation
        !            19:  * on the part of Sun Microsystems, Inc. to assist in their use, correction,
        !            20:  * modification or enhancement.
        !            21:  * 
        !            22:  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
        !            23:  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THE SUN X
        !            24:  * DRIVERS OR ANY PART THEREOF.
        !            25:  * 
        !            26:  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
        !            27:  * or profits or other special, indirect and consequential damages, even if
        !            28:  * Sun has been advised of the possibility of such damages.
        !            29:  * 
        !            30:  * Sun Microsystems, Inc.
        !            31:  * 2550 Garcia Avenue
        !            32:  * Mountain View, California  94043
        !            33:  */
        !            34: 
        !            35: #ifndef        lint
        !            36: static char sccsid[] = "@(#)util.c 2.1 86/01/28 Copyright 1986 Sun Micro";
        !            37: #endif
        !            38: 
        !            39: /*-
        !            40:  * Copyright (c) 1986 by Sun Microsystems,  Inc.
        !            41:  */
        !            42: 
        !            43: /* util.c              Various utilities
        !            44:  *
        !            45:  *     SoundBell       Generate audible bell
        !            46:  *     SetKeyClick     Control key click
        !            47:  *     SetAutoRepeat   Control auto repeat
        !            48:  *     SetLockLED      Control Lock LED
        !            49:  *     SetVideo        Disable/enable video
        !            50:  *     QueryShape      Determine shapes
        !            51:  *     ResolveColors   does nothing
        !            52:  *     StoreColors     does nothing
        !            53:  */
        !            54: 
        !            55: /*
        !            56:  *     ToDo:
        !            57:  *             SetKeyClick
        !            58:  */
        !            59: 
        !            60: #include "Xsun.h"
        !            61: #include <sys/time.h>
        !            62: 
        !            63: extern int vsdev;
        !            64: 
        !            65: /*
        !            66:  * Ring the bell on a sun 120, volume between 0 (quiet) and 7 (loud).  
        !            67:  * Need to make the /dev/bell device with
        !            68:  * the same major device number as tty[ab] but with a new minor number.
        !            69:  *
        !            70:  *  # /etc/mknod /dev/bell c 12 2
        !            71:  *
        !            72:  *  crw-rw-rw-  1 root      12,   0 Jan  6 18:18 /dev/ttya
        !            73:  *  crw-rw-rw-  1 root      12,   1 Feb 26  1985 /dev/ttyb
        !            74:  *  crw-rw-rw-  1 root      12,   2 Jan 14 08:45 /dev/bell
        !            75:  *
        !            76:  */
        !            77: 
        !            78: 
        !            79: #define RING_ON         0x02    /* Control-B */
        !            80: #define RING_OFF        0x03    /* Control-C */
        !            81: #define RING_WAIT       25000 /* microseconds, for volume 1 */
        !            82: #ifndef NULL
        !            83: #define NULL            0
        !            84: #endif
        !            85: 
        !            86: SoundBell (volume)
        !            87:     int volume;
        !            88: {
        !            89:     static int bell = -1;
        !            90:     int status;
        !            91:     char outbuf[1];
        !            92:     struct timeval ring_time;
        !            93: 
        !            94:     if (volume == 0) {
        !            95:        return(0);
        !            96:     }
        !            97:     if (bell < 0) {
        !            98:        bell = open("/dev/bell",2);
        !            99:        if (bell < 0) {
        !           100:            return(1);
        !           101:        }
        !           102:     }
        !           103:     ring_time.tv_sec = 0;
        !           104:     ring_time.tv_usec = RING_WAIT * volume;
        !           105:     outbuf[0] = RING_ON;
        !           106:     status = write(bell,outbuf,1);
        !           107:     if (status < 0) {
        !           108:        return(1);
        !           109:     }
        !           110: 
        !           111:     select(0, NULL, NULL, NULL, &ring_time);
        !           112: 
        !           113:     outbuf[0] = RING_OFF;
        !           114:     status = write(bell,outbuf,1);
        !           115:     if (status < 0) {
        !           116:        return(1);
        !           117:     }
        !           118:     return (0);
        !           119: }
        !           120: 
        !           121: /* Set key click, volume between -1 (default), 0 (off) and 8 (loud) */
        !           122: 
        !           123: SetKeyClick (volume)
        !           124:        int volume;
        !           125: {
        !           126:        return (0);
        !           127: }
        !           128: 
        !           129: /* Set autorepeat */
        !           130: 
        !           131: SetAutoRepeat (onoff)
        !           132:        int onoff;
        !           133: {
        !           134:        return (0);
        !           135: }
        !           136: 
        !           137: int SetVideo(onoff)
        !           138:        int onoff;
        !           139: {
        !           140:        extern struct pixrect *PixRect;
        !           141:         static int have_saved;
        !           142:         static struct pixrect *saved;
        !           143: 
        !           144:         if (have_saved && onoff) {
        !           145:                 pr_rop (PixRect, 0, 0, PixRect->pr_width, PixRect->pr_height,
        !           146:                         PIX_SRC | PIX_DONTCLIP, saved, 0, 0);
        !           147:                 have_saved = 0;
        !           148:         }
        !           149:         else if (!have_saved && !onoff) {
        !           150:                if (saved == NULL)
        !           151:                        saved = mem_create(PixRect->pr_width,
        !           152:                                PixRect->pr_height, PixRect->pr_depth);
        !           153:                if (saved) {
        !           154:                   pr_rop (saved, 0, 0, PixRect->pr_width, PixRect->pr_height,
        !           155:                        PIX_SRC | PIX_DONTCLIP, PixRect, 0, 0);
        !           156:                   pr_rop (PixRect, 0, 0, PixRect->pr_width,
        !           157:                        PixRect->pr_height, PIX_SRC | PIX_DONTCLIP, NULL, 0, 0);
        !           158:                   have_saved = 1;
        !           159:                }
        !           160:         }
        !           161:        return(0);
        !           162: }
        !           163: 
        !           164: QueryShape (shape, width, height)
        !           165:        int shape;
        !           166:        short *width, *height;
        !           167: {
        !           168:        /* Cursors & tiles unrestricted */
        !           169: }
        !           170: 
        !           171: SetLockLED (onoff)
        !           172:        int onoff;
        !           173: {
        !           174:        return (0);
        !           175: }
        !           176: 
        !           177: ResolveColor (red, green, blue)
        !           178:        unsigned short *red, *green, *blue;
        !           179: {
        !           180:     *red &= ~0377;
        !           181:     *green &= ~0377;
        !           182:     *blue &= ~0377;
        !           183: }
        !           184: 
        !           185: StoreColors (count, entries)
        !           186:        int count;
        !           187:        ColorDef *entries;
        !           188: 
        !           189: {
        !           190:     /* XXX - should keep interal shadow of color map and rewrite whole */
        !           191:     extern struct pixrect *PixRect;
        !           192:     while (count--) {
        !           193:        u_char r, g, b;
        !           194: 
        !           195:        r = (u_char) (entries->red>>8);
        !           196:        g = (u_char) (entries->green>>8);
        !           197:        b = (u_char) (entries->blue>>8);
        !           198:        pr_putcolormap(PixRect, entries->pixel, 1, &r, &g, &b);
        !           199:        entries++;
        !           200:     }
        !           201: }
        !           202: 
        !           203: extern u_char InvPix[];
        !           204: 
        !           205: InvertPixelOrder(p, n)
        !           206:        register unsigned short *p;
        !           207:        register int n;
        !           208: {
        !           209:        for (; n--; p++) {
        !           210:            register unsigned short l = (*p & 0xff), h = (*p >> 8)&0xff;
        !           211:            unsigned short         old = *p;
        !           212: 
        !           213:            *p = (unsigned short) ((InvPix[l] << 8) | InvPix[h]);
        !           214:        }
        !           215: }
        !           216: #endif sun

unix.superglobalmegacorp.com

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