- struct stat buf;
- 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;
- yylex();
-
- printf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
- printf("<rdf:RDF xml:lang=\"en\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:h=\"file:mattone.rdf#\">\n");
- printf("\t<h:Object rdf:about=\"");
- printf("%s",argv[1]);
- printf("\">\n");
- print_all();
- printf("\t</h:Object>\n");
- printf("</rdf:RDF>\n");
- fclose(yyin);
- }
-
-search(uri,first_child,position)
+ 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;
+}
+
+
+search(uri,first_child,position,depth)