2011-01-26 40 views
1

我期待通過爲PolicyKit包在GNOME的源代碼,我已經遇到了一些代碼上的./src/polkitgnomeauthenticationdialog.c,我需要與PolicyKit-gnome的以下部分是什麼意思?

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

這是一個條件語句的一部分有點幫助568線這將決定當用戶通過輸入密碼要求他們進行身份驗證時向用戶顯示哪個對話。我需要幫助的是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.")); 
     } 
    } 

回答

3

在C中,

ptr->memb 

是完全等效於

(*ptr).memb 

擴大,

dialog->priv->users 

相同

(*(*dialog).priv).users 

dialog已經鍵入PolkitGnomeAuthenticationDialog *dialog->priv已鍵入PolkitGnomeAuthenticationDialogPrivate *:他們都指向結構的指針,因此,使用的->

1

A' - >'用於將指針取消引用到結構,在這種情況下,它意味着「取消引用指向結構對話框的指針,然後將指針取消引用到結構特權」,從而獲得結構成員用戶的值'

1

通常,在訪問指向結構的指針的成員數據字段時,您會在C中看到->。它是「取消引用指針和上網本領域的」速記符號,因此,例如,如果我有:

struct Data* d 
(*d).dataitem; 
d->dataitem; 

最後兩個項目是等價的。

您可以找到所述對象的定義here