Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef _MSC_VER
- #define _CRT_SECURE_NO_WARNINGS
- #endif
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #include <ctype.h>
- #define MAX_LINE_LEN 1000
- #define ROOM_NAME_MAX 6
- #define SIZE_TMP 70
- typedef struct room_raw {
- int id;
- char name[ROOM_NAME_MAX];
- char type[11];
- } room_t_raw;
- typedef struct role_raw {
- int id;
- char type[20];
- } role_t_raw;
- typedef struct person_raw {
- int id;
- char name[SIZE_TMP];
- int role;
- int salery;
- } person_t_raw;
- typedef struct subject_raw {
- int id;
- char name[SIZE_TMP];
- } subject_t_raw;
- typedef struct group_raw {
- int id;
- char name[SIZE_TMP];
- int subject_id;
- int supervisor_id;
- int co_supervisor_id;
- char subject[45];
- char supervisor[40];
- char co_supervisor[40];
- } group_t_raw;
- typedef struct ressource_raw {
- int id;
- char name[SIZE_TMP];
- } ressource_t_raw;
- typedef struct booking_raw {
- int room_id;
- int room_timeslot_id;
- int room_ressource_id;
- char room_ressource_type[20]; /* room or person */
- char room_date[15];
- char room_timeslot[15];
- int person_id;
- int person_timeslot_id;
- int person_ressource_id;
- char person_ressource_type[26]; /* room or person */
- char person_date[15];
- char person_timeslot[15];
- } booking_t_raw;
- typedef struct timeslot_raw {
- int id;
- char date[15];
- char week_day[4];
- char time_string[15]; // her
- } timeslot_t_raw;
- typedef struct seminar_raw {
- int id;
- int presenter;
- int opponent;
- int external_supervisor;
- int room;
- int timeslot;
- int supervisor;
- int co_supervisor;
- int presenter_subject;
- int opp_subject;
- char date[15];
- } seminar_t_raw;
- void create_room_t_raw(FILE *file_p, room_t_raw all_data[]);
- void create_role_t_raw(FILE *file_h, role_t_raw role[]);
- void create_person_t_raw(FILE *file_g, person_t_raw person[]);
- void create_subject_t_raw(FILE *file_a, subject_t_raw subject[]);
- void create_group_t_raw(FILE *file_b, group_t_raw group[]);
- void create_ressource_t_raw(FILE *file_c, ressource_t_raw ressource[]);
- void create_booking_rooms_t_raw(FILE *file_d, booking_t_raw booking[]);
- void create_seminar_t_raw(FILE *file_f, seminar_t_raw seminar[]);
- void create_timeslot_t_raw(FILE *file_p, timeslot_t_raw timeslot[]);
- void create_booking_persons_t_raw(FILE *file_e, booking_t_raw booking[]);
- int main(void)
- {
- FILE *file_p;
- FILE *file_h;
- FILE *file_g;
- FILE *file_a;
- FILE *file_b;
- FILE *file_c;
- FILE *file_d;
- FILE *file_e;
- FILE *file_f;
- FILE *file_j;
- file_p = fopen("Room.txt", "r");
- file_h = fopen("Role.txt", "r");
- file_g = fopen("Person.txt", "r");
- file_a = fopen("Subject.txt", "r");
- file_b = fopen("Group.txt", "r");
- file_c = fopen("Ressource_type.txt", "r");
- file_d = fopen("Timeslot.txt", "r");
- file_e = fopen("Booking_Persons.txt", "r");
- file_f = fopen("seminar.txt", "r");
- file_j = fopen("Booking_Rooms.txt", "r");
- room_t_raw all_data[75];
- role_t_raw role[75];
- person_t_raw person[500];
- subject_t_raw subject[500];
- group_t_raw group[500];
- ressource_t_raw ressource[500];
- timeslot_t_raw timeslot[500];
- booking_t_raw booking[500];
- seminar_t_raw seminar[500];
- create_room_t_raw(file_p, all_data);
- create_role_t_raw(file_h, role);
- create_person_t_raw(file_g, person);
- create_subject_t_raw(file_a, subject);
- create_group_t_raw(file_b, group);
- create_ressource_t_raw(file_c, ressource);
- create_timeslot_t_raw(file_d, timeslot);
- create_booking_rooms_t_raw(file_j, booking);
- create_seminar_t_raw(file_f, seminar);
- create_booking_persons_t_raw(file_e, booking);
- for (int i = 0; i < 5; ++i) {
- printf("Printer name: %s id: %d type: %s \n",
- all_data[i].name, all_data[i].id,
- all_data[i].type);
- }
- //for (int i = 0; i <3; ++i) {
- // printf("Printer id: %s type: %d \n",
- // role[i].type, role[i].id);
- //}
- /* for (int i = 0; i < 21; ++i) {
- printf("Printer Navn: %s id: %d role: %d\n",
- person[i].name, person[i].id,
- person[i].role);
- }*/
- /*for (int i = 0; i < 10; ++i) {
- printf("Printer id: %s name: %d \n",
- subject[i].name, subject[i].id);
- }*/
- /*for (int i = 0; i < 31; ++i) {
- printf("Printer id: %d name: %s subject: %s subject_id: %d supervisor: %s supervisor_id: %d co_supervisor: %s co_supervisor_id: %d\n",
- group[i].id, group[i].name, group[i].subject,
- group[i].subject_id, group[i].supervisor, group[i].supervisor_id,
- group[i].co_supervisor, group[i].co_supervisor_id);
- }*/
- /*for (int i = 0; i < 3; ++i) {
- printf("Printer name: %s id: %d\n",
- ressource[i].name, ressource[i].id);
- }*/
- /*for (int i = 0; i < 37; ++i) {
- printf("Printer id: %d date: %s timeslot: %s timeslot_id: %d ressource: %s ressource_id: %d \n",
- booking[i].room_id, booking[i].room_date,
- booking[i].room_timeslot, booking[i].room_timeslot_id,
- booking[i].room_ressource_type, booking[i].room_ressource_id);
- }*/
- /*for (int i = 0; i < 37; ++i) {
- printf("Printer id: %d date: %s timeslot: %s timeslot_id: %d ressource: %s ressource_id: %d \n",
- booking[i].person_id, booking[i].person_date,
- booking[i].person_timeslot, booking[i].person_timeslot_id,
- booking[i].person_ressource_type, booking[i].person_ressource_id);
- }*/
- /*for (int i = 0; i < 31; ++i) {
- printf("Printer id: %d presenter: %d opponot: %d ex_supervisor: %d room: %d timeslot: %d supervisor: %d co_supervisor: %d pre_subject: %d opp_subject: %d date: %s\n",
- seminar[i].id, seminar[i].presenter,
- seminar[i].opponent, seminar[i].external_supervisor,
- seminar[i].room, seminar[i].timeslot,
- seminar[i].supervisor, seminar[i].co_supervisor,
- seminar[i].presenter_subject, seminar[i].opp_subject,
- seminar[i].date);
- }*/
- /*for (int i = 0; i < 56; ++i) {
- printf("Printer date: %s weekday: %s timestring: %s id: %d \n",
- timeslot[i].date, timeslot[i].week_day,
- timeslot[i].time_string, timeslot[i].id);
- }*/
- return 0;
- }
- void create_room_t_raw(FILE *file_p, room_t_raw all_data[]) {
- char buff[MAX_LINE_LEN];
- int i = 0;
- fgets(buff, MAX_LINE_LEN, file_p);
- while (!feof(file_p)) {
- fgets(buff, MAX_LINE_LEN, file_p);
- sscanf(buff,
- "%[^\t\n] %d %s",
- all_data[i].name, &all_data[i].id,
- all_data[i].type);
- i++;
- }
- fclose(file_p);
- }
- void create_role_t_raw(FILE *file_h, role_t_raw role[]) {
- char buff[MAX_LINE_LEN];
- int i = 0;
- fgets(buff, MAX_LINE_LEN, file_h);
- while (!feof(file_h)) {
- fgets(buff, MAX_LINE_LEN, file_h);
- sscanf(buff,
- "%s %d ",
- role[i].type, &role[i].id);
- i++;
- }
- fclose(file_h);
- }
- void create_person_t_raw(FILE *file_g, person_t_raw person[]) {
- char buff[MAX_LINE_LEN];
- int i = 0;
- fgets(buff, MAX_LINE_LEN, file_g);
- while (!feof(file_g)) {
- fgets(buff, MAX_LINE_LEN, file_g);
- sscanf(buff,
- "%[^\t\n] %d %d",
- person[i].name, &person[i].id,
- &person[i].role);
- i++;
- }
- fclose(file_g);
- }
- void create_subject_t_raw(FILE *file_a, subject_t_raw subject[]) {
- char buff[MAX_LINE_LEN];
- int i = 0;
- fgets(buff, MAX_LINE_LEN, file_a);
- while (!feof(file_a)) {
- fgets(buff, MAX_LINE_LEN, file_a);
- sscanf(buff,
- "%[^\t\n] %d",
- subject[i].name, &subject[i].id);
- i++;
- }
- fclose(file_a);
- }
- void create_group_t_raw(FILE *file_b, group_t_raw group[]) {
- char buff[MAX_LINE_LEN];
- int i = 0;
- fgets(buff, MAX_LINE_LEN, file_b);
- while (!feof(file_b)) {
- fgets(buff, MAX_LINE_LEN, file_b);
- sscanf(buff,
- "%d %[^\t\n] %[^\t\n] %d %[^\t\n] %d %[^\t\n] %d",
- &group[i].id, group[i].name, group[i].subject,
- &group[i].subject_id, group[i].supervisor, &group[i].supervisor_id,
- group[i].co_supervisor, &group[i].co_supervisor_id);
- i++;
- }
- fclose(file_b);
- }
- void create_ressource_t_raw(FILE *file_c, ressource_t_raw ressource[]) {
- char buff[MAX_LINE_LEN];
- int i = 0;
- fgets(buff, MAX_LINE_LEN, file_c);
- while (!feof(file_c)) {
- fgets(buff, MAX_LINE_LEN, file_c);
- sscanf(buff,
- "%s %d",
- ressource[i].name, &ressource[i].id);
- i++;
- }
- fclose(file_c);
- }
- void create_booking_rooms_t_raw(FILE *file_j, booking_t_raw booking[]) {
- char buff[MAX_LINE_LEN];
- int i = 0;
- fgets(buff, MAX_LINE_LEN, file_j);
- while (!feof(file_j)) {
- fgets(buff, MAX_LINE_LEN, file_j);
- sscanf(buff,
- "%d %[^\t\n] %[^\t\n] %d %s %d",
- &booking[i].room_id, booking[i].room_date,
- booking[i].room_timeslot, &booking[i].room_timeslot_id,
- booking[i].room_ressource_type, &booking[i].room_ressource_id);
- i++;
- }
- fclose(file_j);
- }
- void create_seminar_t_raw(FILE *file_f, seminar_t_raw seminar[]) {
- char buff[MAX_LINE_LEN];
- int i = 0;
- while (!feof(file_f)) {
- fgets(buff, MAX_LINE_LEN, file_f);
- sscanf(buff,
- "%d %d %d %d %d %d %d %d %d %d %[^,]",
- &seminar[i].id, &seminar[i].presenter,
- &seminar[i].opponent, &seminar[i].external_supervisor,
- &seminar[i].room, &seminar[i].timeslot,
- &seminar[i].supervisor, &seminar[i].co_supervisor,
- &seminar[i].presenter_subject, &seminar[i].opp_subject,
- seminar[i].date);
- i++;
- }
- fclose(file_f);
- }
- void create_timeslot_t_raw(FILE *file_d, timeslot_t_raw timeslot[]) {
- char buff[MAX_LINE_LEN];
- int i = 0;
- fgets(buff, MAX_LINE_LEN, file_d);
- while (!feof(file_d)) {
- fgets(buff, MAX_LINE_LEN, file_d);
- sscanf(buff,
- "%[^\t\n] %s %[^\t\n] %d",
- timeslot[i].date, timeslot[i].week_day,
- timeslot[i].time_string, ×lot[i].id);
- i++;
- }
- fclose(file_d);
- }
- void create_booking_persons_t_raw(FILE *file_e, booking_t_raw booking[]) {
- char buff[MAX_LINE_LEN];
- int i = 0;
- fgets(buff, MAX_LINE_LEN, file_e);
- while (!feof(file_e)) {
- fgets(buff, MAX_LINE_LEN, file_e);
- sscanf(buff,
- "%d %[^\t\n] %[^\t\n] %d %[^\t\n] %d",
- &booking[i].person_id, booking[i].person_date,
- booking[i].person_timeslot, &booking[i].person_timeslot_id,
- booking[i].person_ressource_type, &booking[i].person_ressource_id);
- i++;
- }
- fclose(file_e);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement