summaryrefslogtreecommitdiffstats
path: root/src/cmd/ndb/dnsquery.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-02-14 19:43:19 +0000
committerrsc <devnull@localhost>2006-02-14 19:43:19 +0000
commit5c9f76b5e5dc5c0537896b0e487b101dad38a746 (patch)
treedfee973b76db00b0e011610298ca13c5a997e1c9 /src/cmd/ndb/dnsquery.c
parent54357361fbc3032b36688bb4c1d4ced1f14f08f6 (diff)
downloadplan9port-5c9f76b5e5dc5c0537896b0e487b101dad38a746.tar.gz
plan9port-5c9f76b5e5dc5c0537896b0e487b101dad38a746.zip
remove unused
Diffstat (limited to 'src/cmd/ndb/dnsquery.c')
-rwxr-xr-xsrc/cmd/ndb/dnsquery.c69
1 files changed, 27 insertions, 42 deletions
diff --git a/src/cmd/ndb/dnsquery.c b/src/cmd/ndb/dnsquery.c
index 597cc480..5aa19775 100755
--- a/src/cmd/ndb/dnsquery.c
+++ b/src/cmd/ndb/dnsquery.c
@@ -2,58 +2,43 @@
#include <libc.h>
#include <bio.h>
#include <ndb.h>
+#include <thread.h>
#include "dns.h"
#include "ip.h"
void
+usage(void)
+{
+ fprint(2, "usage: dnsquery [-x dns]\n");
+ threadexitsall("usage");
+}
+
+void
main(int argc, char *argv[])
{
- int fd, n, len, domount;
+ char *dns;
+ CFid *fd;
+ int n, len;
Biobuf in;
char line[1024], *lp, *p, *np, *mtpt, *srv, *dns;
char buf[1024];
- dns = "/net/dns";
- mtpt = "/net";
- srv = "/srv/dns";
- domount = 1;
- ARGBEGIN {
+ dns = "dns";
+ ARGBEGIN{
case 'x':
- dns = "/net.alt/dns";
- mtpt = "/net.alt";
- srv = "/srv/dns_net.alt";
+ dns = EARGF(usage());
break;
default:
- fprint(2, "usage: %s -x [dns-mount-point]\n", argv0);
- exits("usage");
- } ARGEND;
+ usage();
+ }ARGEND;
- if(argc == 1){
- domount = 0;
- mtpt = argv[0];
- }
+ if(argc)
+ usage();
+
+ fd = nsopen(dns, nil, "dns", ORDWR);
+ if(fd == nil)
+ sysfatal("open %s!dns: %r", dns);
- fd = open(dns, ORDWR);
- if(fd < 0){
- if(domount == 0){
- fprint(2, "can't open %s: %r\n", mtpt);
- exits(0);
- }
- fd = open(srv, ORDWR);
- if(fd < 0){
- print("can't open %s: %r\n", srv);
- exits(0);
- }
- if(mount(fd, -1, mtpt, MBEFORE, "") < 0){
- print("can't mount(%s, %s): %r\n", srv, mtpt);
- exits(0);
- }
- fd = open(mtpt, ORDWR);
- if(fd < 0){
- print("can't open %s: %r\n", mtpt);
- exits(0);
- }
- }
Binit(&in, 0, OREAD);
for(print("> "); lp = Brdline(&in, '\n'); print("> ")){
n = Blinelen(&in)-1;
@@ -98,16 +83,16 @@ main(int argc, char *argv[])
n = strlen(line);
}
- seek(fd, 0, 0);
- if(write(fd, line, n) < 0) {
+ fsseek(fd, 0, 0);
+ if(fswrite(fd, line, n) < 0) {
print("!%r\n");
continue;
}
- seek(fd, 0, 0);
- while((n = read(fd, buf, sizeof(buf))) > 0){
+ fsseek(fd, 0, 0);
+ while((n = fsread(fd, buf, sizeof(buf))) > 0){
buf[n] = 0;
print("%s\n", buf);
}
}
- exits(0);
+ threadexitsall(0);
}