aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cgit.h8
-rw-r--r--parsing.c47
2 files changed, 55 insertions, 0 deletions
diff --git a/cgit.h b/cgit.h
index 5e19b11..9b517a7 100644
--- a/cgit.h
+++ b/cgit.h
@@ -27,6 +27,13 @@ struct commitinfo {
27 char *msg; 27 char *msg;
28}; 28};
29 29
30struct taginfo {
31 char *tagger;
32 char *tagger_email;
33 int tagger_date;
34 char *msg;
35};
36
30extern const char cgit_version[]; 37extern const char cgit_version[];
31 38
32extern char *cgit_root; 39extern char *cgit_root;
@@ -87,6 +94,7 @@ extern void html_filemode(unsigned short mode);
87extern int cgit_read_config(const char *filename, configfn fn); 94extern int cgit_read_config(const char *filename, configfn fn);
88extern int cgit_parse_query(char *txt, configfn fn); 95extern int cgit_parse_query(char *txt, configfn fn);
89extern struct commitinfo *cgit_parse_commit(struct commit *commit); 96extern struct commitinfo *cgit_parse_commit(struct commit *commit);
97extern struct taginfo *cgit_parse_tag(struct tag *tag);
90 98
91extern char *cache_safe_filename(const char *unsafe); 99extern char *cache_safe_filename(const char *unsafe);
92extern int cache_lock(struct cacheitem *item); 100extern int cache_lock(struct cacheitem *item);
diff --git a/parsing.c b/parsing.c
index 4412dee..8aad1dd 100644
--- a/parsing.c
+++ b/parsing.c
@@ -196,3 +196,50 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
196 } 196 }
197 return ret; 197 return ret;
198} 198}
199
200
201struct taginfo *cgit_parse_tag(struct tag *tag)
202{
203 void *data;
204 char type[20];
205 unsigned long size;
206 char *p, *t;
207 struct taginfo *ret;
208
209 data = read_sha1_file(tag->object.sha1, type, &size);
210 if (!data || strcmp(type, tag_type)) {
211 free(data);
212 return 0;
213 }
214
215 ret = xmalloc(sizeof(*ret));
216 ret->tagger = NULL;
217 ret->tagger_email = NULL;
218 ret->tagger_date = 0;
219 ret->msg = NULL;
220
221 p = data;
222
223 while (p) {
224 if (*p == '\n')
225 break;
226
227 if (!strncmp(p, "tagger ", 7)) {
228 p += 7;
229 t = strchr(p, '<') - 1;
230 ret->tagger = substr(p, t);
231 p = t;
232 t = strchr(t, '>') + 1;
233 ret->tagger_email = substr(p, t);
234 ret->tagger_date = atol(++t);
235 }
236 p = strchr(p, '\n') + 1;
237 }
238
239 while (p && (*p == '\n'))
240 p = strchr(p, '\n') + 1;
241 if (p)
242 ret->msg = xstrdup(p);
243 free(data);
244 return ret;
245}