From ac3ba726f9b4978829e4ad186b00109262fa2b93 Mon Sep 17 00:00:00 2001 From: Akshat Kumar Date: Mon, 24 Sep 2012 10:35:01 -0400 Subject: src/cmd: Add a repurposed import(4), called `9import', to the ports. The code is adapted from Plan 9's import(4); this allows us to speak that protocol. We don't currently support AAN (in the works) or TLS/SSL. Thanks to David for help with the man page, testing, and development. R=0intro, rsc CC=plan9port.codebot http://codereview.appspot.com/6458100 --- src/cmd/9import.c | 239 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 src/cmd/9import.c (limited to 'src/cmd') diff --git a/src/cmd/9import.c b/src/cmd/9import.c new file mode 100644 index 00000000..c74ffb50 --- /dev/null +++ b/src/cmd/9import.c @@ -0,0 +1,239 @@ +#include +#include +#include +#include + +enum { + Encnone, + Encssl, + Enctls, +}; + +static char *encprotos[] = { + [Encnone] = "clear", + [Encssl] = "ssl", + [Enctls] = "tls", + nil, +}; + +char *keyspec = ""; +char *filterp; +char *ealgs = "rc4_256 sha1"; +int encproto = Encnone; +AuthInfo *ai; +int debug; +int doauth = 1; +int timedout; + +int connectez(char*, char*); +void sysfatal(char*, ...); +void usage(void); +int filter(int, char *, char *); + +int +catcher(void *v, char *msg) +{ + timedout = 1; + if(strcmp(msg, "alarm") == 0) + return 1; + return 0; +} + +static int +lookup(char *s, char *l[]) +{ + int i; + + for (i = 0; l[i] != 0; i++) + if (strcmp(l[i], s) == 0) + return i; + return -1; +} + +static char* +srvname(char *addr) +{ + int i; + + for(i=0; i