tagged release 0.6.4
[parrot.git] / config / gen / crypto / digest_pmc.in
blob15d3a58f5a749dcd2e4126edd17c546b2ba268a9
1 /*
2 Copyright (C) 2008, The Perl Foundation.
3 $Id$
5 =head1 NAME
7 src/dynpmc/@md_file@.pmc - @md_name@ wrapper of libcrypto (libssl)
9 =head1 DESCRIPTION
11 See L<www.openssl.org>
13 =head2 Methods
15 =over 4
17 =cut
21 #include <openssl/@md_inc@.h>
23 pmclass @md_name@
24     dynpmc
25     need_ext
26     group digest_group {
30 =item C<void init()>
32 =cut
35     void init() {
36 @md_guard@
37         @md_ctx@ *c     = mem_allocate_zeroed_typed(@md_ctx@);
38         PMC_data(SELF) = c;
39         PObj_active_destroy_SET(SELF);
40 #else
41         real_exception(interp, NULL, ILL_INHERIT, "@md_name@ is disabled");
42 #endif
43     }
47 =item C<void destroy()>
49 =cut
52     void destroy() {
53 @md_guard@
54         @md_ctx@ *c = PMC_data_typed(SELF, @md_ctx@ *);
55         if (c) {
56             mem_sys_free(c);
57             PMC_data(SELF) = NULL;
58         }
59 #endif
60     }
64 =item C<PMC* clone()>
66 =cut
69     PMC* clone() {
70 @md_guard@
71         PMC     *retval  = pmc_new_noinit(INTERP, SELF->vtable->base_type);
72         @md_ctx@ *c       = mem_allocate_zeroed_typed(@md_ctx@);
74         memcpy(c, PMC_data(SELF), sizeof (@md_ctx@));
75         PMC_data(retval) = c;
77         PObj_active_destroy_SET(retval);
78         return retval;
79 #else
80         return NULL;
81 #endif
82     }
87 =back
89 =head2 Specific Methods
91 =over 4
93 =item C<void Init()>
95 =cut
98     METHOD void Init() {
99 @md_guard@
100         @md_ctx@ *c = PMC_data_typed(SELF, @md_ctx@ *);
101         (void)@md_name@_Init(c);
102 #endif
103     }
107 =item C<void Update(STRING *buf)>
109 =cut
112     METHOD void Update(STRING *buf) {
113 @md_guard@
114         @md_ctx@ *c = PMC_data_typed(SELF, @md_ctx@ *);
115         (void)@md_name@_Update(c, (unsigned char *)buf->strstart, buf->bufused);
116 #endif
117     }
121 =item C<STRING* Final()>
123 =cut
126     METHOD STRING* Final() {
127 @md_guard@
128         unsigned char digest[@md_digest@_LENGTH];
129         @md_ctx@      *c = PMC_data_typed(SELF, @md_ctx@ *);
130         STRING       *retval;
132         (void)@md_name@_Final(digest, c);
133         retval = string_from_cstring(INTERP, (char *)digest, @md_digest@_LENGTH);
135         RETURN(STRING *retval);
136 #else
137         return;
138 #endif
139     }
145 =back
147 =head1 AUTHORS
149 Francois Perrad
151 =cut
156  * Local variables:
157  *   c-file-style: "parrot"
158  * End:
159  * vim: expandtab shiftwidth=4:
160  */