-
Notifications
You must be signed in to change notification settings - Fork 1
/
database.c
46 lines (38 loc) · 1.03 KB
/
database.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
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
#include "../Api/commons.h"
#include "../Api/namedPipe/namedPipe.h"
#include "databaseapi.h"
void processRequestDatabase (Request * request) {
int state;
printf("Procensado request DB ...\n");
switch (request->action) {
case ADD_STUDENT:
state = DbAddStudent(request->connection->data->name, request->connection->data->average);
writeResponse(request, state);
break;
case DELETE_STUDENT:
state = DbDeleteStudent(request->connection->data->name);
writeResponse(request, state);
break;
case READ_STUDENTS:
state = DbReadStudents();
writeResponse(request, state);
break;
case DROP_TABLE:
state = DbDropTable();
writeResponse(request, state);
break;
case CREATE_TABLE:
state = DbCreateTable();
writeResponse(request, state);
break;
default:
printf("Error request action\n");
}
}