int main(int argc, char *argv[]) { quark_t *qrk = quark_new(); int qid = 0; qid = quark_get(qrk, "zero"); qid = quark_get(qrk, "one"); qid = quark_get(qrk, "zero"); qid = quark_to_id(qrk, "three"); qid = quark_get(qrk, "two"); qid = quark_get(qrk, "three"); qid = quark_to_id(qrk, "three"); qid = quark_get(qrk, "zero"); qid = quark_get(qrk, "one"); printf("%s\n", quark_to_string(qrk, 0)); printf("%s\n", quark_to_string(qrk, 1)); printf("%s\n", quark_to_string(qrk, 2)); printf("%s\n", quark_to_string(qrk, 3)); quark_delete(qrk); return 0; }
int crf_dictionary_create_instance(const char *interface, void **ptr) { if (strcmp(interface, "dictionary") == 0) { crf_dictionary_t* dic = (crf_dictionary_t*)calloc(1, sizeof(crf_dictionary_t)); if (dic != NULL) { dic->internal = quark_new(); dic->nref = 1; dic->addref = dictionary_addref; dic->release = dictionary_release; dic->get = dictionary_get; dic->to_id = dictionary_to_id; dic->to_string = dictionary_to_string; dic->num = dictionary_num; dic->free = dictionary_free; *ptr = dic; return 0; } else { return -1; } } else { return 1; } }