Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6816c4eacf | ||
|
|
ac45c8cb65 | ||
|
|
aee1ab81a9 | ||
|
|
3612334ffc | ||
|
|
d794d1c59c | ||
|
|
1f54110aa5 | ||
|
|
60cfa51406 | ||
|
|
8d6d6b2870 | ||
|
|
5f65a91ffb | ||
|
|
14705844d7 | ||
|
|
2d0bd1341b | ||
|
|
6f3cd456f4 | ||
|
|
3b8bd5dc40 | ||
|
|
d7cf85b44f | ||
|
|
ca261158c6 | ||
|
|
52718c972e | ||
|
|
24150229d4 | ||
|
|
a925ca1678 | ||
|
|
053bf501b5 | ||
|
|
503182c0ca | ||
|
|
2b162f532f | ||
|
|
e4b1580d1e | ||
|
|
4acaefdd42 | ||
|
|
e27e6f0b28 | ||
|
|
33b0d3087b | ||
|
|
0c27b315a9 | ||
|
|
db3f7a4de7 | ||
|
|
10a36c4a88 | ||
|
|
7946b3e548 | ||
|
|
5d7e7d83b6 | ||
|
|
752f144113 | ||
|
|
7dfcf1500b | ||
|
|
87c5fa8225 | ||
|
|
42183a0747 | ||
|
|
809239492d | ||
|
|
5e3d89fb57 | ||
|
|
5d76c54213 | ||
|
|
9d903f62f2 | ||
|
|
b5dc110cd2 | ||
|
|
fdfdada4d8 | ||
|
|
9b3238978b | ||
|
|
a833bb456a | ||
|
|
08145cd4a2 | ||
|
|
f72c98de28 | ||
|
|
a302bfc4e8 | ||
|
|
78a0bc4806 | ||
|
|
ac8a64695f | ||
|
|
d428589063 | ||
|
|
1fb016296b | ||
|
|
dd88cd8b64 | ||
|
|
24f0e9e7ec | ||
|
|
63ee77f5c4 | ||
|
|
cf63dc4712 | ||
|
|
10dc2a7e04 | ||
|
|
81a0d68cc2 | ||
|
|
bf14307a71 | ||
|
|
b792eed3d2 | ||
|
|
ad20db3995 | ||
|
|
8cea008459 | ||
|
|
81c62f892d | ||
|
|
f6cea89dd2 | ||
|
|
7f6a2c865b | ||
|
|
b027a12354 | ||
|
|
b308dc4c95 | ||
|
|
834b3270b9 | ||
|
|
0ef20822fd | ||
|
|
e32c7d8951 | ||
|
|
5ebd852864 | ||
|
|
06a81ad27e | ||
|
|
9a9dddaad0 | ||
|
|
e34431e810 | ||
|
|
fe4f8e295b | ||
|
|
c1195de54b | ||
|
|
8c695e4eb7 | ||
|
|
e97cd55e28 | ||
|
|
36a3f8d28c | ||
|
|
7da1172d3a | ||
|
|
749c0400fa | ||
|
|
0504491668 | ||
|
|
85ea3ffca8 | ||
|
|
d86bcbfcf2 |
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
testing
|
testing
|
||||||
debugOut
|
debugOut
|
||||||
|
.idea
|
||||||
# ---> C
|
# ---> C
|
||||||
# Prerequisites
|
# Prerequisites
|
||||||
*.d
|
*.d
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="StudyPlanner" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" RUN_PATH="$PROJECT_DIR$/Makefile" EXPLICIT_BUILD_TARGET_NAME="all">
|
||||||
|
<method v="2">
|
||||||
|
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#compiler flags
|
#compiler flags
|
||||||
|
|
||||||
CFLAGS=-Wall -Wextra -g
|
CFLAGS=-Wall -Wextra -g
|
||||||
|
INCLUDES = -Isrc
|
||||||
|
|
||||||
|
|
||||||
#files
|
#files
|
||||||
@@ -35,7 +36,7 @@ edit:
|
|||||||
nvim $(PLF) Makefile $(LLST) src/test.c
|
nvim $(PLF) Makefile $(LLST) src/test.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf *.o debugOut src/*.gch
|
rm -rf *.o debugOut src/*.gch *.csv *.ics
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/* Create a database and handel it
|
||||||
|
* Created by Jan on 13.12.2024.
|
||||||
* INPUT: query for previous state
|
* INPUT: query for previous state
|
||||||
* linked list of tasks to store
|
* linked list of tasks to store
|
||||||
*
|
*
|
||||||
@@ -9,60 +10,98 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/************************************************************
|
#include "llist.h"
|
||||||
*Create a database and handel it
|
|
||||||
*Created by Jan on 13.12.2024.
|
|
||||||
*
|
|
||||||
************************************************************/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include "sqlite3.h"
|
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
extern struct llist;
|
/*
|
||||||
|
write a complete linkedlist to a task csv file.
|
||||||
|
*/
|
||||||
|
void write_linkedlist_to_csv(llist *head, const char *filename) {
|
||||||
|
// Open file with write permision
|
||||||
|
FILE *file = fopen(filename, "w");
|
||||||
|
// if there is no file or a wrong file path you becom an error
|
||||||
|
if (file == NULL) {
|
||||||
|
fprintf(stderr, "Could not open file %s\n", filename);
|
||||||
|
exit(1);
|
||||||
|
|
||||||
// Initialize a new Database if there no one.
|
} else {
|
||||||
void init_db(sqlite3 *db) {
|
// write the file header
|
||||||
const char *sql_LinkedList =
|
fprintf(file, "TaskName, Created, Deadline, Priority, Spare\n");
|
||||||
"CREATE TABLE LinkedList ("
|
|
||||||
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
|
|
||||||
"data TEXT;)";
|
|
||||||
|
|
||||||
// Checks the SQL answer and if it's not ok prints the error code
|
// Iterate through the linked list and write the data to the CSV
|
||||||
char *errmsg = NULL;
|
llist *current = head;
|
||||||
if (sqlite3_exec(db, sql_LinkedList, NULL, NULL, &errmsg) != SQLITE_OK) {
|
Task *task;
|
||||||
fprintf(stderr, "Error in creation Table: %s\n", errmsg);
|
|
||||||
sqlite3_free(errmsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save a single node of the linkedlist in the database
|
|
||||||
// node needs to be replaced with the correct name and pointer
|
|
||||||
void save_node_to_db(sqlite3 *db, Node *node) {
|
|
||||||
|
|
||||||
char* errmsg = NULL;
|
|
||||||
sqlite3_stmt *stmt;
|
|
||||||
const char* sql = "INSERT INTO LinkedList (id, data) VALUES (?, ?);";
|
|
||||||
if (sqlite3_prepare_v2(db, sql, -1, &stmt, NULL) != SQLITE_OK) {
|
|
||||||
fprintf(stderr, "Failed to prepare statement: %s\n", sqlite3_errmsg(db));
|
|
||||||
} else {
|
|
||||||
sqlite3_bind_int(stmt, 1, node->id); // ? -> node->id
|
|
||||||
sqlite3_bind_text(stmt, 2, node->data, -1, SQLITE_STATIC); // ? -> node->data
|
|
||||||
if (sqlite3_step(stmt) != SQLITE_DONE) {
|
|
||||||
fprintf(stderr, "Execution failed: %s\n", sqlite3_errmsg(db));
|
|
||||||
} else {
|
|
||||||
printf("Node with ID %d saved.\n", node->id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sqlite3_finalize(stmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
// save a whole linkedlist in the database
|
|
||||||
// node needs to be replaced with the correct name and pointer
|
|
||||||
void save_linked_list_to_db(sqlite3* db, Node* head) {
|
|
||||||
Node* current = head;
|
|
||||||
while (current != NULL) {
|
while (current != NULL) {
|
||||||
save_node_to_db(db, current);
|
task = current->data;
|
||||||
current = current->next;
|
// Write the task data to the CSV file
|
||||||
|
fprintf(file, "%s, %llu, %llu, %d, %llu\n", task->name, task->created,
|
||||||
|
task->deadline, task->priority, task->spare);
|
||||||
|
|
||||||
|
current = current->next;
|
||||||
}
|
}
|
||||||
|
fclose(file); // Close the file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
read a task csv file and write the data in a linked list
|
||||||
|
*/
|
||||||
|
|
||||||
|
llist *write_csv_to_llist(const char *filename) {
|
||||||
|
llist *list = NULL; // list to return
|
||||||
|
// Open file with read permision
|
||||||
|
FILE *file = fopen(filename, "r");
|
||||||
|
if (file == NULL) {
|
||||||
|
fprintf(stderr, "Could not open file %s\n", filename);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
char *line = NULL; // Line Buffer
|
||||||
|
size_t nnread, len;
|
||||||
|
int count = 0; // task counter
|
||||||
|
getline(&line, &len, file);
|
||||||
|
free(line);
|
||||||
|
line = NULL;
|
||||||
|
|
||||||
|
while ((nnread = getline(&line, &len, file)) != -1) {
|
||||||
|
count++;
|
||||||
|
// remove newline sign
|
||||||
|
line[strcspn(line, "\n")] = '\0';
|
||||||
|
|
||||||
|
// column slice
|
||||||
|
char *taskname = strtok(line, ",");
|
||||||
|
char *taskcreation_dateSTR = strtok(NULL, ",");
|
||||||
|
char *taskdeadline_dateSTR = strtok(NULL, ",");
|
||||||
|
char *taskprioritySTR = strtok(NULL, ",");
|
||||||
|
char *taskspareSTR = strtok(NULL, ",");
|
||||||
|
printf(" Der Name des Task ist %s\n", taskname);
|
||||||
|
|
||||||
|
// convert char in integer and date
|
||||||
|
unsigned long int taskcreation_date =
|
||||||
|
strtoul(taskcreation_dateSTR, NULL, 10);
|
||||||
|
unsigned long int taskdeadline_date =
|
||||||
|
strtoul(taskdeadline_dateSTR, NULL, 10);
|
||||||
|
unsigned long int taskspare = strtoul(taskspareSTR, NULL, 10);
|
||||||
|
int priority = atoi(taskprioritySTR);
|
||||||
|
|
||||||
|
// create Task
|
||||||
|
Task *task = newTask(taskname, taskcreation_date, taskdeadline_date,
|
||||||
|
priority, taskspare);
|
||||||
|
|
||||||
|
// Insert task into the linked list
|
||||||
|
if (list == NULL) {
|
||||||
|
// If the list is empty, initialize it with the first task
|
||||||
|
list = llistNew(task, cmpTaskN);
|
||||||
|
} else {
|
||||||
|
// Append the task to the linked list
|
||||||
|
llistAppend(list, task);
|
||||||
|
}
|
||||||
|
line = NULL;
|
||||||
|
}
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
return list; // null on error
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,5 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void init_db(sqlite3 *db);
|
void write_linkedlist_to_csv(llist *head, const char *filename);
|
||||||
extern void save_node_to_db(sqlite3 *db, Node *node);
|
llist *write_csv_to_llist(const char *filename);
|
||||||
extern void save_linked_list_to_db(sqlite3* db, Node* head);
|
|
||||||
@@ -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>
|
||||||
|
|
||||||
|
|||||||
+78
-4
@@ -15,8 +15,13 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
const uint intervalLen = 45; // min
|
#ifdef _WIN32
|
||||||
const uint pauseLen = 10; //
|
#define ctime_r(T, Tm) (localtime_s(Tm, T) ? NULL : Tm)
|
||||||
|
#define localtime_r(T, Tm) (localtime_s(Tm, T) ? NULL : Tm)
|
||||||
|
#endif /* ifdef _WIN32 */
|
||||||
|
|
||||||
|
const unsigned int intervalLen = 45; // min
|
||||||
|
const unsigned int pauseLen = 10; //
|
||||||
|
|
||||||
const char taskFormat[] =
|
const char taskFormat[] =
|
||||||
"Task { %.64s = {\n created={%lu},\n deadline={%lu},\n "
|
"Task { %.64s = {\n created={%lu},\n deadline={%lu},\n "
|
||||||
@@ -221,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
|
||||||
@@ -252,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);
|
||||||
@@ -269,3 +275,71 @@ llist *genPlan(llist *head, time_t timeAvail) {
|
|||||||
|
|
||||||
return events_ll;
|
return events_ll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *iCalHeader = "BEGIN:VCALENDAR\r\n"
|
||||||
|
"VERSION:2.0\r\n"
|
||||||
|
"PRODID:-//hacksw/handcal//NONSGML v1.0//EN\r\n";
|
||||||
|
const char *iCalEvent = "BEGIN:VEVENT\r\n"
|
||||||
|
"UID:%s%d\r\n"
|
||||||
|
"DTSTAMP:%s\r\n"
|
||||||
|
"DTSTART:%s\r\n"
|
||||||
|
"DTEND:%s\r\n"
|
||||||
|
"SUMMARY:%s\r\n"
|
||||||
|
"END:VEVENT\r\n";
|
||||||
|
|
||||||
|
int exportiCal(llist *events_ll) {
|
||||||
|
|
||||||
|
llist *ev_ll = events_ll;
|
||||||
|
|
||||||
|
llistPrintE(ev_ll);
|
||||||
|
|
||||||
|
printf("%s", iCalHeader);
|
||||||
|
|
||||||
|
time_t now = time(NULL);
|
||||||
|
struct tm lc;
|
||||||
|
localtime_r(&now, &lc);
|
||||||
|
|
||||||
|
// gen filename & open for write
|
||||||
|
char nameBuf[32];
|
||||||
|
strftime(nameBuf, 32 - 12, "%F", &lc);
|
||||||
|
strcat(nameBuf, "dayplan.ics");
|
||||||
|
FILE *fp = fopen(nameBuf, "w");
|
||||||
|
if (fp == NULL) {
|
||||||
|
planLog("fopen failed!!", 1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
// write iCal header to file
|
||||||
|
fprintf(fp, "%s", iCalHeader);
|
||||||
|
|
||||||
|
// for every event in events_ll create VEVENT str and write to fp
|
||||||
|
int count = 0;
|
||||||
|
while (ev_ll != NULL) {
|
||||||
|
// gen iCal compatible time str
|
||||||
|
Event *current = ev_ll->data;
|
||||||
|
struct tm startlc;
|
||||||
|
struct tm endlc;
|
||||||
|
localtime_r(¤t->plannedStartTime, &startlc);
|
||||||
|
localtime_r(¤t->plannedEndTime, &endlc);
|
||||||
|
char timeStartBuf[17];
|
||||||
|
char timeEndBuf[17];
|
||||||
|
char timeStamp[17];
|
||||||
|
strftime(timeStamp, 17, "%Y%m%dT%k%M%SZ", &lc);
|
||||||
|
printf("%s\n", timeStamp);
|
||||||
|
strftime(timeStartBuf, 17, "%Y%m%dT%k%M%SZ", &startlc);
|
||||||
|
printf("%s\n", timeStartBuf);
|
||||||
|
strftime(timeEndBuf, 17, "%Y%m%dT%k%M%SZ", &endlc);
|
||||||
|
printf("%s\n", timeEndBuf);
|
||||||
|
|
||||||
|
fprintf(fp, iCalEvent, current->task->name, count, timeStamp, timeStartBuf,
|
||||||
|
timeEndBuf, current->task->name);
|
||||||
|
ev_ll = ev_ll->next;
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// after all events are written end cal with
|
||||||
|
// END:VCALENDAR
|
||||||
|
fprintf(fp, "END:VCALENDAR\r\n");
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -77,10 +77,13 @@ 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
|
||||||
*/
|
*/
|
||||||
llist *genPlan(llist *head, time_t timeAvail);
|
llist *genPlan(llist *head, time_t timeAvail);
|
||||||
|
|
||||||
|
int exportiCal(llist *head);
|
||||||
|
|
||||||
#endif // !PLANNER
|
#endif // !PLANNER
|
||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
int main() {
|
int test() {
|
||||||
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,189 @@
|
|||||||
* command line interface for user input
|
* command line interface for user input
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/* Created by Juergen Buechel, 13.12.2024/
|
||||||
|
*/
|
||||||
|
#include "ui.h"
|
||||||
|
#include "db.h"
|
||||||
|
#include "llist.h"
|
||||||
#include "planner.h" // for subject and event structs
|
#include "planner.h" // for subject and event structs
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define localtime_r(T, Tm) (localtime_s(Tm, T) ? NULL : Tm)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *dbName = "db.csv";
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int taskcreation_date = 0;
|
||||||
|
int taskdeadline_date = 0;
|
||||||
|
int taskpriority = 0;
|
||||||
|
int taskspare = 0;
|
||||||
|
char *taskname = NULL; // taskName Buffer
|
||||||
|
|
||||||
|
llist *listT = NULL;
|
||||||
|
llist *listE = NULL;
|
||||||
|
int choice = 0, i = 0;
|
||||||
|
do {
|
||||||
|
printf(" -1- Neues Fach eingeben\n");
|
||||||
|
printf(" -2- Verfuegbare Zeit eingeben\n");
|
||||||
|
printf(" -3- Alle vorhandenen Faecher aufliesten\n");
|
||||||
|
printf(" -4- Kalenderlink ausgeben\n");
|
||||||
|
printf(" -5- Faecher Importieren\n");
|
||||||
|
printf(" -6- Planer beenden\n");
|
||||||
|
printf(" Waehle die gewuenschte Option aus\n");
|
||||||
|
volatile int r = scanf("%d", &choice);
|
||||||
|
if (r != 1) {
|
||||||
|
printf("Falsche Eingabe\n");
|
||||||
|
fgetc(stdin);
|
||||||
|
choice = 0;
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
taskname = NULL;
|
||||||
|
size_t nameLen;
|
||||||
|
size_t nnread;
|
||||||
|
switch (choice) {
|
||||||
|
case 1:
|
||||||
|
printf(" Geben sie das gewünschte Fach ein: \n");
|
||||||
|
time_t now = time(NULL);
|
||||||
|
struct tm lc;
|
||||||
|
localtime_r(&now, &lc);
|
||||||
|
fgetc(stdin);
|
||||||
|
nnread = getline(&taskname, &nameLen, stdin);
|
||||||
|
taskname[nnread - 1] = '\0';
|
||||||
|
if (nnread < 0) {
|
||||||
|
printf("Ungültige Eingabe für den Namen.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" Wie viel Zeit bleibt ihnen (tage bis deadline):\n");
|
||||||
|
if (scanf("%d", &taskdeadline_date) != 1) {
|
||||||
|
printf("Ungueltige Eingabe.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" Gib die Prioritaet des Faches an: \n");
|
||||||
|
if (scanf("%d", &taskpriority) != 1) {
|
||||||
|
printf("Ungueltige Eingabe.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// printf(" Wie viel Zeit habe Sie für dieses Fach: \n");
|
||||||
|
// if (scanf("%d", &taskspare) != 1) {
|
||||||
|
// printf("Ungültige Eingabe.\n");
|
||||||
|
// return -1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// create deadline timestamp
|
||||||
|
lc.tm_yday += taskdeadline_date;
|
||||||
|
time_t deadline = mktime(&lc);
|
||||||
|
Task *newT = newTask(taskname, now, deadline, taskpriority, 0);
|
||||||
|
if (listT == NULL) {
|
||||||
|
listT = llistNew(newT, cmpTaskN);
|
||||||
|
} else {
|
||||||
|
llistAppend(listT, newT);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
printf(
|
||||||
|
"Geben Sie die zur verfuegung stehende Zeit für die Faecher an: \n");
|
||||||
|
scanf("%d", &taskspare);
|
||||||
|
// if list exists use it to generate plan
|
||||||
|
if (listT != NULL) {
|
||||||
|
struct tm lc;
|
||||||
|
now = time(NULL);
|
||||||
|
localtime_r(&now, &lc);
|
||||||
|
lc.tm_hour += taskspare;
|
||||||
|
time_t avail = mktime(&lc);
|
||||||
|
listE = genPlan(listT, avail);
|
||||||
|
write_linkedlist_to_csv(listT, dbName);
|
||||||
|
} else {
|
||||||
|
printf("list is empty!");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
if (listT == NULL) {
|
||||||
|
printf("Die Liste ist leer");
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
llistPrintT(listT);
|
||||||
|
// llist *iterator = list;
|
||||||
|
// while (iterator != NULL) {
|
||||||
|
// Task *currentTask = (Task *)(iterator->data); // Cast zu Task
|
||||||
|
// printf("Fach: %s, Deadline: %ld, Priorität: %d\n",
|
||||||
|
// currentTask->name, currentTask->deadline,
|
||||||
|
// currentTask->priority);
|
||||||
|
// iterator = iterator->next; // Gehe zum nächsten Listenelement
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// // case 4: iCAl();break;
|
||||||
|
//
|
||||||
|
// printf(" Wie viel Zeit bleibt ihnen:\n");
|
||||||
|
// if (scanf("%d", &taskdeadline_date) != 1) {
|
||||||
|
// printf("Ungültige Eingabe.\n");
|
||||||
|
// return -1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// printf(" Gib die Priorität des Faches an: \n");
|
||||||
|
// if (scanf("%d", &taskpriority) != 1) {
|
||||||
|
// printf("Ungültige Eingabe.\n");
|
||||||
|
// return -1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// printf(" Wie viel Zeit habe Sie für dieses Fach: \n");
|
||||||
|
// if (scanf("%d", &taskspare) != 1) {
|
||||||
|
// printf("Ungültige Eingabe.\n");
|
||||||
|
// return -1;
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
case 4:
|
||||||
|
if (listE == NULL || taskspare <= 0) {
|
||||||
|
printf("vor Export erst task list erstellen, dann verfuegbare zeit "
|
||||||
|
"eingeben!\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
llistPrintE(listE);
|
||||||
|
exportiCal(listE);
|
||||||
|
// printf(
|
||||||
|
// "Geben Sie die zur verfuegung stehende Zeit für die Fächer an:
|
||||||
|
// \n");
|
||||||
|
// scanf("%d", &taskspare);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
listT = write_csv_to_llist(dbName);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
printf("Goodbye!\n");
|
||||||
|
if (listE != NULL)
|
||||||
|
llistFreeE(listE);
|
||||||
|
if (listT != NULL)
|
||||||
|
llistPrintT(listT);
|
||||||
|
// if (task == NULL) {//task?
|
||||||
|
// printf("Die Liste ist leer");
|
||||||
|
// } else {
|
||||||
|
// llist *iterator = list;
|
||||||
|
// while (iterator != NULL) {
|
||||||
|
// Task *currentTask = (Task *)(iterator->data); // Cast zu Task
|
||||||
|
// printf("Fach: %s, Deadline: %ld, Priorität: %d\n",
|
||||||
|
// currentTask->name, currentTask->deadline,
|
||||||
|
// currentTask->priority);
|
||||||
|
// iterator = iterator->next; // Gehe zum nächsten Listenelement
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
// case 4: iCAl();break;
|
||||||
|
}
|
||||||
|
} while (choice < 6);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user