void cb_main_kniha(int kniha) { int comment; char *s; int h, v, id; char* meno = GETSTR(KNIHA[kniha].meno); printf("\n\n<a name=\"%s\">\n", meno); init_search(meno); add_search(1, 1, -1, -1); do_search(); h = 0; v = 0; while (get_result_id(&comment, &s, &id)) { if (!comment) { while (1) { // normalize h / v while (1) { if (h < 0 || h >= KNIHA[kniha].n_hlav) { h = -1; break; } else if (v >= GETPTR(hlava, KNIHA[kniha].hlava)[h].n_versov) { v = 0; h++; } else break; } if (h >= 0 && GETPTR(vers, (GETPTR(hlava, KNIHA[kniha].hlava)[h].vers))[v].min <= id) { printf("<a name=\"%s%d,%d\">\n", meno, h + 1, v + 1); v++; } else break; } TranslateLinksAndPrint(s); printf("\n"); } else { printf("<span id=\"e%d\" ", html_id); printf("class=\"komentar\">("); TranslateLinksAndPrint(s); printf(")</span>\n"); html_id++; } } }
/*% parses a file and fills in the data structure. */ isc_result_t irs_resconf_load(isc_mem_t *mctx, const char *filename, irs_resconf_t **confp) { FILE *fp = NULL; char word[256]; isc_result_t rval, ret = ISC_R_SUCCESS; irs_resconf_t *conf; int i, stopchar; REQUIRE(mctx != NULL); REQUIRE(filename != NULL); REQUIRE(strlen(filename) > 0U); REQUIRE(confp != NULL && *confp == NULL); conf = isc_mem_get(mctx, sizeof(*conf)); if (conf == NULL) return (ISC_R_NOMEMORY); conf->mctx = mctx; ISC_LIST_INIT(conf->nameservers); conf->numns = 0; conf->domainname = NULL; conf->searchnxt = 0; conf->resdebug = 0; conf->ndots = 1; for (i = 0; i < RESCONFMAXSEARCH; i++) conf->search[i] = NULL; errno = 0; if ((fp = fopen(filename, "r")) != NULL) { do { stopchar = getword(fp, word, sizeof(word)); if (stopchar == EOF) { rval = ISC_R_SUCCESS; POST(rval); break; } if (strlen(word) == 0U) rval = ISC_R_SUCCESS; else if (strcmp(word, "nameserver") == 0) rval = resconf_parsenameserver(conf, fp); else if (strcmp(word, "domain") == 0) rval = resconf_parsedomain(conf, fp); else if (strcmp(word, "search") == 0) rval = resconf_parsesearch(conf, fp); else if (strcmp(word, "sortlist") == 0) rval = resconf_parsesortlist(conf, fp); else if (strcmp(word, "options") == 0) rval = resconf_parseoption(conf, fp); else { /* unrecognised word. Ignore entire line */ rval = ISC_R_SUCCESS; stopchar = eatline(fp); if (stopchar == EOF) { break; } } if (ret == ISC_R_SUCCESS && rval != ISC_R_SUCCESS) ret = rval; } while (1); fclose(fp); } else { switch (errno) { case ENOENT: break; default: isc_mem_put(mctx, conf, sizeof(*conf)); return (ISC_R_INVALIDFILE); } } /* If we don't find a nameserver fall back to localhost */ if (conf->numns == 0) { INSIST(ISC_LIST_EMPTY(conf->nameservers)); /* XXX: should we catch errors? */ (void)add_server(conf->mctx, "127.0.0.1", &conf->nameservers); (void)add_server(conf->mctx, "::1", &conf->nameservers); } /* * Construct unified search list from domain or configured * search list */ ISC_LIST_INIT(conf->searchlist); if (conf->domainname != NULL) { ret = add_search(conf, conf->domainname); } else if (conf->searchnxt > 0) { for (i = 0; i < conf->searchnxt; i++) { ret = add_search(conf, conf->search[i]); if (ret != ISC_R_SUCCESS) break; } } conf->magic = IRS_RESCONF_MAGIC; if (ret != ISC_R_SUCCESS) irs_resconf_destroy(&conf); else { if (fp == NULL) ret = ISC_R_FILENOTFOUND; *confp = conf; } return (ret); }
void Print(struct casti *_c) { char *k, *s; int vb, ve, hb, he, comment; struct casti *c; static struct strbuf q; Rst(&q); //nepekne: spoliehame sa, ze vsetko je z jednej knihy if (!_c) return; k = check_book(_c->k); if (!k) return; init_search(k); hb=vb=-1; he=ve=-1; for (c=_c; c!=NULL; c=c->n) { if (c->h!=-1) { hb = c->h; vb=-1; } if (c->v!=-1) vb = c->v; ve = vb; he = hb; if (c->range && c->n) { c=c->n; if (c->h!=-1) he = c->h; if (c->v!=-1) ve = c->v; } if (hb==-1) { hb = vb; vb = -1; } if (he==-1) { he = ve; ve = -1; } // zapiseme do kontextu if (first.h==-1) { first.h=hb; first.k=k; } if (hb!=kontext_last_hb || he!=kontext_last_he) { if (hb!=he) Prn(&kontext, ";%s%d-%d", k, hb,he); else Prn(&kontext, ";%s%d", k, hb); kontext_last_hb = hb; kontext_last_he = he; } add_search(hb,vb,he,ve); vb = ve; hb = he; } last.h = kontext_last_he; last.k = k; do_search(); while (get_result(&comment, &s)) { if (!comment) printf("%s\n", s); else printf("<span class=\"komentar\">(%s)</span>\n", s); } free_search(); // do not free k - it might be used in first/last }