From 43c206b4e7e3587d371941d09ab2768ddc785651 Mon Sep 17 00:00:00 2001 From: Jonathan Wyss Date: Wed, 11 Sep 2024 15:21:20 +0200 Subject: [PATCH] clean up --- config | 4 ---- main.c | 12 ++++++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config b/config index 9962c59..edda6f7 100644 --- a/config +++ b/config @@ -1,6 +1,2 @@ /org/freedesktop/systemd1/unit/NetworkManager_2dwait_2donline_2eservice /org/freedesktop/systemd1/unit/NetworkManager_2eservice -/systemd/blalbla/1 -/systemd/blalbla/2 -/systemd/blalbla/3 -/systemd/blalbla/4 diff --git a/main.c b/main.c index cb3dfba..10e9c0a 100644 --- a/main.c +++ b/main.c @@ -27,6 +27,7 @@ typedef struct service char *name; char *targetPath; bool alert; + int priority; } Service; int main(int argc,char *argv[]) @@ -75,7 +76,7 @@ int main(int argc,char *argv[]) { if(argc>2) { - Service service1; + Service service1[64]; char *str_entry[64]={'\0'}; int i=0; @@ -177,7 +178,7 @@ int checkState(char *ServiceName,char *result) printf("\n\nresult systemdUnitCall: %s\n",result); for(i=0;i<(sizeof(error_strings)/sizeof(error_strings[0]));i++) { - printf("%s %ld\n",error_strings[i],sizeof(error_strings)/sizeof(error_strings[0])); + //printf("%s %ld\n",error_strings[i],sizeof(error_strings)/sizeof(error_strings[0])); if(strcmp(result,error_strings[i])==0) { gotify_message("https://5ccppi.org:4433",ServiceName,"is not running"); @@ -198,7 +199,8 @@ int gotify_message(char *url,char *title,char *message) CURL *curl; CURLcode res; char post_buffer[128]; - char url_buffer[128]; + char url_buffer[128]; + long response_code; curl = curl_easy_init(); @@ -224,7 +226,7 @@ int gotify_message(char *url,char *title,char *message) ret = snprintf(post_buffer,sizeof(post_buffer),"title=%s&message=%s&priority=6",title,message); if(ret < sizeof(post_buffer)) { - printf("%s %d",post_buffer,ret); + printf("%s %d\n",post_buffer,ret); if(curl) { @@ -237,6 +239,8 @@ int gotify_message(char *url,char *title,char *message) { fprintf(stderr,"curl_easy_perform failed: %s\n",curl_easy_strerror(res)); } + curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&response_code); + printf("Server returned:%ld\n",response_code); curl_easy_cleanup(curl); } }