-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
63 lines (49 loc) · 1.14 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <malloc.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
typedef struct Data {
} Data;
typedef struct Code {
Data* (*encode)(void*, Data*);
Data* (*decode)(void*, Data*);
void* info;
bool initialized;
} Code;
Data* encode(Code* code, Data* data) {
if (code->initialized) {
return code->encode(code->info, data);
} else {
printf("NOT INIALIZED\n");
}
return NULL;
}
Data* decode(Code* code, Data* data) {
return code->decode(code->info, data);
}
// ------ AES.h --------
typedef struct {
} AES_config;
// ------ AES.c
Data* aes_encode(void* config, Data* input) {
printf("AES ENCODE CALLED\n");
return NULL;
}
Data* aes_decode(void* config, Data* input) {
printf("AES DECODE CALLED\n");
return NULL;
}
void aes(Code* code, AES_config* config) {
code->encode = aes_encode;
code->decode = aes_decode;
code->info = config;
}
int main(int argc, char* argv[]) {
Code code = {0};
if (argc > 1 && strcmp(argv[1], "aes") == 0) {
AES_config config;
aes(&code, &config);
}
Data* data;
Data* encoded = encode(&code, data);
}