aboutsummaryrefslogtreecommitdiff
path: root/src/Probe.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Probe.java')
-rw-r--r--src/Probe.java29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/Probe.java b/src/Probe.java
index 8e4f9c2..c83b9ac 100644
--- a/src/Probe.java
+++ b/src/Probe.java
@@ -7,6 +7,10 @@
* (c) CENA
*
* Changelog:
+ * 1.2.6
+ * - no more java ping
+ * 1.2.5
+ * - uses apache regexp instead of gnu regexp
* 1.2.4
* - now uses the bindListener paradigm to display the binding/unbinding dynamically
* - adds the -s (send to self) command line switch
@@ -41,11 +45,12 @@ package fr.dgac.ivy ;
import java.io.*;
import java.util.*;
import gnu.getopt.Getopt;
-import gnu.regexp.*;
+/* import gnu.regexp.*; GNURETOAPACHERE */
+import org.apache.regexp.*;
public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBindListener, Runnable {
- public static final String helpCommands = "Available commands:\n.die CLIENTNAME sends a die message\n.direct CLIENTNAME ID MESSAGE sends the direct message to the client, with a message id set to the numerical ID\n.bye quits the application\n.quit idem\n.list lists the available clients\n.ping sends a ping request if IVY_PING is enabled\n.bind REGEXP binds to a regexp at runtime\n.unbind REGEXP unbinds to a regexp at runtime";
+ public static final String helpCommands = "Available commands:\n.die CLIENTNAME sends a die message\n.direct CLIENTNAME ID MESSAGE sends the direct message to the client, with a message id set to the numerical ID\n.bye quits the application\n.quit idem\n.list lists the available clients\n.bind REGEXP binds to a regexp at runtime\n.unbind REGEXP unbinds to a regexp at runtime";
public static final String helpmsg = "usage: java fr.dgac.ivy.Probe [options] [regexp]\n\t-b BUS\tspecifies the Ivy bus domain\n\t-n ivyname (default JPROBE)\n\t-q\tquiet, no tty output\n\t-d\tdebug\n\t-t\ttime stamp each message\n\t-s\tsends to self\n\t-h\thelp\n\n\t regexp is a Perl5 compatible regular expression";
@@ -102,7 +107,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin
this.debug = debug;
try {
directMsgRE = new RE("^\\.direct ([^ ]*) ([0-9]+) (.*)");
- } catch (REException ree) {
+ } catch (RESyntaxException ree) {
System.err.println("Regexp fatal error in the Probe program.");
ree.printStackTrace();
System.exit(0);
@@ -143,7 +148,6 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin
}
void parseCommand(String s) throws IOException {
- REMatch result;
traceDebug("parsing the ["+s+"] (length "+s.length()+") string");
// crude parsing of the ".xyz" commands
if (s.length()==0) {
@@ -152,10 +156,10 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin
} catch (IvyException ie) {
println("-> not sent, the message contains incorrect characters");
}
- } else if ((result=directMsgRE.getMatch(s))!=null) {
- String target = result.toString(1);
- int id = Integer.parseInt(result.toString(2));
- String message = result.toString(3);
+ } else if (directMsgRE.match(s)) {
+ String target = directMsgRE.getParen(1);
+ int id = Integer.parseInt(directMsgRE.getParen(2));
+ String message = directMsgRE.getParen(3);
Vector v=bus.getIvyClientsByName(target);
if (v.size()==0) println("no Ivy client with the name \""+target+"\"");
try {
@@ -184,15 +188,6 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin
} catch (IvyException ie) {
System.out.println("warning, the regular expression '" + regexp + "' is invalid. Not bound !");
}
- } else if (s.lastIndexOf(".ping ")>=0){
- String target=s.substring(6);
- Vector v=bus.getIvyClientsByName(target);
- if (v.size()==0) {
- println("no Ivy client with the name \""+target+"\"");
- }
- for (int i=0;i<v.size();i++) {
- ((IvyClient)v.elementAt(i)).sendPing("test");
- }
} else if ( (s.lastIndexOf(".quit")>=0)||(s.lastIndexOf(".bye")>=0)){
bus.stop();
System.exit(0);