Commit | Line | Data |
---|---|---|
9e8e5516 C |
1 | /* showattr.c - */ |
2 | ||
3 | #ifndef lint | |
4 | static char *rcsid = "$Header: /f/osi/quipu/dish/RCS/showattr.c,v 7.2 91/02/22 09:40:53 mrose Interim $"; | |
5 | #endif | |
6 | ||
7 | /* | |
8 | * $Header: /f/osi/quipu/dish/RCS/showattr.c,v 7.2 91/02/22 09:40:53 mrose Interim $ | |
9 | * | |
10 | * | |
11 | * $Log: showattr.c,v $ | |
12 | * Revision 7.2 91/02/22 09:40:53 mrose | |
13 | * Interim 6.8 | |
14 | * | |
15 | * Revision 7.1 90/10/17 11:55:40 mrose | |
16 | * sync | |
17 | * | |
18 | * Revision 7.0 89/11/23 22:20:21 mrose | |
19 | * Release 6.0 | |
20 | * | |
21 | */ | |
22 | ||
23 | /* | |
24 | * NOTICE | |
25 | * | |
26 | * Acquisition, use, and distribution of this module and related | |
27 | * materials are subject to the restrictions of a license agreement. | |
28 | * Consult the Preface in the User's Manual for the full terms of | |
29 | * this agreement. | |
30 | * | |
31 | */ | |
32 | ||
33 | ||
34 | #include "quipu/util.h" | |
35 | #include "quipu/attrvalue.h" | |
36 | #include "quipu/entry.h" | |
37 | ||
38 | extern Entry current_entry; | |
39 | extern DN current_dn; | |
40 | extern DN dn; | |
41 | ||
42 | #define OPT (!frompipe || rps -> ps_byteno == 0 ? opt : rps) | |
43 | #define RPS (!frompipe || opt -> ps_byteno == 0 ? rps : opt) | |
44 | extern char frompipe; | |
45 | extern PS rps, opt; | |
46 | ||
47 | extern char value_flag; | |
48 | extern char key_flag; | |
49 | extern char print_format; | |
50 | extern char show_all_flag; | |
51 | ||
52 | static Attr_Sequence ignore_attr = NULLATTR; | |
53 | static char ignore_unknown = FALSE; | |
54 | ||
55 | showattribute (at) | |
56 | AttributeType at; | |
57 | { | |
58 | Attr_Sequence eptr; | |
59 | ||
60 | if (! show_all_flag) { | |
61 | if ( ! check_want_attr (at)) | |
62 | return; | |
63 | } else if ( ! check_want_tmp_attr (at)) | |
64 | return; | |
65 | ||
66 | for (eptr = current_entry->e_attributes; eptr != NULLATTR; eptr = eptr->attr_link) { | |
67 | /* Tiptoe through the list of types until one matches, and then print value. */ | |
68 | if (AttrT_cmp (eptr->attr_type,at) == 0) { | |
69 | if (value_flag) | |
70 | if (key_flag) | |
71 | as_comp_print (RPS,eptr,print_format); | |
72 | else | |
73 | avs_print (RPS,eptr->attr_value,print_format); | |
74 | else { | |
75 | AttrT_print (RPS,at,print_format); | |
76 | ps_print (RPS, "\n"); | |
77 | } | |
78 | break; | |
79 | } | |
80 | } | |
81 | ||
82 | if (eptr == NULLATTR) | |
83 | if (key_flag) | |
84 | ps_printf (OPT, "%-21s - (No such attribute in this entry)\n", at->oa_ot.ot_name); | |
85 | else | |
86 | ps_printf (OPT, "No value\n"); | |
87 | ||
88 | } | |
89 | ||
90 | show_unknown () | |
91 | { | |
92 | ignore_unknown = TRUE; | |
93 | } | |
94 | ||
95 | check_want_attr (at) | |
96 | AttributeType at; | |
97 | { | |
98 | Attr_Sequence as; | |
99 | ||
100 | if (at == NULLTABLE_ATTR) | |
101 | return (ignore_unknown); | |
102 | ||
103 | if (at->oa_syntax == 0) | |
104 | return (ignore_unknown); | |
105 | ||
106 | for (as=ignore_attr; as != NULLATTR; as=as->attr_link) | |
107 | if (AttrT_cmp (at,as->attr_type) == 0) | |
108 | return (FALSE); | |
109 | ||
110 | return (check_want_tmp_attr(at)); | |
111 | } | |
112 | ||
113 | check_want_tmp_attr (at) | |
114 | AttributeType at; | |
115 | { | |
116 | Attr_Sequence as; | |
117 | Attr_Sequence as2; | |
118 | extern Attr_Sequence tmp_ignore; | |
119 | extern Attr_Sequence as_flag; | |
120 | ||
121 | if (at->oa_syntax == 0) | |
122 | return (ignore_unknown || show_all_flag); | |
123 | ||
124 | for (as=tmp_ignore; as != NULLATTR; as=as->attr_link) | |
125 | if (AttrT_cmp (at,as->attr_type) == 0) { | |
126 | /* may be explicitly wanted... */ | |
127 | for (as2=as_flag; as2 != NULLATTR; as2=as2->attr_link) | |
128 | if (AttrT_cmp (as2->attr_type,as->attr_type) == 0) | |
129 | return (TRUE); | |
130 | return (FALSE); | |
131 | } | |
132 | ||
133 | return (TRUE); | |
134 | } | |
135 | ||
136 | new_ignore (ptr) | |
137 | char * ptr; | |
138 | { | |
139 | AttributeType at; | |
140 | Attr_Sequence newas; | |
141 | ||
142 | if ((at = str2AttrT (ptr)) == NULLAttrT) | |
143 | return; | |
144 | newas = as_comp_new (at,NULLAV,NULLACL_INFO); | |
145 | ignore_attr = as_merge(ignore_attr,newas); | |
146 | } |