Index: libabac/abac_pl_yap.c
===================================================================
--- libabac/abac_pl_yap.c	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
+++ libabac/abac_pl_yap.c	(revision 8bd77b59df89993868555d3b87f91fc241b09228)
@@ -12,26 +12,21 @@
 #include <Yap/YapInterface.h>
 
-#include "abac_pl.h"
+#include "abac_internal.h"
+
 #include "abac_pl_yap.h"
-
-#include "abac_list.h"
 #include "abac_util.h"
 
 #include "uthash.h"
 
-extern char *abac_cn_with_role(abac_role_t *);
-extern char *abac_cn_with_oset(abac_oset_t *);
-extern char *abac_principalname_with_role(abac_role_t *);
-extern char *abac_principalname_with_oset(abac_oset_t *);
 extern abac_list_t *abac_credential_clauses(abac_credential_t *);
-extern char *abac_id_clause(abac_id_cert_t *);
-extern abac_oset_t *abac_yy_get_rule_tail_oset();
-extern abac_oset_t *abac_yy_get_rule_head_oset();
-extern abac_role_t *abac_yy_get_rule_tail_role();
-extern abac_role_t *abac_yy_get_rule_head_role();
+extern char *abac_id_clause(abac_id_credential_t *);
+extern abac_aspect_t *abac_yy_get_rule_tail_aspect();
+extern abac_aspect_t *abac_yy_get_rule_head_aspect();
 
 
 static int debug=0;
+
 /* track constraint's external clause's -unique name id */
+
 static int constraint_label_count=0;
 static char *constraint_label="isABAC_constraint";
@@ -162,5 +157,5 @@
 }
 
-int abac_pl_add_type_credential(abac_pl_t *pl, abac_id_cert_t *id_cert)
+int abac_pl_add_type_credential(abac_pl_t *pl, abac_id_credential_t *id_cert)
 {
     char *clause=abac_id_clause(id_cert);
@@ -295,5 +290,5 @@
 
       acme.buys_rocket <- acme.preferred_customer  -- NOT DONE YET */
-static abac_stack_t *_query_with_role(abac_pl_t *pl, abac_role_t* role, abac_role_t* role_prin)
+static abac_stack_t *_query_with_aspect(abac_pl_t *pl, abac_aspect_t* head, abac_aspect_t* tail)
 {
     char tmp[5000];
@@ -301,84 +296,43 @@
 
     if(debug)
-        _show_yap_db("DEBUG:calling within _query_with_role");
-
-    /* if using cn */
-    char *prin_nm;
-    char *role_nm;
-    if(USE("ABAC_CN")) {
-        prin_nm=abac_cn_with_role(role_prin);
-        role_nm=abac_cn_with_role(role);
+        _show_yap_db("DEBUG:calling within _query_with_aspect");
+
+    
+    char *nm=abac_aspect_principal_name(head);
+
+    /* could be obj or principal */
+    char *prin_nm=NULL;
+    if(abac_aspect_is_object(tail)) {
+        prin_nm=abac_aspect_object_name(tail);
         } else {
-           prin_nm=abac_principalname_with_role(role_prin);
-           role_nm=abac_principalname_with_role(role);
-    }
-
-    if(abac_role_role_name(role_prin)!=NULL) {
-        printf("fail, a.r <- b.r query is not implemented yet !!!\n");
-        YAP_Exit(1);
-    }
-
-    if (prin_nm == NULL || role_nm == NULL) {
-        printf("fail, query's call got bad roles.. \n");
+            prin_nm=abac_aspect_principal_name(tail);
+    }
+
+    if(abac_aspect_aspect_name(tail)!=NULL) {
+        printf("fail, a.o <- b.o and a.r <- a.r query is not implemented yet !!!\n");
+        YAP_Exit(1);
+    }
+
+    if (prin_nm == NULL || nm == NULL) {
+        printf("fail, query's call got bad aspect names .. \n");
         YAP_Exit(1);
     }
 
     if(debug) printf("printing up the yap query ..\n");
-    char *pstring=abac_role_role_param_string(role);
+    char *pstring=abac_aspect_aspect_param_string(head);
+    char *stub=abac_aspect_type_string(head);
     if(pstring) {
-        sprintf(tmp,"role(%s,%s,%s)", role_nm, abac_role_role_name(role),pstring);
+        sprintf(tmp,"%s(%s,%s,%s)", stub, nm, abac_aspect_aspect_name(head),pstring);
         free(pstring);
         } else {
-            sprintf(tmp,"role(%s,%s)", role_nm, abac_role_role_name(role));
-    }
-    ret=_make_yap_query(prin_nm,role_nm,tmp);
+            sprintf(tmp,"%s(%s,%s)", stub, nm, abac_aspect_aspect_name(head));
+    }
+
+    ret=_make_yap_query(prin_nm,nm,tmp);
     return ret;
 }
 
-static abac_stack_t *_query_with_oset(abac_pl_t *pl, abac_oset_t* oset, abac_oset_t* oset_obj)
-{
-    char tmp[5000];
-    abac_stack_t *ret=NULL;
-
-    if(debug)
-        _show_yap_db("DEBUG:calling within _query_with_oset");
-
-    
-    char *oset_nm=NULL;
-    if(USE("ABAC_CN")) oset_nm=abac_cn_with_oset(oset);
-        else oset_nm=abac_principalname_with_oset(oset);
-    /* could be obj or principal */
-    char *prin_nm=NULL;
-    if(abac_oset_is_object(oset_obj)) {
-        prin_nm=abac_oset_object_name(oset_obj);
-        } else {
-            if(USE("ABAC_CN")) prin_nm=abac_oset_principal_cn(oset_obj);
-                else prin_nm=abac_oset_principal_principalname(oset_obj);
-    }
-
-    if(abac_oset_oset_name(oset_obj)!=NULL) {
-        printf("fail, a.o <- b.o query is not implemented yet !!!\n");
-        YAP_Exit(1);
-    }
-
-    if (prin_nm == NULL || oset_nm == NULL) {
-        printf("fail, query's call got bad oset.. \n");
-        YAP_Exit(1);
-    }
-
-    if(debug) printf("printing up the yap query ..\n");
-    char *pstring=abac_oset_oset_param_string(oset);
-    if(pstring) {
-        sprintf(tmp,"oset(%s,%s,%s)", oset_nm, abac_oset_oset_name(oset),pstring);
-        free(pstring);
-        } else {
-            sprintf(tmp,"oset(%s,%s)", oset_nm, abac_oset_oset_name(oset));
-    }
-
-    ret=_make_yap_query(prin_nm,oset_nm,tmp);
-    return ret;
-}
-
-static abac_stack_t *_dump(abac_pl_t *pl)
+/* this is only if the db is rather complete */
+static abac_stack_t *_dump_db(abac_pl_t *pl)
 {
     YAP_Term *eterm;
@@ -388,5 +342,5 @@
 
     if(USE("DUMP_DB"))
-        _show_yap_db("DEBUG:calling within _dump");
+        _show_yap_db("DEBUG:calling within _dump_db");
 
     char *estring=NULL;
@@ -419,5 +373,5 @@
         }
     } else {
-        printf("YAP _dump query failed\n");
+        printf("YAP _dump_db query failed\n");
         /* YAP_Exit(1); */
     }
