2 * ========================================================================
3 * Copyright 2013-2021 Eduardo Chappa
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * ========================================================================
14 #include "../pith/headers.h"
15 #include "../pith/body.h"
16 #include "../pith/smime.h"
17 #include "../pith/ical.h"
20 create_body_sparep(SpareType stype
, void *s
)
24 rv
= fs_get(sizeof(BODY_SPARE_S
));
31 get_body_sparep_type(void *s
)
33 return ((BODY_SPARE_S
*)s
)->sptype
;
37 get_body_sparep_data(void *s
)
39 return ((BODY_SPARE_S
*)s
)->data
;
43 free_body_sparep(void **sparep
)
49 if(sparep
&& *sparep
){
50 switch(get_body_sparep_type(*sparep
)){
52 case P7Type
: PKCS7_free((PKCS7
*) get_body_sparep_data(*sparep
));
55 case CharType
: s
= (char *)get_body_sparep_data(*sparep
);
56 fs_give((void **) &s
);
58 case SizedText
: st
= (SIZEDTEXT
*)get_body_sparep_data(*sparep
);
59 fs_give((void **) &st
->data
);
60 fs_give((void **) &st
);
62 case iCalType
: vcal
= (VCALENDAR_S
*)get_body_sparep_data(*sparep
);
63 ical_free_vcalendar((void **) &vcal
);
67 ((BODY_SPARE_S
*)(*sparep
))->data
= NULL
;