X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/25105d7ecaba474d4b7c364ebb586aac3dfc5abb..dc3ac3f76077c5d612d42e8beb4878e43acfc58a:/html.c
diff --git a/html.c b/html.c
index bf1490f..33a956f 100644
--- a/html.c
+++ b/html.c
@@ -1,3 +1,11 @@
+/* html.c: helper functions for html output
+ *
+ * Copyright (C) 2006 Lars Hjemli
+ *
+ * Licensed under GNU General Public License v2
+ * (see COPYING for full license text)
+ */
+
#include "cgit.h"
char *fmt(const char *format, ...)
@@ -37,7 +45,7 @@ void htmlf(const char *format, ...)
void html_txt(char *txt)
{
char *t = txt;
- while(*t){
+ while(t && *t){
int c = *t;
if (c=='<' || c=='>' || c=='&') {
*t = '\0';
@@ -57,11 +65,39 @@ void html_txt(char *txt)
html(txt);
}
+void html_ntxt(int len, char *txt)
+{
+ char *t = txt;
+ while(t && *t && len--){
+ int c = *t;
+ if (c=='<' || c=='>' || c=='&') {
+ *t = '\0';
+ html(txt);
+ *t = c;
+ if (c=='>')
+ html(">");
+ else if (c=='<')
+ html("<");
+ else if (c=='&')
+ html("&");
+ txt = t+1;
+ }
+ t++;
+ }
+ if (t!=txt) {
+ char c = *t;
+ *t = '\0';
+ html(txt);
+ *t = c;
+ }
+ if (len<0)
+ html("...");
+}
void html_attr(char *txt)
{
char *t = txt;
- while(*t){
+ while(t && *t){
int c = *t;
if (c=='<' || c=='>' || c=='\'') {
*t = '\0';
@@ -81,6 +117,15 @@ void html_attr(char *txt)
html(txt);
}
+void html_hidden(char *name, char *value)
+{
+ html("");
+}
+
void html_link_open(char *url, char *title, char *class)
{
html("> 6);
+ html_fileperm(mode >> 3);
+ html_fileperm(mode);
+}
+
+int html_include(const char *filename)
+{
+ FILE *f;
+ char buf[4096];
+ size_t len;
+
+ if (!(f = fopen(filename, "r")))
+ return -1;
+ while((len = fread(buf, 1, 4096, f)) > 0)
+ write(htmlfd, buf, len);
+ fclose(f);
+ return 0;
+}