Added initial SCGI server and a handler for serving JARs from the filesystem.
[jsvc.git] / src / dolda / jsvc / util / Misc.java
index 122a654..9b7f8e1 100644 (file)
@@ -6,6 +6,7 @@ import java.io.*;
 
 public class Misc {
     public static final java.nio.charset.Charset utf8 = java.nio.charset.Charset.forName("UTF-8");
+    public static final java.nio.charset.Charset ascii = java.nio.charset.Charset.forName("US-ASCII");
     private static Map<Integer, String> stext = new HashMap<Integer, String>();
     
     static {
@@ -122,4 +123,23 @@ public class Misc {
        }
        return(buf.toString());
     }
+    
+    public static boolean boolval(String val) {
+       val = val.trim().toLowerCase();
+       if(val.equals("1") || val.equals("on") || val.equals("true") || val.equals("yes") || val.equals("\u22a4"))
+           return(true);
+       if(val.equals("0") || val.equals("off") || val.equals("false") || val.equals("no") || val.equals("\u22a5"))
+           return(false);
+       throw(new IllegalArgumentException("value not recognized as boolean: " + val));
+    }
+    
+    public static void eatws(PushbackReader in) throws IOException {
+       int c;
+       do {
+           c = in.read();
+           if(c < 0)
+               return;
+       } while(Character.isWhitespace(c));
+       in.unread(c);
+    }
 }