/* $Header: CHenumerate.c,v 2.2 87/04/01 12:42:12 jqj Exp $ */
/* $Log: CHenumerate.c,v $
* Revision 2.2 87/04/01 12:42:12 jqj
* reworked wrongserver code to correspond to new GetOtherCH semantics
* Revision 2.1 87/03/17 09:59:08 ed
* webster changes: handle WrongServer error
* Revision 2.1 87/03/17 09:59:08 ed
* Handle WrongServer error from first Clearinghouse
* Revision 2.0 85/11/21 07:22:30 jqj
* *** empty log message ***
* Revision 2.0 85/11/21 07:22:30 jqj
* 4.3BSD standard release
* Revision 1.1 85/03/26 06:26:59 jqj
* Revision 1.1 85/03/26 06:26:59 jqj
#include "Clearinghouse2_defs.h"
#include <xnscourier/CHEntries.h>
#include <xnscourier/except.h>
* This module contains the routine:
* int CH_Enumerate(pattern,property,eachName)
* ObjectNamePattern pattern;
* NameProcedure eachName;
* where NameProcedure is a procedure of the form:
static (*ProcEachName
)(); /* use: (*ProcEachName)(arg); */
static Cardinal nullhash
= 0;
static Authenticator nullagent
= {{0,{0,(Unspecified
*) 0}},
static ObjectName currentname
;
extern struct ns_addr
*LookupCHAddr();
printf("%s:%s:%s\n", name
.object
, name
.domain
, name
.organization
);
Unspecified buffer
[MAXWORDS
*MAXPACKS
], *bp
, *bufend
;
bp
= buffer
+((MAXWORDS
-1)*MAXPACKS
); /* end of available space */
while (count
= BDTread(conn
, (char*)bufend
,
MAXWORDS
*sizeof(Unspecified
))
bufend
+= count
/sizeof(Unspecified
);
fprintf(stderr
,"BDT read too big to fit\n");
/* should clear out stuff here if we knew how much */
bp
+= internalize_StreamOfObject(&obnames
,bp
);
if (0 == (int) obnames
.designator
) {
for (i
=0; i
< obnames
.nextSegment_case
.segment
.length
; i
++) {
obnames
.nextSegment_case
.segment
.sequence
[i
];
(*ProcEachName
)(currentname
);
free(obnames
.nextSegment_case
.segment
.sequence
);
for (i
= 0; i
< obnames
.lastSegment_case
.length
; i
++) {
obnames
.lastSegment_case
.sequence
[i
];
(*ProcEachName
)(currentname
);
free(obnames
.lastSegment_case
.sequence
);
CH_Enumerate(pattern
,property
,eachName
)
ObjectNamePattern pattern
;
CourierConnection
*conn
, *ch2conn
;
Clearinghouse2_ObjectName hint
; /* from WrongServer errors */
extern CourierConnection
*CH_GetFirstCH(), *CH_GetOtherCH();
ProcEachName
= listObject
;
if (pattern
.object
== NULL
||
pattern
.domain
== NULL
||
pattern
.organization
== NULL
)
currentname
.domain
= pattern
.domain
;
currentname
.organization
= pattern
.organization
;
if ((conn
= CH_GetFirstCH()) == NULL
) {
fprintf(stderr
,"Can't open connection to local Clearinghouse\n");
for (tries
= 5; tries
> 0 && retval
== -1; tries
--) {
ListObjects(conn
, GetObjects
, pattern
, property
,
BulkData1_immediateSink
, nullagent
);
if (Exception
.Code
== REJECT_ERROR
) {
if ((ch2conn
= CH_GetOtherCH(conn
, NULL
)) == NULL
)
} else if (Exception
.Code
== Clearinghouse2_WrongServer
) {
hint
= CourierErrArgs(Clearinghouse2_WrongServerArgs
, hint
);
if ((ch2conn
= CH_GetOtherCH(conn
, hint
)) == NULL
)