mf/tests: Test IMediaObject_GetOutputSizeInfo.
[wine.git] / dlls / msasn1 / main.c
blob480683c3bb5d29d53a0270edd27b8c90f25fd0c9
1 /*
2 * Copyright 2014 Austin English
3 * Copyright 2020 Vijay Kiran Kamuju
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "msasn1.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(msasn1);
31 ASN1module_t WINAPI ASN1_CreateModule(ASN1uint32_t ver, ASN1encodingrule_e rule, ASN1uint32_t flags,
32 ASN1uint32_t pdu, const ASN1GenericFun_t encoder[],
33 const ASN1GenericFun_t decoder[], const ASN1FreeFun_t freemem[],
34 const ASN1uint32_t size[], ASN1magic_t magic)
36 ASN1module_t module = NULL;
38 TRACE("(%08lx %08x %08lx %lu %p %p %p %p %lu)\n", ver, rule, flags, pdu, encoder, decoder, freemem, size, magic);
40 if (!encoder || !decoder || !freemem || !size)
41 return module;
43 module = malloc(sizeof(*module));
44 if (module)
46 module->nModuleName = magic;
47 module->eRule = rule;
48 module->dwFlags = flags;
49 module->cPDUs = pdu;
50 module->apfnFreeMemory = freemem;
51 module->acbStructSize = size;
53 if (rule & ASN1_PER_RULE)
55 module->PER.apfnEncoder = (ASN1PerEncFun_t *)encoder;
56 module->PER.apfnDecoder = (ASN1PerDecFun_t *)decoder;
58 else if (rule & ASN1_BER_RULE)
60 module->BER.apfnEncoder = (ASN1BerEncFun_t *)encoder;
61 module->BER.apfnDecoder = (ASN1BerDecFun_t *)decoder;
63 else
65 module->PER.apfnEncoder = NULL;
66 module->PER.apfnDecoder = NULL;
70 return module;
73 void WINAPI ASN1_CloseModule(ASN1module_t module)
75 TRACE("(%p)\n", module);
77 free(module);
80 ASN1error_e WINAPI ASN1_CreateEncoder(ASN1module_t module, ASN1encoding_t *encoder, ASN1octet_t *buf,
81 ASN1uint32_t bufsize, ASN1encoding_t parent)
83 ASN1encoding_t enc;
85 TRACE("(%p %p %p %lu %p)\n", module, encoder, buf, bufsize, parent);
87 if (!module || !encoder)
88 return ASN1_ERR_BADARGS;
90 enc = malloc(sizeof(*enc));
91 if (!enc)
93 return ASN1_ERR_MEMORY;
96 if (parent)
97 FIXME("parent not implemented.\n");
99 enc->magic = 0x44434e45;
100 enc->version = 0;
101 enc->module = module;
102 enc->buf = 0;
103 enc->size = 0;
104 enc->len = 0;
105 enc->err = ASN1_SUCCESS;
106 enc->bit = 0;
107 enc->pos = 0;
108 enc->cbExtraHeader = 0;
109 enc->eRule = module->eRule;
110 enc->dwFlags = module->dwFlags;
112 if (buf && bufsize)
114 enc->buf = buf;
115 enc->pos = buf;
116 enc->size = bufsize;
117 enc->dwFlags |= ASN1ENCODE_SETBUFFER;
120 *encoder = enc;
122 return ASN1_SUCCESS;
125 void WINAPI ASN1_CloseEncoder(ASN1encoding_t encoder)
127 FIXME("(%p): Stub!\n", encoder);
130 ASN1error_e WINAPI ASN1_CreateDecoder(ASN1module_t module, ASN1decoding_t *decoder, ASN1octet_t *buf,
131 ASN1uint32_t bufsize, ASN1decoding_t parent)
133 ASN1decoding_t dec;
135 TRACE("(%p %p %p %lu %p)\n", module, decoder, buf, bufsize, parent);
137 if (!module || !decoder)
138 return ASN1_ERR_BADARGS;
140 dec = malloc(sizeof(*dec));
141 if (!dec)
143 return ASN1_ERR_MEMORY;
146 if (parent)
147 FIXME("parent not implemented.\n");
149 dec->magic = 0x44434544;
150 dec->version = 0;
151 dec->module = module;
152 dec->buf = 0;
153 dec->size = bufsize;
154 dec->len = 0;
155 dec->err = ASN1_SUCCESS;
156 dec->bit = 0;
157 dec->pos = 0;
158 dec->eRule = module->eRule;
159 dec->dwFlags = module->dwFlags;
161 if (buf)
163 dec->buf = buf;
164 dec->pos = buf;
165 dec->dwFlags |= ASN1DECODE_SETBUFFER;
168 *decoder = dec;
170 return ASN1_SUCCESS;
173 void WINAPI ASN1_CloseDecoder(ASN1decoding_t decoder)
175 FIXME("(%p): Stub!\n", decoder);
178 ASN1error_e WINAPI ASN1_Decode(ASN1decoding_t decoder, void **outdata, ASN1uint32_t pdunum,
179 ASN1uint32_t flags, ASN1octet_t *buf, ASN1uint32_t bufsize)
181 FIXME("(%p %p %lu %08lx %p %lu): Stub!\n", decoder, outdata, pdunum, flags, buf, bufsize);
183 if (!decoder)
184 return ASN1_ERR_BADARGS;
186 if (!buf || !bufsize)
188 decoder->err = ASN1_ERR_BADARGS;
189 return ASN1_ERR_BADARGS;
192 decoder->err = ASN1_ERR_BADPDU;
193 return ASN1_ERR_BADPDU;