-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain file
More file actions
117 lines (102 loc) · 6.25 KB
/
Copy pathmain file
File metadata and controls
117 lines (102 loc) · 6.25 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
#include <stdio.h>
#include <stdlib.h>
FILE* open_file(const char* argv[]);
int main(int argc, char* argv[]) {
if (argc == 1){
error_code(2);
} else{
FILE* data_base = open_file(argv[argc-1]);
for (int i=1; i<(argc-1);++i) // Processing of parameters
}
return 0;
}
void command_getter_library(){
printf("Please enter the command\n");
char* string = dynsting('/n');
if (!strcmp(string,"add_book")){add_book();command_getter_library();}
else if (!strcmp(string,"del_book")){del_book();command_getter_library();}
else if (!strcmp(string,"get_book")){get_book();command_getter_library();}
else if (!strcmp(string,"bring_book")){bring_book();command_getter_library();}
else if (!strcmp(string,"list_books")){list_books();command_getter_library();}
else if (!strcmp(string,"change_count_book_isbn")){change_count_book_isbn();command_getter_library();}
else if (!strcmp(string,"backup_library")){backup_library();command_getter_library();}
else if (!strcmp(string,"open_backup_library")){open_backup_library();command_getter_library();}
else if (!strcmp(string,"exit_library_db")){exit_library_db();}
else {error_code(20);}
}
void command_getter_student(){
printf("Please enter the command\n");
char* string = dynsting('/n');
if (!strcmp(string,"add_student")){add_student();command_getter_student();}
else if (!strcmp(string,"del_student")){del_student();command_getter_student();}
else if (!strcmp(string,"find_student")){find_student();command_getter_student();}
else if (!strcmp(string,"find_students_by_surname")){find_students_by_surname();command_getter_student();}
else if (!strcmp(string,"list_students")){list_students();command_getter_student();}
else if (!strcmp(string,"change_count_book_isbn")){change_count_book_isbn();command_getter_student();}
else if (!strcmp(string,"backup_student")){backup_student();command_getter_student();}
else if (!strcmp(string,"open_backup_student")){open_backup_student();command_getter_student();}
else if (!strcmp(string,"exit_student_db")){exit_student_db();}
else {error_code(20);}
}
void help() {
printf("*Commands for library database*\n");
printf("_________________________________________________________________\n");
printf("add_book Add book to library\n");
printf("del_book Delete book from library\n");
printf("get_book Get book from library and adds book to student\n");
printf("bring_book Adds count of book to library and delete book from student\n");
printf("list_books Shows all books in library\n"); // sorted ny ISBN
printf("change_count_book_isbn Change count of book to library by ISBN \n");
printf("backup_library Save the data of library in backup file\n");
printf("open_backup_library Open backup version of library\n");
printf("exit_library_db Save and close file of library\n\n");
printf("----------Example for initializing programme--------\n");
printf("Project_database your_file.csv \n");
printf("----------Example for initializing programme--------\n\n");
printf("_________________________________________________________________");
printf("*Commands for student database*\n");
printf("_________________________________________________________________\n");
printf("add_student Add student to database\n");
printf("del_student Delete student from database\n");
printf("find_student Get student from database by number\n");
printf("find_students_by_surname Get student from database by surname\n");
printf("list_students Shows all students in database\n"); // sorted ny number
printf("edit_student Change count of book to library by ISBN \n");
printf("backup_student Save the data of students database in backup file\n");
printf("open_backup_student Open backup version of students database\n");
printf("exit_student_db Save and close file of student database\n\n");
printf("----------Example for initializing programme--------\n");
printf("Project_database your_file.csv \n");
printf("----------Example for initializing programme--------\n\n");
printf("_________________________________________________________________");
};
void error_code (int a){
switch (a) {
case 1: printf("ERROR: File not be opened\n"); exit(0);
case 2: printf("ERROR: File not indicated\n"); help(); exit(0);
case 3: printf("ERROR: Logger error\n"); exit(0);
case 4: printf("ERROR: Wrong login or password\n"); exit(0);
case 5: printf("ERROR: File not be opened\n"); exit(0);
case 6: printf("ERROR: Can't add the book\n"); exit(0);
case 7: printf("ERROR: Can't delete the book\n"); exit(0);
case 8: printf("ERROR: Can't get the book\n"); exit(0);
case 9: printf("ERROR: Can't bring the book\n"); exit(0);
case 10: printf("ERROR: Can't change count of book \n"); exit(0);
case 11: printf("ERROR: Can't create backup the library database \n"); exit(0);
case 12: printf("ERROR: Can't open backup of library\n"); exit(0);
case 13: printf("ERROR: Can't add the student\n"); exit(0);
case 14: printf("ERROR: Can't delete the student\n"); exit(0);
case 15: printf("ERROR: Can't find student by number\n"); exit(0);
case 16: printf("ERROR: Can't find students by surname\n"); exit(0);
case 17: printf("ERROR: Can't edit the student \n"); exit(0);
case 18: printf("ERROR: Can't backup the students database \n"); exit(0);
case 19: printf("ERROR: Can't open backup of students database \n"); exit(0);
case 21: printf("ERROR: Enter wrong command\n"); exit(0);
}
}
FILE* open_file(const char* argv[]){
FILE* file_thread;
if ((file_thread = (argv[0],"r");)==NULL) {
error_code(1);
}
}