46 |
private static final int SEARCHMAX = 10; |
private static final int SEARCHMAX = 10; |
47 |
private static final PrintStream stdout = System.out; |
private static final PrintStream stdout = System.out; |
48 |
private static final PrintStream stderr = System.err; |
private static final PrintStream stderr = System.err; |
49 |
|
private static final Creator creator = new CreatorImpl(); |
50 |
/* class variables */ |
/* class variables */ |
51 |
private static String pxhost = null; |
private static String pxhost = null; |
52 |
private static int pxport = 0; |
private static int pxport = 0; |
53 |
private static int timeout = -1; |
private static int timeout = -1; |
54 |
private static String authname = null; |
private static String authname = null; |
55 |
private static String authpass = null; |
private static String authpass = null; |
|
private static int condopts = 0; |
|
56 |
//---------------------------------------------------------------- |
//---------------------------------------------------------------- |
57 |
// public static methods |
// public static methods |
58 |
//---------------------------------------------------------------- |
//---------------------------------------------------------------- |
298 |
List attrs = new ArrayList(3); |
List attrs = new ArrayList(3); |
299 |
String ord = null; |
String ord = null; |
300 |
int max = SEARCHMAX; |
int max = SEARCHMAX; |
301 |
|
int opts = 0; |
302 |
int depth = 0; |
int depth = 0; |
303 |
for(int i = 1; i < args.length; i++){ |
for(int i = 1; i < args.length; i++){ |
304 |
String arg = args[i]; |
String arg = args[i]; |
317 |
if(++i >= args.length) usage(); |
if(++i >= args.length) usage(); |
318 |
authpass = args[i]; |
authpass = args[i]; |
319 |
} else if(arg.equals("-sf")){ |
} else if(arg.equals("-sf")){ |
320 |
condopts |= Condition.CONDSIMPLE; |
opts |= Condition.CONDSIMPLE; |
321 |
} else if(arg.equals("-attr")){ |
} else if(arg.equals("-attr")){ |
322 |
if(++i >= args.length) usage(); |
if(++i >= args.length) usage(); |
323 |
attrs.add(args[i]); |
attrs.add(args[i]); |
342 |
} |
} |
343 |
} |
} |
344 |
if(nurl == null) usage(); |
if(nurl == null) usage(); |
345 |
return procsearch(nurl, phrase, attrs, ord, max, depth); |
return procsearch(nurl, phrase, attrs, ord, max, opts, depth); |
346 |
} |
} |
347 |
/* parse arguments of the setuser command */ |
/* parse arguments of the setuser command */ |
348 |
private static int runsetuser(String[] args){ |
private static int runsetuser(String[] args){ |
431 |
FileInputStream fis = null; |
FileInputStream fis = null; |
432 |
try { |
try { |
433 |
fis = new FileInputStream(file); |
fis = new FileInputStream(file); |
434 |
data = Utility.readAll(fis); |
data = Utility.read_all(fis); |
435 |
} catch(IOException e){ |
} catch(IOException e){ |
436 |
printerror(e.toString()); |
printerror(e.toString()); |
437 |
return 1; |
return 1; |
442 |
} |
} |
443 |
} else { |
} else { |
444 |
try { |
try { |
445 |
data = Utility.readAll(System.in); |
data = Utility.read_all(System.in); |
446 |
} catch(IOException e){ |
} catch(IOException e){ |
447 |
printerror(e.toString()); |
printerror(e.toString()); |
448 |
return 1; |
return 1; |
455 |
printerror(e.toString()); |
printerror(e.toString()); |
456 |
return 1; |
return 1; |
457 |
} |
} |
458 |
Document doc = new DocumentImpl(draft); |
Document doc = creator.create_document(draft); |
459 |
Node node = new NodeImpl(); |
Node node = creator.create_node(); |
460 |
node.set_url(nurl); |
node.set_url(nurl); |
461 |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
462 |
if(timeout > 0) node.set_timeout(timeout); |
if(timeout > 0) node.set_timeout(timeout); |
475 |
} catch(NumberFormatException e){ |
} catch(NumberFormatException e){ |
476 |
id = -1; |
id = -1; |
477 |
} |
} |
478 |
Node node = new NodeImpl(); |
Node node = creator.create_node(); |
479 |
node.set_url(nurl); |
node.set_url(nurl); |
480 |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
481 |
if(timeout > 0) node.set_timeout(timeout); |
if(timeout > 0) node.set_timeout(timeout); |
501 |
} catch(NumberFormatException e){ |
} catch(NumberFormatException e){ |
502 |
id = -1; |
id = -1; |
503 |
} |
} |
504 |
Node node = new NodeImpl(); |
Node node = creator.create_node(); |
505 |
node.set_url(nurl); |
node.set_url(nurl); |
506 |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
507 |
if(timeout > 0) node.set_timeout(timeout); |
if(timeout > 0) node.set_timeout(timeout); |
525 |
} |
} |
526 |
/* perform the uriid command */ |
/* perform the uriid command */ |
527 |
private static int procuriid(String nurl, String uri){ |
private static int procuriid(String nurl, String uri){ |
528 |
Node node = new NodeImpl(); |
Node node = creator.create_node(); |
529 |
node.set_url(nurl); |
node.set_url(nurl); |
530 |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
531 |
if(timeout > 0) node.set_timeout(timeout); |
if(timeout > 0) node.set_timeout(timeout); |
540 |
} |
} |
541 |
/* perform the inform command */ |
/* perform the inform command */ |
542 |
private static int procinform(String nurl){ |
private static int procinform(String nurl){ |
543 |
Node node = new NodeImpl(); |
Node node = creator.create_node(); |
544 |
node.set_url(nurl); |
node.set_url(nurl); |
545 |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
546 |
if(timeout > 0) node.set_timeout(timeout); |
if(timeout > 0) node.set_timeout(timeout); |
559 |
} |
} |
560 |
/* perform the search command */ |
/* perform the search command */ |
561 |
private static int procsearch(String nurl, String phrase, List attrs, String ord, |
private static int procsearch(String nurl, String phrase, List attrs, String ord, |
562 |
int max, int depth){ |
int max, int opts, int depth){ |
563 |
Node node = new NodeImpl(); |
Node node = creator.create_node(); |
564 |
node.set_url(nurl); |
node.set_url(nurl); |
565 |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
566 |
if(timeout > 0) node.set_timeout(timeout); |
if(timeout > 0) node.set_timeout(timeout); |
567 |
if(authname != null) node.set_auth(authname, authpass); |
if(authname != null) node.set_auth(authname, authpass); |
568 |
Condition cond = new ConditionImpl(); |
Condition cond = creator.create_condition(); |
569 |
if(phrase != null) cond.set_phrase(phrase); |
if(phrase != null) cond.set_phrase(phrase); |
570 |
Iterator attrsit = attrs.iterator(); |
Iterator attrsit = attrs.iterator(); |
571 |
while(attrsit.hasNext()){ |
while(attrsit.hasNext()){ |
573 |
} |
} |
574 |
if(ord != null) cond.set_order(ord); |
if(ord != null) cond.set_order(ord); |
575 |
cond.set_max(max); |
cond.set_max(max); |
576 |
cond.set_options(condopts); |
cond.set_options(opts); |
577 |
NodeResult nres = node.search(cond, depth); |
NodeResult nres = node.search(cond, depth); |
578 |
Calendar cal = new GregorianCalendar(); |
Calendar cal = new GregorianCalendar(); |
579 |
String border = "--------[" + cal.getTimeInMillis() + "]--------"; |
String border = "--------[" + cal.getTimeInMillis() + "]--------"; |
625 |
} |
} |
626 |
/* perform the setuser command */ |
/* perform the setuser command */ |
627 |
private static int procsetuser(String nurl, String name, int mode){ |
private static int procsetuser(String nurl, String name, int mode){ |
628 |
Node node = new NodeImpl(); |
Node node = creator.create_node(); |
629 |
node.set_url(nurl); |
node.set_url(nurl); |
630 |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
631 |
if(timeout > 0) node.set_timeout(timeout); |
if(timeout > 0) node.set_timeout(timeout); |
638 |
} |
} |
639 |
/* perform the setlink command */ |
/* perform the setlink command */ |
640 |
private static int procsetlink(String nurl, String url, String label, int credit){ |
private static int procsetlink(String nurl, String url, String label, int credit){ |
641 |
Node node = new NodeImpl(); |
Node node = creator.create_node(); |
642 |
node.set_url(nurl); |
node.set_url(nurl); |
643 |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
if(pxhost != null) node.set_proxy(pxhost, pxport); |
644 |
if(timeout > 0) node.set_timeout(timeout); |
if(timeout > 0) node.set_timeout(timeout); |