]> git.cameronkatri.com Git - cgit.git/blobdiff - html.c
Use mode 0644 for non-executable files
[cgit.git] / html.c
diff --git a/html.c b/html.c
index 1237076b32702fb8bee99672746c31e82752bd69..d7d9fd7007ff764c17ead46f23f00eaf44ade142 100644 (file)
--- a/html.c
+++ b/html.c
@@ -35,6 +35,11 @@ char *fmt(const char *format, ...)
        return buf[bufidx];
 }
 
+void html_raw(const char *data, size_t size)
+{
+       write(htmlfd, data, size);
+}
+
 void html(const char *txt)
 {
        write(htmlfd, txt, strlen(txt));
@@ -51,9 +56,9 @@ void htmlf(const char *format, ...)
        html(buf);
 }
 
-void html_status(int code, int more_headers)
+void html_status(int code, const char *msg, int more_headers)
 {
-       htmlf("Status: %d\n", code);
+       htmlf("Status: %d %s\n", code, msg);
        if (!more_headers)
                html("\n");
 }
@@ -123,6 +128,38 @@ void html_attr(char *txt)
                html(txt);
 }
 
+void html_url_path(char *txt)
+{
+       char *t = txt;
+       while(t && *t){
+               int c = *t;
+               if (c=='"' || c=='#' || c=='\'' || c=='?') {
+                       write(htmlfd, txt, t - txt);
+                       write(htmlfd, fmt("%%%2x", c), 3);
+                       txt = t+1;
+               }
+               t++;
+       }
+       if (t!=txt)
+               html(txt);
+}
+
+void html_url_arg(char *txt)
+{
+       char *t = txt;
+       while(t && *t){
+               int c = *t;
+               if (c=='"' || c=='#' || c=='%' || c=='&' || c=='\'' || c=='+' || c=='?') {
+                       write(htmlfd, txt, t - txt);
+                       write(htmlfd, fmt("%%%2x", c), 3);
+                       txt = t+1;
+               }
+               t++;
+       }
+       if (t!=txt)
+               html(txt);
+}
+
 void html_hidden(char *name, char *value)
 {
        html("<input type='hidden' name='");