|
|
1.1 root 1: /* read.c - */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/quipu/dish/RCS/read.c,v 7.0 89/11/23 22:20:18 mrose Rel $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/quipu/dish/RCS/read.c,v 7.0 89/11/23 22:20:18 mrose Rel $
9: *
10: *
11: * $Log: read.c,v $
12: * Revision 7.0 89/11/23 22:20:18 mrose
13: * Release 6.0
14: *
15: */
16:
17: /*
18: * NOTICE
19: *
20: * Acquisition, use, and distribution of this module and related
21: * materials are subject to the restrictions of a license agreement.
22: * Consult the Preface in the User's Manual for the full terms of
23: * this agreement.
24: *
25: */
26:
27:
28: #include "quipu/util.h"
29: #include "quipu/read.h"
30: #include "quipu/entry.h"
31:
32: extern DN dn;
33:
34: #define OPT (!frompipe || rps -> ps_byteno == 0 ? opt : rps)
35: #define RPS (!frompipe || opt -> ps_byteno == 0 ? rps : opt)
36: extern char frompipe;
37: extern PS opt, rps;
38:
39: extern DN current_dn;
40: extern Entry current_entry;
41: char value_flag;
42: char all_flag;
43: char name_flag;
44: char show_all_flag;
45: Attr_Sequence as_flag = NULLATTR;
46: Attr_Sequence tmp_ignore = NULLATTR;
47: char flag_show;
48: char key_flag;
49: char print_format;
50:
51: read_cache (argc, argv)
52: int argc;
53: char **argv;
54: {
55: extern char doneget;
56:
57: if (doneget)
58: return (argc);
59:
60: return (read_cache_aux (argc,argv,TRUE, (CommonArgs *) 0));
61: }
62:
63: read_cache_aux (argc, argv, ali, ca)
64: int argc;
65: char **argv;
66: char ali;
67: CommonArgs *ca;
68: {
69: Entry read_entry;
70: int x = 1;
71: char noread_flag = FALSE;
72: char do_read = FALSE;
73: Attr_Sequence as;
74: extern int copy_flag;
75: int deref = FALSE;
76: struct ds_read_arg read_arg;
77:
78: value_flag = TRUE;
79: all_flag = TRUE;
80: show_all_flag = FALSE;
81: if (as_flag != NULLATTR) {
82: as_free (as_flag);
83: as_flag = NULLATTR;
84: }
85: flag_show = TRUE;
86: key_flag = TRUE;
87:
88: if (ca)
89: read_arg.rda_common = *ca; /* struct copy */
90: else
91: if ((argc = service_control (OPT, argc, argv, &read_arg.rda_common)) == -1)
92: return (-1);
93:
94: if ( (argc = set_read_flags (argc,argv)) == -1)
95: return (-1);
96:
97: read_arg.rda_eis.eis_infotypes = value_flag;
98: read_arg.rda_eis.eis_allattributes = all_flag;
99: read_arg.rda_eis.eis_select = as_flag;
100:
101: if (!copy_flag)
102: do_read = TRUE;
103:
104: for (x=1; x< argc; x++) {
105: if (test_arg (argv[x], "-nocache",4))
106: do_read = TRUE;
107: else if (test_arg (argv[x], "-cache",2))
108: noread_flag = TRUE;
109: else
110: continue;
111: shuffle_up (argc--,argv,x--);
112: }
113:
114: if ( ! ali )
115: read_arg.rda_common.ca_servicecontrol.svc_options |= SVC_OPT_DONTDEREFERENCEALIAS;
116:
117: else if ((read_arg.rda_common.ca_servicecontrol.svc_options & SVC_OPT_DONTDEREFERENCEALIAS) == 0)
118: deref = TRUE;
119:
120: if ((read_entry = local_find_entry (dn, deref)) != NULLENTRY) {
121:
122: for (as = as_flag; as!= NULLATTR; as = as->attr_link)
123: if (as_find_type (read_entry->e_attributes, as->attr_type) == NULL)
124: do_read = TRUE;
125:
126: if (value_flag && (!read_entry->e_lock))
127: do_read = TRUE;
128:
129: if ((read_arg.rda_eis.eis_allattributes == 1) && (!read_entry->e_complete))
130: do_read = TRUE;
131:
132: current_entry = read_entry;
133: dn_free (current_dn);
134: current_dn = get_copy_dn (read_entry);
135: } else
136: do_read = TRUE;
137:
138: if (do_read)
139: if (noread_flag)
140: if (read_entry == NULLENTRY) {
141: ps_print (OPT, "No data in cache, but '-cache' prevents me reading it!\n");
142: return (-1);
143: } else
144: ps_print (OPT, "Read required, but '-cache' specified,\nproceeding using cache...\n");
145: else {
146: struct DSError error;
147: struct ds_read_result result;
148:
149: read_arg.rda_object = dn;
150:
151: if (rebind () != OK)
152: return(-2);
153:
154: /* Strong authentication */
155: if (read_arg.rda_common.ca_security !=
156: (struct security_parms *) 0)
157: {
158: struct signature *sign_operation();
159: int encode_DAS_ReadArgumentData();
160:
161: read_arg.rda_common.ca_sig =
162: sign_operation((caddr_t)&read_arg,
163: encode_DAS_ReadArgumentData);
164: }
165:
166: while (ds_read (&read_arg, &error, &result) != DS_OK) {
167: if (dish_error (OPT, &error) == 0)
168: return (-2);
169: read_arg.rda_object = error.ERR_REFERRAL.DSE_ref_candidates->cr_name;
170: }
171:
172: if (result.rdr_entry.ent_attr == NULLATTR) {
173: ps_print (OPT, "No attributes\n");
174: return (-2);
175: }
176:
177: if (result.rdr_common.cr_aliasdereferenced) {
178: ps_print (RPS, "(Alias dereferenced)\n");
179: }
180:
181: cache_entry (&(result.rdr_entry), read_arg.rda_eis.eis_allattributes, value_flag);
182:
183: entryinfo_comp_free (&result.rdr_entry,0);
184:
185: return (argc);
186: }
187:
188: return (argc);
189: }
190:
191:
192: set_read_flags (argc,argv)
193: int argc;
194: char ** argv;
195: {
196: register int x;
197: AttributeType at;
198: extern char allow_move;
199:
200: print_format = READOUT;
201: tmp_ignore = NULLATTR;
202:
203: for (x = 1; x < argc; x++) {
204: if (test_arg (argv[x], "-all",1)) {
205: show_all_flag = TRUE;
206: all_flag = TRUE;
207: } else if (test_arg (argv[x], "-noall",3)) {
208: show_all_flag = FALSE;
209: all_flag = FALSE;
210: } else if (test_arg (argv[x], "-value",1))
211: value_flag = EIS_ATTRIBUTESANDVALUES;
212: else if (test_arg (argv[x], "-novalue",3))
213: value_flag = EIS_ATTRIBUTETYPESONLY;
214: else if (test_arg (argv[x], "-show",2))
215: flag_show = TRUE;
216: else if (test_arg (argv[x], "-noshow",4))
217: flag_show = FALSE;
218: else if (test_arg(argv[x],"-noname",3))
219: name_flag = FALSE;
220: else if (test_arg (argv[x],"-name",2))
221: name_flag = TRUE;
222: else if (test_arg (argv[x], "-key",1))
223: key_flag = TRUE;
224: else if (test_arg (argv[x], "-nokey",3))
225: key_flag = FALSE;
226: else if (test_arg (argv[x], "-edb",3))
227: print_format = EDBOUT;
228: else if (test_arg (argv[x], "-sequence",3)) {
229: if (x + 1 == argc) {
230: ps_printf (OPT, "We need a sequence name.\n");
231: return (-1);
232: } else {
233: shuffle_up (argc--, argv, x);
234: set_sequence (argv[x]);
235: }
236: } else if (test_arg (argv[x],"-types",2)) {
237: shuffle_up (argc--, argv, x);
238: if (x >= argc) {
239: ps_printf (OPT,"-types argument missing\n");
240: return (-1);
241: }
242: if ((at = AttrT_new (argv[x])) != NULLAttrT) {
243: show_all_flag = TRUE;
244: all_flag = FALSE;
245: as_flag = as_merge (as_flag,as_comp_new (AttrT_cpy (at), NULLAV, NULLACL_INFO));
246: } else {
247: ps_printf (OPT,"Unknown attribute type %s\n",argv[x]);
248: return (-1);
249: }
250: for (x++; x < argc;) {
251: if (*argv[x] == '-')
252: break;
253: if ((at = AttrT_new (argv[x])) != NULLAttrT)
254: as_flag = as_merge (as_flag,as_comp_new (AttrT_cpy (at), NULLAV, NULLACL_INFO));
255: else
256: break;
257: shuffle_up (argc--,argv,x);
258: }
259: x--;
260: } else if (test_arg (argv[x],"-notypes",4)) {
261: shuffle_up (argc--, argv, x);
262: if (x >= argc) {
263: ps_printf (OPT,"-notypes argument missing\n");
264: return (-1);
265: }
266: if ((at = AttrT_new (argv[x])) != NULLAttrT) {
267: tmp_ignore = as_merge (tmp_ignore,as_comp_new (AttrT_cpy (at), NULLAV, NULLACL_INFO));
268: } else {
269: ps_printf (OPT,"Unknown attribute type %s\n",argv[x]);
270: return (-1);
271: }
272: for (x++; x < argc;) {
273: if (*argv[x] == '-')
274: break;
275: if ((at = AttrT_new (argv[x])) != NULLAttrT)
276: tmp_ignore = as_merge (tmp_ignore,as_comp_new (AttrT_cpy (at), NULLAV, NULLACL_INFO));
277: else
278: break;
279: shuffle_up (argc--,argv,x);
280: }
281: x--;
282: } else if (test_arg (argv[x],"-proc",3)) {
283: short sntx;
284: shuffle_up (argc--, argv, x);
285: if (x >= argc) {
286: ps_printf (OPT,"<syntax> missing\n");
287: return (-1);
288: }
289: if ((sntx = str2syntax (argv[x])) == 0) {
290: if (lexequ (argv[x],"ASN") != 0) {
291: ps_printf (OPT,"Unknown syntax %s\n",argv[x]);
292: return (-1);
293: }
294: }
295: shuffle_up (argc--, argv, x);
296: set_av_pe_print (sntx,argv[x]);
297: } else if (allow_move) {
298: if (move (argv[x]) != OK)
299: continue;
300: } else
301: continue;
302:
303: shuffle_up (argc--,argv,x--);
304: }
305: return (argc);
306: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.