Debian Codegraph @

ext/docheader.c

raw symbols SCIP
1 /*
2 * docheader -- get values from the document header
3 *
4 * Copyright (C) 2007 David L Parsons.
5 * The redistribution terms are provided in the COPYRIGHT file that must
6 * be distributed with this source code.
7 */
8 #include "config.h"
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <ctype.h>
12
13 #include "cstring.h"
14 #include "markdown.h"
15 #include "amalloc.h"
16
17 static char *
18 onlyifset(Line *l)
19 {
20 char *ret;
21
22 if ( l->dle < 0 || l->dle >= S(l->text) )
23 return 0;
24
25 ret = T(l->text) + l->dle;
26
27 return ret[0] ? ret : 0;
28 }
29
30 char *
31 mkd_doc_title(Document *doc)
32 {
33 if ( doc && doc->title )
34 return onlyifset(doc->title);
35 return 0;
36 }
37
38
39 char *
40 mkd_doc_author(Document *doc)
41 {
42 if ( doc && doc->author )
43 return onlyifset(doc->author);
44 return 0;
45 }
46
47
48 char *
49 mkd_doc_date(Document *doc)
50 {
51 if ( doc && doc->date )
52 return onlyifset(doc->date);
53 return 0;
54 }