|
|
1.1 root 1: #include <stdio.h>
2:
3: /* contains:
4: * CH_RetrieveItem
5: */
6:
7: #include <sys/types.h>
8: #include <netns/ns.h>
9: #include "Clearinghouse2_defs.h"
10: #include <xnscourier/CHEntries.h>
11: #include <xnscourier/except.h>
12:
13: /*
14: * This module contains the routine:
15: * CH_RetrieveItem(pattern,property,result)
16: * ObjectNamePattern pattern;
17: * Property property;
18: * RetrieveItemResults *result;
19: */
20:
21: static Cardinal nullhash = 0;
22: static Authenticator nullagent = {{0,{0,(Unspecified*) 0}},
23: {1,&nullhash}};
24: static ObjectName currentname;
25: extern struct ns_addr *LookupCHAddr();
26:
27: CH_RetrieveItem(pattern,property,result)
28: ObjectNamePattern pattern;
29: Property property;
30: RetrieveItemResults *result;
31: {
32: CourierConnection *conn, *ch2conn;
33: extern CourierConnection *CH_GetFirstCH(), *CH_GetOtherCH();
34: RetrieveItemResults riresult;
35: ObjectName hint; /* from WrongServer errors */
36:
37: if (pattern.object == NULL ||
38: pattern.domain == NULL ||
39: pattern.organization == NULL) {
40: return(1);
41: }
42:
43: if ((conn = CH_GetFirstCH()) == NULL) {
44: fprintf(stderr,"Can't open connection to local Clearinghouse\n");
45: return(1);
46: }
47: DURING {
48: riresult= RetrieveItem(conn, NULL,
49: pattern,property,nullagent);
50: } HANDLER {
51: if (Exception.Code == REJECT_ERROR) {
52: CourierClose(conn);
53: fprintf(stderr,"Problem with clearinghouse.addresses. Local CH rejected request\n");
54: return(1);
55: }
56:
57: if (Exception.Code != WrongServer) {
58: CourierClose(conn);
59: return(1); /* some random error */
60: }
61: hint = CourierErrArgs(WrongServerArgs,hint);
62: ch2conn = CH_GetOtherCH(conn,hint);
63: CourierClose(conn);
64: if (ch2conn == NULL) return(1);
65: conn = ch2conn;
66: /* probe the second clearinghouse */
67: DURING
68: riresult = RetrieveItem(conn,NULL,
69: pattern, property, nullagent);
70: HANDLER {
71: /* should be smarter is WrongServer here */
72: CourierClose(conn);
73: return(1);
74: } END_HANDLER;
75: /* we got it */
76: } END_HANDLER;
77:
78: CourierClose(conn);
79:
80: bcopy(&riresult, result, sizeof(Clearinghouse2_RetrieveItemResults));
81:
82: return(0);
83: }
84:
85:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.