Compare commits
	
		
			5 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 97869f4530 | |||
| 
						 | 
					93aa77bb5b | ||
| 59cac98023 | |||
| 
						 | 
					3c0f48a28d | ||
| 
						 | 
					a4f31f9414 | 
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1,8 +1,5 @@
 | 
				
			|||||||
testing
 | 
					testing
 | 
				
			||||||
debugOut
 | 
					debugOut
 | 
				
			||||||
.idea
 | 
					 | 
				
			||||||
.run
 | 
					 | 
				
			||||||
.vscode
 | 
					 | 
				
			||||||
# ---> C
 | 
					# ---> C
 | 
				
			||||||
# Prerequisites
 | 
					# Prerequisites
 | 
				
			||||||
*.d
 | 
					*.d
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										28
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							@ -1,28 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
    "tasks": [
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            "type": "cppbuild",
 | 
					 | 
				
			||||||
            "label": "C/C++: gcc.exe build active file",
 | 
					 | 
				
			||||||
            "command": "C:\\MinGW\\bin\\gcc.exe",
 | 
					 | 
				
			||||||
            "args": [
 | 
					 | 
				
			||||||
                "-fdiagnostics-color=always",
 | 
					 | 
				
			||||||
                "-g",
 | 
					 | 
				
			||||||
                "${file}",
 | 
					 | 
				
			||||||
                "-o",
 | 
					 | 
				
			||||||
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
 | 
					 | 
				
			||||||
            ],
 | 
					 | 
				
			||||||
            "options": {
 | 
					 | 
				
			||||||
                "cwd": "${fileDirname}"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            "problemMatcher": [
 | 
					 | 
				
			||||||
                "$gcc"
 | 
					 | 
				
			||||||
            ],
 | 
					 | 
				
			||||||
            "group": {
 | 
					 | 
				
			||||||
                "kind": "build",
 | 
					 | 
				
			||||||
                "isDefault": true
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            "detail": "Task generated by Debugger."
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    ],
 | 
					 | 
				
			||||||
    "version": "2.0.0"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										20
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								Makefile
									
									
									
									
									
								
							@ -1,7 +1,6 @@
 | 
				
			|||||||
#compiler flags
 | 
					#compiler flags
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CFLAGS=-Wall -Wextra -g
 | 
					CFLAGS=-Wall -Wextra -g
 | 
				
			||||||
INCLUDES = -Isrc
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#files
 | 
					#files
 | 
				
			||||||
@ -12,19 +11,12 @@ CALF=src/iCal.c src/iCal.h
 | 
				
			|||||||
LLST=src/llist.c src/llist.h
 | 
					LLST=src/llist.c src/llist.h
 | 
				
			||||||
CONFIG=src/config.h #config file
 | 
					CONFIG=src/config.h #config file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ALLF=$(UIF) $(PLF) $(DBF) $(LLST)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
all: debug 
 | 
					 | 
				
			||||||
#targets
 | 
					#targets
 | 
				
			||||||
debug: test ui planner db iCal llist
 | 
					debug: test ui planner db iCal config llist
 | 
				
			||||||
	gcc -DDEBUG test.o ui.o planner.o db.o iCal.o llist.o -o debugOut 
 | 
						gcc test.o ui.o planner.o db.o iCal.o llist.o -o debugOut 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					config: $(CONFIG)
 | 
				
			||||||
# release: $(ALLF)
 | 
					 | 
				
			||||||
	# gcc -DRELEASE -fPIC -shared -o  $(ALLF)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# config: $(CONFIG)
 | 
					 | 
				
			||||||
llist: $(LLST)
 | 
					llist: $(LLST)
 | 
				
			||||||
	gcc -c $(CFLAGS) $(LLST)
 | 
						gcc -c $(CFLAGS) $(LLST)
 | 
				
			||||||
test: src/test.c
 | 
					test: src/test.c
 | 
				
			||||||
@ -32,7 +24,7 @@ test: src/test.c
 | 
				
			|||||||
iCal: $(CALF)
 | 
					iCal: $(CALF)
 | 
				
			||||||
	gcc -c $(CFLAGS) $(CALF)
 | 
						gcc -c $(CFLAGS) $(CALF)
 | 
				
			||||||
ui: $(UIF) 
 | 
					ui: $(UIF) 
 | 
				
			||||||
	gcc -DDEBUG -c $(CFLAGS) $(UIF)
 | 
						gcc -c $(CFLAGS) $(UIF)
 | 
				
			||||||
planner: $(PLF)
 | 
					planner: $(PLF)
 | 
				
			||||||
	gcc -c $(CFLAGS) $(PLF)
 | 
						gcc -c $(CFLAGS) $(PLF)
 | 
				
			||||||
db: $(DBF)
 | 
					db: $(DBF)
 | 
				
			||||||
@ -40,10 +32,10 @@ db: $(DBF)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
edit: 
 | 
					edit: 
 | 
				
			||||||
	nvim $(PLF) Makefile $(ALLF)
 | 
						nvim $(PLF) Makefile $(LLST) src/test.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
clean: 
 | 
					clean: 
 | 
				
			||||||
	rm -rf *.o debugOut src/*.gch  *.csv *.ics *.so
 | 
						rm -rf *.o debugOut src/*.gch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							@ -13,16 +13,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Time management optimisation tool.
 | 
					Time management optimisation tool.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# How to use
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - to use program directly compile with
 | 
					 | 
				
			||||||
          make debug
 | 
					 | 
				
			||||||
      . this creates executable binary.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - to integrate in other software use:
 | 
					 | 
				
			||||||
          make release
 | 
					 | 
				
			||||||
      . This creates shared library. use StudyPlanner.h (untested)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Procedure
 | 
					# Procedure
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## User input
 | 
					## User input
 | 
				
			||||||
 | 
				
			|||||||
@ -1,116 +0,0 @@
 | 
				
			|||||||
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/25.0.2 Chrome/128.0.6613.186 Electron/32.2.7 Safari/537.36" version="25.0.2">
 | 
					 | 
				
			||||||
  <diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">
 | 
					 | 
				
			||||||
    <mxGraphModel dx="1527" dy="2012" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
 | 
					 | 
				
			||||||
      <root>
 | 
					 | 
				
			||||||
        <mxCell id="WIyWlLk6GJQsqaUBKTNV-0" />
 | 
					 | 
				
			||||||
        <mxCell id="WIyWlLk6GJQsqaUBKTNV-1" parent="WIyWlLk6GJQsqaUBKTNV-0" />
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-39" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=1;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-5" target="sFZgEorzihY-HOV9npow-36">
 | 
					 | 
				
			||||||
          <mxGeometry relative="1" as="geometry">
 | 
					 | 
				
			||||||
            <mxPoint x="-10" y="-10" as="targetPoint" />
 | 
					 | 
				
			||||||
          </mxGeometry>
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-5" value="ui" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="90" y="20" width="120" height="80" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-6" value="db" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="90" y="460" width="120" height="80" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-20" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-7" target="sFZgEorzihY-HOV9npow-21">
 | 
					 | 
				
			||||||
          <mxGeometry relative="1" as="geometry">
 | 
					 | 
				
			||||||
            <mxPoint x="490" y="520" as="targetPoint" />
 | 
					 | 
				
			||||||
          </mxGeometry>
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-7" value="iCal" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="430" y="360" width="120" height="80" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-8" value="planner" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="430" y="30" width="120" height="80" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-10" value="" style="curved=1;endArrow=classic;html=1;rounded=0;entryX=0.025;entryY=0.313;entryDx=0;entryDy=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryPerimeter=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-5" target="sFZgEorzihY-HOV9npow-6">
 | 
					 | 
				
			||||||
          <mxGeometry width="50" height="50" relative="1" as="geometry">
 | 
					 | 
				
			||||||
            <mxPoint x="180" y="240" as="sourcePoint" />
 | 
					 | 
				
			||||||
            <mxPoint x="140" y="280" as="targetPoint" />
 | 
					 | 
				
			||||||
            <Array as="points">
 | 
					 | 
				
			||||||
              <mxPoint x="50" y="180" />
 | 
					 | 
				
			||||||
              <mxPoint x="30" y="370" />
 | 
					 | 
				
			||||||
              <mxPoint x="80" y="430" />
 | 
					 | 
				
			||||||
            </Array>
 | 
					 | 
				
			||||||
          </mxGeometry>
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-11" value="get stored subjects<div><br></div>" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="30" y="290" width="60" height="30" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-12" value="" style="curved=1;endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-6" target="sFZgEorzihY-HOV9npow-5">
 | 
					 | 
				
			||||||
          <mxGeometry width="50" height="50" relative="1" as="geometry">
 | 
					 | 
				
			||||||
            <mxPoint x="290" y="310" as="sourcePoint" />
 | 
					 | 
				
			||||||
            <mxPoint x="160" y="110" as="targetPoint" />
 | 
					 | 
				
			||||||
            <Array as="points">
 | 
					 | 
				
			||||||
              <mxPoint x="130" y="320" />
 | 
					 | 
				
			||||||
              <mxPoint x="150" y="210" />
 | 
					 | 
				
			||||||
            </Array>
 | 
					 | 
				
			||||||
          </mxGeometry>
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-13" value="return stored data" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="130" y="280" width="60" height="30" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-14" value="" style="endArrow=classic;html=1;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-5" target="sFZgEorzihY-HOV9npow-8">
 | 
					 | 
				
			||||||
          <mxGeometry width="50" height="50" relative="1" as="geometry">
 | 
					 | 
				
			||||||
            <mxPoint x="290" y="310" as="sourcePoint" />
 | 
					 | 
				
			||||||
            <mxPoint x="340" y="260" as="targetPoint" />
 | 
					 | 
				
			||||||
            <Array as="points" />
 | 
					 | 
				
			||||||
          </mxGeometry>
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-15" value="send subjects" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="250" y="20" width="100" height="30" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-18" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.45;exitY=0.988;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-8" target="sFZgEorzihY-HOV9npow-7">
 | 
					 | 
				
			||||||
          <mxGeometry width="50" height="50" relative="1" as="geometry">
 | 
					 | 
				
			||||||
            <mxPoint x="500" y="120" as="sourcePoint" />
 | 
					 | 
				
			||||||
            <mxPoint x="340" y="260" as="targetPoint" />
 | 
					 | 
				
			||||||
          </mxGeometry>
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-19" value="send event list" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="490" y="190" width="60" height="30" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-21" value="generate and safe iCal file" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="430" y="490" width="120" height="60" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-22" value="" style="endArrow=classic;html=1;rounded=0;entryX=1;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-8" target="sFZgEorzihY-HOV9npow-6">
 | 
					 | 
				
			||||||
          <mxGeometry width="50" height="50" relative="1" as="geometry">
 | 
					 | 
				
			||||||
            <mxPoint x="290" y="310" as="sourcePoint" />
 | 
					 | 
				
			||||||
            <mxPoint x="340" y="260" as="targetPoint" />
 | 
					 | 
				
			||||||
          </mxGeometry>
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-23" value="send updated subjects" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="260" y="270" width="60" height="30" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-24" value="subject db file" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="90" y="620" width="120" height="60" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-25" value="" style="endArrow=classic;html=1;rounded=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-6" target="sFZgEorzihY-HOV9npow-24">
 | 
					 | 
				
			||||||
          <mxGeometry width="50" height="50" relative="1" as="geometry">
 | 
					 | 
				
			||||||
            <mxPoint x="290" y="440" as="sourcePoint" />
 | 
					 | 
				
			||||||
            <mxPoint x="340" y="390" as="targetPoint" />
 | 
					 | 
				
			||||||
            <Array as="points" />
 | 
					 | 
				
			||||||
          </mxGeometry>
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-26" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-6" target="sFZgEorzihY-HOV9npow-24">
 | 
					 | 
				
			||||||
          <mxGeometry width="50" height="50" relative="1" as="geometry">
 | 
					 | 
				
			||||||
            <mxPoint x="290" y="440" as="sourcePoint" />
 | 
					 | 
				
			||||||
            <mxPoint x="340" y="390" as="targetPoint" />
 | 
					 | 
				
			||||||
            <Array as="points" />
 | 
					 | 
				
			||||||
          </mxGeometry>
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-27" value="serialise/deserialise<div><br></div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="150" y="573" width="130" height="40" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-36" value="" style="shape=actor;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="-30" y="-80" width="40" height="60" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
        <mxCell id="sFZgEorzihY-HOV9npow-40" value="ask human for input" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
 | 
					 | 
				
			||||||
          <mxGeometry x="-10" y="20" width="60" height="30" as="geometry" />
 | 
					 | 
				
			||||||
        </mxCell>
 | 
					 | 
				
			||||||
      </root>
 | 
					 | 
				
			||||||
    </mxGraphModel>
 | 
					 | 
				
			||||||
  </diagram>
 | 
					 | 
				
			||||||
</mxfile>
 | 
					 | 
				
			||||||
@ -1,6 +0,0 @@
 | 
				
			|||||||
#ifndef SPLANNER
 | 
					 | 
				
			||||||
#define SPLANNER
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int StudyPlanner();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif // StudyPlanner
 | 
					 | 
				
			||||||
							
								
								
									
										17
									
								
								src/config.h
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								src/config.h
									
									
									
									
									
								
							@ -9,7 +9,20 @@
 | 
				
			|||||||
#define hours(n) (60 * minutes(n))
 | 
					#define hours(n) (60 * minutes(n))
 | 
				
			||||||
#define days(n) (24 * hours(n))
 | 
					#define days(n) (24 * hours(n))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const time_t pauseLenght = minutes(15);
 | 
					static const time_t pauseLenght = minutes(10);
 | 
				
			||||||
static const time_t minIntervalLen = minutes(30);
 | 
					static const time_t minIntervalLen = minutes(30);
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// static const char *iCalHeader = "BEGIN:VCALENDAR"
 | 
				
			||||||
 | 
					//                                 "VERSION:2.0"
 | 
				
			||||||
 | 
					//                                 "PRODID:-//hacksw/handcal//NONSGML v1.0//EN";
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// static const char *iCalEvent =
 | 
				
			||||||
 | 
					//     "BEGIN:VEVENT"
 | 
				
			||||||
 | 
					//     "UID:uid1@example.com"
 | 
				
			||||||
 | 
					//     "ORGANIZER:CN=John Doe : MAILTO: john.doe@example.com"
 | 
				
			||||||
 | 
					//     "DTSTART:19970714T170000Z"
 | 
				
			||||||
 | 
					//     "DTEND:19970715T040000Z"
 | 
				
			||||||
 | 
					//     "SUMMARY:Bastille Day Party"
 | 
				
			||||||
 | 
					//     "END:VEVENT ";
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										97
									
								
								src/db.c
									
									
									
									
									
								
							
							
						
						
									
										97
									
								
								src/db.c
									
									
									
									
									
								
							@ -1,5 +1,4 @@
 | 
				
			|||||||
/* 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
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@ -10,99 +9,5 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "llist.h"
 | 
					 | 
				
			||||||
#include "planner.h"
 | 
					#include "planner.h"
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#include <time.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
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);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    // write the file header
 | 
					 | 
				
			||||||
    fprintf(file, "TaskName, Created, Deadline, Priority, Spare\n");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Iterate through the linked list and write the data to the CSV
 | 
					 | 
				
			||||||
    llist *current = head;
 | 
					 | 
				
			||||||
    Task *task;
 | 
					 | 
				
			||||||
    while (current != NULL) {
 | 
					 | 
				
			||||||
      task = current->data;
 | 
					 | 
				
			||||||
      // 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
 | 
					 | 
				
			||||||
    ssize_t nnread;
 | 
					 | 
				
			||||||
    size_t 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
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								src/db.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								src/db.h
									
									
									
									
									
								
							@ -3,6 +3,4 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "planner.h"
 | 
					#include "planner.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void write_linkedlist_to_csv(llist *head, const char *filename);
 | 
					 | 
				
			||||||
llist *write_csv_to_llist(const char *filename);
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										144
									
								
								src/iCal.c
									
									
									
									
									
								
							
							
						
						
									
										144
									
								
								src/iCal.c
									
									
									
									
									
								
							@ -1,143 +1,7 @@
 | 
				
			|||||||
 | 
					/* INPUT: linked list of events
 | 
				
			||||||
#include "llist.h"
 | 
					 *
 | 
				
			||||||
#include "planner.h"
 | 
					 * OUTPUT: Ical File, OK to caller
 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const char *iCalHeader =
 | 
					 | 
				
			||||||
    "BEGIN:VCALENDAR\r\n" // definition of commands for final iCal file
 | 
					 | 
				
			||||||
    "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";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const char *iCalFileExtension = "ics"; // doctype
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * Wikipedia
 | 
					 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *The body of the iCalendar object (the icalbody) contains single-line Calendar
 | 
					 | 
				
			||||||
 * Properties that apply to the entire calendar, as well as one or more blocks
 | 
					 | 
				
			||||||
 * of multiple lines that each define a Calendar Component such as an event,
 | 
					 | 
				
			||||||
 * journal entry, alarm, or one of several other types. Here is a simple example
 | 
					 | 
				
			||||||
 * of an iCalendar object with a single calendar containing a single Calendar
 | 
					 | 
				
			||||||
 * Component, a "Bastille Day Party" event starting at 5pm on July 14, 1997, and
 | 
					 | 
				
			||||||
 * ending at 4am the following morning:[10]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
BEGIN:VCALENDAR
 | 
					 | 
				
			||||||
VERSION:2.0
 | 
					 | 
				
			||||||
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
 | 
					 | 
				
			||||||
BEGIN:VEVENT
 | 
					 | 
				
			||||||
UID:uid1@example.com
 | 
					 | 
				
			||||||
ORGANIZER;CN=John Doe:MAILTO:john.doe@example.com
 | 
					 | 
				
			||||||
DTSTART:19970714T170000Z
 | 
					 | 
				
			||||||
DTEND:19970715T040000Z
 | 
					 | 
				
			||||||
SUMMARY:Bastille Day Party
 | 
					 | 
				
			||||||
GEO:48.85299;2.36885
 | 
					 | 
				
			||||||
END:VEVENT
 | 
					 | 
				
			||||||
END:VCALENDAR
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The UID field distributes updates when a scheduled event changes. When the event
 | 
					 | 
				
			||||||
is first generated a globally unique identifier is created. If a later event is
 | 
					 | 
				
			||||||
distributed with the same UID, it replaces the original one. An example UID
 | 
					 | 
				
			||||||
might be Y2007S2C131M5@example.edu, for the 5th meeting of class 131 in semester
 | 
					 | 
				
			||||||
2 at a hypothetical college. Email-style UIDs are now considered bad practice,
 | 
					 | 
				
			||||||
with a UUID recommended instead.[11]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The most common representation of date and time is a tz timestamp such as
 | 
					 | 
				
			||||||
20010911T124640Z with the format <year (4 digits)><month (2)><day (2)>T<hour
 | 
					 | 
				
			||||||
(2)><minute (2)><second (2)>Z for a total fixed length of 16 characters. Z
 | 
					 | 
				
			||||||
indicates the use of UTC (referring to its Zulu time zone).[12] When used in
 | 
					 | 
				
			||||||
DTSTART and DTEND properties, start times are inclusive while end times are not.
 | 
					 | 
				
			||||||
This allows an event's end time to be the same as a consecutive event's start
 | 
					 | 
				
			||||||
without those events overlapping and potentially creating (false) scheduling
 | 
					 | 
				
			||||||
conflicts.[13]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
// exportical function: generates ical file from llist
 | 
					 | 
				
			||||||
int exportiCal(llist *events_ll) {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  llist *ev_ll = events_ll; // input from llist
 | 
					#include "planner.h" // for task and event structs
 | 
				
			||||||
 | 
					 | 
				
			||||||
  llistPrintE(ev_ll);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  printf("%s", iCalHeader);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  time_t now = time(NULL); // current time is captured an formatted
 | 
					 | 
				
			||||||
  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) {
 | 
					 | 
				
			||||||
    printf("fopen failed!!");
 | 
					 | 
				
			||||||
    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); // strftime to match ical format
 | 
					 | 
				
			||||||
    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;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// export data from llist to csv file
 | 
					 | 
				
			||||||
const char *taskFileFormat = "%s,%lu,%lu,%d,%lu\n";
 | 
					 | 
				
			||||||
int taskLlToFile(llist *tll) {
 | 
					 | 
				
			||||||
  // open file
 | 
					 | 
				
			||||||
  FILE *fp = fopen("db.csv", "w");
 | 
					 | 
				
			||||||
  if (fp == NULL)
 | 
					 | 
				
			||||||
    return -1; // if file cannot be opend, return -1
 | 
					 | 
				
			||||||
  llist *c = tll;
 | 
					 | 
				
			||||||
  while (c != NULL) {
 | 
					 | 
				
			||||||
    Task *ct = (Task *)c->data; // loop to go through tasks(name, created time,
 | 
					 | 
				
			||||||
                                // deadline, priority, etc.)
 | 
					 | 
				
			||||||
    fprintf(fp, taskFileFormat, ct->name, ct->created, ct->deadline,
 | 
					 | 
				
			||||||
            ct->priority, ct->spare);
 | 
					 | 
				
			||||||
    c = c->next;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  fclose(fp);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +0,0 @@
 | 
				
			|||||||
#ifndef iCAL
 | 
					 | 
				
			||||||
#define iCAL
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "llist.h"
 | 
					 | 
				
			||||||
int exportiCal(llist *events_ll);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
#include "llist.h"
 | 
					#include "llist.h"
 | 
				
			||||||
 | 
					#include <asm-generic/errno.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -24,6 +24,6 @@ void llistFree(llist *head);
 | 
				
			|||||||
int llistLen(llist *head);
 | 
					int llistLen(llist *head);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void llistPrintT(llist *head);
 | 
					void llistPrintT(llist *head);
 | 
				
			||||||
void llistPrintH(llist *head);
 | 
					void llistPrintE(llist *head);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -15,13 +15,8 @@
 | 
				
			|||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <time.h>
 | 
					#include <time.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _WIN32
 | 
					const uint intervalLen = 45; // min
 | 
				
			||||||
#define ctime_r(T, Tm) (_localtime64_s(Tm, T) ? NULL : Tm)
 | 
					const uint pauseLen = 10;    //
 | 
				
			||||||
#define localtime_r(T, Tm) (_localtime64_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 "
 | 
				
			||||||
@ -151,7 +146,9 @@ int cmpTaskN(const void *a, const void *b) {
 | 
				
			|||||||
int cmpTaskP(const void *a, const void *b) {
 | 
					int cmpTaskP(const void *a, const void *b) {
 | 
				
			||||||
  Task *aa = (Task *)a;
 | 
					  Task *aa = (Task *)a;
 | 
				
			||||||
  Task *bb = (Task *)b;
 | 
					  Task *bb = (Task *)b;
 | 
				
			||||||
 | 
					  if (bb->priority - aa->priority != 0)
 | 
				
			||||||
    return bb->priority - aa->priority;
 | 
					    return bb->priority - aa->priority;
 | 
				
			||||||
 | 
					  return aa->spare - bb->spare;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// cmp event by task name
 | 
					// cmp event by task name
 | 
				
			||||||
@ -161,14 +158,6 @@ int cmpEvent(const void *a, const void *b) {
 | 
				
			|||||||
  return cmpTaskN(aa->task, bb->task);
 | 
					  return cmpTaskN(aa->task, bb->task);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void resetPrio(Task **sortedPrio, int len) {
 | 
					 | 
				
			||||||
  for (int i = 0; i < len; i++) {
 | 
					 | 
				
			||||||
    if ((*sortedPrio)[i].priority < 0) // ignore past deadline
 | 
					 | 
				
			||||||
      continue;
 | 
					 | 
				
			||||||
    printf("incrementing prio!\n");
 | 
					 | 
				
			||||||
    (*sortedPrio)[i].priority += 10;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
llist *genPlan(llist *head, time_t timeAvail) {
 | 
					llist *genPlan(llist *head, time_t timeAvail) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // map llist to pointer arr & sort by priority
 | 
					  // map llist to pointer arr & sort by priority
 | 
				
			||||||
@ -178,7 +167,7 @@ llist *genPlan(llist *head, time_t timeAvail) {
 | 
				
			|||||||
  printf("len: %d\n", lLen);
 | 
					  printf("len: %d\n", lLen);
 | 
				
			||||||
  llistPrintT(head);
 | 
					  llistPrintT(head);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  time_t now = time(NULL);
 | 
					  // Task *sortedNames = calloc(lLen, sizeof(Task));
 | 
				
			||||||
  Task *sortedPrio = calloc(lLen, sizeof(Task));
 | 
					  Task *sortedPrio = calloc(lLen, sizeof(Task));
 | 
				
			||||||
  if (/*sortedNames == NULL ||*/ sortedPrio == NULL) {
 | 
					  if (/*sortedNames == NULL ||*/ sortedPrio == NULL) {
 | 
				
			||||||
    planLog("gen plan : calloc failed!!\n", true);
 | 
					    planLog("gen plan : calloc failed!!\n", true);
 | 
				
			||||||
@ -186,16 +175,19 @@ llist *genPlan(llist *head, time_t timeAvail) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // add Tasks from llist to arr
 | 
					  // add Tasks from llist to arr
 | 
				
			||||||
 | 
					  // ignore tasks  after deadline
 | 
				
			||||||
  llist *c = head;
 | 
					  llist *c = head;
 | 
				
			||||||
 | 
					  time_t now = time(NULL);
 | 
				
			||||||
  for (int i = 0; c != NULL; i++) {
 | 
					  for (int i = 0; c != NULL; i++) {
 | 
				
			||||||
    sortedPrio[i] = *(Task *)c->data;
 | 
					    sortedPrio[i] = *(Task *)c->data;
 | 
				
			||||||
    if (sortedPrio[i].deadline + 1 < now) {
 | 
					    if (sortedPrio[i].deadline <= now)
 | 
				
			||||||
      sortedPrio[i].priority = -1; // ignore past deadlines
 | 
					      sortedPrio[i].priority = 0;
 | 
				
			||||||
    }
 | 
					
 | 
				
			||||||
    c = c->next;
 | 
					    c = c->next;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // sort
 | 
					  // sort
 | 
				
			||||||
 | 
					  // qsort(sortedNames, lLen, sizeof(Task), cmpTaskN);
 | 
				
			||||||
  qsort(sortedPrio, lLen, sizeof(Task), cmpTaskP);
 | 
					  qsort(sortedPrio, lLen, sizeof(Task), cmpTaskP);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  planLog("sortendPrio", 0);
 | 
					  planLog("sortendPrio", 0);
 | 
				
			||||||
@ -205,8 +197,7 @@ llist *genPlan(llist *head, time_t timeAvail) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  planLog("creating eventList", false);
 | 
					  planLog("creating eventList", false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // genertate plan based on priorities and available time
 | 
					  // genertate plan basen on priorities and available time
 | 
				
			||||||
  now = time(NULL);
 | 
					 | 
				
			||||||
  struct tm *lc = localtime(&now);
 | 
					  struct tm *lc = localtime(&now);
 | 
				
			||||||
  llist *events_ll = llistNew(NULL, cmpEvent);
 | 
					  llist *events_ll = llistNew(NULL, cmpEvent);
 | 
				
			||||||
  if (events_ll == NULL) {
 | 
					  if (events_ll == NULL) {
 | 
				
			||||||
@ -214,12 +205,6 @@ llist *genPlan(llist *head, time_t timeAvail) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  time_t start, end;
 | 
					  time_t start, end;
 | 
				
			||||||
  do {
 | 
					  do {
 | 
				
			||||||
    if ((*sortedPrio).priority < 0) {
 | 
					 | 
				
			||||||
      continue;
 | 
					 | 
				
			||||||
    } else if ((*sortedPrio).priority == 0) {
 | 
					 | 
				
			||||||
      printf("All tasks have priority <0!!");
 | 
					 | 
				
			||||||
      resetPrio(&sortedPrio, lLen);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    start = mktime(lc); // start now
 | 
					    start = mktime(lc); // start now
 | 
				
			||||||
    lc->tm_min += intervalLen;
 | 
					    lc->tm_min += intervalLen;
 | 
				
			||||||
    end = mktime(lc); //
 | 
					    end = mktime(lc); //
 | 
				
			||||||
@ -230,17 +215,26 @@ llist *genPlan(llist *head, time_t timeAvail) {
 | 
				
			|||||||
      c = newEvent(tmp->data, start, end,
 | 
					      c = newEvent(tmp->data, start, end,
 | 
				
			||||||
                   0); // use elem with wighest priority
 | 
					                   0); // use elem with wighest priority
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    llistAppend(events_ll, c);
 | 
					    llistAppend(events_ll, c);
 | 
				
			||||||
    printEvent(c);
 | 
					    // printEvent(c);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // decrement priority of first elem and resort list
 | 
					    // decrement priority of first elem and resort list
 | 
				
			||||||
    (*sortedPrio).priority -= 1;
 | 
					    (*sortedPrio).priority -= 1;
 | 
				
			||||||
 | 
					    // increment spare(used as counter)
 | 
				
			||||||
 | 
					    // counter counts how often a task hsa been in addet to event list
 | 
				
			||||||
 | 
					    // this is used to break ties if priorites are equal
 | 
				
			||||||
 | 
					    (*sortedPrio).spare += 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // sort again
 | 
				
			||||||
    qsort(sortedPrio, lLen, sizeof(Task), cmpTaskP);
 | 
					    qsort(sortedPrio, lLen, sizeof(Task), cmpTaskP);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    planLog("sortendPrio", 0);
 | 
				
			||||||
 | 
					    for (int i = 0; i < lLen; i++) {
 | 
				
			||||||
 | 
					      printTask(sortedPrio + i);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    lc->tm_min += pauseLen; // add pause
 | 
					    lc->tm_min += pauseLen; // add pause
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  } while (mktime(lc) < timeAvail);
 | 
					  } while (mktime(lc) < timeAvail && (*sortedPrio).priority > 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // free empty head
 | 
					  // free empty head
 | 
				
			||||||
  llist *tmp = events_ll;
 | 
					  llist *tmp = events_ll;
 | 
				
			||||||
@ -248,6 +242,7 @@ llist *genPlan(llist *head, time_t timeAvail) {
 | 
				
			|||||||
  tmp->next = NULL;
 | 
					  tmp->next = NULL;
 | 
				
			||||||
  llistFreeE(tmp);
 | 
					  llistFreeE(tmp);
 | 
				
			||||||
  // llistPrintE(events_ll);
 | 
					  // llistPrintE(events_ll);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // 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);
 | 
				
			||||||
@ -258,6 +253,8 @@ llist *genPlan(llist *head, time_t timeAvail) {
 | 
				
			|||||||
  free(sortedPrio);
 | 
					  free(sortedPrio);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  planLog("END GEN PLAN", 0);
 | 
					  planLog("END GEN PLAN", 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // llistFreeT(head);
 | 
				
			||||||
  // send updated tasks to db for storage
 | 
					  // send updated tasks to db for storage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return events_ll;
 | 
					  return events_ll;
 | 
				
			||||||
 | 
				
			|||||||
@ -77,13 +77,10 @@ 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
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@
 | 
				
			|||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <time.h>
 | 
					#include <time.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int test() {
 | 
					int main() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  time_t now = time(NULL);
 | 
					  time_t now = time(NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -25,6 +25,8 @@ int test() {
 | 
				
			|||||||
  assert(t3 != NULL);
 | 
					  assert(t3 != NULL);
 | 
				
			||||||
  Task *t4 = newTask("TM1", now, now + days(1), 9, 0);
 | 
					  Task *t4 = newTask("TM1", now, now + days(1), 9, 0);
 | 
				
			||||||
  assert(t4 != NULL);
 | 
					  assert(t4 != NULL);
 | 
				
			||||||
 | 
					  Task *t5 = newTask("Akt1", now, now, 9, 0);
 | 
				
			||||||
 | 
					  assert(t5 != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  printf("%s\n", ctime(&now));
 | 
					  printf("%s\n", ctime(&now));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -33,12 +35,14 @@ int test() {
 | 
				
			|||||||
  llistAppend(list1, t2);
 | 
					  llistAppend(list1, t2);
 | 
				
			||||||
  llistAppend(list1, t3);
 | 
					  llistAppend(list1, t3);
 | 
				
			||||||
  llistAppend(list1, t4);
 | 
					  llistAppend(list1, t4);
 | 
				
			||||||
 | 
					  llistAppend(list1, t5);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // gnerate plan from task list in time
 | 
					  // gnerate plan from task list in time
 | 
				
			||||||
  struct tm *lc = localtime(&now);
 | 
					  struct tm *lc = localtime(&now);
 | 
				
			||||||
  lc->tm_hour += 9;                    // add available time;
 | 
					  lc->tm_hour += 4;                    // add available time;
 | 
				
			||||||
  time_t maxTime = mktime(lc);         // create timestamp
 | 
					  time_t maxTime = mktime(lc);         // create timestamp
 | 
				
			||||||
  llist *l1 = genPlan(list1, maxTime); // return inked list of event;
 | 
					  llist *l1 = genPlan(list1, maxTime); // return inked list of event;
 | 
				
			||||||
 | 
					  llistPrintE(l1);
 | 
				
			||||||
  llistFreeE(l1);
 | 
					  llistFreeE(l1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // print test tasks
 | 
					  // print test tasks
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										290
									
								
								src/ui.c
									
									
									
									
									
								
							
							
						
						
									
										290
									
								
								src/ui.c
									
									
									
									
									
								
							@ -4,198 +4,136 @@
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
/* Created by Juergen Buechel, 13.12.2024/
 | 
					/* Created by Juergen Buechel, 13.12.2024/
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#define _GNU_SOURCE
 | 
					 | 
				
			||||||
#include "ui.h"
 | 
					 | 
				
			||||||
#include "StudyPlanner.h"
 | 
					 | 
				
			||||||
#include "db.h"
 | 
					 | 
				
			||||||
#include "iCal.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 <stdio.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include "ui.h"
 | 
				
			||||||
#include <time.h>
 | 
					#include "planner.h"
 | 
				
			||||||
 | 
					#include "iCal.h"
 | 
				
			||||||
 | 
					#include "db.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _WIN32
 | 
					void dump_buffer(FILE *fp){
 | 
				
			||||||
#define localtime_r(T, Tm) (_localtime64_s(Tm, T) ? NULL : Tm)
 | 
					    int ch;
 | 
				
			||||||
#endif
 | 
					    while((ch = fgetc(fp)) != EOF && ch != '\n');
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define minutes(n) (60 * n)
 | 
					 | 
				
			||||||
#define hours(n) (60 * minutes(n))
 | 
					 | 
				
			||||||
#define days(n) (24 * hours(n))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *dbName = "db.csv";
 | 
					void insertTask(task_ptr newtask)
 | 
				
			||||||
#define DEBUG
 | 
					{
 | 
				
			||||||
#ifdef DEBUG
 | 
					    task_ptr TaskPointer;
 | 
				
			||||||
int main(void) {
 | 
					    if (firsttask == NULL){
 | 
				
			||||||
#endif
 | 
					        firsttask = newtask;
 | 
				
			||||||
#ifdef RELEASE
 | 
					        newtask->nextTask ;
 | 
				
			||||||
  int StudyPlanner() {
 | 
					    }
 | 
				
			||||||
#endif
 | 
					    else {
 | 
				
			||||||
    int taskcreation_date = 0;
 | 
					        TaskPointer = firsttask;
 | 
				
			||||||
    int taskdeadline_date = 0;
 | 
					        while(TaskPointer->nextTask!=NULL)
 | 
				
			||||||
    int taskpriority = 0;
 | 
					        {
 | 
				
			||||||
    int taskspare = 0;
 | 
					            TaskPointer = TaskPointer->nextTask;
 | 
				
			||||||
    char *taskname = NULL; // taskName Buffer
 | 
					        }
 | 
				
			||||||
 | 
					        TaskPointer->nextTask = newtask;
 | 
				
			||||||
 | 
					        newtask ->nextTask;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    llist *listT = NULL;
 | 
					void newTask (void)
 | 
				
			||||||
    llist *listE = NULL;
 | 
					{
 | 
				
			||||||
 | 
					    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 eingeben: ");
 | 
				
			||||||
 | 
					    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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void getlink (void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
    int choice = 0, i = 0;
 | 
					    int choice = 0, i = 0;
 | 
				
			||||||
    do {
 | 
					    do
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        printf(" -1- Neues Fach eingeben\n");
 | 
					        printf(" -1- Neues Fach eingeben\n");
 | 
				
			||||||
        printf(" -2- Verfuegbare Zeit eingeben\n");
 | 
					        printf(" -2- Verfuegbare Zeit eingeben\n");
 | 
				
			||||||
        printf(" -3- Alle vorhandenen Faecher aufliesten\n");
 | 
					        printf(" -3- Alle vorhandenen Faecher aufliesten\n");
 | 
				
			||||||
        printf(" -4- Kalenderlink ausgeben\n");
 | 
					        printf(" -4- Kalenderlink ausgeben\n");
 | 
				
			||||||
      printf(" -5- Faecher Importieren\n");
 | 
					        printf(" -5- Planer beenden\n");
 | 
				
			||||||
      printf(" -6- Planer beenden\n");
 | 
					        if( scanf("%d", &choice) != 1){
 | 
				
			||||||
      printf(" Waehle die gewuenschte Option aus\n");
 | 
					            printf("Falsche Eingabe\n");};
 | 
				
			||||||
      volatile int r = scanf("%d", &choice);
 | 
					 | 
				
			||||||
      if (r != 1) {
 | 
					 | 
				
			||||||
        printf("Falsche Eingabe\n");
 | 
					 | 
				
			||||||
        fgetc(stdin);
 | 
					 | 
				
			||||||
        choice = 0;
 | 
					        choice = 0;
 | 
				
			||||||
        continue;
 | 
					        dump_buffer(stdin);
 | 
				
			||||||
      };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      taskname = NULL;
 | 
					        switch (choice)
 | 
				
			||||||
      size_t nameLen;
 | 
					        {
 | 
				
			||||||
      ssize_t nnread;
 | 
					        case 1: newTask();break;
 | 
				
			||||||
      switch (choice) {
 | 
					        case 2: newTime();break;
 | 
				
			||||||
      case 1:
 | 
					        case 3: if( firsttask == NULL){
 | 
				
			||||||
        printf(" Geben sie das gewünschte Fach ein (Name): \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(1-10): \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
 | 
					 | 
				
			||||||
        time_t deadline = now + days(taskdeadline_date);
 | 
					 | 
				
			||||||
        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 "
 | 
					 | 
				
			||||||
               "(geplante arbeitsstunden huete): \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");
 | 
					            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;
 | 
					        else{
 | 
				
			||||||
        // // case 4: iCAl();break;
 | 
					            tasklisting();
 | 
				
			||||||
        //
 | 
					        }break;
 | 
				
			||||||
        // printf(" Wie viel Zeit bleibt ihnen:\n");
 | 
					        case 4: iCAl();break;
 | 
				
			||||||
        // 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);
 | 
					    }while (choice !=5);
 | 
				
			||||||
        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;
 | 
					    return EXIT_SUCCESS;
 | 
				
			||||||
        // case 4: iCAl();break;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    } while (choice < 6);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user