diff --git a/config b/config index 78c8236..9962c59 100644 --- a/config +++ b/config @@ -1,3 +1,5 @@ +/org/freedesktop/systemd1/unit/NetworkManager_2dwait_2donline_2eservice +/org/freedesktop/systemd1/unit/NetworkManager_2eservice /systemd/blalbla/1 /systemd/blalbla/2 /systemd/blalbla/3 diff --git a/config.c b/config.c index 581213b..b6a0729 100644 --- a/config.c +++ b/config.c @@ -9,7 +9,7 @@ int loadConfig(char *file, char **str_entry,int size) int i=0; bool terminate=false; FILE *f_config; - char temp_str[64]; + char temp_str[256]; printf("\nopening config file\n"); f_config = fopen("config","r"); @@ -19,8 +19,10 @@ int loadConfig(char *file, char **str_entry,int size) { printf("for loop:%d\n",i); printf("str:%s\n",str_entry[i]); - if(fgets(temp_str,64,f_config)!=NULL) + if(fgets(temp_str,256,f_config)!=NULL) { + temp_str[strcspn(temp_str,"\n")]=0; + str_entry[i]=strdup(temp_str); printf("module path:%s",str_entry[i]); } diff --git a/main.c b/main.c index cf1d304..0036ac4 100644 --- a/main.c +++ b/main.c @@ -83,6 +83,7 @@ int main(int argc,char *argv[]) for(i=0;str_entry[i];i++) { printf("entry in config:%s\n",str_entry[i]); + GetSendStatus(connection,str_entry[i]); } } else @@ -158,7 +159,14 @@ int GetSendStatus(DBusConnection *connection,char *objectpath) { char *result=0; int ret = systemdUnitCall(connection,objectpath,"Get","SubState",&result); - checkState(objectpath,result); + if(ret == 0) + { + checkState(objectpath,result); + } + else + { + fprintf(stderr,"could not call systemdunit"); + } return ret; } @@ -409,6 +417,7 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p if(ret_msg == NULL) { fprintf(stderr,"error ond receiving message from peer\n"); + return 1; } else { @@ -474,7 +483,7 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p if(dbus_error_is_set(&error)) { fprintf(stderr,"%s\n",error.message); - return -1; + return 1; } return 0; }