首页 > 其他分享 >glib GVariant 2

glib GVariant 2

时间:2023-04-06 20:55:32浏览次数:38  
标签:glib sessions variant session child GVariant include

#include <stdio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>

 
 
int 
main (void) 
{ 
    g_autoptr(GVariant) sessions = NULL; 

    sessions = g_variant_new_parsed ("[('2', uint32 1000, 'nidhoegger', 'seat0', objectpath '/org/freedesktop/login1/session/_32'), ('6', 1001, 'test', 'seat0', '/org/freedesktop/login1/session/_36'), ('c2', 111, 'lightdm', 'seat0', '/org/freedesktop/login1/session/c2')]"); 

    for (gsize i = 0; i < g_variant_n_children (sessions); i++) 
    { 
     g_autoptr(GVariant) child = g_variant_get_child_value (sessions, i); 
     g_message ("Child %" G_GSIZE_FORMAT ": %s", i, g_variant_get_type_string (child)); 

     guint32 uid; 
     const gchar *id, *user, *seat, *session_path; 

     g_variant_get (child, "(&su&s&s&o)", &id, &uid, &user, &seat, &session_path); 

     g_message ("%s, %u, %s, %s, %s", id, uid, user, seat, session_path); 
    } 

    return 0; 
} 
    

  

标签:glib,sessions,variant,session,child,GVariant,include
From: https://www.cnblogs.com/hshy/p/17294127.html

相关文章

  • glib gmacros.h
    /*GLIB-LibraryofusefulroutinesforCprogramming*Copyright(C)1995-1997PeterMattis,SpencerKimballandJoshMacDonald**Thislibraryisfreesoftware;youcanredistributeitand/or*modifyitunderthetermsoftheGNULesserGeneral......
  • glib g_hash_table_lookup g_hash_table_remove
    这里会简单的说明一下例子中用到的api接口。GHashTable *g_hash_table_new(GHashFunc hash_func, GEqualFunc key_equal_func);功能:生成hash表。参数:hash_func创建hash值得函数,它为key创建一个hash值。这里可以用glib函数库里自带的g_str_hash。也可以用自......
  • glib g_hash_table_new g_hash_table_new_full
    这里会简单的说明一下例子中用到的api接口。GHashTable *g_hash_table_new(GHashFunc hash_func, GEqualFunc key_equal_func);功能:生成hash表。参数:hash_func创建hash值得函数,它为key创建一个hash值。这里可以用glib函数库里自带的g_str_hash。也可以用自......
  • glib 哈希调用
    glib:linux编译调用gccmain.c`pkg-config--libs--cflagsglib-2.0`-omain#include<stdio.h>#include<glib.h>#include<stdlib.h>#include<string.h>typedefstruct_Node{charkey[32];charvalue[32];}Node;staticvo......
  • glib GVariant
    GVariant*g_variant_new_boolean(gbooleanvalue){ gucharv=value; returng_variant_new_from_trusted(G_VARIANT_TYPE_BOOLEAN,&v,1);} typedefstruct_GVariantTypeGVariantType;/** *G_VARIANT_TYPE_BOOLEAN: * *Thetypeofavalueth......
  • Ubuntu切换glibc版本
    Ubuntu切换glibc版本glibc是GNU发布的C语言标准库,不同版本的glibc中函数实现不同,可能导致程序运行结果不同。这里介绍如何切换不同版本的glibc来运行程序首先,要安装patchelf,这是给elf文件打补丁(修改elf文件属性,包括使用的glibc版本)的工具gitclonehttps://github.com/NixOS/pa......
  • 详细介绍Glib 主事件循环轻度分析与编程应用
    glib是一个跨平台、用C语言编写的若干底层库的集合。编写案例最好能够结合glib源码,方便随时查看相关函数定义。glib实现了完整的事件循环分发机制。有一个主循环负责处理各种事件。事件通过事件源描述,常见的事件源文件描述符(文件、管道和socket)超时idle事件当然,也可以自......
  • glib库源码分析1
    /***g_main_loop_quit:*@loop:a#GMainLoop**Stopsa#GMainLoopfromrunning.Anycallstog_main_loop_run()*fortheloopwillreturn.**Notethatsourcesthathavealreadybeendispatchedwhen*g_main_loop_quit()iscalledwillstillbeexec......
  • Spring AOP、AspectJ、CGLIB
     静态代理和动态代理AOP代理则可分为静态代理和动态代理两大类,其中静态代理是指使用AOP框架提供的命令进行编译,从而在编译阶段就可生成AOP代理类,因此也称为编译时......
  • Spring Boot 中的 AOP,到底是 JDK 动态代理还是 Cglib 动态代理?
    好啦,开始今天的正文。大家都知道,AOP底层是动态代理,而Java中的动态代理有两种实现方式:基于JDK的动态代理基于Cglib的动态代理这两者最大的区别在于基于JDK的......