X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmetadata%2Fcreate_V7_mowgli%2FMETADATA%2Fmeta_lex_ind.l;h=ef0abac72c3ea09915f528d463835ec6aa56a4dd;hb=cdb45d73b98f6abaf670229b48a8442e1db902fc;hp=acf86244658752e9388088e775fb963d18ee5e7e;hpb=6dc6f6e97cb85d5b51fbf5d14a9f87b24b2964cd;p=helm.git diff --git a/helm/metadata/create_V7_mowgli/METADATA/meta_lex_ind.l b/helm/metadata/create_V7_mowgli/METADATA/meta_lex_ind.l index acf862446..ef0abac72 100644 --- a/helm/metadata/create_V7_mowgli/METADATA/meta_lex_ind.l +++ b/helm/metadata/create_V7_mowgli/METADATA/meta_lex_ind.l @@ -39,7 +39,8 @@ #include #include #include -#include "sthandler_ind.h" +#include +#include "sthandler.h" %} /***************************************************************/ @@ -81,11 +82,9 @@ char sep = '"'; char *xpointer = "#xpointer(1/"; char *uri; char *tmp; -char *filename; -char *file_uri; -char *inductive_uri; -char *filename_prefix; -char *file_uri_prefix; +char *source_uri; +char *source_uri_prefix; +PGconn *conn; %} /***************************************************************/ @@ -117,17 +116,13 @@ value [^"]+ } "" { tmp = (char *)malloc(sizeof('a')*128); - strcpy(filename,filename_prefix); - /* fprintf(stderr,"tre"); */ - strcpy(file_uri,file_uri_prefix); - sprintf(tmp,",%d.xml", inductive_type); - /* fprintf(stderr,"quattro"); */ - strcat(filename,tmp); + strcpy(source_uri,source_uri_prefix); sprintf(tmp,"#xpointer(1/%d)", inductive_type); - strcat(file_uri,tmp); + strcat(source_uri,tmp); /* fprintf(stderr,"cinque"); */ free(tmp); - print_file(); + print_all(source_uri,conn); + /* print_file(); */ } "" { tmp = (char *)malloc(sizeof('a')*128); - strcpy(filename,filename_prefix); - strcpy(file_uri,file_uri_prefix); - strcpy(inductive_uri,file_uri_prefix); - sprintf(tmp,",%d,%d.xml", inductive_type,constructor); - strcat(filename,tmp); + strcpy(source_uri,source_uri_prefix); sprintf(tmp,"#xpointer(1/%d/%d)",inductive_type,constructor); - strcat(file_uri,tmp); + strcat(source_uri,tmp); free(tmp); - print_file(); + print_all(source_uri,conn); + /* print_file(); */ } "" | -"" { if (position == INHYP) { no_open_source--; @@ -178,8 +169,8 @@ value [^"]+ position = INTYPE; spine_depth++; depth = 0; + first_child = HERE; } - first_child = HERE; } @@ -313,55 +304,46 @@ value [^"]+ main(int argc, char *argv[]) { - filename = malloc((sizeof('a')*2000)); - file_uri = malloc((sizeof('a')*2000)); - inductive_uri = malloc((sizeof('a')*2000)); - filename_prefix=argv[1]; - file_uri_prefix=argv[2]; - /* fprintf(stderr,"qua"); */ - yyin = fopen("tmp/inductive_type.xml", "r"); - yylex(); -} - -print_file() -{ - FILE *out, *outrel, *outsort; - - if (!(out = fopen(filename,"w"))) - { - fprintf(stderr, "error in openinf file %s\n", filename); - exit(-1); - } - 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 type - - fprintf(out,"\n\n"); -fprintf(out," - - - - ]>\n"); - fprintf(out,"\n"); - fprintf(out,"\t\n"); - print_all(file_uri,out,outrel,outsort); - fprintf(out,"\t\n"); - fprintf(out,"\n"); - fclose(out); - fclose(outrel); - fclose(outsort); + struct stat buf; + + char *pghost, + *pgport, + *pgoptions, + *pgtty; + char *dbName; + + /* FILE *debug; */ + + 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); */ + + source_uri = malloc((sizeof('a')*2000)); + source_uri_prefix=argv[1]; + /* fprintf(stderr,"qua"); */ + yyin = fopen("tmp/inductive_type.xml", "r"); + yylex(); } search(uri,first_child,position,depth) @@ -386,8 +368,8 @@ int position; else found = search_bucket(uri,position,depth); - /* if (found == NOTFOUND) - printf( "pos = %d, uri = %s\n", position, uri); */ + if (found == NOTFOUND) + printf( "pos = %d, uri = %s\n", position, uri); }