aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-extended/rxtx/files/multiple_property_dirs.patch
blob: 6664966ba5a17253fcaa683c1eaeab35ed544dd4 (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
Description: Handles the case when "java.ext.dirs" system property contains
 more than one directory.
Author: Philip Ashmore <contact@philipashmore.com>
Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=646069
Index: rxtx/src/gnu/io/RXTXCommDriver.java
===================================================================
--- rxtx.orig/src/gnu/io/RXTXCommDriver.java	2011-10-28 13:02:43.046717064 -0400
+++ rxtx/src/gnu/io/RXTXCommDriver.java	2011-10-28 13:02:43.186717068 -0400
@@ -356,7 +356,7 @@
 	 First try to register ports specified in the properties
 	 file.  If that doesn't exist, then scan for ports.
 	*/
-		for (int PortType=CommPortIdentifier.PORT_SERIAL;PortType<=CommPortIdentifier.PORT_PARALLEL;PortType++) {
+		for (int PortType=CommPortIdentifier.PORT_SERIAL; PortType<=CommPortIdentifier.PORT_PARALLEL; PortType++) {
 			if (!registerSpecifiedPorts(PortType)) {
 				if (!registerKnownPorts(PortType)) {
 					registerScannedPorts(PortType);
@@ -375,10 +375,18 @@
 		while (tok.hasMoreElements())
 		{
 			String PortName = tok.nextToken();
-
-			if (testRead(PortName, PortType))
+			if(debug)
+				System.out.println("Trying " + PortName + ".");
+			if (testRead(PortName, PortType)) {
 				CommPortIdentifier.addPortName(PortName,
 					PortType, this);
+				if(debug)
+					System.out.println("Success: Read from " + PortName + ".");
+			}else{
+				if(debug)
+					System.out.println("Fail: Cannot read from " + PortName
+						+ ".");
+			}
 		}
 	}
 
@@ -402,26 +410,39 @@
 	private boolean registerSpecifiedPorts(int PortType)
 	{
 		String val = null;
-		Properties origp = System.getProperties();//save system properties
-
-		try
-		    {
+		Properties origp = System.getProperties(); // save system properties
 
-		     String ext_dir=System.getProperty("java.ext.dirs")+System.getProperty("file.separator");
-		     FileInputStream rxtx_prop=new FileInputStream(ext_dir+"gnu.io.rxtx.properties");
-		     Properties p=new Properties();
-		     p.load(rxtx_prop);
-		     System.setProperties(p);
-		     for (Iterator it = p.keySet().iterator(); it.hasNext();) {
-		          String key = (String) it.next();
-		          System.setProperty(key, p.getProperty(key));
-		     }
-		    }catch(Exception e){
-			if (debug){
-			    System.out.println("The file: gnu.io.rxtx.properties doesn't exists.");
-			    System.out.println(e.toString());
-			    }//end if
+		String [] ext_dirs = System.getProperty("java.ext.dirs").split(":");
+		String fs = System.getProperty("file.separator");
+		for (int n = 0; n < ext_dirs.length; ++n) {
+			String ext_file = "?";
+			try{
+				ext_file = ext_dirs[n] + fs + "gnu.io.rxtx.properties";
+				FileInputStream rxtx_prop = new FileInputStream(ext_file);
+				Properties p=new Properties();
+				p.load(rxtx_prop);
+				System.setProperties(p);
+				for (Iterator it = p.keySet().iterator(); it.hasNext();) {
+					String key = (String) it.next();
+					String value = p.getProperty(key);
+					if(debug) {
+						System.out.println(key + " -> " + value);
+					}
+					System.setProperty(key, value);
+				}
+			}catch(Exception e){
+				if (debug){
+					System.out.println("The file \"" + ext_file
+						+ "\" doesn't exist.");
+					System.out.println(e.toString());
+				}//end if
+				continue;
 			}//end catch
+			if (debug){
+				System.out.println("Read properties from \"" + ext_file
+					+ "\".");
+			}//end if
+		}//end for
 
 		if (debug)
 			System.out.println("checking for system-known ports of type "+PortType);
Index: rxtx/src/SerialImp.c
===================================================================
--- rxtx.orig/src/SerialImp.c	2011-10-28 13:02:43.078717065 -0400
+++ rxtx/src/SerialImp.c	2011-10-28 13:02:43.190717067 -0400
@@ -4359,7 +4359,11 @@
 
 	if( fd < 0 )
 	{
-		report_verbose( "testRead() open failed\n" );
+		report_verbose( "testRead() open \"" );
+		report_verbose( name );
+		report_verbose( "\" failed: " );
+		report_verbose( strerror(errno) );
+		report_verbose( "\n" );
 		ret = JNI_FALSE;
 		goto END;
 	}
@@ -5095,7 +5099,7 @@
    exceptions:  none
    comments:
 ----------------------------------------------------------*/
-void report_warning(char *msg)
+void report_warning(const char *msg)
 {
 #ifndef DEBUG_MW
 	fprintf(stderr, msg);
@@ -5113,7 +5117,7 @@
    exceptions:  none
    comments:
 ----------------------------------------------------------*/
-void report_verbose(char *msg)
+void report_verbose(const char *msg)
 {
 #ifdef DEBUG_VERBOSE
 #ifdef DEBUG_MW
@@ -5132,7 +5136,7 @@
    exceptions:  none
    comments:
 ----------------------------------------------------------*/
-void report_error(char *msg)
+void report_error(const char *msg)
 {
 #ifndef DEBUG_MW
 	fprintf(stderr, msg);
@@ -5150,7 +5154,7 @@
    exceptions:  none
    comments:
 ----------------------------------------------------------*/
-void report(char *msg)
+void report(const char *msg)
 {
 #ifdef DEBUG
 #	ifndef DEBUG_MW
Index: rxtx/src/SerialImp.h
===================================================================
--- rxtx.orig/src/SerialImp.h	2011-10-28 13:02:43.162717067 -0400
+++ rxtx/src/SerialImp.h	2011-10-28 13:02:43.194717067 -0400
@@ -467,10 +467,10 @@
 jboolean is_interrupted( struct event_info_struct * );
 int send_event(struct event_info_struct *, jint, int );
 void dump_termios(char *,struct termios *);
-void report_verbose(char *);
-void report_error(char *);
-void report_warning(char *);
-void report(char *);
+void report_verbose(const char *);
+void report_error(const char *);
+void report_warning(const char *);
+void report(const char *);
 void throw_java_exception( JNIEnv *, char *, char *, char * );
 int lock_device( const char * );
 void unlock_device( const char * );