X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=input.cpp;h=81bc2dc4ea4d396ce6d9d7855b211919aff878e4;hp=b434eedfe1307cc8bd51dfca83ab38dfda9f4f9b;hb=0229f4414b3b63934c057030deb88cbf6926bb1f;hpb=a0fe013448d188b324c00383cfd91695d9d3d076 diff --git a/input.cpp b/input.cpp index b434eed..81bc2dc 100644 --- a/input.cpp +++ b/input.cpp @@ -30,6 +30,13 @@ void split_user_host(const string &user_host, string *user, string *host) // Extremely rudimentary URL parsing. bool parse_url(const string &url, string *protocol, string *user, string *host, string *port, string *path) { + // pipe:foo (or pipe:"foo"). + if (url.find("pipe:") == 0) { + *protocol = "pipe"; + *path = string(url.begin() + 5, url.end()); + return true; + } + size_t split = url.find("://"); if (split == string::npos) { return false; @@ -100,11 +107,11 @@ Input *create_input(const string &url, Input::Encoding encoding) if (!parse_url(url, &protocol, &user, &host, &port, &path)) { return nullptr; } - if (protocol == "http") { + if (protocol == "http" || protocol == "pipe") { return new HTTPInput(url, encoding); } if (protocol == "udp") { - // encoding is ignored; it's never Metacube. + assert(encoding == Input::INPUT_ENCODING_RAW); return new UDPInput(url); } return nullptr; @@ -116,7 +123,7 @@ Input *create_input(const InputProto &serialized) if (!parse_url(serialized.url(), &protocol, &user, &host, &port, &path)) { return nullptr; } - if (protocol == "http") { + if (protocol == "http" || protocol == "pipe") { return new HTTPInput(serialized); } if (protocol == "udp") {