-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbirbOS.cpp
More file actions
220 lines (217 loc) · 5.7 KB
/
birbOS.cpp
File metadata and controls
220 lines (217 loc) · 5.7 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#include <iostream>
#include <string>
#include <fstream>
#include <windows.h>
#include <direct.h>
#include "libs/sha256.h"
#include <typeinfo>
void print(std::string str){
std::cout << str << std::endl;
};
void wait(int sec){
Sleep(sec * 1000);
};
int main(){
sys_start:
string osbuild="BirbOS C++ 0.2 Beta";
SetConsoleTitle("BirbOS C++ 0.2 Beta");
wait(2);
system("cls");
print("BirbOS c++ is booting...");
wait(3);
print("Booted successfuly!");
login:
system("cls");
print("Login to birbOS. (Type \"Guest\" for guest account, and type \"shutdown\" to shutdown.)");
print("");
print("List of available users:");
print("Guest");
system("dir /b users");
print("");
string u;
string p;
cout << "Username>> ";
getline(cin, u);
if(u.empty()){
print("Please enter an username!");
goto login;
}
int skip = 0;
if(u=="Guest"){
skip = 1;
}
if(u=="shutdown"){
print("Shutting down.. Please wait");
wait(3);
return 0;
}
if(skip != 1){
std::string folder =
"users/" +
u + "/";
if(GetFileAttributes(folder.c_str()) != INVALID_FILE_ATTRIBUTES){
}
else{
print("User does not exist.");
goto login;
};
std::string pwordfile =
"users/" +
u + "/.birbuser";
ifstream ifile(pwordfile.c_str());
if (ifile) {
cout << "Password>> ";
getline(cin, p);
if(u.empty()){
print("Please enter password!");
goto login;
}
char *cp = &p[0u];
std::ifstream ifs (pwordfile.c_str());
std::string s;
getline (ifs, s, (char) ifs.eof());
std::string s1 = s.erase(64,3);
std::string s2 = SHA256(cp);
char *str1 = &s1[0u];
char *str2 = &s2[0u];
if(strcmp(str1, str2) != 0){
print("Password is incorrect!");
goto login;
};
}
ifile.close();
}
p = "";
logon:
print("Login successful.");
print("");
print("");
print(" °°°° ° °°°°°° °°°° °°°° °°°°°");
print(" ° ° ° ° ° ° ° ° °");
print(" ° ° ° ° ° ° ° ° ° °");
print(" °°°°° ° °°°°°°° °°°°° ° ° °°°°°°°");
print(" ° ° ° °° ° ° ° ° °");
print(" ° ° ° ° ° ° ° ° ° °");
print(" °°°° ° ° °° °°°° °°°° °°°°°");
print("");
print("");
wait(1);
system("color 1a");
wait(1);
system("color 2b");
wait(1);
system("color 3c");
wait(1);
system("color 0f");
print("Welcome, " + u);
wait(2);
cmdprompt:
string input;
cout << u + "$birbOS >>";
cin >> input;
if(input=="calculator"){
string exp;
cout << "Enter expression: ";
cin >> exp;
if(exp.empty()){
print("Please enter expression!");
goto cmdprompt;
}
print("This feature is in works..");
goto cmdprompt;
}
if(input == "reboot /refresh"){
print("Rebooting...");
wait(2);
goto sys_start;
}
if(input == "reboot"){
print("Rebooting..");
wait(2);
system("birbtool");
return 0;
}
if(input == "shutdown"){
print("BirbOS is shutting down.");
wait(2);
print("See you later!");
wait(1);
return 0;
}
if(input == "bsod"){
system("cls");
wait(0.5);
system("color 9f");
wait(0.25);
print("BirbOS has been unexpectedly shutdown.");
print("");
print("Please report this error if it is important : ");
print("ERR : USER_INITIATED_CRASH");
print("0;0;01");
print("");
print("");
print("Press ENTER to restart.");
system("pause > nul");
ShellExecute(NULL, "open", "birbtool.exe", NULL, NULL, SW_SHOWDEFAULT);
return 1;
}
if(input == "help"){
print("Commands : reboot [/refresh], shutdown, help, clear, about, logoff, folder, writedoc, readdoc, clean");
goto cmdprompt;
}
if(input == "clear"){
system("cls");
goto cmdprompt;
}
if(input == "about"){
print(osbuild);
print("Developed by ad2017.");
goto cmdprompt;
}
if(input == "logoff"){
print("Logging off..");
wait(3);
system("cls");
goto login;
}
if(input == "makedir"){
string f;
cout << "Enter folder name : ";
cin >> f;
std::string folder =
"users/" +
u + "/" + f + "/";
mkdir(folder.c_str());
print("Folder created!");
goto cmdprompt;
}
if(input == "writedoc"){
print("Feature coming soon..");
goto cmdprompt;
}
if(input == "readdoc"){
print("Feature coming soon..");
goto cmdprompt;
}
if(input == "clean"){
print("This command has no use because apps are not implemented yet.");
goto cmdprompt;
}
if(input == "set-theme"){
string theme;
print("Themes : dark, light");
cin >> theme;
if(theme == "dark"){
system("color 0f");
goto cmdprompt;
}
if(theme == "light"){
system("color f0");
goto cmdprompt;
}
print("Invalid theme.");
goto cmdprompt;
}
print("Invalid command");
goto cmdprompt;
}