gitout

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

index_writer.c (1108B)


      1 #include "writer/gopher/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/gopher/repo_index.h"
      9 
     10 struct GopherIndexWriter {
     11   GopherRepoIndex* index;
     12 };
     13 
     14 GopherIndexWriter* gopher_indexwriter_create() {
     15   GopherIndexWriter* writer = ecalloc(1, sizeof(GopherIndexWriter));
     16   FILE* out = stdout;
     17   writer->index = gopher_repoindex_create(out);
     18   return writer;
     19 }
     20 
     21 void gopher_indexwriter_free(GopherIndexWriter* writer) {
     22   if (!writer) {
     23     return;
     24   }
     25   gopher_repoindex_free(writer->index);
     26   writer->index = NULL;
     27   free(writer);
     28 }
     29 
     30 void gopher_indexwriter_begin(void* writer) {
     31   GopherIndexWriter* gopher_writer = (GopherIndexWriter*)writer;
     32   gopher_repoindex_begin(gopher_writer->index);
     33 }
     34 
     35 void gopher_indexwriter_add_repo(void* writer, GitRepo* repo) {
     36   GopherIndexWriter* gopher_writer = (GopherIndexWriter*)writer;
     37   gopher_repoindex_add_repo(gopher_writer->index, repo);
     38 }
     39 
     40 void gopher_indexwriter_end(void* writer) {
     41   GopherIndexWriter* gopher_writer = (GopherIndexWriter*)writer;
     42   gopher_repoindex_end(gopher_writer->index);
     43 }