Index: include/libroar/vio_dstr.h
===================================================================
--- include/libroar/vio_dstr.h	(revision 1321)
+++ include/libroar/vio_dstr.h	(revision 1323)
@@ -38,4 +38,114 @@
 #include "libroar.h"
 
+#define ROAR_VIO_DEF_TYPE_EOL            -1 
+#define ROAR_VIO_DEF_TYPE_NONE            0
+#define ROAR_VIO_DEF_TYPE_FILE            1
+#define ROAR_VIO_DEF_TYPE_SOCKET          2
+#define ROAR_VIO_DEF_TYPE_FH              3
+#define ROAR_VIO_DEF_TYPE_SOCKETFH        4
+
+#define ROAR_VIO_DSTR_OBJGT_INTERNAL      0x0000
+#define ROAR_VIO_DSTR_OBJGT_GEN           0x0100
+#define ROAR_VIO_DSTR_OBJGT_SOCKET        0x0200
+#define ROAR_VIO_DSTR_OBJGT_PROXY         0x0300
+#define ROAR_VIO_DSTR_OBJGT_COMP          0x0400 /* compression */
+#define ROAR_VIO_DSTR_OBJGT_CRYPT         0x0500
+#define ROAR_VIO_DSTR_OBJGT_PROTO         0x0600 /* protocolls like HTTP and Gopher */
+#define ROAR_VIO_DSTR_OBJGT_SPECAL        0xff00
+
+#define ROAR_VIO_DSTR_OBJT_EOL           -1
+#define ROAR_VIO_DSTR_OBJT_NONE           0
+#define ROAR_VIO_DSTR_OBJT_INTERNAL       1
+
+#define ROAR_VIO_DSTR_OBJT_FILE           (0x01|ROAR_VIO_DSTR_OBJGT_GEN)
+#define ROAR_VIO_DSTR_OBJT_FH             (0x02|ROAR_VIO_DSTR_OBJGT_GEN)
+#define ROAR_VIO_DSTR_OBJT_SOCKETFH       (0x03|ROAR_VIO_DSTR_OBJGT_GEN)
+/* some space to add memory FHs and the like */
+#define ROAR_VIO_DSTR_OBJT_PASS           (0x10|ROAR_VIO_DSTR_OBJGT_GEN)
+#define ROAR_VIO_DSTR_OBJT_RE             (0x11|ROAR_VIO_DSTR_OBJGT_GEN)
+#define ROAR_VIO_DSTR_OBJT_EXEC           (0x20|ROAR_VIO_DSTR_OBJGT_GEN)
+
+#define ROAR_VIO_DSTR_OBJT_SOCKET         (0x01|ROAR_VIO_DSTR_OBJGT_SOCKET)
+#define ROAR_VIO_DSTR_OBJT_UNIX           (0x02|ROAR_VIO_DSTR_OBJGT_SOCKET)
+#define ROAR_VIO_DSTR_OBJT_DECNET         (0x10|ROAR_VIO_DSTR_OBJGT_SOCKET)
+#define ROAR_VIO_DSTR_OBJT_TCP            (0x21|ROAR_VIO_DSTR_OBJGT_SOCKET)
+#define ROAR_VIO_DSTR_OBJT_UDP            (0x22|ROAR_VIO_DSTR_OBJGT_SOCKET)
+#define ROAR_VIO_DSTR_OBJT_TCP6           (0x31|ROAR_VIO_DSTR_OBJGT_SOCKET)
+#define ROAR_VIO_DSTR_OBJT_UDP6           (0x32|ROAR_VIO_DSTR_OBJGT_SOCKET)
+
+#define ROAR_VIO_DSTR_OBJT_SOCKS          (0x10|ROAR_VIO_DSTR_OBJGT_PROXY)
+#define ROAR_VIO_DSTR_OBJT_SOCKS4         (0x14|ROAR_VIO_DSTR_OBJGT_PROXY)
+#define ROAR_VIO_DSTR_OBJT_SOCKS4A        (0x1a|ROAR_VIO_DSTR_OBJGT_PROXY)
+#define ROAR_VIO_DSTR_OBJT_SOCKS4D        (0x1d|ROAR_VIO_DSTR_OBJGT_PROXY)
+#define ROAR_VIO_DSTR_OBJT_SOCKS5         (0x15|ROAR_VIO_DSTR_OBJGT_PROXY)
+#define ROAR_VIO_DSTR_OBJT_SSH            (0x21|ROAR_VIO_DSTR_OBJGT_PROXY)
+//#define ROAR_VIO_DSTR_OBJT_HTTP           (0x31|ROAR_VIO_DSTR_OBJGT_PROXY)
+
+//#define ROAR_VIO_DSTR_OBJT_HTTP           (0x10|ROAR_VIO_DSTR_OBJGT_PROTO)
+#define ROAR_VIO_DSTR_OBJT_HTTP09         (0x11|ROAR_VIO_DSTR_OBJGT_PROTO)
+#define ROAR_VIO_DSTR_OBJT_HTTP10         (0x12|ROAR_VIO_DSTR_OBJGT_PROTO)
+#define ROAR_VIO_DSTR_OBJT_HTTP11         (0x13|ROAR_VIO_DSTR_OBJGT_PROTO)
+#define ROAR_VIO_DSTR_OBJT_HTTP           ROAR_VIO_DSTR_OBJT_HTTP11
+#define ROAR_VIO_DSTR_OBJT_GOPHER         (0x21|ROAR_VIO_DSTR_OBJGT_PROTO)
+
+/*
+#define ROAR_VIO_DSTR_OBJGT_CRYPT         0x0500
+*/
+
+#define ROAR_VIO_DSTR_OBJT_GZIP           (0x10|ROAR_VIO_DSTR_OBJGT_COMP)
+#define ROAR_VIO_DSTR_OBJT_BZIP2          (0x22|ROAR_VIO_DSTR_OBJGT_COMP)
+
+#define ROAR_VIO_DSTR_OBJT_PGP            (0x10|ROAR_VIO_DSTR_OBJGT_CRYPT)
+#define ROAR_VIO_DSTR_OBJT_PGP_ENC        (0x11|ROAR_VIO_DSTR_OBJGT_CRYPT)
+#define ROAR_VIO_DSTR_OBJT_PGP_STORE      (0x11|ROAR_VIO_DSTR_OBJGT_CRYPT)
+#define ROAR_VIO_DSTR_OBJT_SSL1           (0x21|ROAR_VIO_DSTR_OBJGT_CRYPT)
+#define ROAR_VIO_DSTR_OBJT_SSL2           (0x22|ROAR_VIO_DSTR_OBJGT_CRYPT)
+#define ROAR_VIO_DSTR_OBJT_SSL3           (0x23|ROAR_VIO_DSTR_OBJGT_CRYPT)
+#define ROAR_VIO_DSTR_OBJT_TLS            (0x2a|ROAR_VIO_DSTR_OBJGT_CRYPT)
+#define ROAR_VIO_DSTR_OBJT_SSLTLS         ROAR_VIO_DSTR_OBJT_TLS
+
+#define ROAR_VIO_DSTR_OBJT_MAGIC          (0x01|ROAR_VIO_DSTR_OBJGT_SPECAL)
+
+
+struct roar_vio_defaults {
+ int type;
+
+ mode_t o_mode;
+ int    o_flags;
+
+ union {
+  char *   file;
+  int      fh;
+  struct {
+          int               domain;
+          int               type;
+          char            * host;
+          struct sockaddr * sa;
+          socklen_t         len;
+         } socket;
+ } d;
+};
+
+struct roar_vio_dstr_chain {
+ int    type;
+ char * opts;
+ char * dst;
+ int    need_vio;
+ struct roar_vio_defaults * def;
+ struct roar_vio_calls    * vio;
+};
+
+int     roar_vio_dstr_get_type(char * str);
+char *  roar_vio_dstr_get_name(int type);
+
+int     roar_vio_dstr_init_defaults (struct roar_vio_defaults * def, int type, int o_flags, mode_t o_mode);
+
+int     roar_vio_open_dstr    (struct roar_vio_calls * calls, char * dstr, struct roar_vio_defaults * def, int dnum);
+int     roar_vio_open_dstr_vio(struct roar_vio_calls * calls, char * dstr, struct roar_vio_defaults * def, int dnum, struct roar_vio_calls * vio);
+
+int     roar_vio_dstr_parse_opts(struct roar_vio_dstr_chain * chain);
+int     roar_vio_dstr_set_defaults(struct roar_vio_dstr_chain * chain);
+int     roar_vio_dstr_build_chain(struct roar_vio_dstr_chain * chain, struct roar_vio_calls * calls, struct roar_vio_calls * vio);
+
 #endif
 