@@ -426,5 +380,5 @@
 
 /* findall(X,isMember(_,_,X),L) */
-static abac_stack_t *_dump2(abac_pl_t *pl)
+static abac_stack_t *_dump2_db(abac_pl_t *pl)
 {
     YAP_Term *eterm;
@@ -434,5 +388,5 @@
 
     if(debug)
-        _show_yap_db("DEBUG:calling within _dump");
+        _show_yap_db("DEBUG:calling within _dump2_db");
 
     char *estring="isMember(_,_,X)";
@@ -452,5 +406,5 @@
         _credentials_from_string(cred_list,tmp); 
         } else {
-            printf("YAP _dump query failed\n");
+            printf("YAP _dump2_db query failed\n");
             /* YAP_Exit(1); */
     }
@@ -464,5 +418,5 @@
 abac_stack_t *abac_pl_credentials(abac_pl_t *pl)
 {
-    abac_stack_t *ret=_dump(pl);
+    abac_stack_t *ret=abac_verifier_dump_creds();
     return ret;
 }
@@ -494,13 +448,8 @@
     }
 
-    if(abac_yy_get_rule_is_oset()) {
-        abac_oset_t *head_oset = abac_yy_get_rule_head_oset();
-        abac_oset_t *tail_oset = abac_yy_get_rule_tail_oset();
-        ret=_query_with_oset(pl,head_oset,tail_oset);
-        } else {
-            abac_role_t *head_role = abac_yy_get_rule_head_role();
-            abac_role_t *tail_role = abac_yy_get_rule_tail_role();
-            ret=_query_with_role(pl,head_role,tail_role);
-    }
+    abac_aspect_t *head_aspect = abac_yy_get_rule_head_aspect();
+    abac_aspect_t *tail_aspect = abac_yy_get_rule_tail_aspect();
+    ret=_query_with_aspect(pl,head_aspect,tail_aspect);
+
     return ret;
 }
