Spelling fixes from Dave.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2268 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2008-01-14 23:41:09 +00:00
parent 6954e1a61b
commit 2338ec8e32
+12 -18
View File
@@ -40,8 +40,7 @@ public class MACUtil
/** /**
public static void main (String[] args) public static void main (String[] args)
{ {
String testOutput = String testOutput = "YOUR TEST STRING GOES HERE";
"YOUR TEST STRING GOES HERE";
String[] macs = parseMACs(testOutput); String[] macs = parseMACs(testOutput);
for (int ii = 0; ii < macs.length; ii++) { for (int ii = 0; ii < macs.length; ii++) {
@@ -51,8 +50,7 @@ public class MACUtil
*/ */
/** /**
* Get all the MAC addresses of the hardware we are running on that we * Get all the MAC addresses of the hardware we are running on that we can find.
* can find.
*/ */
public static String[] getMACAddresses () public static String[] getMACAddresses ()
{ {
@@ -79,8 +77,7 @@ public class MACUtil
mac = mac.replace(':', '-'); mac = mac.replace(':', '-');
// "Didn't you get that memo?" Apparently some people are not // "Didn't you get that memo?" Apparently some people are not
// up on MAC addresses actually being unique, so we will // up on MAC addresses actually being unique, so we will ignore those.
// ignore those.
// //
// 44-45-53-XX-XX-XX - PPP Adaptor // 44-45-53-XX-XX-XX - PPP Adaptor
// 00-53-45-XX-XX-XX - PPP Adaptor // 00-53-45-XX-XX-XX - PPP Adaptor
@@ -115,8 +112,8 @@ public class MACUtil
} }
/** /**
* Takes a lists of commands and trys to run each one till one works. * Takes a lists of commands and tries to run each one till one works.
* The idea being to beable to 'gracefully' cope with not knowing * The idea being to be able to 'gracefully' cope with not knowing
* where a command is installed on different installations. * where a command is installed on different installations.
*/ */
protected static String tryCommands (String[] cmds) protected static String tryCommands (String[] cmds)
@@ -138,14 +135,13 @@ public class MACUtil
} }
/** /**
* Run the specificed command and return the output as a string. * Run the specified command and return the output as a string.
*/ */
protected static String runCommand (String cmd) protected static String runCommand (String cmd)
{ {
try { try {
Process p = Runtime.getRuntime().exec(cmd); Process p = Runtime.getRuntime().exec(cmd);
BufferedReader cin = new BufferedReader( BufferedReader cin = new BufferedReader(new InputStreamReader(p.getInputStream()));
new InputStreamReader(p.getInputStream()));
StringBuilder buffer= new StringBuilder(); StringBuilder buffer= new StringBuilder();
String line = ""; String line = "";
@@ -158,18 +154,16 @@ public class MACUtil
return buffer.toString(); return buffer.toString();
} catch (IOException e) { } catch (IOException e) {
// don't want to log anything for the client to know what we // don't want to log anything for the client to know what we are doing.
// are doing. This will almost always be thrown/caught when // This will almost always be thrown/caught when the cmd isn't there.
// the cmd isn't there.
return null; return null;
} }
} }
/** Look for 2 hex values in a row followed by a ':' or '-' repeated 5 /** Look for 2 hex values in a row followed by a ':' or '-' repeated 5 times, followed by 2 hex
times, followed by 2 hex values. */ * values. */
protected static Pattern MACRegex = protected static Pattern MACRegex =
Pattern.compile("((?:\\p{XDigit}{2}+[:\\-]){5}+\\p{XDigit}{2}+)", Pattern.compile("((?:\\p{XDigit}{2}+[:\\-]){5}+\\p{XDigit}{2}+)", Pattern.CASE_INSENSITIVE);
Pattern.CASE_INSENSITIVE);
// TODO maybe we should obfuscate these with rot13 or something so // TODO maybe we should obfuscate these with rot13 or something so
// that people can't run 'strings' on us and instantly see what we try // that people can't run 'strings' on us and instantly see what we try