static void tcc_split_path(TCCState *s, void ***p_ary, int *p_nb_ary, const char *in) { const char *p; do { int c; CString str; cstr_new (&str); for (p = in; c = *p, c != '\0' && c != PATHSEP; ++p) { if (c == '{' && p[1] && p[2] == '}') { c = p[1], p += 2; if (c == 'B') { cstr_cat (&str, s->tcc_lib_path); } } else { cstr_ccat (&str, c); } } cstr_ccat (&str, '\0'); dynarray_add (p_ary, p_nb_ary, str.data); in = p + 1; } while (*p); }
void *parse(void *data) { json_ctx *ctx; char *ptr; char *p = (char*)data; int j; ctx = json_ctx_new(); cstr path = cstr_create(128); ptr = rindex(p, '/'); if(ptr != NULL) { cstr_ncat(path, p, ptr - p); cstr_cat_char(path, '/'); } cstr_cat(path, "test1.json"); FILE *f = fopen(path,"r"); j = json_parse_file(ctx, f); printf("parse file result: %d\n", j); if(j) printf("error:%s, line:%d col:%d token:%s\n", ctx->err, ctx->lineno, ctx->colno ,ctx->token); fclose(f); cstr_free(path); json_ctx_free(ctx); return NULL; }