diary

Text-based journaling program
git clone https://git.in0rdr.ch/diary.git
Log | Files | Refs | Pull requests |Archive | README | LICENSE

commit d051e7150c4e95ecb63e49587d60d7221301c487
parent 08ef71c1b7d05208c4c388351b7f372cd7cbfad2
Author: Andreas Gruhler <agruhl@gmx.ch>
Date:   Tue,  4 Feb 2025 22:50:03 +0100

fix(caldav): missing caldav_port

Diffstat:
Msrc/caldav.c | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/caldav.c b/src/caldav.c @@ -316,12 +316,13 @@ int caldav_sync(struct tm* date, } // extract host without path as basis for further api paths - char *caldav_host; char* caldav_host_scheme; + char *caldav_host; char *caldav_port; char* caldav_host_scheme; CURLU *h = curl_url(); CURLUcode uc = curl_url_set(h, CURLUPART_URL, CONFIG.caldav_server, 0); uc = curl_url_get(h, CURLUPART_HOST, &caldav_host, 0); uc = curl_url_get(h, CURLUPART_SCHEME, &caldav_host_scheme, 0); + uc = curl_url_get(h, CURLUPART_PORT, &caldav_port, 0); debug("Caldav server host name: %s", caldav_host); + debug("Caldav server port: %s", caldav_port); debug("Caldav server scheme/protocol: %s", caldav_host_scheme); - debug("Caldav server host name: %s", caldav_host); if (!uc) { debug("%s", "cur_url_get() failed in caldav_sync()"); } @@ -329,7 +330,7 @@ int caldav_sync(struct tm* date, // get the home-set of the user char uri[300]; - sprintf(uri, "%s://%s%s", caldav_host_scheme, caldav_host, current_user_principal); + sprintf(uri, "%s://%s:%s%s", caldav_host_scheme, caldav_host, caldav_port, current_user_principal); char* home_set = caldav_req(date, uri, "PROPFIND", homeset_request, 0, basicauth_enabled, "application/xml", 0); debug("Home set xml %s", home_set); @@ -347,7 +348,7 @@ int caldav_sync(struct tm* date, return -1; } - sprintf(uri, "%s://%s%s", caldav_host_scheme, caldav_host, home_set_parsed); + sprintf(uri, "%s://%s:%s%s", caldav_host_scheme, caldav_host, caldav_port, home_set_parsed); free(home_set); free(home_set_parsed); @@ -390,7 +391,7 @@ int caldav_sync(struct tm* date, dstr_end); // fetch event for the cursor date - sprintf(uri, "%s://%s%s", caldav_host_scheme, caldav_host, calendar_href); + sprintf(uri, "%s://%s:%s%s", caldav_host_scheme, caldav_host, caldav_port, calendar_href); char* events_xml = caldav_req(date, uri, "REPORT", caldata_postfields, 1, basicauth_enabled, "application/xml", 0); @@ -471,6 +472,7 @@ int caldav_sync(struct tm* date, // free memory allocated to store curl response curl_free(caldav_host_scheme); curl_free(caldav_host); + curl_free(caldav_port); free(remote_uid); return 0; } else if (timediff > 0) { @@ -478,7 +480,7 @@ int caldav_sync(struct tm* date, if (remote_uid) { // purge any existing daily calendar entries on the remote side char event_uri[300]; - sprintf(event_uri, "%s://%s%s%s.ics", caldav_host_scheme, caldav_host, calendar_href, remote_uid); + sprintf(event_uri, "%s://%s:%s%s%s.ics", caldav_host_scheme, caldav_host, caldav_port, calendar_href, remote_uid); //sprintf(event_uri, "%s%s%s.ics", CONFIG.caldav_server, calendar_href, remote_uid); debug("Event URI for DELETE request: %s", event_uri); char* response = caldav_req(date, event_uri, "DELETE", NULL, 0, basicauth_enabled, "", 0);