-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
69 lines (60 loc) · 2.25 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
/*
This main function is used to ask the user which type of IP address they want to print.
It includes the custom ipv4.h and ipv6.h header files that define the functions for handling IPv4 and IPv6 addresses.
The user can enter either 4 or 6 as an input to choose the desired address format.
The function then calls the appropriate print function from the header files and displays the IP address on the screen.
*/
#include <stdio.h>
#include <string.h>
#include "headers/ipv4.h"
#include "headers/ipv6.h"
#include "docs/version.h"
#include "docs/error.h"
#include "docs/help.h"
/*
This paragraph explains the main function of our program.
It also demonstrates how to use the custom version and help options that we have implemented.
You can access these options by typing -vh or --help in the command line.
These options will show you the current version of the program and the available commands that you can use.
*/
int main(int argc, char *argv[])
{
for (int i = 1; i < argc; ++i)
{
if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
{
show_version();
return 0;
}
else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
{
show_help();
return 0;
}
else
{
show_error();
return 0;
}
}
int ip;
printf("\033[1;35m\t-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
printf("\033[1;32m\t\t IP ADDRESS GENERATOR \n");
printf("\033[1;35m\t-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n\n");
printf("\n\033[1;33m [+]\033[1;32m 1.IPV4 \n");
printf("\033[1;33m [+]\033[1;32m 2.IPV6 \n");
printf("\n\033[1;33m [+]\033[1;32m Which IP You want (1 or 2): ");
scanf("%d", &ip);
switch (ip)
{
case 1:
ipv4_generator();
break;
case 2:
ipv6_generator();
break;
default:
printf("\n\033[1;33m [!]\033[1;31m Invalid number of value. Exiting...\n");
}
return 0;
}