batch checking from config
This commit is contained in:
parent
632efc640d
commit
ffe88a7133
2
config
2
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
|
||||
|
6
config.c
6
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]);
|
||||
}
|
||||
|
11
main.c
11
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);
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user