Exemplo n.º 1
0
/* qrk_save:
 *   Save list of keys present in the map object in the id order to the given
 *   file. We put one key per line so, if no key contains a new line, the line
 *   number correspond to the id.
 */
void qrk_save(const qrk_t *qrk, FILE *file) {
    if (fprintf(file, "#qrk#%"PRIu64"\n", qrk->count) < 0)
        pfatal("cannot write to file");
    if (qrk->count == 0)
        return;
    for (uint64_t n = 0; n < qrk->count; n++)
        ns_writestr(file, qrk->leafs[n]->key);
}
Exemplo n.º 2
0
/* rdr_save:
 *   Save the reader to the given file so it can be loaded back. The save format
 *   is plain text and portable accros computers.
 */
void rdr_save(const rdr_t *rdr, FILE *file) {
	if (fprintf(file, "#rdr#%"PRIu32"/%"PRIu32"/%d\n",
			rdr->npats, rdr->ntoks, rdr->autouni) < 0)
		pfatal("cannot write to file");
	for (uint32_t p = 0; p < rdr->npats; p++)
		ns_writestr(file, rdr->pats[p]->src);
	qrk_save(rdr->lbl, file);
	qrk_save(rdr->obs, file);
}