clean up spacing, clean up new lines
This commit is contained in:
parent
142a850a5b
commit
f22ae88b97
6
config.c
6
config.c
@ -39,13 +39,10 @@ int loadConfig(char *str_file, char **str_entry,char **host,int *intervall,int s
|
||||
}
|
||||
*host = strdup(ptr_host);
|
||||
printf("my host is:%s\n",*host);
|
||||
}else{
|
||||
fprintf(stderr,"keyword Hostname not found in config");
|
||||
}
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if(strcmp(temp_str,"[Services]")==0)
|
||||
@ -91,13 +88,10 @@ int loadConfig(char *str_file, char **str_entry,char **host,int *intervall,int s
|
||||
}
|
||||
*intervall = atoi(ptr_intervall);
|
||||
printf("intervall:%d\n",*intervall);
|
||||
}else{
|
||||
fprintf(stderr,"keyword Intervall not found in config\n");
|
||||
}
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
ret = fgets(temp_str,256,f_config);
|
||||
|
51
main.c
51
main.c
@ -231,8 +231,7 @@ int ServiceGetSendStatus(DBusConnection *connection,Service *service)
|
||||
if(ret == 0)
|
||||
{
|
||||
checkState(service->name,result,service);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
fprintf(stderr,"could not call systemdunit\n");
|
||||
}
|
||||
return ret;
|
||||
@ -242,7 +241,7 @@ int checkState(char *ServiceName,char *result,Service *service)
|
||||
{
|
||||
int i=0;
|
||||
char *error_strings[]={"dead","inactive","exited"};
|
||||
printf("\n\nresult systemdUnitCall: %s\n",result);
|
||||
printf("result 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]));
|
||||
@ -259,7 +258,7 @@ int checkState(char *ServiceName,char *result,Service *service)
|
||||
gotify_message(service->host,ServiceName,"Running again, after crash");
|
||||
}
|
||||
service->alerted=false;
|
||||
printf("!!service seems okay!!\n");
|
||||
printf("service seems okay!!\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -296,12 +295,10 @@ 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\n",post_buffer,ret);
|
||||
|
||||
if(curl)
|
||||
{
|
||||
curl_easy_setopt(curl,CURLOPT_URL,url_buffer);
|
||||
@ -352,7 +349,7 @@ int systemdCall(DBusConnection *connection,char *method,char *param)
|
||||
msg = dbus_message_new_method_call("org.freedesktop.systemd1","/org/freedesktop/systemd1","org.freedesktop.systemd1.Manager",method);
|
||||
if(NULL == msg)
|
||||
{
|
||||
fprintf(stderr,"Message null, no message created");
|
||||
fprintf(stderr,"Message null, no message created\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -366,12 +363,9 @@ int systemdCall(DBusConnection *connection,char *method,char *param)
|
||||
dbus_message_iter_init_append(msg,&iter);
|
||||
if(!dbus_message_iter_append_basic(&iter,DBUS_TYPE_STRING,¶m))
|
||||
{
|
||||
fprintf(stderr,"Error appending");
|
||||
fprintf(stderr,"Error appending\n");
|
||||
return -1;
|
||||
}
|
||||
else{
|
||||
printf("message appended\n");
|
||||
}
|
||||
}
|
||||
|
||||
ret_msg = dbus_connection_send_with_reply_and_block(connection,msg,DBUS_TIMEOUT_INFINITE,&error);
|
||||
@ -409,15 +403,10 @@ int systemdCall(DBusConnection *connection,char *method,char *param)
|
||||
ret2 = dbus_message_iter_get_arg_type(&array_iter);
|
||||
while(ret2 != DBUS_TYPE_INVALID)
|
||||
{
|
||||
|
||||
//printf("type:%c\n",ret2);
|
||||
|
||||
//dbus_message_iter_get_basic(&array_iter,&reply_msg);
|
||||
//printf("Received message:%s\n",reply_msg);
|
||||
ret2 = dbus_message_iter_get_arg_type(&array_iter);
|
||||
|
||||
DBusMessageIter sub_iter;
|
||||
int ret3;
|
||||
|
||||
ret2 = dbus_message_iter_get_arg_type(&array_iter);
|
||||
dbus_message_iter_recurse(&array_iter,&sub_iter);
|
||||
ret3 = dbus_message_iter_get_arg_type(&sub_iter);
|
||||
while(ret3 != DBUS_TYPE_INVALID)
|
||||
@ -431,18 +420,12 @@ int systemdCall(DBusConnection *connection,char *method,char *param)
|
||||
}
|
||||
ret3=dbus_message_iter_next(&sub_iter);
|
||||
}
|
||||
|
||||
|
||||
ret2=dbus_message_iter_next(&array_iter);
|
||||
i2++;
|
||||
//printf("i2:%d\n",i2);
|
||||
}
|
||||
}
|
||||
//printf("iter:%c\n",ret1);
|
||||
ret1=dbus_message_iter_next(&reply_iter);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(dbus_error_is_set(&error))
|
||||
{
|
||||
@ -475,10 +458,6 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p
|
||||
fprintf(stderr,"Message null, no message created\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("message created!\n");
|
||||
}
|
||||
|
||||
if(param2 != NULL)
|
||||
{
|
||||
@ -488,17 +467,11 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p
|
||||
fprintf(stderr,"Error appending\n");
|
||||
return -1;
|
||||
}
|
||||
else{
|
||||
printf("message appended\n");
|
||||
}
|
||||
if(!dbus_message_iter_append_basic(&iter,DBUS_TYPE_STRING,¶m))
|
||||
{
|
||||
fprintf(stderr,"Error appending\n");
|
||||
return -1;
|
||||
}
|
||||
else{
|
||||
printf("message appended\n");
|
||||
}
|
||||
}
|
||||
|
||||
ret_msg = dbus_connection_send_with_reply_and_block(connection,msg,DBUS_TIMEOUT_INFINITE,&error);
|
||||
@ -512,7 +485,6 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p
|
||||
DBusMessageIter reply_iter;
|
||||
dbus_message_iter_init(ret_msg,&reply_iter);
|
||||
ret1=dbus_message_iter_get_arg_type(&reply_iter);
|
||||
printf("ret1 type:%c\n",ret1);
|
||||
while(ret1 != DBUS_TYPE_INVALID)
|
||||
{
|
||||
if(ret1 == DBUS_TYPE_OBJECT_PATH)
|
||||
@ -532,19 +504,18 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p
|
||||
{
|
||||
dbus_message_iter_recurse(&reply_iter,&variant_iter);
|
||||
char *type = dbus_message_iter_get_signature(&variant_iter);
|
||||
printf("str_val:%s\n",type);
|
||||
//printf("str_val:%s\n",type);
|
||||
if(type[0] == DBUS_TYPE_STRING)
|
||||
{
|
||||
printf("[func]&result:%p , result:%p",&result,result);
|
||||
//printf("[func]&result:%p , result:%p\n",&result,result);
|
||||
dbus_message_iter_get_basic(&variant_iter,result);
|
||||
printf("\n--\n*result:%s",*result);
|
||||
//printf("*result:%s\n",*result);
|
||||
}
|
||||
}
|
||||
if(ret1 == DBUS_TYPE_ARRAY)
|
||||
{
|
||||
int element_count = dbus_message_iter_get_element_count(&reply_iter);
|
||||
printf("Array:Elem count %d\n",element_count);
|
||||
//ret2 = dbus_message_iter_get_element_type(&reply_iter);
|
||||
dbus_message_iter_recurse(&reply_iter,&array_iter);
|
||||
ret2 = dbus_message_iter_get_arg_type(&array_iter);
|
||||
while(ret2 != DBUS_TYPE_INVALID)
|
||||
@ -558,7 +529,7 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p
|
||||
if(ret3 == DBUS_TYPE_STRING)
|
||||
{
|
||||
dbus_message_iter_get_basic(&sub_iter,&reply_msg);
|
||||
printf("%s\n",reply_msg);
|
||||
//printf("%s\n",reply_msg);
|
||||
}
|
||||
ret3=dbus_message_iter_next(&sub_iter);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user