summaryrefslogtreecommitdiffstats
path: root/system_part.c
diff options
context:
space:
mode:
authorGalin Simeonov <gts@volconst.com>2021-09-26 23:45:45 +0300
committerGalin Simeonov <gts@volconst.com>2021-09-26 23:45:45 +0300
commitb24710fdd33599b83020d92b99961da36655cc4f (patch)
tree99b45bebffe713bac3863287f9833c32b38f8506 /system_part.c
parent2057bf1eb5aaf0a9fea2beb8083a3052936b34ea (diff)
downloadvolgit-b24710fdd33599b83020d92b99961da36655cc4f.tar.gz
added html struff
Diffstat (limited to 'system_part.c')
-rw-r--r--system_part.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/system_part.c b/system_part.c
index 526f9be..f3ef526 100644
--- a/system_part.c
+++ b/system_part.c
@@ -77,11 +77,34 @@ int create_branch_dir(const char *branch_name)
FILE* create_file(int branch_dir,const char *filename)
{
int fd;
- unlinkat(branch_dir,filename,0);
- fd=openat(branch_dir,filename,O_CREAT|O_RDWR,0660);
+ char *new_filename;
+ size_t old_filename_len;
+ FILE *ret;
+
+ old_filename_len=strlen(filename);
+ new_filename=calloc(old_filename_len+sizeof(".html"),1);
+ if(new_filename==NULL)
+ die("Ran out of memory!\n");
+
+ memcpy(new_filename,filename,old_filename_len);
+ memcpy(new_filename+old_filename_len,".html",sizeof(".html"));
+
+ unlinkat(branch_dir,new_filename,0);
+ fd=openat(branch_dir,new_filename,O_CREAT|O_RDWR,0660);
if(fd==-1)
die("Could not open the file '%s' for one of the branches\n",filename);
- return fdopen(fd,"w");
+
+ free(new_filename);
+
+ ret=fdopen(fd,"w");
+
+ fprintf(ret,"%s",options.header);
+ return ret;
+}
+void close_file(FILE *file)
+{
+ fprintf(file,"%s",options.footer);
+ fclose(file);
}
int create_dir(int base_dir,const char *dir_name)
{
@@ -105,4 +128,12 @@ void die(const char *format, ...)
vfprintf(stderr,format,args);
exit(1);
}
+void push_html_link_for_blob(FILE *out,const char *filename,const char *oid)
+{
+ fprintf(out,"<a href=\"%s.html\" class=\"blob_entry\">%s</a>\n",oid,filename);
+}
+void push_html_link_for_tree(FILE *out,const char *filename,const char *oid)
+{
+ fprintf(out,"<a href=\"%s/index.html\" class=\"tree_entry\">%s</a>\n",oid,filename);
+}
#endif