1
2 /*
3 * Diverse Bristol audio routines.
4 * Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2012
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22 #include <stdio.h>
23 #include <stdlib.h>
24
25 #include "brightoninternals.h"
26 #include "brightonX11.h"
27
28 extern void initSqrtTab();
29
30 brightonDisplay *
brightonOpenDisplay(char * displayname)31 brightonOpenDisplay(char *displayname)
32 {
33 brightonDisplay *display;
34
35 /*
36 * This should be moved to a more generic init() procedure, it is not
37 * required for each display connection, but at the same time we will
38 * probably only connect to one anyway.
39 */
40 initSqrtTab();
41
42 display = (brightonDisplay *) brightonmalloc(sizeof(brightonDisplay));
43
44 if (displayname == NULL)
45 if ((displayname = getenv("DISPLAY")) == NULL)
46 displayname = BRIGHTON_DEFAULT_DISPLAY;
47
48 sprintf(&display->name[0], "%s", displayname);
49
50 if ((display->display = (void *)
51 BOpenDisplay(display, displayname)) == NULL)
52 {
53 printf("brightonOpenDisplay(): cannot open %s\n", displayname);
54 brightonfree(display);
55 return(0);
56 }
57
58 return(display);
59 }
60
61 brightonDisplay *
brightonFindDisplay(brightonDisplay * dlist,brightonDisplay * display)62 brightonFindDisplay(brightonDisplay *dlist, brightonDisplay *display)
63 {
64 if (dlist == 0)
65 return(0);
66
67 if (dlist == display)
68 return(display);
69
70 return(brightonFindDisplay(dlist->next, display));
71 }
72
73 int
brightonCloseDisplay(brightonDisplay * display)74 brightonCloseDisplay(brightonDisplay *display)
75 {
76 BCloseDisplay(display->display);
77
78 brightonfree(display);
79
80 return(0);
81 }
82
83