aboutsummaryrefslogtreecommitdiff
path: root/src/pms_ref.h
blob: d0da38ba3f85e87968d4af590bd7fb5bc5a42e78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef PMS_REF_H
#define PMS_REF_H

#include <regex.h>
#include <stdbool.h>

#define PMS_REF_SEARCH 1
#define PMS_REF_EXACT 2
#define PMS_REF_EXACT_SET 3
#define PMS_REF_RANGE 4
#define PMS_REF_RANGE_EXT 5

#define PMS_MAX_VERSE_SET 64

typedef struct pms_ref {
    int type;
    unsigned int book;
    unsigned int chapter;
    unsigned int chapter_end;
    unsigned int verse;
    unsigned int verse_end;
    unsigned int verse_set[PMS_MAX_VERSE_SET];
    int verse_set_count;
    char *search_str;
    regex_t search;
} pms_ref;

pms_ref *pms_newref(void);
void pms_freeref(pms_ref *ref);

/* Match a book name, abbreviation, or modern alias to book number (1..73), or 0 if not found. */
int pms_book_from_name(const char *name);

/* Parse a reference string (e.g. "Gn 1:1-5", "1Rs:3:16", "/principio", "Jo 1 /luz") into ref. Returns 0 on success. */
int pms_parse_ref(const char *input, pms_ref *ref);

#endif /* PMS_REF_H */