Merge branch 'master' of https://gitea.fhgr.ch/schurtisimon/StudyPlanner
modified: src/llist.c modified: src/planner.c modified: src/planner.h modified: src/ui.cbugfix
commit
3b8bd5dc40
|
@ -1,5 +1,4 @@
|
||||||
#include "llist.h"
|
#include "llist.h"
|
||||||
#include <asm-generic/errno.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
|
@ -226,7 +226,7 @@ llist *genPlan(llist *head, time_t timeAvail) {
|
||||||
0); // use elem with wighest priority
|
0); // use elem with wighest priority
|
||||||
}
|
}
|
||||||
llistAppend(events_ll, c);
|
llistAppend(events_ll, c);
|
||||||
// printEvent(c);
|
printEvent(c);
|
||||||
// printEvent((Event *)((events_ll)->next)->data);
|
// printEvent((Event *)((events_ll)->next)->data);
|
||||||
|
|
||||||
// decrement priority of first elem and resort list
|
// decrement priority of first elem and resort list
|
||||||
|
@ -257,8 +257,9 @@ llist *genPlan(llist *head, time_t timeAvail) {
|
||||||
events_ll = events_ll->next;
|
events_ll = events_ll->next;
|
||||||
tmp->next = NULL;
|
tmp->next = NULL;
|
||||||
llistFreeE(tmp);
|
llistFreeE(tmp);
|
||||||
|
printf("====EVENTSLL:\n");
|
||||||
llistPrintE(events_ll);
|
llistPrintE(events_ll);
|
||||||
|
printf("====EVENTSLL:\n");
|
||||||
// update prioriteis in original llist
|
// update prioriteis in original llist
|
||||||
for (int i = 0; i < lLen; i++) {
|
for (int i = 0; i < lLen; i++) {
|
||||||
llist *tmp = llistGet(head, sortedPrio + i);
|
llist *tmp = llistGet(head, sortedPrio + i);
|
||||||
|
|
|
@ -77,6 +77,7 @@ Event *newEvent(Task *t, time_t s, time_t e, uint64_t sp);
|
||||||
*/
|
*/
|
||||||
void freeEvent(Event *e);
|
void freeEvent(Event *e);
|
||||||
void llistFreeE(llist *head);
|
void llistFreeE(llist *head);
|
||||||
|
void llistPrintE(llist *head);
|
||||||
int cmpEvent(const void *a, const void *b);
|
int cmpEvent(const void *a, const void *b);
|
||||||
/*
|
/*
|
||||||
* takes llist of tasks and returns llist of events
|
* takes llist of tasks and returns llist of events
|
||||||
|
|
18
src/ui.c
18
src/ui.c
|
@ -35,7 +35,7 @@ int main(void) {
|
||||||
printf(" -4- Kalenderlink ausgeben\n");
|
printf(" -4- Kalenderlink ausgeben\n");
|
||||||
printf(" -5- Faecher Importieren\n");
|
printf(" -5- Faecher Importieren\n");
|
||||||
printf(" -6- Planer beenden\n");
|
printf(" -6- Planer beenden\n");
|
||||||
printf(" Wähle die gewünschte Option aus\n");
|
printf(" Waehle die gewuenschte Option aus\n");
|
||||||
volatile int r = scanf("%d", &choice);
|
volatile int r = scanf("%d", &choice);
|
||||||
if (r != 1) {
|
if (r != 1) {
|
||||||
printf("Falsche Eingabe\n");
|
printf("Falsche Eingabe\n");
|
||||||
|
@ -46,27 +46,30 @@ int main(void) {
|
||||||
|
|
||||||
char *taskname = NULL; // taskName Buffer
|
char *taskname = NULL; // taskName Buffer
|
||||||
size_t nameLen;
|
size_t nameLen;
|
||||||
|
size_t nnread;
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 1:
|
case 1:
|
||||||
printf(" Geben sie das gewünschte Fach ein: \n");
|
printf(" Geben sie das gewünschte Fach ein: \n");
|
||||||
fgetc(stdin);
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
struct tm lc;
|
struct tm lc;
|
||||||
localtime_r(&now, &lc);
|
localtime_r(&now, &lc);
|
||||||
if (getline(&taskname, &nameLen, stdin) < 0) {
|
fgetc(stdin);
|
||||||
|
nnread = getline(&taskname, &nameLen, stdin);
|
||||||
|
taskname[nnread - 1] = '\0';
|
||||||
|
if (nnread < 0) {
|
||||||
printf("Ungültige Eingabe für den Namen.\n");
|
printf("Ungültige Eingabe für den Namen.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" Wie viel Zeit bleibt ihnen (tage bis deadline):\n");
|
printf(" Wie viel Zeit bleibt ihnen (tage bis deadline):\n");
|
||||||
if (scanf("%d", &taskdeadline_date) != 1) {
|
if (scanf("%d", &taskdeadline_date) != 1) {
|
||||||
printf("Ungültige Eingabe.\n");
|
printf("Ungueltige Eingabe.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" Gib die Priorität des Faches an: \n");
|
printf(" Gib die Prioritaet des Faches an: \n");
|
||||||
if (scanf("%d", &taskpriority) != 1) {
|
if (scanf("%d", &taskpriority) != 1) {
|
||||||
printf("Ungültige Eingabe.\n");
|
printf("Ungueltige Eingabe.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +92,7 @@ int main(void) {
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
printf(
|
printf(
|
||||||
"Geben Sie die zur verfuegung stehende Zeit für die Fächer an: \n");
|
"Geben Sie die zur verfuegung stehende Zeit für die Faecher an: \n");
|
||||||
scanf("%d", &taskspare);
|
scanf("%d", &taskspare);
|
||||||
// if list exists use it to generate plan
|
// if list exists use it to generate plan
|
||||||
if (listT != NULL) {
|
if (listT != NULL) {
|
||||||
|
@ -143,6 +146,7 @@ int main(void) {
|
||||||
"eingeben!\n");
|
"eingeben!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
llistPrintE(listE);
|
||||||
exportiCal(listE);
|
exportiCal(listE);
|
||||||
// printf(
|
// printf(
|
||||||
// "Geben Sie die zur verfuegung stehende Zeit für die Fächer an:
|
// "Geben Sie die zur verfuegung stehende Zeit für die Fächer an:
|
||||||
|
|
Loading…
Reference in New Issue