summaryrefslogtreecommitdiff
path: root/pith/body.c
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2018-02-24 16:53:39 -0700
committerEduardo Chappa <chappa@washington.edu>2018-02-24 16:53:39 -0700
commiteefc696ec87ae287803aa68032649e5a7a9b89d0 (patch)
tree1a0be044bb1a4d542cf3c722e8b6131a92915621 /pith/body.c
parenta6441d6f5b283ba98ba2524a64cf5704cd47cb0b (diff)
parent4675349e255a189126ab4922c7b95f761e673c64 (diff)
downloadalpine-eefc696ec87ae287803aa68032649e5a7a9b89d0.tar.xz
Merge branch 'ical'
Diffstat (limited to 'pith/body.c')
-rw-r--r--pith/body.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/pith/body.c b/pith/body.c
new file mode 100644
index 00000000..7d935810
--- /dev/null
+++ b/pith/body.c
@@ -0,0 +1,70 @@
+/*
+ * ========================================================================
+ * Copyright 2013-2017 Eduardo Chappa
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * ========================================================================
+ */
+
+#include "../pith/headers.h"
+#include "../pith/body.h"
+#include "../pith/smime.h"
+#include "../pith/ical.h"
+
+void *
+create_body_sparep(SpareType stype, void *s)
+{
+ BODY_SPARE_S *rv;
+
+ rv = fs_get(sizeof(BODY_SPARE_S));
+ rv->sptype = stype;
+ rv->data = s;
+ return (void *) rv;
+}
+
+SpareType
+get_body_sparep_type(void *s)
+{
+ return ((BODY_SPARE_S *)s)->sptype;
+}
+
+void *
+get_body_sparep_data(void *s)
+{
+ return ((BODY_SPARE_S *)s)->data;
+}
+
+void
+free_body_sparep(void **sparep)
+{
+ char *s;
+ SIZEDTEXT *st;
+ VCALENDAR_S *vcal;
+
+ if(sparep && *sparep){
+ switch(get_body_sparep_type(*sparep)){
+#ifdef SMIME
+ case P7Type: PKCS7_free((PKCS7 *) get_body_sparep_data(*sparep));
+ break;
+#endif /* SMIME */
+ case CharType: s = (char *)get_body_sparep_data(*sparep);
+ fs_give((void **) &s);
+ break;
+ case SizedText: st = (SIZEDTEXT *)get_body_sparep_data(*sparep);
+ fs_give((void **) &st->data);
+ fs_give((void **) &st);
+ break;
+ case iCalType: vcal = (VCALENDAR_S *)get_body_sparep_data(*sparep);
+ ical_free_vcalendar((void **) &vcal);
+ break;
+ default : break;
+ }
+ ((BODY_SPARE_S *)(*sparep))->data = NULL;
+ fs_give(sparep);
+ }
+}