-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_encode.c
68 lines (60 loc) · 1.83 KB
/
test_encode.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
64
65
66
67
68
#include <stdio.h>
#include <string.h>
#include "encode.h"
#include "decode.h"
#include "types.h"
int main(int argc,char*argv[])
{
//Structure for encoding
EncodeInfo encInfo;
//Structure for decoding
DecodeInfo decInfo;
//validation for input arguments
if(argc>=3)
{
if((check_operation_type(argv))==e_encode) //checking for e_encode
{
printf("Selected Encoding\n");
if(read_and_validate_encode_args(argv,&encInfo)==e_failure)
{
printf("Unsuccessful reading and validating\n");
}
else
{
printf("Successful reading and validating\n");
if(do_encoding(&encInfo)==e_success) //function call encoding
printf("Encoding Successful\n");
else
printf("ENcoding failure\n");
}
}
else if((check_operation_type(argv))==e_decode) //checking for e_decode
{
printf("Selected Decoding\n");
if(read_and_validate_decode_args(argv,&decInfo)==e_success)
{
printf("Successfull reading and validation\n");
if(do_decoding(&decInfo)==e_success) //function call decoding
printf("Decoding Successful\n");
else
printf("Decoding unsuccessful");
}
else
printf("UNsuccessful reading and validating\n");
}
else //printing error msg for other option
printf("Error:Entered option is not valid\n");
}
else
printf("Error:Enter Cmd line inputs more than 3 or equal to 3\n");
}
//function definition for operation type
OperationType check_operation_type(char*argv[])
{
if(strcmp(argv[1],"-e")==0) //for encoding
return e_encode;
else if(strcmp(argv[1],"-d")==0) //for decoding
return e_decode;
else
return e_unsupported;
}