| 1 |
#include <stdio.h> |
| 2 |
#include <string.h> |
| 3 |
#include <stdarg.h> |
| 4 |
#include "cstring.h" |
| 5 |
#include "markdown.h" |
| 6 |
#include "amalloc.h" |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
void |
| 12 |
Csputc(int c, Cstring *iot) |
| 13 |
{ |
| 14 |
EXPAND(*iot) = c; |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
int |
| 21 |
Csprintf(Cstring *iot, char *fmt, ...) |
| 22 |
{ |
| 23 |
va_list ptr; |
| 24 |
int siz=100; |
| 25 |
|
| 26 |
do { |
| 27 |
RESERVE(*iot, siz); |
| 28 |
va_start(ptr, fmt); |
| 29 |
siz = vsnprintf(T(*iot)+S(*iot), ALLOCATED(*iot)-S(*iot), fmt, ptr); |
| 30 |
va_end(ptr); |
| 31 |
} while ( siz > (ALLOCATED(*iot)-S(*iot)) ); |
| 32 |
|
| 33 |
S(*iot) += siz; |
| 34 |
return siz; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
int |
| 41 |
Cswrite(Cstring *iot, char *bfr, int size) |
| 42 |
{ |
| 43 |
RESERVE(*iot, size); |
| 44 |
memcpy(T(*iot)+S(*iot), bfr, size); |
| 45 |
S(*iot) += size; |
| 46 |
return size; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
void |
| 53 |
Csreparse(Cstring *iot, char *buf, int size, mkd_flag_t flags) |
| 54 |
{ |
| 55 |
MMIOT f; |
| 56 |
___mkd_initmmiot(&f, 0); |
| 57 |
___mkd_reparse(buf, size, flags, &f, 0); |
| 58 |
___mkd_emblock(&f); |
| 59 |
SUFFIX(*iot, T(f.out), S(f.out)); |
| 60 |
___mkd_freemmiot(&f, 0); |
| 61 |
} |