Index: libroar/vio_dstr.c
===================================================================
--- libroar/vio_dstr.c	(revision 1321)
+++ libroar/vio_dstr.c	(revision 1323)
@@ -35,3 +35,212 @@
 #include "libroar.h"
 
+struct {
+ int    id;
+ char * name;
+ int    pdeftype[16];
+} _roar_vio_dstr_objs[] = {
+/*
+grep '^#define ROAR_VIO_DSTR_OBJT_' vio_dstr.h | cut -d' ' -f2 | while read objt; do name=`cut -d_ -f5,6,7,8,9,10 <<<$objt | tr A-Z a-z`; echo -e " {$objt,\t \"$name\","; echo "      {ROAR_VIO_DEF_TYPE_EOL}},"; done;
+*/
+ {ROAR_VIO_DSTR_OBJT_FILE,       "file",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_FH,         "fh",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_SOCKETFH,   "socketfh",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_PASS,       "pass",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_RE,         "re",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_EXEC,       "exec",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+
+ {ROAR_VIO_DSTR_OBJT_SOCKET,     "socket",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_UNIX,       "unix",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_DECNET,     "decnet",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_TCP,        "tcp",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_UDP,        "udp",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_TCP6,       "tcp6",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_UDP6,       "udp6",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+
+ {ROAR_VIO_DSTR_OBJT_SOCKS,      "socks",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_SOCKS4,     "socks4",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_SOCKS4A,    "socks4a",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_SOCKS4D,    "socks4d",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_SOCKS5,     "socks5",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_SSH,        "ssh",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+
+ {ROAR_VIO_DSTR_OBJT_HTTP09,     "http09",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_HTTP10,     "http10",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_HTTP11,     "http11",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_HTTP,       "http",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_GOPHER,     "gopher",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+
+ {ROAR_VIO_DSTR_OBJT_GZIP,       "gzip",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_BZIP2,      "bzip2",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+
+ {ROAR_VIO_DSTR_OBJT_PGP,        "pgp",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_PGP_ENC,    "pgp_enc",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_PGP_STORE,  "pgp_store",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_SSL1,       "ssl1",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_SSL2,       "ssl2",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_SSL3,       "ssl3",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_TLS,        "tls",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_SSLTLS,     "ssltls",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+
+ {ROAR_VIO_DSTR_OBJT_MAGIC,      "magic",
+      {ROAR_VIO_DEF_TYPE_EOL}},
+
+ {ROAR_VIO_DSTR_OBJT_INTERNAL, "INTERNAL",
+      {ROAR_VIO_DEF_TYPE_FILE, ROAR_VIO_DEF_TYPE_SOCKET, ROAR_VIO_DEF_TYPE_FH, ROAR_VIO_DEF_TYPE_SOCKETFH,
+       ROAR_VIO_DEF_TYPE_EOL}},
+ {ROAR_VIO_DSTR_OBJT_EOL, NULL, {ROAR_VIO_DEF_TYPE_EOL}}
+};
+
+int     roar_vio_dstr_get_type(char * str) {
+ int i;
+
+ for (i = 0; _roar_vio_dstr_objs[i].id != ROAR_VIO_DSTR_OBJT_EOL; i++) {
+  if ( strcasecmp(_roar_vio_dstr_objs[i].name, str) == 0 )
+   return _roar_vio_dstr_objs[i].id;
+ }
+
+ return -1;
+}
+
+char *  roar_vio_dstr_get_name(int type) {
+ int i;
+
+ for (i = 0; _roar_vio_dstr_objs[i].id != ROAR_VIO_DSTR_OBJT_EOL; i++) {
+  if ( _roar_vio_dstr_objs[i].id == type )
+   return _roar_vio_dstr_objs[i].name;
+ }
+
+ return NULL;
+}
+
+int     roar_vio_dstr_init_defaults (struct roar_vio_defaults * def, int type, int o_flags, mode_t o_mode) {
+ if ( def == NULL )
+  return -1;
+
+ memset(def, 0, sizeof(struct roar_vio_defaults));
+
+ def->type    = type;
+ def->o_flags = o_flags;
+ def->o_mode  = o_mode;
+
+ return 0;
+}
+
+int     roar_vio_open_dstr    (struct roar_vio_calls * calls, char * dstr, struct roar_vio_defaults * def, int dnum) {
+ return roar_vio_open_dstr_vio(calls, dstr, def, dnum, NULL);
+}
+
+#define _ret(x) free(dstr); return (x)
+
+int     roar_vio_open_dstr_vio(struct roar_vio_calls * calls,
+                               char * dstr, struct roar_vio_defaults * def, int dnum,
+                               struct roar_vio_calls * vio) {
+ char * next;
+ char * this;
+ char * name;
+ char * opts;
+ char * dst;
+ char * c;
+ int    inopts;
+ int    type;
+
+ if ( calls == NULL || dstr == NULL )
+  return -1;
+
+ if ( dnum != 0 && def == NULL )
+  return -1;
+
+ if ( dnum > 1 )
+  return -1;
+
+ if ( (dstr = strdup(dstr)) == NULL )
+  return -1;
+
+ next = dstr;
+
+ while (next != NULL) {
+  this = next;
+  next = strstr(next, "##");
+
+  if (next != NULL) {
+   *next = 0;
+   next += 2;
+  }
+
+  // we have the current token in 'this'.
+
+  opts   = NULL;
+  dst    = NULL;
+
+  if ( strstr(this, ":") != NULL ) {
+   name   = this;
+   inopts = 0;
+   for (c = this; *c != 0; c++) {
+    if ( *c == '[' ) {
+     *c     = 0;
+     opts   = c + 1;
+     inopts = 1;
+    } else if ( *c == ']' &&  inopts ) {
+     *c     = 0;
+     inopts = 0;
+    } else if ( *c == ':' && !inopts ) {
+     *c     = 0;
+     dst    = *(c+1) == 0 ? NULL : c + 1;
+     break;
+    }
+   }
+  } else {
+   // we need to guess that this is here...
+   // currently we guess this is a file in all cases
+   name = "file";
+   dst  = this;
+  }
+
+  ROAR_WARN("roar_vio_open_dstr_vio(*): name='%s', opts='%s', dst='%s'", name, opts, dst);
+
+  if ( (type = roar_vio_dstr_get_type(name)) == -1 ) {
+   _ret(-1);
+  }
+
+  ROAR_WARN("roar_vio_open_dstr_vio(*): type=0x%.4x(%s)", type, roar_vio_dstr_get_name(type));
+
+ }
+
+ _ret(-1);
+}
+
 //ll
