summaryrefslogtreecommitdiffstats
path: root/system_part.c
diff options
context:
space:
mode:
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