--- /dev/null
+/* $Header: CH.h,v 1.1 87/05/11 10:00:00 ed Exp $ */
+/*
+ * $Log: CH.h,v $
+ * Revision 1.1 87/05/11 10:00:00 ed
+ * Initial revision
+ *
+ * Revision 2.2 87/04/01 11:03:03 jqj
+ * added CH_NameToString and CH_NameToUser
+ *
+ * Revision 2.1 86/12/10 16:34:39 ed
+ * Webster changes
+ *
+ * Revision 2.1 86/12/10 16:34:39 ed
+ * Decide on correct Clearinghouse version until V3 is implemented
+ * consistently.
+ *
+ * Revision 2.0 85/11/21 07:22:27 jqj
+ * 4.3BSD standard release
+ *
+ * Revision 1.1 85/11/21 07:01:27 root
+ * Initial revision
+ *
+ */
+/*
+ * definitions for routines distributed as part of the Clearinghouse
+ * support package. See clearinghouse(3) for documentation.
+ */
+/*
+ * other include files needed:
+ * #include <sys/types.h>
+ * #include <netns/ns.h>
+ * #include <courier/Clearinghouse2.h>
+ */
+extern struct ns_addr *CH_LookupAddr(), *CH_LookupAddrDN();
+extern CourierConnection* CH_GetFirstCH(),
+ *CH_GetOtherCH();
+#ifdef __Clearinghouse2
+extern Clearinghouse2_ObjectName CH_StringToName();
+#endif
+#ifdef __Clearinghouse3
+extern Clearinghouse3_ObjectName CH_StringToName();
+#endif
+extern CH_Enumerate(), CH_EnumerateAliases();
+extern char *CH_NameToString(), *CH_NameToUser();
--- /dev/null
+# This is the default domain/organization on this system
--- /dev/null
+#include <stdio.h>
+
+/* contains:
+ * CH_RetrieveItem
+ */
+
+#include <sys/types.h>
+#include <netns/ns.h>
+#include "Clearinghouse2_defs.h"
+#include <xnscourier/CHEntries.h>
+#include <xnscourier/except.h>
+
+/*
+ * This module contains the routine:
+ * CH_RetrieveItem(pattern,property,result)
+ * ObjectNamePattern pattern;
+ * Property property;
+ * RetrieveItemResults *result;
+ */
+
+static Cardinal nullhash = 0;
+static Authenticator nullagent = {{0,{0,(Unspecified*) 0}},
+ {1,&nullhash}};
+static ObjectName currentname;
+extern struct ns_addr *LookupCHAddr();
+
+CH_RetrieveItem(pattern,property,result)
+ ObjectNamePattern pattern;
+ Property property;
+ RetrieveItemResults *result;
+{
+ CourierConnection *conn, *ch2conn;
+ extern CourierConnection *CH_GetFirstCH(), *CH_GetOtherCH();
+ RetrieveItemResults riresult;
+ ObjectName hint; /* from WrongServer errors */
+
+ if (pattern.object == NULL ||
+ pattern.domain == NULL ||
+ pattern.organization == NULL) {
+ return(1);
+ }
+
+ if ((conn = CH_GetFirstCH()) == NULL) {
+ fprintf(stderr,"Can't open connection to local Clearinghouse\n");
+ return(1);
+ }
+ DURING {
+ riresult= RetrieveItem(conn, NULL,
+ pattern,property,nullagent);
+ } HANDLER {
+ if (Exception.Code == REJECT_ERROR) {
+ CourierClose(conn);
+ fprintf(stderr,"Problem with clearinghouse.addresses. Local CH rejected request\n");
+ return(1);
+ }
+
+ if (Exception.Code != WrongServer) {
+ CourierClose(conn);
+ return(1); /* some random error */
+ }
+ hint = CourierErrArgs(WrongServerArgs,hint);
+ ch2conn = CH_GetOtherCH(conn,hint);
+ CourierClose(conn);
+ if (ch2conn == NULL) return(1);
+ conn = ch2conn;
+ /* probe the second clearinghouse */
+ DURING
+ riresult = RetrieveItem(conn,NULL,
+ pattern, property, nullagent);
+ HANDLER {
+ /* should be smarter is WrongServer here */
+ CourierClose(conn);
+ return(1);
+ } END_HANDLER;
+ /* we got it */
+ } END_HANDLER;
+
+ CourierClose(conn);
+
+ bcopy(&riresult, result, sizeof(Clearinghouse2_RetrieveItemResults));
+
+ return(0);
+}
+
+
--- /dev/null
+#ifndef lint
+static char *rcsid = "$Header: CHusername.c,v 1.1 87/05/11 09:59:41 ed Exp $";
+#endif lint
+
+/* contains:
+ * CH_NameToUser
+ */
+
+#ifndef CHUSERIDFILE
+#define CHUSERIDFILE "/usr/new/lib/xnscourier/chusermap"
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <netns/ns.h>
+#include <xnscourier/Clearinghouse2.h>
+#include <ctype.h>
+#include <ndbm.h>
+extern char *rindex(), *CH_NameToString();
+
+/*
+ * produce a UNIX user name by table lookup given a CHS name
+ */
+char *
+CH_NameToUser(chs_name)
+ Clearinghouse2_ThreePartName chs_name;
+{
+ static char userid[12];
+ DBM *db;
+ datum cptr, uptr;
+ register char *ptr;
+ Clearinghouse2_ObjectName chdefault;
+ FILE *dbf;
+ char charbuf[100];
+ int n;
+
+ uptr.dptr = NULL;
+ cptr.dptr = CH_NameToString(chs_name);
+ for (ptr =cptr.dptr; *ptr != '\0'; ptr++)
+ if (islower(*ptr)) *ptr = toupper(*ptr);
+
+ /* lookup user id in hashed database */
+ if ( (db= dbm_open(CHUSERIDFILE, 0, 0)) != (DBM*)0 ) {
+ cptr.dsize = strlen(cptr.dptr);
+ uptr = dbm_fetch(db, cptr);
+ dbm_close(db);
+ }
+ /* lookup user id in text database using linear search */
+ else if ( (dbf = fopen(CHUSERIDFILE, 0)) >= 0 ) {
+ while ((n=fscanf(dbf, "%[^\t\n]\t%s\n",charbuf,userid)) >= 0) {
+ if (n != 2) continue;
+ for (ptr=charbuf; *ptr != '\0'; ptr++)
+ if (islower(*ptr)) *ptr = toupper(*ptr);
+ if (strcmp(charbuf,cptr.dptr) == 0) {
+ uptr.dptr = userid;
+ break; /* found it! */
+ }
+ }
+ fclose(dbf);
+ }
+ if (uptr.dptr != NULL) return(uptr.dptr);
+
+ /* default case */
+ chdefault.object = chdefault.domain = chdefault.organization = NULL;
+ CH_NameDefault(&chdefault);
+ if ( strcmp(chs_name.domain,chdefault.domain) != 0 ||
+ strcmp(chs_name.organization,chdefault.organization) != 0)
+ return("nobody");
+ else if ( (ptr= rindex(chs_name.object, ' ')) == 0 )
+ return(chs_name.object);
+ else
+ return(ptr+1);
+}
--- /dev/null
+3H.AA0F0CD3 ":Computer Science:Cornell-Univ"