1 #include "csf.h" 2 #include "csfimpl.h" 3 4 /* delete attribute from map 5 * MdelAttribute deletes an attribute 6 * from a map, if the attribute is available. 7 * returns 8 * the id argument if the attribute is successfully deleted, 9 * or 0 in case of error or if the attribute is not found. 10 * 11 * Merrno 12 * NOACCESS 13 * WRITE_ERROR 14 */ 15 CSF_ATTR_ID MdelAttribute( 16 MAP *m, /* map handle */ 17 CSF_ATTR_ID id) /* identification of attribute */ 18 { 19 ATTR_CNTRL_BLOCK b; 20 CSF_FADDR32 pos; 21 22 if (! WRITE_ENABLE(m)) 23 { 24 M_ERROR(NOACCESS); 25 goto error; 26 } 27 28 pos = CsfGetAttrBlock(m, id, &b); 29 if (pos == 0) 30 goto error; 31 32 b.attrs[CsfGetAttrIndex(id, &b)].attrId = ATTR_NOT_USED; 33 if (CsfWriteAttrBlock(m, pos, &b)) 34 { 35 M_ERROR(WRITE_ERROR); 36 goto error; 37 } 38 39 return id ; 40 41 error: return 0 ; /* not found or an error */ 42 } 43