-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathdecorate.c
190 lines (151 loc) · 9.1 KB
/
decorate.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// Welcome to the program. The declaration of the functions and the library used is in .h file
#include "main.h"
void screenAdjust () {
screenClear ();
bannerCenBorder ("", "", "", "POS Version : 1.0");
for ( int i = 0; i < 3; i++ )
bannerBlankBorder ();
bannerBlankBorderTextCen ("Please configure the terminal screen to optimum size.");
bannerBlankBorderTextCen ("Optimal screen size : 140 x 40 character");
for ( int i = 0; i < 23; i++ )
bannerBlankBorder ();
if ( errorResponse == 1 ) {
bannerBlankBorderTextCen ("Invalid response. Please try again.");
} else {
bannerBlankBorder ();
}
bannerBlankBorder ();
bannerBlankBorderTextCen ("Type 'Q' to stop | Type 'Y' to login | Type 'C' to see credits");
bannerFullBorder ();
bannerUserInput ();
char flags;
scanf (" %1c", &flags);
errorResponse = 0;
switch ( toupper (flags)) {
case ('Y'):
authInterface ();
return;
case ('Q'):
terminate ();
return;
case ('C'):
settingContributorList ();
screenAdjust ();
return;
default:
errorResponse = 1;
printf("\n");
screenAdjust ();
return;
}
}
void terminate () {
// Type in the text that will be displayed after the user wants to terminate the program
int i = 0;
char text[300];
for ( i = i; i < 10; i++ ) {
screenClear ();
strcpy (text, " ");
bannerFullBorder ();
bannerBlankBorderTextCen ("You about to terminate the POS system...");
bannerFullBorder ();
bannerBlankBorder ();
bannerBlankBorderTextCen ("Shutting the program down....");
bannerBlankBorderTextCen ("Saving Context");
bannerBlankBorder ();
strcat (text, "[ ");
for ( int j = i * 10; j > 0; j-- ) {
strcat (text, "|");
}
strcat (text, " ] ");
bannerBlankBorderTextCen (text);
for ( int i = 29; i > 0; i-- )
bannerBlankBorder ();
bannerBlankBorderTextCen ("Have a good luck. Bye Bye!");
bannerFullBorder ();
delay (1);
}
screenClear ();
exit (0);
}
void screenClear () {
// This function will clean the screen, and the other function will reprint the page.
printf("\n");
system ("clear");
}
void banner (char *bannerLine1, char *bannerLine2, char *bannerLine3, char *bannerLine4) {
// This function will print out the official banner.
printf (":: ██████╗ ██████╗ ███████╗ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n");
printf (":: ██╔══██╗██╔═══██╗██╔════╝ :: %-105s ::\n", bannerLine1);
printf (":: ██████╔╝██║ ██║███████╗ :: %-105s ::\n", bannerLine2);
printf (":: ██╔═══╝ ██║ ██║╚════██║ :: %-105s ::\n", bannerLine3);
printf (":: ██║ ╚██████╔╝███████║ :: %-105s ::\n", bannerLine4);
printf (":: ╚═╝ ╚═════╝ ╚══════╝ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n");
}
void bannerInverse (char *bannerLine1, char *bannerLine2, char *bannerLine3, char *bannerLine4) {
// This function will print out the official banner.
printf ("::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ██████╗ ██████╗ ███████╗ ::\n");
printf (":: %105s :: ██╔══██╗██╔═══██╗██╔════╝ ::\n", bannerLine1);
printf (":: %105s :: ██████╔╝██║ ██║███████╗ ::\n", bannerLine2);
printf (":: %105s :: ██╔═══╝ ██║ ██║╚════██║ ::\n", bannerLine3);
printf (":: %105s :: ██║ ╚██████╔╝███████║ ::\n", bannerLine4);
printf ("::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ╚═╝ ╚═════╝ ╚══════╝ ::\n");
}
void bannerCen () {
// This function will print out the official banner.
printf ("::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ██████╗ ██████╗ ███████╗ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n");
printf ("::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ██╔══██╗██╔═══██╗██╔════╝ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n");
printf ("::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ██████╔╝██║ ██║███████╗ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n");
printf ("::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ██╔═══╝ ██║ ██║╚════██║ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n");
printf ("::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ██║ ╚██████╔╝███████║ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n");
printf ("::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ╚═╝ ╚═════╝ ╚══════╝ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n");
}
void bannerCenBorder (char *bannerLine1, char *bannerLine2, char *bannerLine3, char *bannerLine4) {
// This function will print out the official banner.
printf ("::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ██████╗ ██████╗ ███████╗ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n");
printf (":: %-54s ██╔══██╗██╔═══██╗██╔════╝ %53s ::\n", bannerLine1, bannerLine2);
printf (":: ██████╔╝██║ ██║███████╗ ::\n");
printf (":: ██╔═══╝ ██║ ██║╚════██║ ::\n");
printf (":: %-54s ██║ ╚██████╔╝███████║ %53s ::\n", bannerLine3, bannerLine4);
printf ("::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ╚═╝ ╚═════╝ ╚══════╝ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n");
}
void bannerCenStrikethrough (char *bannerLine1, char *bannerLine2, char *bannerLine3, char *bannerLine4) {
// This function will print out the official banner.
printf (":: ██████╗ ██████╗ ███████╗ ::\n");
printf ("::%55s ██╔══██╗██╔═══██╗██╔════╝ %55s::\n", bannerLine1, bannerLine2);
printf ("::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ██████╔╝██║ ██║███████╗ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n");
printf ("::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ██╔═══╝ ██║ ██║╚════██║ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n");
printf ("::%55s ██║ ╚██████╔╝███████║ %55s::\n", bannerLine3, bannerLine4);
printf (":: ╚═╝ ╚═════╝ ╚══════╝ ::\n");
}
void bannerFullBorder () {
for ( int i = 0; i < 14; i++ )
printf ("::::::::::");
printf ("\n");
}
void bannerBlankBorderTextCen (char *text) {
int length = strlen (text) - 1; // Remove the terminal '\0'
int pad = (length >= 134) ? 0 : ((134 - length) / 2);
printf (":: %*s%s%*s ::\n", pad, " ", text, 133 - pad - length, " ");
}
void bannerBlankBorderText (char *text) {
printf (":: %134s ::\n", text);
}
void bannerBlankBorderTextLeft (char *text) {
printf (":: %-134s ::\n", text);
}
void bannerBlankBorder () {
printf (":: %134s ::\n", "");
}
void bannerUserInput () {
printf ("\n>>> ");
}
void bannerFullBorderSection () {
printf (":: ______________________________________________________________________________________________________________________________________ ::\n");
}
void delay (int interval) {
// This function will stop all threads from executing everything. Please be cautious about this...
if ( interval < 30 ) {// Avoiding excessive delay time.
sleep (interval);
}
}