+struct int_list *add(l,m)
+ struct int_list *l;
+ int m;
+{
+ struct int_list *curr;
+ /* scan the list looking for m */
+ curr = l;
+ while ((curr != NULL) && (m != (curr->val)))
+ curr = curr->next;
+ if (curr == NULL)
+ /* m is not in the list */
+ {
+ curr = (struct int_list *)malloc(sizeof(struct int_list));
+ curr->val = m;
+ curr->next = l;
+ return curr;
+ }
+ else
+ return l;
+
+}
+
+print_mainhyp(about,conn,uri,l)
+ char *about;
+ PGconn *conn;
+ char *uri;
+ struct int_list *l;
+{
+ PGresult *res;
+ char *command = (char *)malloc((sizeof('a')*200));
+ struct int_list *curr;
+ curr = l;
+ if (!strcmp(uri,"Rel"))
+ {
+ /* scan the list */
+ while (curr != NULL)
+ {
+ size_t len = strlen(about) + 1;
+ char *qabout = malloc (sizeof(char) * len * 2);
+ PQescapeString(qabout,about,len);
+ sprintf(command,"INSERT INTO refRel values ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis', %d)",qabout,curr->val);
+ /* fprintf(stderr, "%s\n", command); */
+ res = PQexec(conn, command);
+ if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
+ {
+ fprintf(stderr, "BEGIN command failed\n");
+ PQclear(res);
+ exit_nicely(conn);
+ }
+ curr = curr->next;
+ }
+ }
+ else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) ||
+ (!strcmp(uri,"Set")))
+ {
+ /* scan the list */
+ while (curr != NULL)
+ {
+ size_t len = strlen(about) + 1;
+ char *qabout = malloc (sizeof(char) * len * 2);
+ PQescapeString(qabout,about,len);
+ sprintf(command,"INSERT INTO refSort values ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis', %d, '%s')",qabout,curr->val,uri);
+ /* fprintf(stderr, "%s\n", command); */
+ res = PQexec(conn, command);
+ if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
+ {
+ fprintf(stderr, "BEGIN command failed\n");
+ PQclear(res);
+ exit_nicely(conn);
+ }
+ curr = curr->next;
+ }
+ }
+ else
+ {
+ /* scan the list */
+ while (curr != NULL)
+ {
+ size_t len = strlen(about) + 1;
+ char *qabout = malloc (sizeof(char) * len * 2);
+ char *quri;
+ PQescapeString(qabout,about,len);
+ len = strlen(uri) + 1;
+ quri = malloc (sizeof(char) * len * 2);
+ PQescapeString(quri,uri,len);
+ sprintf(command,"INSERT INTO refObj values ('%s', '%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis', %d)",qabout,quri,curr->val);
+ /* fprintf(stderr, "%s\n", command); */
+ res = PQexec(conn, command);
+ if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
+ {
+ fprintf(stderr, "BEGIN command failed\n");
+ PQclear(res);
+ exit_nicely(conn);
+ }
+ curr = curr->next;
+ }
+ }
+}
+
+print_mainconcl(about,conn,uri,depth)
+ char *about;
+ PGconn *conn;