-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
104 lines (102 loc) · 3.37 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
Name:Suresh Kumar
Date:23/11/2023
Description:Steganography
Input:./a.out -e beautiful.bmp secret.txt stego.bmp
Output:Selected encoding
Read and validate encode arguments is a success
############# Started Encoding #############
Open files is a successfully
width = 1024
height = 768
Check capacity is successfully
Copied bmp header successfully
Encoded magic string successfully
Encoded secret file extn size successfully
Encoded secret file extn successfully
Encoded secret file size successfully
Encoded secret file data successfully
Copied remaining data successfully
<--------Completed encoding-------->
Input:./a.out -d stego.bmp decode.txt
Output:Selected decoding
Read and validate decode arguments is a success
############### Started Decoding ##############
Open files is a successfully
Decoded magic string Successfully
Decoded file extension size Succesfully
Decoded Secret File Extension Succesfully
Decoded secret file size Successfully
Decoded secret file data Succuessfully
<---------Completed decoding--------->
*/
#include <stdio.h>
#include <string.h>
#include "encode.h"
#include "types.h"
#include "common.h"
#include "decode.h"
/* Passing arguments through command line arguments */
int main(int argc, char *argv[])
{
// Function call for check operation type
if (check_operation_type(argv) == e_encode)
{
printf("Selected encoding\n");
// Declare structure variable
EncodeInfo encInfo;
// Read and validate encode arguments
if (read_and_validate_encode_args(argv, &encInfo) == e_success)
{
printf("Read and validate encode arguments is a success\n");
printf("############# Started Encoding #############\n");
// Function call for encoding
if (do_encoding(&encInfo) == e_success)
{
printf("<--------Completed encoding-------->\n");
}
else
{
printf("Failed to encode\n");
return e_failure;
}
}
else
{
printf("Read and validate encode arguments is a failure\n");
return e_failure;
}
}
// Function call for check operation type
else if (check_operation_type(argv) == e_decode)
{
printf("Selected decoding\n");
// Declare structure variables
DecodeInfo decInfo;
if (read_and_validate_decode_args(argv, &decInfo) == d_success)
{
printf("Read and validate decode arguments is a success\n");
printf("############### Started Decoding ##############\n");
// Function call for do decoding
if (do_decoding(&decInfo) == d_success)
{
printf("<---------Completed decoding--------->\n");
}
else
{
printf("Failed to decode\n");
return e_failure;
}
}
else
{
printf("Read and validate decode arguments is a failure\n");
return e_failure;
}
}
else
{
printf("Invalid option\nKindly pass for\nEncoding: ./a.out -e beautiful.bmp secret.txt stego.bmp\nDecoding: ./a.out -d stego.bmp decode.txt\n");
}
return 0;
}