Get back in sync with json-pull

This commit is contained in:
Eric Fischer 2015-06-03 11:31:41 -07:00
parent fd60cc6600
commit b70d19288e
2 changed files with 9 additions and 19 deletions

View File

@ -58,29 +58,22 @@ json_pull *json_begin_file(FILE *f) {
return json_begin(read_file, f);
}
#if 0
static int read_string(json_pull *j) {
static int read_string(json_pull *j, char *buffer, int n) {
char *cp = j->source;
if (*cp == '\0') {
return EOF;
}
int c = (unsigned char) *cp;
j->source = cp + 1;
return c;
}
int out = 0;
static int peek_string(json_pull *p) {
char *cp = p->source;
if (*cp == '\0') {
return EOF;
while (out < n && cp[out] != '\0') {
buffer[out] = cp[out];
out++;
}
return (unsigned char) *cp;
j->source = cp + out;
return out;
}
json_pull *json_begin_string(char *s) {
return json_begin(read_string, peek_string, s);
return json_begin(read_string, s);
}
#endif
void json_end(json_pull *p) {
free(p->buffer);

View File

@ -48,10 +48,7 @@ typedef struct json_pull {
} json_pull;
json_pull *json_begin_file(FILE *f);
#if 0
json_pull *json_begin_string(char *s);
#endif
json_pull *json_begin(int (*read)(struct json_pull *, char *buffer, int n), void *source);
void json_end(json_pull *p);