aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2004-10-08 19:58:41 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2004-10-08 19:58:41 +0000
commitb97d28b62346f3cec40e30162d6cb6e404281592 (patch)
tree639286d0dcd4a790c41009772c98770d734fdfb6 /src
parent5c3839c300b45980ac9c106cfa22ce2a68237aa4 (diff)
downloadellinika-b97d28b62346f3cec40e30162d6cb6e404281592.tar.gz
ellinika-b97d28b62346f3cec40e30162d6cb6e404281592.tar.bz2
Removed
git-svn-id: file:///home/puszcza/svnroot/ellinika/trunk@205 941c8c0f-9102-463b-b60b-cd22ce0e6858
Diffstat (limited to 'src')
-rw-r--r--src/.cvsignore8
-rw-r--r--src/.gdbinit1
-rw-r--r--src/Makefile.am21
-rw-r--r--src/emit.c109
-rw-r--r--src/gram.y271
-rw-r--r--src/input.l131
-rw-r--r--src/list.c318
-rw-r--r--src/list.h48
-rw-r--r--src/main.c381
-rw-r--r--src/mem.h2
-rw-r--r--src/sql.c140
-rw-r--r--src/trans.h86
-rw-r--r--src/xcript.c157
13 files changed, 0 insertions, 1673 deletions
diff --git a/src/.cvsignore b/src/.cvsignore
deleted file mode 100644
index e023f01..0000000
--- a/src/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-gram.h
-input.c
-.deps
-trans
-gram.output
-gram.c
diff --git a/src/.gdbinit b/src/.gdbinit
deleted file mode 100644
index 9f53896..0000000
--- a/src/.gdbinit
+++ /dev/null
@@ -1 +0,0 @@
-set args -v -d ellinika ../data/dict.1
diff --git a/src/Makefile.am b/src/Makefile.am
deleted file mode 100644
index 6319ea0..0000000
--- a/src/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-# This file is part of Ellinika project.
-# Copyright (C) 2004 Sergey Poznyakoff
-#
-# Ellinika is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Ellinika is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ellinika; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-noinst_PROGRAMS=trans
-trans_SOURCES=main.c list.c sql.c xcript.c gram.y input.l
-trans_LDADD=-ll
-AM_YFLAGS = -dtv \ No newline at end of file
diff --git a/src/emit.c b/src/emit.c
deleted file mode 100644
index ff99700..0000000
--- a/src/emit.c
+++ /dev/null
@@ -1,109 +0,0 @@
-#include "trans.h"
-#include <unistd.h>
-
-static unsigned long dict_index;
-static unsigned long article_index;
-
-static RAD_LIST *antonym_list;
-
-int
-_emit_headers(void *item, void *data)
-{
- struct header *hp = item;
- if (hp->forms)
- sql_query("INSERT INTO dict VALUES(%lu,'%s','%s','%s')",
- dict_index, hp->key, hp->pos, hp->forms);
- else
- sql_query("INSERT INTO dict (ident,word,pos) VALUES(%lu,'%s','%s')",
- dict_index, hp->key, hp->pos);
- return 0;
-}
-
-static int
-_antonym_cmp(const void *item, const void *data)
-{
- const struct antonym *a = item, *b = data;
- return !(a->index == b->index && strcmp(a->value, b->value) == 0);
-}
-
-int
-insert_antonym(unsigned long dict_index, u_char *value)
-{
- unsigned long index;
- if (sql_query_n(&index,
- "SELECT ident FROM dict WHERE word='%s'",
- value) == 0) {
- sql_query("REPLACE INTO antonym VALUES (%lu,%lu)",
- index, dict_index);
- sql_query("REPLACE INTO antonym VALUES (%lu,%lu)",
- dict_index, index);
- return 0;
- }
- return 1;
-}
-
-int
-_emit_descr(void *item, void *data)
-{
- struct descr *descr = item;
- unsigned long index;
-
- switch (descr->type) {
- case descr_topic:
- if (sql_query_n(&index,
- "SELECT ident FROM topic WHERE title='%s'",
- descr->value)) {
- sql_query("INSERT INTO topic (title) VALUES ('%s')",
- descr->value);
- sql_query_n(&index, "SELECT LAST_INSERT_ID()");
- }
- sql_query("INSERT INTO topic_tab VALUES(%lu,%lu)",
- index, dict_index);
- break;
-
- case descr_meaning:
- sql_query("INSERT INTO articles VALUES (%lu, %lu, '%s')",
- dict_index,
- article_index++,
- descr->value);
- break;
-
- case descr_antonym:
- if (insert_antonym(dict_index, descr->value)) {
- struct antonym *p = emalloc(sizeof(*p));
- p->index = dict_index;
- p->value = descr->value;
- list_append(antonym_list, p);
- }
- }
- return 0;
-}
-
-static int
-cmp_descr_type(const void *a, const void *b)
-{
- const struct descr *da = a, *db = b;
- return da->type != db->type;
-}
-
-void
-emit_node(RAD_LIST *hdr, RAD_LIST *descr)
-{
- article_index = 0;
-
- list_iterate(hdr, _emit_headers, NULL);
- list_iterate(descr, _emit_descr, NULL);
-
- dict_index++;
-}
-
-int
-_antonym_fixup(void *item, void *data)
-{
- struct antonym *ant = item;
- if (insert_antonym(ant->index, ant->value)) {
- fprintf(stderr, "unhandled antonym: %lu - \"%s\"\n",
- ant->index, ant->value);
- }
- return 0;
-}
diff --git a/src/gram.y b/src/gram.y
deleted file mode 100644
index 93484a7..0000000
--- a/src/gram.y
+++ /dev/null
@@ -1,271 +0,0 @@
-%{
-/*
- This file is part of Ellinika project.
- Copyright (C) 2004 Sergey Poznyakoff
-
- Ellinika is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Ellinika is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Ellinika; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-#include "trans.h"
-#define obstack_chunk_alloc malloc
-#define obstack_chunk_free free
-#include <obstack.h>
-
-struct obstack stk;
-
-struct descr *make_descr(enum descr_type type, u_char *value);
-
-static int _register_topic(void *item, void *data);
-static int convert_pos(char *text, int *pos);
-
-%}
-
-%token NODE POS END MEANING ALIAS ANT TOPIC FORMS XREF
-%token <string> STRING
-
-%type <num> pos
-%type <string> string forms
-%type <header> nodehdr alias
-%type <descr> descr
-%type <list> list aliases descrlist header
-%type <item> item
-
-%union {
- int num;
- u_char *string;
- struct header *header;
- struct descr *descr;
- RAD_LIST *list;
- struct gram_item item;
-};
-
-
-%%
-
-input : list
- {
- node_list = $1;
- }
- ;
-
-list : item
- {
- $$ = list_create();
- switch ($1.type) {
- case item_node:
- list_append($$, $1.v.node);
- break;
-
- case item_list:
- list_concat($$, $1.v.list);
- list_destroy(&$1.v.list, NULL, NULL);
- }
- }
- | list item
- {
- switch ($2.type) {
- case item_node:
- list_append($1, $2.v.node);
- break;
-
- case item_list:
- list_concat($1, $2.v.list);
- list_destroy(&$2.v.list, NULL, NULL);
- }
- $$ = $1;
- }
- ;
-
-item : header descrlist end
- {
- $$.type = item_node;
- $$.v.node = create_node($1, $2);
- }
- | TOPIC string list end
- {
- $$.type = item_list;
- $$.v.list = $3;
- list_iterate($3, _register_topic,
- make_descr(descr_topic, $2));
- }
- ;
-
-end : END
- ;
-
-header : nodehdr
- {
- $$ = list_create();
- list_append($$, $1);
- }
- | nodehdr aliases
- {
- list_prepend($2, $1);
- $$ = $2;
- }
- ;
-
-nodehdr : NODE string pos forms
- {
- $$ = emalloc(sizeof(*$$));
- $$->key = $2;
- $$->pos = $3;
- $$->forms = $4;
- }
- ;
-
-pos : /* empty */
- {
- $$ = -1;
- }
- | POS string
- {
- if (convert_pos($2, &$$))
- YYERROR;
- }
- ;
-
-forms : /* empty */
- {
- $$ = NULL;
- }
- | FORMS string
- {
- $$ = $2;
- }
- ;
-
-aliases : alias
- {
- $$ = list_create();
- list_append($$, $1);
- }
- | aliases alias
- {
- list_append($1, $2);
- $$ = $1;
- }
- ;
-
-alias : ALIAS string pos forms
- {
- $$ = emalloc(sizeof(*$$));
- $$->key = $2;
- $$->pos = $3;
- $$->forms = $4;
- }
- ;
-
-descrlist: descr
- {
- $$ = list_create();
- list_append($$, $1);
- }
- | descrlist descr
- {
- list_append($1, $2);
- $$ = $1;
- }
- ;
-
-descr : TOPIC string
- {
- $$ = make_descr(descr_topic, $2);
- }
- | MEANING string
- {
- $$ = make_descr(descr_meaning, $2);
- }
- | ANT string
- {
- $$ = make_descr(descr_antonym, $2);
- }
- | XREF string
- {
- $$ = make_descr(descr_xref, $2);
- }
- ;
-
-string : mstring
- {
- obstack_1grow(&stk, 0);
- $$ = obstack_finish(&stk);
- }
- ;
-
-mstring : STRING
- {
- obstack_grow(&stk, $1, strlen($1));
- }
- | mstring STRING
- {
- obstack_1grow(&stk, '\n');
- obstack_grow(&stk, $2, strlen($2));
- }
- ;
-
-%%
-
-yyerror(char *s)
-{
- fprintf (stderr, "%s:%d: %s\n",
- file_name ? file_name : "<stdin>", input_line, s);
-}
-
-int
-parse(int argc, char **argv)
-{
- if (argc)
- open_input(argc, argv);
- obstack_init(&stk);
- return yyparse();
-}
-
-struct descr *
-make_descr(enum descr_type type, u_char *value)
-{
- struct descr *p = emalloc(sizeof(*p));
- p->type = type;
- p->value = value;
- return p;
-}
-
-static int
-_register_topic(void *item, void *data)
-{
- struct node *node = item;
- list_append(node->descr, data);
- return 0;
-}
-
-
-static int
-convert_pos(char *text, int *pos)
-{
- unsigned long n;
- if (sql_query_n(&n,
- "SELECT id FROM pos WHERE abbr=\"%s\"",
- text)
- && sql_query_n(&n,
- "SELECT id FROM pos WHERE abbr_lat=\"%s\"",
- text)
- && sql_query_n(&n,
- "SELECT id FROM pos WHERE name=\"%s\"",
- text)) {
- yyerror("unknown or misspelled part of speech");
- return 1;
- }
- *pos = n;
- return 0;
-}
diff --git a/src/input.l b/src/input.l
deleted file mode 100644
index f05a6b5..0000000
--- a/src/input.l
+++ /dev/null
@@ -1,131 +0,0 @@
-%{
-/*
- This file is part of Ellinika project.
- Copyright (C) 2004 Sergey Poznyakoff
-
- Ellinika is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Ellinika is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Ellinika; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#include "trans.h"
-#include "gram.h"
-#include <string.h>
-
-char *file_name = NULL;
-int input_line = 1;
-
-void set_location();
-#define isws(c) ((c)==' ' || (c)=='\t')
-%}
-
-MWS [ \t]*
-WS [ \t]+
-%%
-#.*\n input_line++;
-^[nN][oO][dD][eE] return NODE;
-^[pP][oO][sS] return POS;
-^[eE][nN][dD]{MWS} return END;
-^[mM][eE][aA][nN][iI][nN][gG] return MEANING;
-^[aA][lL][iI][aA][sS] return ALIAS;
-^[aA][nN][tT] return ANT;
-^[tT][oO][pP][iI][cC] return TOPIC;
-^[fF][oO][rR][mM][sS] return FORMS;
-^[xX][rR][eE][fF] return XREF;
-^[lL][iI][nN][eE]{WS}\"[^\"]+\"{WS}[0-9]+\n set_location();
-\n input_line++;
-{WS}[^\n]+\n {
- char *p, *q;
-
- for (p = yytext + yyleng - 1; p > yytext && isspace(*p); p--)
- ;
- p[1] = 0;
- input_line++;
- yylval.string = yytext+1;
- return STRING;
-}
-. { fprintf (stderr, "%s:%d: stray character %c\n",
- file_name, input_line, yytext[0]);
- exit(1); }
-
-%%
-
-
-void
-set_location()
-{
- char *start = strchr(yytext+1, '"');
- char *p = strchr(start+1, '"');
- int len = p-start-1;
- free(file_name);
- file_name = emalloc(len+1);
- memcpy(file_name, start+1, len);
- file_name[len] = 0;
- for (p++; p < yytext+yyleng && isws (*p); p++)
- ;
- input_line = strtoul (p, NULL, 0);
-}
-
-char *m4_cmdline;
-#define DEFAULT_INCLUDE "dict.m4"
-
-void
-make_m4_args (char *m4_bin, RAD_LIST *include_list)
-{
- int i, n;
- size_t len;
-
- len = strlen(m4_bin);
- for (i = 0; i < list_count(include_list); i++)
- len += 3 + strlen(list_item(include_list, i));
- len += 1+strlen(DEFAULT_INCLUDE);
- len++;
- m4_cmdline = emalloc(len);
- n = sprintf(m4_cmdline, "%s ", m4_bin);
- for (i = 0; i < list_count(include_list); i++)
- n += sprintf(m4_cmdline+n, "-I%s ", list_item(include_list, i));
- n += sprintf(m4_cmdline+n, "%s", DEFAULT_INCLUDE);
- m4_cmdline[n] = 0;
-}
-
-void
-open_input(int argc, char **argv)
-{
- char *inv;
- int i, n, len = 0;
-
- for (i = 0; i < argc; i++)
- len += 1 + strlen(argv[i]);
-
- inv = emalloc(strlen(m4_cmdline) + len + 1);
- n = sprintf(inv, "%s", m4_cmdline);
- for (i = 0; i < argc; i++)
- n += sprintf(inv+n, " %s", argv[i]);
- inv[n] = 0;
- yyin = popen(inv, "r");
- if (!yyin) {
- fprintf(stderr, "cannot execute ");
- perror(inv);
- exit(1);
- }
- free(inv);
-}
-
-int
-yywrap()
-{
- if (file_name)
- pclose(yyin);
- return 1;
-}
-
diff --git a/src/list.c b/src/list.c
deleted file mode 100644
index 32b2e72..0000000
--- a/src/list.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* This file is part of GNU Radius.
- Copyright (C) 2003 Free Software Foundation
-
- GNU Radius is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- GNU Radius is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Radius; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <sys/types.h>
-#include <stdlib.h>
-#include <mem.h>
-#include <list.h>
-
-struct list_entry {
- struct list_entry *next;
- void *data;
-};
-
-struct list {
- size_t count;
- struct list_entry *head, *tail;
- struct iterator *itr;
-};
-
-struct iterator {
- struct iterator *next;
- RAD_LIST *list;
- struct list_entry *cur;
- int advanced;
-};
-
-struct list *
-list_create()
-{
- struct list *p = emalloc(sizeof(*p));
- p->head = p->tail = NULL;
- p->itr = NULL;
- p->count = 0;
- return p;
-}
-
-void
-list_destroy(struct list **plist, list_iterator_t user_free, void *data)
-{
- struct list_entry *p;
-
- if (!*plist)
- return;
-
- p = (*plist)->head;
- while (p) {
- struct list_entry *next = p->next;
- if (user_free)
- user_free(p->data, data);
- efree(p);
- p = next;
- }
- efree(*plist);
- *plist = NULL;
-}
-
-void *
-iterator_current(ITERATOR *ip)
-{
- if (!ip)
- return NULL;
- return ip->cur ? ip->cur->data : NULL;
-}
-
-ITERATOR *
-iterator_create(RAD_LIST *list)
-{
- ITERATOR *itr;
-
- if (!list)
- return NULL;
- itr = emalloc(sizeof(*itr));
- itr->list = list;
- itr->cur = NULL;
- itr->next = list->itr;
- itr->advanced = 0;
- list->itr = itr;
- return itr;
-}
-
-void
-iterator_destroy(ITERATOR **ip)
-{
- ITERATOR *itr, *prev;
-
- if (!ip || !*ip)
- return;
- for (itr = (*ip)->list->itr, prev = NULL;
- itr;
- prev = itr, itr = itr->next)
- if (*ip == itr)
- break;
- if (itr) {
- if (prev)
- prev->next = itr->next;
- else
- itr->list->itr = itr->next;
- efree(itr);
- *ip = NULL;
- }
-
-}
-
-void *
-iterator_first(ITERATOR *ip)
-{
- if (!ip)
- return NULL;
- ip->cur = ip->list->head;
- ip->advanced = 0;
- return iterator_current(ip);
-}
-
-void *
-iterator_next(ITERATOR *ip)
-{
- if (!ip || !ip->cur)
- return NULL;
- if (!ip->advanced)
- ip->cur = ip->cur->next;
- ip->advanced = 0;
- return iterator_current(ip);
-}
-
-static void
-_iterator_advance(ITERATOR *ip, struct list_entry *e)
-{
- for (; ip; ip = ip->next) {
- if (ip->cur == e) {
- ip->cur = e->next;
- ip->advanced++;
- }
- }
-}
-
-void *
-list_item(struct list *list, size_t n)
-{
- struct list_entry *p;
- if (n >= list->count)
- return NULL;
- for (p = list->head; n > 0 && p; p = p->next, n--)
- ;
- return p->data;
-}
-
-size_t
-list_count(struct list *list)
-{
- if (!list)
- return 0;
- return list->count;
-}
-
-void
-list_concat(struct list *a, struct list *b)
-{
- if (a->tail)
- a->tail->next = b->head;
- else
- a->head = b->head;
- a->tail = b->tail;
- a->count += b->count;
-
- b->count = 0;
- b->head = b->tail = NULL;
-}
-
-void
-list_append(struct list *list, void *data)
-{
- struct list_entry *ep;
-
- if (!list)
- return;
- ep = emalloc(sizeof(*ep));
- ep->next = NULL;
- ep->data = data;
- if (list->tail)
- list->tail->next = ep;
- else
- list->head = ep;
- list->tail = ep;
- list->count++;
-}
-
-void
-list_prepend(struct list *list, void *data)
-{
- struct list_entry *ep;
-
- if (!list)
- return;
- ep = emalloc(sizeof(*ep));
- ep->data = data;
- ep->next = list->head;
- list->head = ep;
- if (!list->tail)
- list->tail = list->head;
- list->count++;
-}
-
-static int
-cmp_ptr(const void *a, const void *b)
-{
- return a != b;
-}
-
-void *
-list_remove(struct list *list, void *data, list_comp_t cmp)
-{
- struct list_entry *p, *prev;
-
- if (!list)
- return NULL;
- if (!list->head)
- return NULL;
- if (!cmp)
- cmp = cmp_ptr;
- for (p = list->head, prev = NULL; p; prev = p, p = p->next)
- if (cmp(p->data, data) == 0)
- break;
-
- if (!p)
- return 0;
- _iterator_advance(list->itr, p);
- if (p == list->head) {
- list->head = list->head->next;
- if (!list->head)
- list->tail = NULL;
- } else
- prev->next = p->next;
-
- if (p == list->tail)
- list->tail = prev;
-
- efree(p);
- list->count--;
-
- return data;
-}
-
-void
-list_iterate(struct list *list, list_iterator_t func, void *data)
-{
- ITERATOR *itr;
- void *p;
-
- if (!list)
- return;
- itr = iterator_create(list);
- if (!itr)
- return;
- for (p = iterator_first(itr); p; p = iterator_next(itr)) {
- if (func(p, data))
- break;
- }
- iterator_destroy(&itr);
-}
-
-void *
-list_locate(struct list *list, void *data, list_comp_t cmp)
-{
- struct list_entry *cur;
- if (!list)
- return NULL;
- if (!cmp)
- cmp = cmp_ptr;
- for (cur = list->head; cur; cur = cur->next)
- if (cmp(cur->data, data) == 0)
- break;
- return cur ? cur->data : NULL;
-}
-
-int
-list_insert_sorted(struct list *list, void *data, list_comp_t cmp)
-{
- struct list_entry *cur, *prev;
-
- if (!list)
- return -1;
- if (!cmp)
- return -1;
-
- for (cur = list->head, prev = NULL; cur; prev = cur, cur = cur->next)
- if (cmp(cur->data, data) > 0)
- break;
-
- if (!prev) {
- list_prepend(list, data);
- } else if (!cur) {
- list_append(list, data);
- } else {
- struct list_entry *ep = emalloc(sizeof(*ep));
- ep->data = data;
- ep->next = cur;
- prev->next = ep;
- }
- return 0;
-}
-
diff --git a/src/list.h b/src/list.h
deleted file mode 100644
index ee79cd1..0000000
--- a/src/list.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* This file is part of GNU Radius
- Copyright (C) 2003 Free Software Foundation, Inc.
-
- Written by Sergey Poznyakoff
-
- GNU Radius is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- GNU Radius is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Radius; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef LIST_H
-#define LIST_H
-
-typedef struct list RAD_LIST;
-typedef struct iterator ITERATOR;
-
-typedef int (*list_iterator_t)(void *item, void *data);
-typedef int (*list_comp_t)(const void *, const void *);
-
-RAD_LIST *list_create();
-void list_destroy(RAD_LIST **list, list_iterator_t free, void *data);
-void list_iterate(RAD_LIST *list, list_iterator_t itr, void *data);
-void *list_item(RAD_LIST *list, size_t n);
-size_t list_count(RAD_LIST *list);
-void list_append(RAD_LIST *list, void *data);
-void list_prepend(RAD_LIST *list, void *data);
-int list_insert_sorted(struct list *list, void *data, list_comp_t cmp);
-void *list_locate(RAD_LIST *list, void *data, list_comp_t cmp);
-void *list_remove(RAD_LIST *list, void *data, list_comp_t cmp);
-
-void *iterator_current(ITERATOR *ip);
-ITERATOR *iterator_create(RAD_LIST *list);
-void iterator_destroy(ITERATOR **ip);
-void *iterator_first(ITERATOR *ip);
-void *iterator_next(ITERATOR *ip);
-
-
-#endif
-
diff --git a/src/main.c b/src/main.c
deleted file mode 100644
index 4d0f2cf..0000000
--- a/src/main.c
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- This file is part of Ellinika project.
- Copyright (C) 2004 Sergey Poznyakoff
-
- Ellinika is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Ellinika is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Ellinika; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#include "trans.h"
-#include <unistd.h>
-#include <getopt.h>
-
-char *sql_database; /* Database name */
-char *sql_host; /* SQL server host name */
-int sql_port = 3306; /* SQL port */
-char *sql_user; /* SQL user name */
-char *sql_password; /* Password for this user */
-
-int compile_only; /* Compile input into the internal representation
- and exit. Do not write the database */
-
-int preserve_flag; /* Preserve closed cross-reference links in
- pending_links table. */
-int debug; /* Debug level */
-
-static int error_count; /* Number of errors encountered during compilation */
-
-static RAD_LIST *include_list; /* List of m4 include directories */
-static char *m4_bin = "/usr/bin/m4"; /* Full file name to the m4 binary.
- FIXME: Should be autoconf'ed */
-
-void *
-emalloc(size_t size)
-{
- void *ptr;
- ptr = malloc(size);
- if (!ptr) {
- fprintf(stderr, "not enough memory\n");
- exit(1);
- }
- return ptr;
-}
-
-void
-efree(void *ptr)
-{
- free(ptr);
-}
-
-RAD_LIST *node_list;
-
-struct node *
-create_node(RAD_LIST *hdr, RAD_LIST *descr)
-{
- struct node *node = emalloc(sizeof(*node));
- struct header *prev = NULL;
- int i;
-
- for (i = list_count(hdr)-1; i >= 0; i--) {
- struct header *dp = list_item(hdr, i);
- if (dp->pos < 0) {
- if (prev)
- dp->pos = prev->pos;
- else {
- fprintf(stderr,
- "%s:%d: no POS is set for \"%s\"\n",
- file_name,
- input_line,
- dp->key);
- error_count++;
- }
- }
- if (dp->pos >= 0)
- prev = dp;
- }
- node->header = hdr;
- node->descr = descr;
- return node;
-}
-
-
-
-static unsigned long dict_index;
-static unsigned long article_index;
-
-int
-_emit_headers(void *item, void *data)
-{
- struct header *hp = item;
- char *sound;
-
- if (debug)
- fprintf(stderr, "Emitting %s\n", hp->key);
- sound = greek_to_transcription(hp->key);
- if (hp->forms)
- sql_query("INSERT INTO dict VALUES(%lu,\"%s\",\"%s\",%d,\"%s\")",
- dict_index, hp->key, sound, hp->pos, hp->forms);
- else
- sql_query("INSERT INTO dict (ident,word,sound,pos) VALUES(%lu,\"%s\",\"%s\",%d)",
- dict_index, hp->key, sound, hp->pos);
- efree(sound);
- return 0;
-}
-
-static void
-set_link(char *type, unsigned long dict_index, u_char *value)
-{
- sql_query("INSERT INTO pending_links (type,originator,word) "
- "VALUES('%s',%lu,'%s')",
- type, dict_index, value);
-}
-
-int
-_emit_descr(void *item, void *data)
-{
- struct descr *descr = item;
- unsigned long index;
-
- switch (descr->type) {
- case descr_topic:
- if (sql_query_n(&index,
- "SELECT ident FROM topic WHERE title=\"%s\"",
- descr->value)) {
- sql_query("INSERT INTO topic (title) VALUES (\"%s\")",
- descr->value);
- sql_query_n(&index, "SELECT LAST_INSERT_ID()");
- }
- sql_query("INSERT INTO topic_tab VALUES(%lu,%lu)",
- index, dict_index);
- break;
-
- case descr_meaning:
- sql_query("INSERT INTO articles VALUES (%lu, %lu, \"%s\")",
- dict_index,
- article_index++,
- descr->value);
- break;
-
- case descr_antonym:
- set_link("ANT", dict_index, descr->value);
- break;
-
- case descr_xref:
- set_link("XREF", dict_index, descr->value);
- break;
- }
- return 0;
-}
-
-int
-emit_node(void *item, void *data)
-{
- struct node *node = item;
- article_index = 0;
-
- dict_index++;
-
- list_iterate(node->header, _emit_headers, NULL);
- list_iterate(node->descr, _emit_descr, NULL);
-
- return 0;
-}
-
-
-void
-pending_fixup()
-{
- unsigned long val;
-
- sql_query("INSERT IGNORE INTO links "
- "SELECT p.type,p.originator,d.ident "
- "FROM dict d, pending_links p "
- "WHERE p.word = d.word AND p.type != 'CLOSED'");
- sql_query("INSERT IGNORE INTO links "
- "SELECT p.type,d.ident,p.originator "
- "FROM dict d, pending_links p "
- "WHERE p.word = d.word AND p.type != 'CLOSED'");
- sql_query("UPDATE pending_links p, dict d SET p.type='CLOSED' "
- "WHERE p.word = d.word");
- /* SQL92:
- UPDATE pending_links SET type='CLOSED'
- WHERE originator in (SELECT d.ident from dict d, pending_links p
- WHERE p.word=d.word) */
-
- if (!preserve_flag)
- sql_query("DELETE FROM pending_links WHERE type = 'CLOSED'");
-
- if (sql_query("SELECT count(*) FROM pending_links "
- " WHERE type != 'CLOSED' "
- " GROUP BY word") == 0)
- fprintf (stderr, "%lu unresolved references\n",
- sql_num_tuples());
-}
-
-
-
-void
-update_stat()
-{
- unsigned long count;
-
- sql_query_n(&count,
- "SELECT count(*) from dict");
- sql_query("DELETE from stat");
- sql_query("INSERT INTO stat (count,updated) VALUES(%lu,now())",
- count);
-}
-
-void
-cleanup_db()
-{
- sql_query("DELETE FROM links");
- sql_query("DELETE FROM articles");
- sql_query("DELETE FROM dict");
- sql_query("DELETE FROM topic");
- sql_query("DELETE FROM topic_tab");
- sql_query("DELETE FROM pending_links");
-}
-
-
-
-#define ARG_CLEANUP 256
-#define ARG_HELP 257
-#define ARG_VERSION 258
-#de