Advertisement
Guest User

Runedata

a guest
Dec 15th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.45 KB | None | 0 0
  1. #ifdef _MSC_VER
  2. #define _CRT_SECURE_NO_WARNINGS
  3. #endif
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <time.h>
  9. #include <ctype.h>
  10.  
  11. #define MAX_LINE_LEN 1000
  12. #define ROOM_NAME_MAX 6
  13. #define SIZE_TMP 70
  14.  
  15.  
  16. typedef struct room_raw {
  17. int id;
  18. char name[ROOM_NAME_MAX];
  19. char type[11];
  20.  
  21. } room_t_raw;
  22.  
  23. typedef struct role_raw {
  24. int id;
  25. char type[20];
  26.  
  27. } role_t_raw;
  28.  
  29. typedef struct person_raw {
  30. int id;
  31. char name[SIZE_TMP];
  32. int role;
  33. int salery;
  34.  
  35. } person_t_raw;
  36.  
  37. typedef struct subject_raw {
  38. int id;
  39. char name[SIZE_TMP];
  40.  
  41. } subject_t_raw;
  42.  
  43. typedef struct group_raw {
  44. int id;
  45. char name[SIZE_TMP];
  46. int subject_id;
  47. int supervisor_id;
  48. int co_supervisor_id;
  49. char subject[45];
  50. char supervisor[40];
  51. char co_supervisor[40];
  52.  
  53. } group_t_raw;
  54.  
  55. typedef struct ressource_raw {
  56. int id;
  57. char name[SIZE_TMP];
  58.  
  59. } ressource_t_raw;
  60.  
  61. typedef struct booking_raw {
  62. int room_id;
  63. int room_timeslot_id;
  64. int room_ressource_id;
  65. char room_ressource_type[20]; /* room or person */
  66. char room_date[15];
  67. char room_timeslot[15];
  68. int person_id;
  69. int person_timeslot_id;
  70. int person_ressource_id;
  71. char person_ressource_type[26]; /* room or person */
  72. char person_date[15];
  73. char person_timeslot[15];
  74.  
  75. } booking_t_raw;
  76.  
  77. typedef struct timeslot_raw {
  78. int id;
  79. char date[15];
  80. char week_day[4];
  81. char time_string[15]; // her
  82.  
  83. } timeslot_t_raw;
  84.  
  85. typedef struct seminar_raw {
  86. int id;
  87. int presenter;
  88. int opponent;
  89. int external_supervisor;
  90. int room;
  91. int timeslot;
  92. int supervisor;
  93. int co_supervisor;
  94. int presenter_subject;
  95. int opp_subject;
  96. char date[15];
  97.  
  98.  
  99. } seminar_t_raw;
  100.  
  101. void create_room_t_raw(FILE *file_p, room_t_raw all_data[]);
  102. void create_role_t_raw(FILE *file_h, role_t_raw role[]);
  103. void create_person_t_raw(FILE *file_g, person_t_raw person[]);
  104. void create_subject_t_raw(FILE *file_a, subject_t_raw subject[]);
  105. void create_group_t_raw(FILE *file_b, group_t_raw group[]);
  106. void create_ressource_t_raw(FILE *file_c, ressource_t_raw ressource[]);
  107. void create_booking_rooms_t_raw(FILE *file_d, booking_t_raw booking[]);
  108. void create_seminar_t_raw(FILE *file_f, seminar_t_raw seminar[]);
  109. void create_timeslot_t_raw(FILE *file_p, timeslot_t_raw timeslot[]);
  110. void create_booking_persons_t_raw(FILE *file_e, booking_t_raw booking[]);
  111.  
  112. int main(void)
  113. {
  114.  
  115. FILE *file_p;
  116. FILE *file_h;
  117. FILE *file_g;
  118. FILE *file_a;
  119. FILE *file_b;
  120. FILE *file_c;
  121. FILE *file_d;
  122. FILE *file_e;
  123. FILE *file_f;
  124. FILE *file_j;
  125.  
  126.  
  127. file_p = fopen("Room.txt", "r");
  128. file_h = fopen("Role.txt", "r");
  129. file_g = fopen("Person.txt", "r");
  130. file_a = fopen("Subject.txt", "r");
  131. file_b = fopen("Group.txt", "r");
  132. file_c = fopen("Ressource_type.txt", "r");
  133. file_d = fopen("Timeslot.txt", "r");
  134. file_e = fopen("Booking_Persons.txt", "r");
  135. file_f = fopen("seminar.txt", "r");
  136. file_j = fopen("Booking_Rooms.txt", "r");
  137.  
  138.  
  139.  
  140. room_t_raw all_data[75];
  141. role_t_raw role[75];
  142. person_t_raw person[500];
  143. subject_t_raw subject[500];
  144. group_t_raw group[500];
  145. ressource_t_raw ressource[500];
  146. timeslot_t_raw timeslot[500];
  147. booking_t_raw booking[500];
  148. seminar_t_raw seminar[500];
  149.  
  150. create_room_t_raw(file_p, all_data);
  151. create_role_t_raw(file_h, role);
  152. create_person_t_raw(file_g, person);
  153. create_subject_t_raw(file_a, subject);
  154. create_group_t_raw(file_b, group);
  155. create_ressource_t_raw(file_c, ressource);
  156. create_timeslot_t_raw(file_d, timeslot);
  157. create_booking_rooms_t_raw(file_j, booking);
  158. create_seminar_t_raw(file_f, seminar);
  159. create_booking_persons_t_raw(file_e, booking);
  160.  
  161. for (int i = 0; i < 5; ++i) {
  162. printf("Printer name: %s id: %d type: %s \n",
  163. all_data[i].name, all_data[i].id,
  164. all_data[i].type);
  165. }
  166.  
  167. //for (int i = 0; i <3; ++i) {
  168. // printf("Printer id: %s type: %d \n",
  169. // role[i].type, role[i].id);
  170. //}
  171.  
  172. /* for (int i = 0; i < 21; ++i) {
  173. printf("Printer Navn: %s id: %d role: %d\n",
  174. person[i].name, person[i].id,
  175. person[i].role);
  176. }*/
  177.  
  178. /*for (int i = 0; i < 10; ++i) {
  179. printf("Printer id: %s name: %d \n",
  180. subject[i].name, subject[i].id);
  181. }*/
  182.  
  183. /*for (int i = 0; i < 31; ++i) {
  184. printf("Printer id: %d name: %s subject: %s subject_id: %d supervisor: %s supervisor_id: %d co_supervisor: %s co_supervisor_id: %d\n",
  185. group[i].id, group[i].name, group[i].subject,
  186. group[i].subject_id, group[i].supervisor, group[i].supervisor_id,
  187. group[i].co_supervisor, group[i].co_supervisor_id);
  188. }*/
  189.  
  190. /*for (int i = 0; i < 3; ++i) {
  191. printf("Printer name: %s id: %d\n",
  192. ressource[i].name, ressource[i].id);
  193. }*/
  194.  
  195. /*for (int i = 0; i < 37; ++i) {
  196. printf("Printer id: %d date: %s timeslot: %s timeslot_id: %d ressource: %s ressource_id: %d \n",
  197. booking[i].room_id, booking[i].room_date,
  198. booking[i].room_timeslot, booking[i].room_timeslot_id,
  199. booking[i].room_ressource_type, booking[i].room_ressource_id);
  200.  
  201. }*/
  202.  
  203. /*for (int i = 0; i < 37; ++i) {
  204. printf("Printer id: %d date: %s timeslot: %s timeslot_id: %d ressource: %s ressource_id: %d \n",
  205. booking[i].person_id, booking[i].person_date,
  206. booking[i].person_timeslot, booking[i].person_timeslot_id,
  207. booking[i].person_ressource_type, booking[i].person_ressource_id);
  208.  
  209. }*/
  210.  
  211. /*for (int i = 0; i < 31; ++i) {
  212. 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",
  213. seminar[i].id, seminar[i].presenter,
  214. seminar[i].opponent, seminar[i].external_supervisor,
  215. seminar[i].room, seminar[i].timeslot,
  216. seminar[i].supervisor, seminar[i].co_supervisor,
  217. seminar[i].presenter_subject, seminar[i].opp_subject,
  218. seminar[i].date);
  219. }*/
  220.  
  221. /*for (int i = 0; i < 56; ++i) {
  222. printf("Printer date: %s weekday: %s timestring: %s id: %d \n",
  223. timeslot[i].date, timeslot[i].week_day,
  224. timeslot[i].time_string, timeslot[i].id);
  225. }*/
  226.  
  227. return 0;
  228. }
  229.  
  230. void create_room_t_raw(FILE *file_p, room_t_raw all_data[]) {
  231.  
  232.  
  233. char buff[MAX_LINE_LEN];
  234. int i = 0;
  235.  
  236. fgets(buff, MAX_LINE_LEN, file_p);
  237.  
  238. while (!feof(file_p)) {
  239. fgets(buff, MAX_LINE_LEN, file_p);
  240. sscanf(buff,
  241. "%[^\t\n] %d %s",
  242. all_data[i].name, &all_data[i].id,
  243. all_data[i].type);
  244. i++;
  245.  
  246.  
  247. }
  248. fclose(file_p);
  249.  
  250. }
  251.  
  252. void create_role_t_raw(FILE *file_h, role_t_raw role[]) {
  253.  
  254.  
  255. char buff[MAX_LINE_LEN];
  256. int i = 0;
  257.  
  258. fgets(buff, MAX_LINE_LEN, file_h);
  259.  
  260. while (!feof(file_h)) {
  261. fgets(buff, MAX_LINE_LEN, file_h);
  262. sscanf(buff,
  263. "%s %d ",
  264. role[i].type, &role[i].id);
  265. i++;
  266.  
  267.  
  268. }
  269. fclose(file_h);
  270.  
  271. }
  272.  
  273. void create_person_t_raw(FILE *file_g, person_t_raw person[]) {
  274.  
  275.  
  276. char buff[MAX_LINE_LEN];
  277. int i = 0;
  278.  
  279. fgets(buff, MAX_LINE_LEN, file_g);
  280.  
  281. while (!feof(file_g)) {
  282. fgets(buff, MAX_LINE_LEN, file_g);
  283. sscanf(buff,
  284. "%[^\t\n] %d %d",
  285. person[i].name, &person[i].id,
  286. &person[i].role);
  287. i++;
  288.  
  289.  
  290. }
  291. fclose(file_g);
  292.  
  293. }
  294.  
  295. void create_subject_t_raw(FILE *file_a, subject_t_raw subject[]) {
  296.  
  297.  
  298. char buff[MAX_LINE_LEN];
  299. int i = 0;
  300.  
  301. fgets(buff, MAX_LINE_LEN, file_a);
  302.  
  303. while (!feof(file_a)) {
  304. fgets(buff, MAX_LINE_LEN, file_a);
  305. sscanf(buff,
  306. "%[^\t\n] %d",
  307. subject[i].name, &subject[i].id);
  308.  
  309. i++;
  310.  
  311.  
  312. }
  313. fclose(file_a);
  314.  
  315. }
  316.  
  317. void create_group_t_raw(FILE *file_b, group_t_raw group[]) {
  318.  
  319.  
  320. char buff[MAX_LINE_LEN];
  321. int i = 0;
  322.  
  323. fgets(buff, MAX_LINE_LEN, file_b);
  324.  
  325. while (!feof(file_b)) {
  326. fgets(buff, MAX_LINE_LEN, file_b);
  327. sscanf(buff,
  328. "%d %[^\t\n] %[^\t\n] %d %[^\t\n] %d %[^\t\n] %d",
  329. &group[i].id, group[i].name, group[i].subject,
  330. &group[i].subject_id, group[i].supervisor, &group[i].supervisor_id,
  331. group[i].co_supervisor, &group[i].co_supervisor_id);
  332.  
  333. i++;
  334.  
  335.  
  336. }
  337. fclose(file_b);
  338.  
  339. }
  340.  
  341. void create_ressource_t_raw(FILE *file_c, ressource_t_raw ressource[]) {
  342.  
  343.  
  344. char buff[MAX_LINE_LEN];
  345. int i = 0;
  346.  
  347. fgets(buff, MAX_LINE_LEN, file_c);
  348.  
  349. while (!feof(file_c)) {
  350. fgets(buff, MAX_LINE_LEN, file_c);
  351. sscanf(buff,
  352. "%s %d",
  353. ressource[i].name, &ressource[i].id);
  354.  
  355. i++;
  356.  
  357.  
  358. }
  359. fclose(file_c);
  360.  
  361. }
  362.  
  363. void create_booking_rooms_t_raw(FILE *file_j, booking_t_raw booking[]) {
  364.  
  365.  
  366. char buff[MAX_LINE_LEN];
  367. int i = 0;
  368.  
  369. fgets(buff, MAX_LINE_LEN, file_j);
  370.  
  371. while (!feof(file_j)) {
  372. fgets(buff, MAX_LINE_LEN, file_j);
  373. sscanf(buff,
  374. "%d %[^\t\n] %[^\t\n] %d %s %d",
  375. &booking[i].room_id, booking[i].room_date,
  376. booking[i].room_timeslot, &booking[i].room_timeslot_id,
  377. booking[i].room_ressource_type, &booking[i].room_ressource_id);
  378.  
  379. i++;
  380.  
  381.  
  382. }
  383. fclose(file_j);
  384.  
  385. }
  386.  
  387. void create_seminar_t_raw(FILE *file_f, seminar_t_raw seminar[]) {
  388.  
  389.  
  390. char buff[MAX_LINE_LEN];
  391. int i = 0;
  392.  
  393. while (!feof(file_f)) {
  394. fgets(buff, MAX_LINE_LEN, file_f);
  395. sscanf(buff,
  396. "%d %d %d %d %d %d %d %d %d %d %[^,]",
  397. &seminar[i].id, &seminar[i].presenter,
  398. &seminar[i].opponent, &seminar[i].external_supervisor,
  399. &seminar[i].room, &seminar[i].timeslot,
  400. &seminar[i].supervisor, &seminar[i].co_supervisor,
  401. &seminar[i].presenter_subject, &seminar[i].opp_subject,
  402. seminar[i].date);
  403.  
  404. i++;
  405.  
  406.  
  407. }
  408. fclose(file_f);
  409.  
  410. }
  411.  
  412. void create_timeslot_t_raw(FILE *file_d, timeslot_t_raw timeslot[]) {
  413.  
  414.  
  415. char buff[MAX_LINE_LEN];
  416. int i = 0;
  417.  
  418. fgets(buff, MAX_LINE_LEN, file_d);
  419.  
  420. while (!feof(file_d)) {
  421. fgets(buff, MAX_LINE_LEN, file_d);
  422. sscanf(buff,
  423. "%[^\t\n] %s %[^\t\n] %d",
  424. timeslot[i].date, timeslot[i].week_day,
  425. timeslot[i].time_string, &timeslot[i].id);
  426. i++;
  427.  
  428.  
  429. }
  430. fclose(file_d);
  431.  
  432. }
  433.  
  434. void create_booking_persons_t_raw(FILE *file_e, booking_t_raw booking[]) {
  435.  
  436.  
  437. char buff[MAX_LINE_LEN];
  438. int i = 0;
  439.  
  440. fgets(buff, MAX_LINE_LEN, file_e);
  441.  
  442. while (!feof(file_e)) {
  443. fgets(buff, MAX_LINE_LEN, file_e);
  444. sscanf(buff,
  445. "%d %[^\t\n] %[^\t\n] %d %[^\t\n] %d",
  446. &booking[i].person_id, booking[i].person_date,
  447. booking[i].person_timeslot, &booking[i].person_timeslot_id,
  448. booking[i].person_ressource_type, &booking[i].person_ressource_id);
  449.  
  450. i++;
  451.  
  452.  
  453. }
  454. fclose(file_e);
  455.  
  456. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement