diff options
-rw-r--r-- | buf.c | 2 | ||||
-rw-r--r-- | buf.h | 2 | ||||
-rw-r--r-- | doc.c | 5 | ||||
-rw-r--r-- | doc.h | 3 |
4 files changed, 10 insertions, 2 deletions
diff --git a/buf.c b/buf.c index 8460631..fb3af82 100644 --- a/buf.c +++ b/buf.c @@ -25,7 +25,7 @@ void buf_grow(buf_t *b, size_t n) { } } -void buf_cat(buf_t *b, char *src, size_t n) { +void buf_cat(buf_t *b, const char *src, size_t n) { buf_grow(b, n); memcpy(&b->buf[b->sz], src, n); b->sz += n; diff --git a/buf.h b/buf.h index c275f9c..59c521b 100644 --- a/buf.h +++ b/buf.h @@ -12,7 +12,7 @@ void buf_init(buf_t *, size_t); void buf_grow(buf_t *, size_t); void buf_free(buf_t *); -void buf_cat(buf_t *b, char *src, size_t n); +void buf_cat(buf_t *b, const char *src, size_t n); void buf_catc(buf_t *b, char c); #endif diff --git a/doc.c b/doc.c index 3d1b378..3f63ba8 100644 --- a/doc.c +++ b/doc.c @@ -54,6 +54,11 @@ void doc_add_textn(struct doc *d, const char *s, size_t n) { dl->len += n; } +unsigned short doc_add_link(struct doc *d, const char *url) { + buf_cat(&d->lnk, url, strlen(url) + 1); + return d->linkc++; +} + /* line navigation */ struct doc_line *doc_line_at(struct doc *d, size_t ofs) { diff --git a/doc.h b/doc.h index 01a8235..ea9a521 100644 --- a/doc.h +++ b/doc.h @@ -20,6 +20,7 @@ enum doc_type { struct doc { buf_t txt, lnk; size_t latest; + unsigned short linkc; }; void doc_init(struct doc *); @@ -34,4 +35,6 @@ struct doc_line *doc_line_at(struct doc *d, size_t ofs); int doc_line_prev(struct doc *d, size_t *ofs); int doc_line_next(struct doc *d, size_t *ofs); +unsigned short doc_add_link(struct doc *d, const char *url); + #endif |