-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.c
174 lines (137 loc) · 4.24 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/* Zeta Command Interpreter.
Zeta is a Command interpreter built purely in C.
It provides a command-line interface to users to access the services offered by
the kernel of the OS.
Works with the Windows line of Operating Systems.
Coding by - Arun Michael Dsouza
Date : 26/08/2013
NOTE : Zeta has been built at an 'implementation-scale'. Although the native OS
is equipped with a standard command-line utility, use of Zeta is completely encouraged.
*/
//Header File Inclusion
#include <stdio.h>
#include <string.h>
#include <process.h>
#include <stdlib.h>
#include "sys_snap.h"
#include "str_manip.h"
void initiate();
void main_exit();
#define SIZE 30
char input[SIZE];
int main(int argc,char* argv[])
{
initiate();
return 0;
}
void initiate()
{
//Prompt Start
printf("\n:> ");
fgets(input,sizeof(input),stdin);
if((stricmp(input,"\n")==0))
{
initiate();
}
//----------------------------------------------------------------------------------------
//EXIT COMMAND
else if((stricmp(input,"exit\n")==0)) //To exit command interpreter
{
main_exit();
}
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//CLEAR SCREEN COMMAND
else if(stricmp(input,"clr\n")==0) //To clear screen
{
system("cls");
initiate();
}
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//TIME COMMANDS
else if((stricmp(input,"time\n")==0)) //To show time (default format-24hr HH/MM/SS.MS)
{
sys_time_def();
initiate();
}
else if((stricmp(input,"time-24\n")==0)) //To show time in 24hrformat (HH:MM)
{
sys_time_24hr();
initiate();
}
else if((stricmp(input,"time-12\n")==0)) //To show time in 12hr format (HH:MM AM/PM)
{
sys_time_12hr();
initiate();
}
else if((stricmp(input,"time-e\n")==0)) //To show time and provide 'editing' option
{
system("time");
initiate();
}
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//DATE COMMANDS
else if((stricmp(input,"date\n")==0)) //To show date (default format:MM/DD/YYYY)
{
sys_date_def();
initiate();
}
else if((stricmp(input,"date-e\n")==0)) //To show date and provide 'editing' option
{
system("date");
initiate();
}
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//DAY COMMANDS
else if((stricmp(input,"day\n")==0)) //To show day/date of month
{
sys_day();
initiate();
}
else if((stricmp(input,"day-i\n")==0)) //To show complete day info
{
sys_day_info();
initiate();
}
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
// STRING MANIPULATION COMMANDS
else if((stricmp(input,"strln\n")==0)) // Returns length of String
{
strln();
initiate();
}
else if((stricmp(input,"strwht\n")==0)) // Returns no. of whitespaces in the String
{
strwht();
initiate();
}
else if((stricmp(input,"strslice\n")==0)) // Returns a SubString from the given String using mentioned indices
{
strslice();
initiate();
}
else if((stricmp(input,"strcap\n")==0)) // Capitalises the entered String
{
strcap();
initiate();
}
else if((stricmp(input,"strtolow\n")==0)) // Converts uppercase String to lowercase
{
strtolow();
initiate();
}
//----------------------------------------------------------------------------------------
else
{
printf("\aCommand not found.\n");
initiate();
}
}
void main_exit()
{
exit(0);
}