File: gsvs.c

package info (click to toggle)
pact 980714-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 13,096 kB
  • ctags: 26,034
  • sloc: ansic: 109,076; lisp: 9,645; csh: 7,147; fortran: 1,050; makefile: 136; lex: 95; sh: 32
file content (102 lines) | stat: -rw-r--r-- 3,058 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * GSVS.C - view surface routines for SUN
 *
 * Source Version: 2.0
 * Software Release #92-0043
 *
 */

#include "cpyright.h"

#include <sunwindow/window_hs.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sun/fbio.h>
#include <stdio.h>
#include <usercore.h>

int
 cgpixwindd(),
 gp1pixwindd(),
 pixwindd(),
 bw1dd(),
 bw2dd(),
 cg1dd(),
 cg2dd(),
 gp1dd();

char *getenv();

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* GET_VIEW_SURFACE - try SUN's way of finding a view surface */

get_view_surface(vsptr)
   struct vwsurf *vsptr;
   {int fd, devhaswindows;
    char *wptr, dev[DEVNAMESIZE];
    struct screen screen;
    struct fbtype fbtype;

    if (wptr = getenv("WINDOW_ME"))
       {devhaswindows = TRUE;
        if ((fd = open(wptr, O_RDWR, 0)) < 0)
           {io_printf(stderr, "GET_VIEW_SURFACE: CAN'T OPEN %s\n", wptr);
            return(FALSE);};
        win_screenget(fd, &screen);
        close(fd);
        strncpy(dev, screen.scr_fbname, DEVNAMESIZE);}
    else
       {devhaswindows = FALSE;
        strncpy(dev, "/dev/fb", DEVNAMESIZE);};

    if ((fd = open(dev, O_RDWR, 0)) < 0)
       {io_printf(stderr, "GET_VIEW_SURFACE: CAN'T OPEN %s\n", dev);
        return(FALSE);};

    if (ioctl(fd, FBIOGTYPE, &fbtype) == -1)
       {io_printf(stderr, "GET_VIEW_SURFACE: IOCTL FBIOGTYPE FAILED ON %s\n",
		  dev);
        close(fd);
        return(FALSE);};

    close(fd);

    if (devhaswindows)
       {switch (fbtype.fb_type)
           {case FBTYPE_SUN1BW    :
            case FBTYPE_SUN2BW    : vsptr->dd = pixwindd;
                                    break;
            case FBTYPE_SUN1COLOR :
            case FBTYPE_SUN2COLOR : vsptr->dd = cgpixwindd;
                                    break;
            case FBTYPE_SUN2GP    : vsptr->dd = gp1pixwindd;
                                    break;
            default               : io_printf(stderr,
					      "GET_VIEW_SURFACE: UNKNOWN %s\n",
					      dev);
                                    return(FALSE);};}
    else
       {switch (fbtype.fb_type)
           {case FBTYPE_SUN1BW    : vsptr->dd = bw1dd;
                                    break;
            case FBTYPE_SUN2BW    : vsptr->dd = bw2dd;
                                    break;
            case FBTYPE_SUN1COLOR : vsptr->dd = cg1dd;
                                    break;
            case FBTYPE_SUN2COLOR : vsptr->dd = cg2dd;
                                    break;
            case FBTYPE_SUN2GP    : vsptr->dd = gp1dd;
                                    break;
            default               : io_printf(stderr,
					      "GET_VIEW_SURFACE: UNKNOWN %s\n",
					      dev);
                                    return(FALSE);};};

    strncpy(vsptr->screenname, dev, DEVNAMESIZE);

    return(TRUE);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/