我正在查看gnome中PolicyKit包的源代码,在./src/polkitgnomeauthenticationdialog.c
的第568行遇到了一些需要帮助的代码
if (g_strv_length (dialog->priv->users) > 1)
这是条件语句的一部分,当要求用户通过输入密码进行身份验证时,该语句将确定向用户显示哪个对话框。我需要帮助的是
dialog->priv-.users
的意思。我知道它是一个以空结尾的字符串,因为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/