c - PolicyKit-gnome 的以下部分是什么意思?

标签 c

我正在查看 PolicyKit 的源代码在 gnome 中打包,我在 ./src/polkitgnomeauthenticationdialog.c 的第 568 行遇到了一些代码,我需要一些帮助

if (g_strv_length (dialog->priv->users) > 1)

它是条件语句的一部分,用于确定在要求用户通过输入密码进行身份验证时向用户显示哪个对话框。我需要帮助的是 dialog->priv-.users 的含义。我知道它是一个以 NULL 结尾的字符串,因为它是 g_strv_lngth 操作的对象,而且我认为它与特权用户有关,但语法让我有点失望,特别是 -> 。对此行的快速解释将不胜感激。

作为引用,完整的条件语句是

label = gtk_label_new (NULL);
  if (g_strv_length (dialog->priv->users) > 1)
    {
          gtk_label_set_markup (GTK_LABEL (label),
                                _("An application is attempting to perform an action that requires privileges. "
                                  "Authentication as one of the users below is required to perform this action."));
    }
  else
    {
      if (strcmp (g_get_user_name (), dialog->priv->users[0]) == 0)
        {
          gtk_label_set_markup (GTK_LABEL (label),
                                _("An application is attempting to perform an action that requires privileges. "
                                  "Authentication is required to perform this action."));
        }
      else
        {
          gtk_label_set_markup (GTK_LABEL (label),
                                _("An application is attempting to perform an action that requires privileges. "
                                  "Authentication as the super user is required to perform this action."));
        }
    }

最佳答案

在 C 中,

ptr->memb

完全等同于

(*ptr).memb

展开,

dialog->priv->users

相同
(*(*dialog).priv).users

dialog 的类型为 PolkitGnomeAuthenticationDialog * 并且 dialog->priv 的类型为 PolkitGnomeAuthenticationDialogPrivate *:它们都是指向结构的指针,因此使用 ->

关于c - PolicyKit-gnome 的以下部分是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4809499/

相关文章:

c - 在嵌入式 ARM 系统 (STM32 F4) 上使用 protobuf-c 0.15

c - 更快地找到倍数的方法

c - 1+1/2+1/3+1/4+......+1/n=log n 的和何时等于 n,即 1+1/2+ 1/3+1/4+……+1/n=n

使用 C 在 Connect N 中检查对角线获胜者

c - 不知道为什么我收到 Glibc 检测到错误

c++ - 求图形显示/C++中(头文件)文件依赖关系的工具

c - 包含字符串的数组

c++ - 树莓派uart波特率锁定在9600

c - 用C读取输入设备

c++ - gperf 可以接受宏定义的关键字吗?