#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
+#include <postgresql/libpq-fe.h>
#include "sthandler.h"
%}
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;
"</body>"(" "|\n)*"<type" {
position = INTYPE; // Variables have both a body and a type
+ first_child = HERE;
+ no_open_source = 0;
+ spine_depth = 0;
+ depth = 0;
}
"<decl" |
}
"</decl>" |
-"</def" {
+"</def>" {
if (position == INHYP)
{
no_open_source--;
position = INTYPE;
spine_depth++;
depth = 0;
+ first_child = HERE;
}
- first_child = HERE;
+ /* bug? first_child = HERE; */
}
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;
+
+ if (argc != 4)
+ {
+ fprintf(stderr, "Usage: meta <object_uri> <body_file> <type_file>\n");
+ exit(1);
+ }
+
+ /*
+ * 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_test");
+
+ /*
+ * 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(argv[2],&buf))
+ {
+ yyin = fopen(argv[2], "r");
+ position = INBODY;
+ yylex();
+ fclose(yyin);
+ }
+
+ // We process the type
+ yyin = fopen(argv[3], "r");
+ position = INTYPE;
+ first_child = HERE;
+ no_open_source = 0;
+ spine_depth = 0;
+ depth = 0;
+ yylex();
+ fclose(yyin);
+ print_all(argv[1],conn);
+
+ return 0;
+}
- // 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("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
-printf("<!DOCTYPE rdf:RDF [
- <!ENTITY rdfns 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
- <!ENTITY hthns 'http://www.cs.unibo.it/helm/schemas/schema-helmth#'>
- <!ENTITY hns 'http://www.cs.unibo.it/helm/schemas/schema-helm#'>
-
- ]>\n");
-
- printf("<rdf:RDF xml:lang=\"en\" xmlns:rdf=\"&rdfns;\" xmlns:h=\"&hns;\" xmlns:hth=\"&hthns;\">\n");
- printf("\t<h:Object rdf:about=\"");
- printf("%s",argv[1]);
- printf("\">\n");
- print_all(argv[1],outrel,outsort);
- printf("\t</h:Object>\n");
- printf("</rdf:RDF>\n");
- fclose(yyin);
- }
search(uri,first_child,position,depth)
char *uri;
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)
return 1;
}
+
+
+