1 Commits
Author SHA1 Message Date
buechejuerge d86bcbfcf2 new 2024-12-13 22:26:20 +01:00
5 changed files with 158 additions and 33376 deletions

No files matched your search

+4 -9
View File
@@ -13,18 +13,10 @@ CONFIG=src/config.h #config file
#targets
debug: db test ui planner iCal config llist
debug: test ui planner db iCal config llist
gcc test.o ui.o planner.o db.o iCal.o llist.o -o debugOut
config: $(CONFIG)
db: $(DBF)
curl -L https://sqlite.org/2024/sqlite-amalgamation-3470200.zip --output src/sqlite.zip
unzip src/sqlite.zip
mv sqlite-amalgamation-3470200/* src/
rm -rf sqlite-amalgamation-3470200
gcc -c $(CFLAGS) $(DBF)
llist: $(LLST)
gcc -c $(CFLAGS) $(LLST)
test: src/test.c
@@ -35,6 +27,9 @@ ui: $(UIF)
gcc -c $(CFLAGS) $(UIF)
planner: $(PLF)
gcc -c $(CFLAGS) $(PLF)
db: $(DBF)
gcc -c $(CFLAGS) $(DBF)
edit:
nvim $(PLF) Makefile $(LLST) src/test.c
+5 -5
View File
@@ -14,16 +14,17 @@
*Created by Jan on 13.12.2024.
*
************************************************************/
#include "planner.h"
#include <sqlite3.h>
#include <stdio.h>
#include <time.h>
#include "sqlite3.h"
#include "planner.h"
extern struct llist;
// Initialize a new Database if there no one.
void init_db(sqlite3 *db) {
const char *sql_LinkedList = "CREATE TABLE LinkedList ("
const char *sql_LinkedList =
"CREATE TABLE LinkedList ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"data TEXT;)";
@@ -46,8 +47,7 @@ void save_node_to_db(sqlite3 *db, Node *node) {
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
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 {
-33362
View File
File diff suppressed because it is too large. Load diff
+140
View File
@@ -3,3 +3,143 @@
*
*/
#include "planner.h" // for subject and event structs
#include <stdio.h>
#include <stdlib.h>
#include "ui.h"
typedef struct task_elements {
char name;
int priority;
struct task *nextTask;
};
typedef struct task task_1;
typedef struct task* task_ptr;
task_ptr firsttask = NULL;
typedef struct time_elements {
int time;
struct time *nextTime;
};
typedef struct time time_1;
typedef struct time* time_ptr;
time_ptr firsttime = NULL;
void dump_buffer(FILE *fp){
int ch;
while((ch = fgetc(fp)) != EOF && ch != '\n');
}
void insertTask(task_ptr newtask)
{
task_ptr TaskPointer;
if (firsttask == NULL){
firsttask = newtask;
newtask->nextTask ;
}
else {
TaskPointer = firsttask;
while(TaskPointer->nextTask!=NULL)
{
TaskPointer = TaskPointer->nextTask;
}
TaskPointer->nextTask = newtask;
newtask ->nextTask;
}
}
void newTask (void)
{
task_ptr new = malloc(sizeof(task_1));
if (new == NULL){
printf("Die Liste ist leer?!\n");
}
printf(" Neues Fach eigeben: ");
if(scanf("%d", &newTask)!=1)
{
dump_buffer(stdin);
printf("Fehlerhafte eingabe\n");
free(new);
return;
}
dump_buffer (stdin);
insertTask(new);
}
void inserttime(time_ptr newtime)
{
time_ptr TimePointer;
if (firsttime == NULL){
firsttime = newtime;
newtime->nextTime =NULL;
}
else {
TimePointer = firsttime;
while(TimePointer->nextTime!=NULL)
{
TimePointer = TimePointer->nextTime;
}
TimePointer->nextTime = newtime;
newtime ->nextTime = NULL;
}
}
void newTime(void)
{
time_ptr newtime = malloc(sizeof(task_1));
if (newtime == NULL){
printf("Die Liste ist leer?!\n");
}
printf(" Neue Zeit eigneben: ");
if(scanf("%d",&newTime)!=1)
{
dump_buffer(stdin);
printf("Fehlerhafte eingabe\n");
free(newtime);
return;
}
dump_buffer (stdin);
inserttime(newtime);
}
void tasklisting(void){
task_ptr TaskPointer = firsttask;
printf("Erfasste Fächer:\n");
while(TaskPointer!=NULL)
printf("\t->%d\n", TaskPointer->name);
TaskPointer = TaskPointer->nextTask;
}
int main(void)
{
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- Planer beenden\n");
if( scanf("%d", &choice) != 1){
printf("Falsche Eingabe\n");};
choice = 0;
dump_buffer(stdin);
switch (choice)
{
case 1: newTask();break;
case 2: newTime();break;
case 3: if( firsttask == NULL){
printf("Die Liste ist leer");
}
else{
tasklisting();
}break;
}
}while (choice != 4);
return EXIT_SUCCESS;
}
+9
View File
@@ -1,4 +1,13 @@
#ifndef UI
#define UI
typedef struct task_elements{
char name;
int priority;
};
typedef struct time{
int time;
};
#endif // !UI