gitout

A static git page generator
git clone https://git.bracken.jp/gitout.git
Log | Files | Refs | Submodules | README | LICENSE

index_writer.c (1230B)


      1 #include "writer/html/index_writer.h"
      2 
      3 #include <stdio.h>
      4 #include <stdlib.h>
      5 
      6 #include "git/repo.h"
      7 #include "utils.h"
      8 #include "writer/html/repo_index.h"
      9 
     10 struct HtmlIndexWriter {
     11   HtmlRepoIndex* index;
     12 };
     13 
     14 HtmlIndexWriter* html_indexwriter_create() {
     15   HtmlIndexWriter* writer = ecalloc(1, sizeof(HtmlIndexWriter));
     16   FILE* out = stdout;
     17   writer->index = html_repoindex_create(out);
     18   return writer;
     19 }
     20 
     21 void html_indexwriter_free(HtmlIndexWriter* writer) {
     22   if (!writer) {
     23     return;
     24   }
     25   html_repoindex_free(writer->index);
     26   writer->index = NULL;
     27   free(writer);
     28 }
     29 
     30 void html_indexwriter_set_me_url(void* writer, const char* url) {
     31   HtmlIndexWriter* html_writer = (HtmlIndexWriter*)writer;
     32   html_repoindex_set_me_url(html_writer->index, url);
     33 }
     34 
     35 void html_indexwriter_begin(void* writer) {
     36   HtmlIndexWriter* html_writer = (HtmlIndexWriter*)writer;
     37   html_repoindex_begin(html_writer->index);
     38 }
     39 
     40 void html_indexwriter_add_repo(void* writer, GitRepo* repo) {
     41   HtmlIndexWriter* html_writer = (HtmlIndexWriter*)writer;
     42   html_repoindex_add_repo(html_writer->index, repo);
     43 }
     44 
     45 void html_indexwriter_end(void* writer) {
     46   HtmlIndexWriter* html_writer = (HtmlIndexWriter*)writer;
     47   html_repoindex_end(html_writer->index);
     48 }