File: lcdproc-5.1.patch

package info (click to toggle)
g15daemon 1.9.5.3-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,144 kB
  • sloc: sh: 9,189; ansic: 3,188; perl: 115; makefile: 66
file content (98 lines) | stat: -rw-r--r-- 2,596 bytes parent folder | download | duplicates (7)
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
Index: g15.c
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/server/drivers/g15.c,v
retrieving revision 1.1
diff -a -u -r1.1 g15.c
--- g15.c	13 Aug 2006 15:55:47 -0000	1.1
+++ g15.c	12 Nov 2006 02:05:36 -0000
@@ -30,6 +30,7 @@
 #include <errno.h>
 #include <syslog.h>
 #include <sys/socket.h>
+#include <sys/types.h>
 #include <libg15.h>
 #include <g15daemon_client.h>
 #include <libg15render.h>
@@ -70,6 +71,7 @@
    p->cellheight = G15_CELL_HEIGHT;
    p->backlight_state = BACKLIGHT_ON;
    p->g15screen_fd = 0;
+   p->g15d_ver = g15daemon_version();
 
    if((p->g15screen_fd = new_g15_screen(G15_G15RBUF)) < 0)
    {
@@ -109,15 +111,8 @@
 	
 	g15_close_screen(p->g15screen_fd);
 	
-	if (p != NULL) {
-		if (p->canvas)
-			free(p->canvas);
-		
-		if (p->backingstore)
-			free(p->backingstore);
-
-		free(p);
-	}
+	if (p != NULL)
+	  free(p);
 	drvthis->store_private_ptr(drvthis, NULL);
 }
 
@@ -372,14 +367,35 @@
 MODULE_EXPORT const char * g15_get_key (Driver *drvthis)
 {
 	PrivateData *p = drvthis->private_data;
-	
+	int toread = 0;
 	unsigned int key_state = 0;
-	
-	if(send(p->g15screen_fd, "k", 1, MSG_OOB)<1) /* request key status */
-        report(RPT_INFO, "%s: Error in send to g15daemon", drvthis->name);    
 
-    	recv(p->g15screen_fd, &key_state , sizeof(key_state),0);
+	if ((strncmp("1.2", p->g15d_ver, 3)))
+	  {	/* other than g15daemon-1.2 (should be >=1.9) */
+		fd_set fds;
+		struct timeval tv;
+		memset (&tv, 0, sizeof(struct timeval));
+
+		FD_ZERO(&fds);
+		FD_SET(p->g15screen_fd, &fds);
+	
+		toread = select(FD_SETSIZE, &fds, NULL, NULL, &tv);
+	  }
+	else
+	  {	/* g15daemon-1.2 */
+		if(send(p->g15screen_fd, "k", 1, MSG_OOB)<1) /* request key status */
+		  {
+	 	  	report(RPT_INFO, "%s: Error in send to g15daemon", drvthis->name);
+			return NULL;
+		  }
+		toread = 1;
+	  }
 	
+	if (toread >= 1)
+	  read(p->g15screen_fd, &key_state, sizeof(key_state));
+	else
+	  return NULL;
+
 	if (key_state & G15_KEY_G1)
 		return "Escape";
 	else if (key_state & G15_KEY_L1)
Index: g15.h
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/server/drivers/g15.h,v
retrieving revision 1.1
diff -a -u -r1.1 g15.h
--- g15.h	13 Aug 2006 15:55:47 -0000	1.1
+++ g15.h	12 Nov 2006 02:05:36 -0000
@@ -32,6 +32,8 @@
 	int cellwidth, cellheight;
 	/* file descriptor for g15daemon socket */
 	int g15screen_fd;
+	/* g15daemon version for compatibility checks */
+	const char *g15d_ver;
 	/* canvas for LCD contents */
 	g15canvas *canvas;
 	g15canvas *backingstore;