X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmetadata%2Fcreate_V7_mowgli%2FMETADATA%2Fmeta_lex.l;h=2f8c4b039f06204e2b77fb5831e52e84bd5038a3;hb=cdb45d73b98f6abaf670229b48a8442e1db902fc;hp=eca7c383d6a1a96568d20a31521b3ca7d82b75c5;hpb=6dc6f6e97cb85d5b51fbf5d14a9f87b24b2964cd;p=helm.git diff --git a/helm/metadata/create_V7_mowgli/METADATA/meta_lex.l b/helm/metadata/create_V7_mowgli/METADATA/meta_lex.l index eca7c383d..2f8c4b039 100644 --- a/helm/metadata/create_V7_mowgli/METADATA/meta_lex.l +++ b/helm/metadata/create_V7_mowgli/METADATA/meta_lex.l @@ -39,6 +39,7 @@ #include #include #include +#include #include "sthandler.h" %} @@ -70,7 +71,7 @@ int found = NOTFOUND; int position = INBODY; int first_child = HERE; int skip = 0; // boolean to skip the insertion of a URI -int no_open_source =0; +int no_open_source = 0; int spine_depth = 0; int depth = 0; int tmp_n; @@ -101,6 +102,10 @@ value [^"]+ ""(" "|\n)*"" | -"" { if (position == INHYP) { no_open_source--; @@ -129,8 +134,9 @@ value [^"]+ position = INTYPE; spine_depth++; depth = 0; + first_child = HERE; } - first_child = HERE; + /* bug? first_child = HERE; */ } @@ -264,54 +270,66 @@ value [^"]+ main(int argc, char *argv[]) { - struct stat buf; - FILE *outrel, *outsort; - - init_symbol_table(); - if (!(outrel = fopen("forward_rel.xml","a"))) - { - fprintf(stderr, "error in openinf file forward_rel.xml\n"); - exit(-1); - } - if (!(outsort = fopen("forward_sort.xml","a"))) - { - fprintf(stderr, "error in openinf file forward_rel.xml\n"); - exit(-1); - } - // We process the body - if (!stat("tmp/body.xml",&buf)) { - yyin = fopen("tmp/body.xml", "r"); - position = INBODY; - yylex(); - fclose(yyin); - } + struct stat buf; + + char *pghost, + *pgport, + *pgoptions, + *pgtty; + char *dbName; + + /* FILE *debug; */ + + PGconn *conn; + PGresult *res; + + /* + * begin, by setting the parameters for a backend connection if the + * parameters are null, then the system will try to use reasonable + * defaults by looking up environment variables or, failing that, + * using hardwired constants + */ + + /* make a connection to the database */ + conn = PQconnectdb("user=helm dbname=mowgli"); + + /* + * check to see that the backend connection was successfully made + */ + if (PQstatus(conn) == CONNECTION_BAD) + { + fprintf(stderr, "Connection to database '%s' failed.\n", dbName); + fprintf(stderr, "%s", PQerrorMessage(conn)); + exit_nicely(conn); + } + + /* debug = fopen("/tmp/trace.out","w"); */ + /* PQtrace(conn, debug); */ + + /* initialize the symbol table */ + init_symbol_table(); + + // We process the body + if (!stat("tmp/body.xml",&buf)) + { + yyin = fopen("tmp/body.xml", "r"); + position = INBODY; + yylex(); + fclose(yyin); + } + + // We process the type + yyin = fopen("tmp/type.xml", "r"); + position = INTYPE; + first_child = HERE; + no_open_source = 0; + spine_depth = 0; + depth = 0; + yylex(); + fclose(yyin); + print_all(argv[1],conn); +} - // We process the type - yyin = fopen("tmp/type.xml", "r"); - position = INTYPE; - first_child = HERE; - no_open_source = 0; - spine_depth = 0; - depth = 0; - yylex(); - - printf("\n\n"); -printf(" - - - - ]>\n"); - - printf("\n"); - printf("\t\n"); - print_all(argv[1],outrel,outsort); - printf("\t\n"); - printf("\n"); - fclose(yyin); - } search(uri,first_child,position,depth) char *uri; @@ -335,8 +353,9 @@ int position; else found = search_bucket(uri,position,depth); - /* if (found == NOTFOUND) - fprintf(stderr,"pos = %d, uri = %s\n", position, uri); */ + /* + if (found == NOTFOUND) + fprintf(stderr,"here = %d, pos = %d, uri = %s\n", first_child,position, uri); */ } /* (first_child == HERE) @@ -361,3 +380,6 @@ int yywrap() { return 1; } + + +