Compare commits
9 Commits
ca261158c6
...
1f54110aa5
Author | SHA1 | Date |
---|---|---|
ketrptr | 1f54110aa5 | |
ketrptr | 60cfa51406 | |
Jan Wild | 8d6d6b2870 | |
Jan Wild | 5f65a91ffb | |
Jan Wild | 14705844d7 | |
Jan Wild | 2d0bd1341b | |
Jan Wild | 6f3cd456f4 | |
ketrptr | 3b8bd5dc40 | |
ketrptr | d7cf85b44f |
4
src/db.c
4
src/db.c
|
@ -63,7 +63,7 @@ llist *write_csv_to_llist(const char *filename) {
|
||||||
int count = 0; // task counter
|
int count = 0; // task counter
|
||||||
fgets(line, sizeof(line), file); // read and ignore file head
|
fgets(line, sizeof(line), file); // read and ignore file head
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), file)) {
|
while (fgets(line, sizeof(line), file)){
|
||||||
count++;
|
count++;
|
||||||
// remove newline sign
|
// remove newline sign
|
||||||
line[strcspn(line, "\n")] = '\0';
|
line[strcspn(line, "\n")] = '\0';
|
||||||
|
@ -74,6 +74,7 @@ llist *write_csv_to_llist(const char *filename) {
|
||||||
char *taskdeadline_dateSTR = strtok(NULL, ",");
|
char *taskdeadline_dateSTR = strtok(NULL, ",");
|
||||||
char *taskprioritySTR = strtok(NULL, ",");
|
char *taskprioritySTR = strtok(NULL, ",");
|
||||||
char *taskspareSTR = strtok(NULL, ",");
|
char *taskspareSTR = strtok(NULL, ",");
|
||||||
|
printf(" Der Name des Task ist %s\n",taskname);
|
||||||
|
|
||||||
// convert char in integer and date
|
// convert char in integer and date
|
||||||
unsigned long int taskcreation_date =
|
unsigned long int taskcreation_date =
|
||||||
|
@ -100,3 +101,4 @@ llist *write_csv_to_llist(const char *filename) {
|
||||||
}
|
}
|
||||||
return list; // null on error
|
return list; // null on error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
22
src/ui.c
22
src/ui.c
|
@ -11,6 +11,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -20,11 +21,11 @@
|
||||||
const char *dbName = "db.csv";
|
const char *dbName = "db.csv";
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
char taskname[256]; // taskName Buffer
|
|
||||||
int taskcreation_date = 0;
|
int taskcreation_date = 0;
|
||||||
int taskdeadline_date = 0;
|
int taskdeadline_date = 0;
|
||||||
int taskpriority = 0;
|
int taskpriority = 0;
|
||||||
int taskspare = 0;
|
int taskspare = 0;
|
||||||
|
char *taskname = NULL; // taskName Buffer
|
||||||
|
|
||||||
llist *listT = NULL;
|
llist *listT = NULL;
|
||||||
llist *listE = NULL;
|
llist *listE = NULL;
|
||||||
|
@ -45,14 +46,20 @@ int main(void) {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
taskname = NULL;
|
||||||
|
size_t nameLen;
|
||||||
|
size_t nnread;
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 1:
|
case 1:
|
||||||
printf(" Geben sie das gewuenschte Fach ein: \n");
|
printf(" Geben sie das gewünschte Fach ein: \n");
|
||||||
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 (fscanf(stdin, "%s", taskname) <= 0) {
|
fgetc(stdin);
|
||||||
printf("Ungueltige Eingabe für den Namen.\n");
|
nnread = getline(&taskname, &nameLen, stdin);
|
||||||
|
taskname[nnread - 1] = '\0';
|
||||||
|
if (nnread < 0) {
|
||||||
|
printf("Ungültige Eingabe für den Namen.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +98,11 @@ int main(void) {
|
||||||
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) {
|
||||||
listE = genPlan(listT, taskspare);
|
struct tm lc;
|
||||||
|
localtime_r(&now, &lc);
|
||||||
|
lc.tm_hour += taskspare;
|
||||||
|
time_t avail = mktime(&lc);
|
||||||
|
listE = genPlan(listT, avail);
|
||||||
write_linkedlist_to_csv(listT, dbName);
|
write_linkedlist_to_csv(listT, dbName);
|
||||||
} else {
|
} else {
|
||||||
printf("list is empty!");
|
printf("list is empty!");
|
||||||
|
@ -141,6 +152,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