ui/common/url: Add pb_url_scheme_name
authorJeremy Kerr <jk@ozlabs.org>
Wed, 6 Mar 2013 05:42:15 +0000 (13:42 +0800)
committerGeoff Levand <geoff@infradead.org>
Wed, 6 Mar 2013 14:06:26 +0000 (06:06 -0800)
Add a function to lookup the name of a scheme, for more useful URL
output.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Geoff Levand <geoff@infradead.org>
ui/common/url.c
ui/common/url.h

index 3e7b3840803e545e3ae35971beed8e9f0151c36f..3e6c8dacc19816df8b45ce158bac948a0d214fc0 100644 (file)
@@ -197,3 +197,14 @@ fail:
        talloc_free(url);
        return NULL;
 }
+
+const char *pb_url_scheme_name(enum pb_url_scheme scheme)
+{
+       unsigned int i;
+
+       for (i = 0; i < sizeof(schemes) / sizeof(schemes[0]); i++)
+               if (schemes[i].scheme == scheme)
+                       return schemes[i].str;
+
+       return NULL;
+}
index a966dc720574c938d96a0ed4497c30d4396db573..3cb7cd876b0ac228c8c76570944eb4c4ef116ffa 100644 (file)
@@ -60,4 +60,6 @@ struct pb_url {
 
 struct pb_url *pb_url_parse(void *ctx, const char *url_str);
 
+const char *pb_url_scheme_name(enum pb_url_scheme scheme);
+
 #endif