*
*/
+#include <talloc.h>
+
+#include <tr.h>
#include <trust_router/tr_name.h>
-#include <tr_rp.h>
#include <tr_config.h>
-#include <tr.h>
+#include <tr_rp.h>
+#include <tr_debug.h>
-TR_RP_CLIENT *tr_rp_client_lookup(TR_INSTANCE *tr, TR_NAME *gss_name) {
+TR_RP_CLIENT *tr_rp_client_lookup(TR_RP_CLIENT *rp_clients, TR_NAME *gss_name) {
TR_RP_CLIENT *rp = NULL;
int i = 0;
- if ((!tr) || (!tr->active_cfg) || (!gss_name)) {
- fprintf(stderr, "tr_rp_client_lookup: Bad parameters.\n");
+ if ((!rp_clients) || (!gss_name)) {
+ tr_debug("tr_rp_client_lookup: Bad parameters.");
return NULL;
}
- for (rp = tr->active_cfg->rp_clients; NULL != rp; rp = rp->next) {
- for (i = 0; i < TR_MAX_GSS_NAMES; i++) {
- if (!strcmp(gss_name->buf, rp->gss_names[i]->buf)) {
+ for (rp = rp_clients; NULL != rp; rp = rp->next) {
+ for (i = 0; ((i < TR_MAX_GSS_NAMES) && (NULL != (rp->gss_names[i]))); i++) {
+ if (!tr_name_cmp(gss_name, rp->gss_names[i])) {
return rp;
}
}
}
return NULL;
}
+
+/* talloc note: lists of idp realms should be assembled using
+ * tr_idp_realm_add(). This will put all of the elements in the
+ * list, other than the head, as children of the head context.
+ * The head can then be placed in whatever context is desired. */
+
+static TR_RP_REALM *tr_rp_realm_tail(TR_RP_REALM *realm)
+{
+ while (realm!=NULL)
+ realm=realm->next;
+ return realm;
+}
+
+/* for correct behavior, call like: rp_realms=tr_rp_realm_add(rp_realms, new_realm); */
+TR_RP_REALM *tr_rp_realm_add(TR_RP_REALM *head, TR_RP_REALM *new)
+{
+ if (head==NULL)
+ head=new;
+ else {
+ tr_rp_realm_tail(head)->next=new;
+ while (new!=NULL) {
+ talloc_steal(head, new); /* put it in the right context */
+ new=new->next;
+ }
+ }
+ return head;
+}