]> gitweb.hhaalo.de Git - feierabend.git/commitdiff
change params to const
authorBastian Dehn <hhaalo@arcor.de>
Sat, 14 Feb 2026 17:21:08 +0000 (18:21 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 14 Feb 2026 17:21:08 +0000 (18:21 +0100)
src/break.c
src/break.h
src/feierabend.c
src/feierabendxml.c
src/time_format.c
src/time_format.h
src/worktime.c
src/worktime.h
src/xml.c
src/xml.h

index c1c521958acdec070dca2e693dba440dfc383289..1afc19f6a96e78a4d3f21426b6cb19e04290b396 100644 (file)
@@ -10,7 +10,7 @@
 #define THIRTY_MINUTES 1800
 #define FOURTY_FIVE_MINITUES 2700
 
-time_t get_break_time(time_t worktime)
+time_t get_break_time(const time_t worktime)
 {
        if (worktime > SIX_HOURS_FOURTY_FIVE_MINUTES)
                return FOURTY_FIVE_MINITUES;
index 90fecf4b382d42e2128732f8d8785fcfab69fb78..8f49563ec14aebc23296f0395e5196e3a095e280 100644 (file)
@@ -2,6 +2,6 @@
 #define BREAK_H
 #include <time.h>
 
-time_t get_break_time(time_t worktime);
+time_t get_break_time(const time_t worktime);
 
 #endif
\ No newline at end of file
index 6a3f1c3ba1f1ee27cc60aead461be7b2b651dfe5..b6b778f8ae201049d04032a11ec7fd1ac295580c 100644 (file)
@@ -126,7 +126,7 @@ struct tm _init_tm_with_time(const char* hour, const char* min)
        return value;
 }
 
-int main(int argc, const char* argv[])
+int main(const int argc, const char* argv[])
 {
        if (argc < 3) {
                printf("ERROR: %s <begin_hours> <begin_minutes>\n", argv[0]);
index 995b7622a89ed47a69b51b6f256a9b0a946d012f..2bf94b98e1668d27ede68f39bf7ad3d6aa144a3e 100644 (file)
@@ -5,7 +5,7 @@
 #include "validate.h"
 #include "xml.h"
 
-int main(int argc, char* argv[])
+int main(const int argc, const char* argv[])
 {
        if (argc < 2) {
                printf("ERROR: %s <init|add|dateadd|merge|version>\n", argv[0]);
index c7cb4f4627eb6ee66e505303c4bf667dc79f1aad..f546b97c868990f3fc4e06743f37b7c7c29df453 100644 (file)
@@ -19,7 +19,7 @@ char* _strdup(const char* str)
        return new_str;
 }
 
-char* get_time_str(time_t timediff)
+char* get_time_str(const time_t timediff)
 {
        int8_t hour = timediff / ONE_HOUR;
        int16_t rest_minutes = timediff % ONE_HOUR;
@@ -42,12 +42,12 @@ char* get_time_str(time_t timediff)
        return timestr;
 }
 
-char* get_time_overtime_str(time_t timediff)
+char* get_time_overtime_str(const time_t timediff)
 {
        return get_time_str(timediff * -1);
 }
 
-char* get_weekday_str(uint8_t wday)
+char* get_weekday_str(const uint8_t wday)
 {
        switch (wday) {
        case 0:
@@ -69,7 +69,7 @@ char* get_weekday_str(uint8_t wday)
        }
 }
 
-char* get_weekday_short_str(uint8_t wday)
+char* get_weekday_short_str(const uint8_t wday)
 {
        switch(wday) {
        case 0:
@@ -91,7 +91,7 @@ char* get_weekday_short_str(uint8_t wday)
        }
 }
 
-char* get_date_str(struct tm date)
+char* get_date_str(const struct tm date)
 {
        char* datestr = malloc(sizeof(char) * MAX_TIME_STR_LENGTH);
        if (datestr == NULL)
@@ -107,7 +107,7 @@ char* get_date_str(struct tm date)
        return datestr;
 }
 
-char* get_time_str_from_tm(struct tm time)
+char* get_time_str_from_tm(const struct tm time)
 {
        char* timestr = malloc(sizeof(char) * MAX_TIME_STR_LENGTH);
        if (timestr == NULL)
index 5922364574e34b3842daabd2b6877f7fdd41b58f..2317c3c11b010f273c295b2ab7488cd1dae48e1e 100644 (file)
@@ -4,12 +4,12 @@
 #include <stdint.h>
 #include <time.h>
 
-char* get_time_str(time_t timediff);
-char* get_time_overtime_str(time_t timediff);
-char* get_weekday_str(uint8_t wday);
-char* get_weekday_short_str(uint8_t wday);
-char* get_date_str(struct tm date);
-char* get_time_str_from_tm(struct tm time);
+char* get_time_str(const time_t timediff);
+char* get_time_overtime_str(const time_t timediff);
+char* get_weekday_str(const uint8_t wday);
+char* get_weekday_short_str(const uint8_t wday);
+char* get_date_str(const struct tm date);
+char* get_time_str_from_tm(const struct tm time);
 
 time_t get_seconds_from_str(const char* timestr);
 uint16_t get_year_from_str(const char* date);
index 501a413dcbeed699ca7fe4cc7479b08d1fef1405..56734db22dc480e6cbb113edc5b3dd4d076c781a 100644 (file)
@@ -4,26 +4,30 @@
 #define TEN_HOURS 36000
 #define ONE_DAY 86400
 
-time_t get_brutto_worktime(time_t begin, time_t now)
+time_t get_brutto_worktime(const time_t begin, const time_t now)
 {
-       if (begin > now)
-               now += ONE_DAY;
+       time_t tmp_now = now;
 
-       return difftime(now, begin);
+       if (begin > tmp_now)
+               tmp_now += ONE_DAY;
+
+       return difftime(tmp_now, begin);
 }
 
-time_t get_current_worktime(time_t begin, time_t now)
+time_t get_current_worktime(const time_t begin, const time_t now)
 {
-       if (begin > now)
-               now += ONE_DAY;
+       time_t tmp_now = now;
+
+       if (begin > tmp_now)
+               tmp_now += ONE_DAY;
 
-       time_t worktime = difftime(now, begin);
+       time_t worktime = difftime(tmp_now, begin);
        worktime -= get_break_time(worktime);
 
        return worktime;
 }
 
-time_t get_eight_hour_end_worktime(time_t begin)
+time_t get_eight_hour_end_worktime(const time_t begin)
 {
        time_t worktime = begin + SOLL_WORKTIME;
        worktime += get_break_time(worktime);
@@ -31,7 +35,7 @@ time_t get_eight_hour_end_worktime(time_t begin)
        return worktime;
 }
 
-time_t get_ten_hour_end_worktime(time_t begin)
+time_t get_ten_hour_end_worktime(const time_t begin)
 {
        time_t worktime = begin + TEN_HOURS;
        worktime += get_break_time(worktime);
@@ -39,12 +43,12 @@ time_t get_ten_hour_end_worktime(time_t begin)
        return worktime;
 }
 
-time_t get_current_worktime_diff_to_end_eight_hour(time_t begin, time_t now)
+time_t get_current_worktime_diff_to_end_eight_hour(const time_t begin, const time_t now)
 {
        return SOLL_WORKTIME - get_current_worktime(begin, now);
 }
 
-time_t get_current_worktime_diff_to_end_ten_hour(time_t begin, time_t now)
+time_t get_current_worktime_diff_to_end_ten_hour(const time_t begin, const time_t now)
 {
        return TEN_HOURS - get_current_worktime(begin, now);
 }
\ No newline at end of file
index ac344cd15c064159cc9a2897c9025c6117b97f98..83f3379c68ff61ec6f76e193be9e189108adcf20 100644 (file)
@@ -7,11 +7,11 @@
 #define ONE_MINUTE 60
 #define SOLL_WORKTIME SOLL_HOUR * ONE_HOUR + SOLL_MINUTES * ONE_MINUTE
 
-time_t get_brutto_worktime(time_t begin, time_t now);
-time_t get_current_worktime(time_t begin, time_t now);
-time_t get_eight_hour_end_worktime(time_t begin);
-time_t get_ten_hour_end_worktime(time_t begin);
-time_t get_current_worktime_diff_to_end_eight_hour(time_t begin, time_t now);
-time_t get_current_worktime_diff_to_end_ten_hour(time_t begin, time_t now);
+time_t get_brutto_worktime(const time_t begin, const time_t now);
+time_t get_current_worktime(const time_t begin, const time_t now);
+time_t get_eight_hour_end_worktime(const time_t begin);
+time_t get_ten_hour_end_worktime(const time_t begin);
+time_t get_current_worktime_diff_to_end_eight_hour(const time_t begin, const time_t now);
+time_t get_current_worktime_diff_to_end_ten_hour(const time_t begin, const time_t now);
 
 #endif
\ No newline at end of file
index 3b6c672d35f75b2df60e06a55207f62515be1141..a273306472d919ef2497fc8dc3c1c6b91b1d8af6 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -14,8 +14,8 @@
 #define MAX_STRING_LENGTH 36
 #define CHUCK_SIZE 32
 
-memFile* _init_mem() {
-       memFile* mem = malloc(sizeof(memFile));
+mem_file_t* _init_mem() {
+       mem_file_t* mem = malloc(sizeof(mem_file_t));
 
        if (mem == NULL)
                return NULL;
@@ -26,12 +26,12 @@ memFile* _init_mem() {
        return mem;
 }
 
-void free_mem(memFile* mem) {
+void free_mem(mem_file_t* mem) {
        free(mem->data);
        mem->data = NULL;
 }
 
-void _alloc_chunk(memFile* mem)
+void _alloc_chunk(mem_file_t* mem)
 {
        mem->size += CHUCK_SIZE;
        char* tmpmem = realloc(mem->data, sizeof(char) * mem->size);
@@ -44,7 +44,7 @@ void _alloc_chunk(memFile* mem)
        mem->data = tmpmem;
 }
 
-void _shrink_mem(size_t readed, memFile* mem)
+void _shrink_mem(const size_t readed, mem_file_t* mem)
 {
        mem->size = readed;
        char* tmpmem = realloc(mem->data, sizeof(char) * mem->size);
@@ -57,7 +57,7 @@ void _shrink_mem(size_t readed, memFile* mem)
        mem->data = tmpmem;
 }
 
-void _read_stdin_into_memory(memFile* mem)
+void _read_stdin_into_memory(mem_file_t* mem)
 {
        char* buf = malloc(sizeof(char));
 
@@ -82,7 +82,7 @@ void _read_stdin_into_memory(memFile* mem)
        buf = NULL;
 }
 
-char* _read_last_saldo(memFile* mem)
+char* _read_last_saldo(mem_file_t* mem)
 {
        char* saldostr = malloc(sizeof(char) * MAX_STRING_LENGTH);
        if (saldostr == NULL)
@@ -166,7 +166,7 @@ void _copy_entry(xmlTextReaderPtr xmlreader, xmlTextWriterPtr xmlwriter)
        xmlElemContent = NULL;
 }
 
-struct tm _init_tm_with_date(const char* date, uint8_t hour, uint8_t min)
+struct tm _init_tm_with_date(const char* date, const uint8_t hour, const uint8_t min)
 {
        struct tm value;
        const time_t now = time(NULL);
@@ -186,11 +186,11 @@ struct tm _init_tm_with_date(const char* date, uint8_t hour, uint8_t min)
 
 void _write_entry_node(xmlTextWriterPtr xmlWriter,
        const char* date,
-       uint8_t begin_hour,
-       uint8_t begin_min,
-       uint8_t end_hour,
-       uint8_t end_min,
-       time_t last_saldo)
+       const uint8_t begin_hour,
+       const uint8_t begin_min,
+       const uint8_t end_hour,
+       const uint8_t end_min,
+       const time_t last_saldo)
 {
        const struct tm begin_tm = _init_tm_with_date(date, begin_hour, begin_min);
        const struct tm end_tm = _init_tm_with_date(date, end_hour, end_min);
@@ -366,12 +366,12 @@ void init_time_acount()
 }
 
 void add_entry(const char* date,
-       uint8_t begin_hour,
-       uint8_t begin_min,
-       uint8_t end_hour,
-       uint8_t end_min)
+       const uint8_t begin_hour,
+       const uint8_t begin_min,
+       const uint8_t end_hour,
+       const uint8_t end_min)
 {
-       memFile* file_content = _init_mem();
+       mem_file_t* file_content = _init_mem();
        _read_stdin_into_memory(file_content);
 
        char* saldostr = _read_last_saldo(file_content);
index e7bf2cb28ded38ec0dbf2beb063a70dd0169b749..a6381b32cc38bee7a94a3c43405c4a445f47db14 100644 (file)
--- a/src/xml.h
+++ b/src/xml.h
@@ -5,14 +5,14 @@
 typedef struct {
        char* data;
        size_t size;
-} memFile;
+} mem_file_t;
 
 void init_time_acount();
 void add_entry(const char* date,
-       uint8_t begin_hour,
-       uint8_t begin_min,
-       uint8_t end_hour,
-       uint8_t end_min);
+       const uint8_t begin_hour,
+       const uint8_t begin_min,
+       const uint8_t end_hour,
+       const uint8_t end_min);
 void merge(const char* dir);
 
 #endif
\ No newline at end of file