#include #include #include #include typedef struct { int id; char *n, *sect, *keywords; } coin_t; int n_coins; coin_t *coins; /* ---------------------------------------------------------------- */ void dehtml (char *s) { char *p; for (p = s; *p && *(p+1) && *(p+2) && *(p+3) && *(p+4) && *(p+5); p++) { if (*p == '&' && *(p+1) == '#' && isdigit ((unsigned)(*(p+2))) && isdigit ((unsigned)(*(p+3))) && isdigit ((unsigned)(*(p+4))) && *(p+5) == ';' ) { *p = (p[2]-'0')*100 + (p[3]-'0')*10 + p[4]-'0'; str_delete (s, p+1); str_delete (s, p+1); str_delete (s, p+1); str_delete (s, p+1); str_delete (s, p+1); } } } /* ---------------------------------------------------------------- */ #define LOAD_DEBUG FALSE int load_coins (void) { int i, nc, nw; char **lines, **w; static FILE *fp=NULL; if (LOAD_DEBUG && fp == NULL) fp = xfopen ("load.debug", "w"); nc = load_textfile ("keywords.txt", &lines); if (nc <= 0) return -1; n_coins = 0; coins = xmalloc (sizeof (coin_t) * nc); for (i=0; i= 'a' && w[i][j] <= 'z') continue; if (w[i][j] >= '0' && w[i][j] <= '9') continue; if (w[i][j] >= 'A' && w[i][j] <= 'Z') w[i][j] += 'a'-'A'; if (w[i][j] == '\'') continue; if (w[i][j] == '_') continue; w[i][j] = ' '; } nw1 = str_words (w[i], &w1, WSEP_SPACES); for (j=0; j\n", s); for (i=0; iword, w2->word); } /* ---------------------------------------------------------------- */ int write_index (void) { int i, j; FILE *fp; qsort (words, n_words, sizeof (word_t), cmp_word); fp = xfopen ("keyword_index.sql", "w"); fprintf (fp, "TRUNCATE `h001273440_coins`.`tab_index`;\n"); for (i=0; i