works
This commit is contained in:
parent
8c4815cd7e
commit
5872d5a21a
18
main.c
18
main.c
@ -21,7 +21,7 @@ int main(void)
|
||||
dbus_bool_t allow_user=0;
|
||||
DBusConnection *connection=NULL;
|
||||
DBusError error;
|
||||
char *result;
|
||||
char *result=NULL;
|
||||
|
||||
dbus_error_init(&error);
|
||||
connection = dbus_bus_get(DBUS_BUS_SESSION,&error);//DBUS_BUS_SYSTEM
|
||||
@ -68,10 +68,11 @@ int main(void)
|
||||
//org/freedesktop/systemd1
|
||||
//systemdCall(connection,"GetUnit","timers.target");
|
||||
//systemdCall(connection,"ListUnits",NULL);
|
||||
|
||||
printf("&result:%p",&result);
|
||||
systemdUnitCall(connection,"/org/freedesktop/systemd1/unit/timers_2etarget","Get","SubState",&result);
|
||||
printf("\n\nresult systemdUnitCall: %s\n",result);
|
||||
systemdUnitCall(connection,"/org/freedesktop/systemd1/unit/sysinit_2etarget","Get","SubState",&result);
|
||||
printf("result systemdUnitCall: %s\n",result);
|
||||
printf("\n\nresult systemdUnitCall: %s\n",result);
|
||||
gotify_message("https://5ccppi.org:4433/message?token=ApPFbwayM5zDXf3","anothertitle","anothermessage");
|
||||
|
||||
return 0;
|
||||
@ -239,7 +240,6 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p
|
||||
DBusMessageIter array_iter;
|
||||
DBusMessageIter variant_iter;
|
||||
|
||||
result=NULL;
|
||||
char *reply_msg=NULL;
|
||||
int ret1,ret2;
|
||||
char *param2 = "org.freedesktop.systemd1.Unit";
|
||||
@ -301,6 +301,7 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p
|
||||
if(ret1 == DBUS_TYPE_STRING)
|
||||
{
|
||||
printf("succesfull received message\narg type %c\n",ret1);
|
||||
printf("[func]reply_msg:%p , &reply_msg:%p , *reply_msg:%p\n", reply_msg,&reply_msg,*reply_msg);
|
||||
dbus_message_iter_get_basic(&reply_iter,&reply_msg);
|
||||
printf("Received message:%s\n",reply_msg);
|
||||
}
|
||||
@ -311,12 +312,9 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p
|
||||
printf("str_val:%s\n",type);
|
||||
if(type[0] == DBUS_TYPE_STRING)
|
||||
{
|
||||
// result = malloc(sizeof(char)*64);
|
||||
dbus_message_iter_get_basic(&variant_iter,*result);
|
||||
// printf("result inside function:%s\n",*result);
|
||||
printf("[func]&result:%p , result:%p",&result,result);
|
||||
dbus_message_iter_get_basic(&variant_iter,result);
|
||||
}
|
||||
//dbus_message_iter_get_basic(&reply_iter,&value);
|
||||
|
||||
}
|
||||
if(ret1 == DBUS_TYPE_ARRAY)
|
||||
{
|
||||
@ -336,7 +334,6 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p
|
||||
while(ret3 != DBUS_TYPE_INVALID)
|
||||
{
|
||||
ret3 = dbus_message_iter_get_arg_type(&sub_iter);
|
||||
//printf("arr_sub_iter:%c\n",ret3);
|
||||
if(ret3 == DBUS_TYPE_STRING)
|
||||
{
|
||||
dbus_message_iter_get_basic(&sub_iter,&reply_msg);
|
||||
@ -345,7 +342,6 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p
|
||||
ret3=dbus_message_iter_next(&sub_iter);
|
||||
}
|
||||
|
||||
|
||||
ret2=dbus_message_iter_next(&array_iter);
|
||||
i2++;
|
||||
//printf("i2:%d\n",i2);
|
||||
|
Loading…
Reference in New Issue
Block a user