-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
92 lines (80 loc) · 2.29 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
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef _WIN32
#include <windows.h>
#include <conio.h>
#include "Lib\cmdFunctions.c"
#include "Lib\screens.c"
#include "Lib\stonks.c"
#include "Lib\history.c"
#define OsWindows 1
#endif
#ifdef linux
#define OsWindows 0
#include <unistd.h>
#include "Lib/cmdFunctions.c"
#include "Lib/screens.c"
#include "Lib/stonks.c"
#include "Lib/history.c"
#endif
int main(){
char nextScreen[20]; // this variable tells what screen should be shown next;
//SetConsoleOutputCP(1252); //Set console encoding to Windows 1252
if (OsWindows){
SetConsoleOutputCP(65001); //Set console encoding to utf8
system("color");
system("cls");
}
clearScreen() ;
/*______importStock Test ______*/
stock *head,*current;
head = (stock*)malloc(sizeof(stock));
// Making the stock list so that id=-1 means that the stock is empty
head->value.id = -1;
head->next = NULL;
// Importing stock data from STOCK_FILE
importStock(head);
/*______ Main Program ______*/
strcpy(nextScreen,"logo"); //set current screen to main Menu
while(1){
clearScreen();
//strcmp(str1,str2) -> return (0 if str1 == str2 else 1)
//Each Screen should set tell us what screen should be displayed next
if (strcmp(nextScreen,"logo") == 0){
show_logo(nextScreen);
}
else if ( strcmp(nextScreen,"add") == 0){
show_addProduct(nextScreen,head);
}
else if (strcmp(nextScreen, "update") == 0) {
show_updateProduct(nextScreen,head);
}
else if (strcmp(nextScreen,"delete") == 0){
show_deleteProduct(nextScreen,head);
}
else if (strcmp(nextScreen,"printstock") == 0){
show_printStock(nextScreen,head);
}
else if (strcmp(nextScreen,"search") == 0){
show_Search(nextScreen,head);
}
else if (strcmp(nextScreen,"printhistory") == 0){
history*hist;
hist = (history*)malloc(sizeof(history));
hist->value.operation_type = -1;
hist->next = NULL;
importHistory(hist);
show_printHistory(nextScreen,hist);
}
else if (strcmp(nextScreen,"main") == 0){
show_MainMenu(nextScreen);
}
else if (strcmp(nextScreen,"STONKS") == 0){
show_STONKS(nextScreen);
}
else if ( strcmp(nextScreen,"exit")== 0) break;
}
resetColor();
/*______ End of Main Program _______*/
}