|
|
1.1 root 1: #include "quipu/util.h"
2: #include "quipu/attrvalue.h"
3: #include "quipu/malloc.h"
4:
5: extern short acl_sntx;
6: extern IFP merge_acl;
7:
8: Attr_Sequence str2as (str)
9: register char * str;
10: {
11: register char * ptr;
12: char * save, val;
13: oid_table_attr *at;
14: Attr_Sequence as;
15:
16: if (str == NULLCP)
17: return (NULLATTR);
18:
19: if ((ptr = index (str,'=')) == 0) {
20: parse_error ("equals missing %s",str);
21: return (NULLATTR);
22: }
23:
24: save = ptr++;
25: if (! isspace (*--save))
26: save++;
27:
28: ptr = SkipSpace (ptr);
29: if (*ptr == 0)
30: return (NULLATTR);
31:
32: val = *save;
33: *save = 0;
34:
35: if ((at = AttrT_new (str)) == NULLTABLE_ATTR) {
36: parse_error ("unknown attribute type '%s'",str);
37: *ptr = '=';
38: return (NULLATTR);
39: }
40:
41: *save = val;
42:
43: as = as_comp_alloc ();
44: as->attr_acl = NULLACL_INFO;
45: as->attr_type = at;
46: as->attr_link = NULLATTR;
47:
48: ATTRIBUTE_HEAP;
49:
50: if ((as->attr_value = str2avs (ptr,as->attr_type)) == NULLAV) {
51: RESTORE_HEAP;
52: as_free (as);
53: return (NULLATTR);
54: }
55:
56: RESTORE_HEAP;
57:
58: return (as);
59:
60: }
61:
62: Attr_Sequence as_combine (as,str)
63: Attr_Sequence as;
64: register char * str;
65: {
66: register char * ptr;
67: char * save, val;
68: AV_Sequence avs;
69: Attr_Sequence as2,nas;
70: oid_table_attr *at;
71:
72: if (str == NULLCP)
73: return (as);
74:
75: if ((ptr = index (str,'=')) == 0) {
76: parse_error ("equals missing %s",str);
77: return (as);
78: }
79:
80: save = ptr++;
81: if (! isspace (*--save))
82: save++;
83:
84: ptr = SkipSpace (ptr);
85: if (*ptr == 0)
86: return (as);
87:
88: val = *save;
89: *save = 0;
90:
91: if ((at = AttrT_new (str)) == NULLTABLE_ATTR) {
92: parse_error ("unknown attribute type '%s'",str);
93: *ptr = '=';
94: return (as);
95: } else
96: for (as2=as; as2 != NULLATTR; as2=as2->attr_link) {
97: if ( at == as2->attr_type ) {
98: *save = val;
99:
100: ATTRIBUTE_HEAP;
101:
102: if (at->oa_syntax == acl_sntx) {
103: (*merge_acl)(as2->attr_value,SkipSpace(ptr));
104: RESTORE_HEAP;
105: return (as);
106: }
107:
108: if ((avs = str2avs (ptr,as2->attr_type)) == NULLAV) {
109: RESTORE_HEAP;
110: return (as);
111: }
112:
113: as2->attr_value = avs_merge (as2->attr_value,avs);
114:
115: RESTORE_HEAP;
116:
117: return (as);
118: }
119: if ( at > as2->attr_type )
120: break;
121: }
122:
123: *save = val;
124:
125: nas = as_comp_alloc ();
126: nas->attr_acl = NULLACL_INFO;
127: nas->attr_type = at;
128: nas->attr_link = NULLATTR;
129:
130: ATTRIBUTE_HEAP;
131:
132: if ((nas->attr_value = str2avs (ptr,nas->attr_type)) == NULLAV) {
133: RESTORE_HEAP;
134: as_free (nas);
135: return (as);
136: }
137:
138: RESTORE_HEAP;
139:
140: return (as_merge(as,nas));
141:
142: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.