static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) { char *out; int rlen; if (__plugin_open (io, pathname, 0)) { RIOBind iob; RIOBfdbg *mal = R_NEW0 (RIOBfdbg); r_io_bind (io, &iob); mal->fd = getmalfd (mal); mal->bfvm = bfvm_new (&iob); out = r_file_slurp (pathname+8, &rlen); if (!out || rlen < 1) { free (mal); free (out); return NULL; } mal->size = rlen; mal->buf = malloc (mal->size+1); if (mal->buf != NULL) { memcpy (mal->buf, out, rlen); free (out); return r_io_desc_new (&r_io_plugin_bfdbg, mal->fd, pathname, rw, mode, mal); } eprintf ("Cannot allocate (%s) %d bytes\n", pathname+9, mal->size); free (mal); free (out); } return NULL; }
static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) { char *out; int rlen, code; if (__plugin_open (io, pathname, 0)) { out = r_socket_http_get (pathname, &code, &rlen); if (out && rlen>0) { RIOMalloc *mal = R_NEW0 (RIOMalloc); if (!mal) return NULL; mal->size = rlen; mal->buf = malloc (mal->size+1); if (!mal->buf) { free (mal); return NULL; } if (mal->buf != NULL) { mal->fd = getmalfd (mal); memcpy (mal->buf, out, mal->size); free (out); return r_io_desc_new (io, &r_io_plugin_http, pathname, rw, mode, mal); } eprintf ("Cannot allocate (%s) %d bytes\n", pathname+9, mal->size); free (mal); } free (out); } return NULL; }
static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) { char *out; int rlen, code; if (__plugin_open (io, pathname, 0)) { RIOR2Web *mal = R_NEW0 (RIOR2Web); if (!mal) return NULL; char *url = r_str_newf ("http://%s/?V", pathname+8); //eprintf ("URL:(%s)\n", url); out = r_socket_http_get (url, &code, &rlen); //eprintf ("RES %d %d\n", code, rlen); //eprintf ("OUT(%s)\n", out); if (out && rlen>0) { mal->fd = getmalfd (mal); mal->url = r_str_newf ("http://%s", pathname+8); free (out); free (url); return r_io_desc_new (&r_io_plugin_r2web, mal->fd, pathname, rw, mode, mal); } free (url); free (mal); free (out); } return NULL; }