mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-31 18:33:11 +00:00
16121a88a7
Converting from virObject to GObject is reasonably straightforward, as illustrated by this patch for virIdentity In the header file - Remove typedef struct _virIdentity virIdentity - Add #define VIR_TYPE_IDENTITY virIdentity_get_type () G_DECLARE_FINAL_TYPE (virIdentity, vir_identity, VIR, IDENTITY, GObject); Which provides the typedef we just removed, and class declaration boilerplate and various other constants/macros. In the source file - Change 'virObject parent' to 'GObject parent' in the struct - Remove the virClass variable and its initializing call - Add G_DEFINE_TYPE(virIdentity, vir_identity, G_TYPE_OBJECT) which declares the instance & class constructor functions - Add an impl of the instance & class constructors wiring up the finalize method to point to our dispose impl In all files - Replace VIR_AUTOUNREF(virIdentityPtr) with g_autoptr(virIdentity) - Replace virObjectRef/Unref with g_object_ref/unref. Note the latter functions do *NOT* accept a NULL object where as libvirt's do. If you replace g_object_unref with g_clear_object it is NULL safe, but also clears the pointer. Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
85 lines
3.2 KiB
C
85 lines
3.2 KiB
C
/*
|
|
* viridentity.h: helper APIs for managing user identities
|
|
*
|
|
* Copyright (C) 2012-2013 Red Hat, Inc.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; If not, see
|
|
* <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "internal.h"
|
|
#include <glib-object.h>
|
|
|
|
#define VIR_TYPE_IDENTITY vir_identity_get_type()
|
|
G_DECLARE_FINAL_TYPE(virIdentity, vir_identity, VIR, IDENTITY, GObject);
|
|
|
|
typedef virIdentity *virIdentityPtr;
|
|
|
|
virIdentityPtr virIdentityGetCurrent(void);
|
|
int virIdentitySetCurrent(virIdentityPtr ident);
|
|
|
|
virIdentityPtr virIdentityGetSystem(void);
|
|
|
|
virIdentityPtr virIdentityNew(void);
|
|
|
|
int virIdentityGetUserName(virIdentityPtr ident,
|
|
const char **username);
|
|
int virIdentityGetUNIXUserID(virIdentityPtr ident,
|
|
uid_t *uid);
|
|
int virIdentityGetGroupName(virIdentityPtr ident,
|
|
const char **groupname);
|
|
int virIdentityGetUNIXGroupID(virIdentityPtr ident,
|
|
gid_t *gid);
|
|
int virIdentityGetProcessID(virIdentityPtr ident,
|
|
pid_t *pid);
|
|
int virIdentityGetProcessTime(virIdentityPtr ident,
|
|
unsigned long long *timestamp);
|
|
int virIdentityGetSASLUserName(virIdentityPtr ident,
|
|
const char **username);
|
|
int virIdentityGetX509DName(virIdentityPtr ident,
|
|
const char **dname);
|
|
int virIdentityGetSELinuxContext(virIdentityPtr ident,
|
|
const char **context);
|
|
|
|
|
|
int virIdentitySetUserName(virIdentityPtr ident,
|
|
const char *username);
|
|
int virIdentitySetUNIXUserID(virIdentityPtr ident,
|
|
uid_t uid);
|
|
int virIdentitySetGroupName(virIdentityPtr ident,
|
|
const char *groupname);
|
|
int virIdentitySetUNIXGroupID(virIdentityPtr ident,
|
|
gid_t gid);
|
|
int virIdentitySetProcessID(virIdentityPtr ident,
|
|
pid_t pid);
|
|
int virIdentitySetProcessTime(virIdentityPtr ident,
|
|
unsigned long long timestamp);
|
|
int virIdentitySetSASLUserName(virIdentityPtr ident,
|
|
const char *username);
|
|
int virIdentitySetX509DName(virIdentityPtr ident,
|
|
const char *dname);
|
|
int virIdentitySetSELinuxContext(virIdentityPtr ident,
|
|
const char *context);
|
|
|
|
int virIdentitySetParameters(virIdentityPtr ident,
|
|
virTypedParameterPtr params,
|
|
int nparams);
|
|
|
|
int virIdentityGetParameters(virIdentityPtr ident,
|
|
virTypedParameterPtr *params,
|
|
int *nparams);
|