update project structure & create Makefile

This commit is contained in:
SowinskiBraeden committed 2024-10-04 21:48:27 -07:00
1 parent b982588fb2
commit 0b14153113
13 files changed
+781 -667

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
#include "main.h"
#include "csv.h"
#ifndef COURSES_H_INCLUDED
#define COURSES_H_INCLUDED
typedef struct {
char uniqueCrsNos[MAX_COURSES][MAX_COURSE_NO_LEN];
uint16_t numberOfCourses;
} UNIQUE_COURSES;
typedef struct {
char crsNo[MAX_COURSE_NO_LEN];
uint16_t requests;
char description[MAX_COURSE_DES_LEN];
uint8_t credits;
uint32_t students[CLASS_CAP * CLASSROOMS * TOTAL_BLOCKS]; // Will be large enough to handle all pupil numbers taking this course, even if it is highly requested.
uint8_t globalNumberOfStudents;
} COURSE; // Course is the general information for selection and stuff?
typedef struct {
char crsNo[MAX_COURSE_NO_LEN];
char description[MAX_COURSE_DES_LEN];
uint32_t students[CLASS_CAP];
uint8_t numberOfStudents;
} CLASS; // A class is an actual active course, there can be many classes for 1 course, each with its own number of students.
UNIQUE_COURSES getNumberOfCourses(CSV_LINE *lines, size_t lines_len);
COURSE *getCourses(CSV_LINE *lines, size_t lines_len, UNIQUE_COURSES unique_course_info);
#endif
+17
View File
@@ -0,0 +1,17 @@
#include <stdbool.h>
#include "main.h"
#ifndef CSV_H_INCLUDED
#define CSV_H_INCLUDED
typedef struct {
uint32_t pupilNum;
char crsNo[MAX_COURSE_NO_LEN];
char description[MAX_COURSE_DES_LEN];
bool alternate;
} CSV_LINE;
int count_lines(char data_dir[]);
CSV_LINE *csvReader(char data_dir[], size_t size);
#endif
+11
View File
@@ -0,0 +1,11 @@
#include "courses.h"
#include "students.h"
#ifndef JSON_H_INCLUDED
#define JSON_H_INCLUDED
int createDirectory(const char *dir_name);
int writeStudentsToJson(STUDENT *students, size_t numberOfStudents, char output_dir[]);
int writeCoursesToJson(COURSE *courses, size_t numberOfCourses, char output_dir[]);
#endif
+34
View File
@@ -0,0 +1,34 @@
#ifndef MAIN_H_INCLUDED
#define MAIN_H_INCLUDED
// Import and define proper functions depending on OS
#ifdef _WIN32
#include <direct.h>
#define MKDIR(name) _mkdir(name)
#else
#include <unistd.h>
#define MKDIR(name) mkdir(name, 0777)
#endif
/*
Using define instead of constants prevents
"Variable modified error"
*/
// Important constants
#define MAX_PUPIL_NUM_LEN 8
#define MAX_COURSE_DES_LEN 50
#define MAX_COURSE_NO_LEN 21
#define MAX_COURSE_ID_LEN MAX_COURSE_NO_LEN + 3 // 3 includes the underscore and the 2 digit unique number to identify the course
#define TOTAL_BLOCKS 10 // the number of blocks between 2 semesters i.e 8 = 4 blocks per semester, 10 = 5 blocks per semester
#define MAX_REQUEST_ALTS 6
#define CLASSROOMS 40
#define MIN_REQ 18
#define CLASS_CAP 30
#define MAX_STUDENTS CLASS_CAP * CLASSROOMS
#define MAX_COURSES CLASSROOMS * TOTAL_BLOCKS
// 5 is the length of "FALSE" & 3 is the number of commas per line
#define MAX_CHAR MAX_PUPIL_NUM_LEN + MAX_COURSE_NO_LEN + MAX_COURSE_DES_LEN + 5 + 3
#endif
+34
View File
@@ -0,0 +1,34 @@
#include <stdbool.h>
#include "csv.h"
#include "main.h"
#ifndef STUDENTS_H_INCLUDED
#define STUDENTS_H_INCLUDED
typedef struct {
char crsNo[MAX_COURSE_NO_LEN];
char description[MAX_COURSE_DES_LEN];
bool alternate;
} REQUEST;
typedef struct {
uint32_t pupilNum;
REQUEST *requests;
uint8_t requestsLen;
char **schedule;
uint8_t expectedClasses;
uint8_t classes;
REQUEST *remainingAlts;
uint8_t remainingAltsLen;
uint8_t grade;
} STUDENT;
typedef struct {
uint32_t uniquePupilNumbers[MAX_STUDENTS];
size_t numberOfStudents;
} UNIQUE_STUDENTS;
UNIQUE_STUDENTS getNumberOfStudents(CSV_LINE *lines, size_t lines_len);
STUDENT *getStudents(CSV_LINE *lines, size_t lines_len, int total_blocks, UNIQUE_STUDENTS students_info);
#endif