* 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, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Authors: Christian Kellner <gicmo@gnome.org>
* Samuel Cormier-Iijima <sciyoshi@gmail.com>
#include "gunixsocketaddress.h"
#include "glibintl.h"
-#include "gnetworkingprivate.h"
+#include "gnetworking.h"
-#include "gioalias.h"
/**
* SECTION:gunixsocketaddress
* @short_description: UNIX GSocketAddress
+ * @include: gio/gunixsocketaddress.h
*
- * Support for UNIX-domain (aka local) sockets.
+ * Support for UNIX-domain (also known as local) sockets.
*
- * Unix domain sockets are generally visible in the filesystem.
+ * UNIX domain sockets are generally visible in the filesystem.
* However, some systems support abstract socket names which are not
* visible in the filesystem and not affected by the filesystem
* permissions, visibility, etc. Currently this is only supported
* under Linux. If you attempt to use abstract sockets on other
* systems, function calls may return %G_IO_ERROR_NOT_SUPPORTED
- * errors. You can use
- * g_unix_socket_address_abstract_names_supported() to see if abstract
- * names are supported.
+ * errors. You can use g_unix_socket_address_abstract_names_supported()
+ * to see if abstract names are supported.
+ *
+ * Note that `<gio/gunixsocketaddress.h>` belongs to the UNIX-specific GIO
+ * interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config file
+ * when using it.
*/
/**
* GUnixSocketAddress:
*
* A UNIX-domain (local) socket address, corresponding to a
- * <type>struct sockaddr_un</type>.
+ * struct sockaddr_un.
*/
-G_DEFINE_TYPE (GUnixSocketAddress, g_unix_socket_address, G_TYPE_SOCKET_ADDRESS);
enum
{
GUnixSocketAddressType address_type;
};
+G_DEFINE_TYPE_WITH_PRIVATE (GUnixSocketAddress, g_unix_socket_address, G_TYPE_SOCKET_ADDRESS)
+
static void
g_unix_socket_address_set_property (GObject *object,
guint prop_id,
break;
case PROP_ABSTRACT:
- /* If the caller already set PROP_ADDRESS_TYPE, don't let the
- * default value of PROP_ABSTRACT overwrite it.
- */
- if (address->priv->address_type != G_UNIX_SOCKET_ADDRESS_INVALID)
- return;
-
+ /* Only set it if it's not the default... */
if (g_value_get_boolean (value))
- address->priv->address_type = G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED;
- else
- address->priv->address_type = G_UNIX_SOCKET_ADDRESS_PATH;
+ address->priv->address_type = G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED;
break;
case PROP_ADDRESS_TYPE:
- /* If the caller already set PROP_ABSTRACT, don't let the
- * default value of PROP_ADDRESS_TYPE overwrite it.
- */
- if (address->priv->address_type != G_UNIX_SOCKET_ADDRESS_INVALID)
- return;
-
- address->priv->address_type = g_value_get_enum (value);
+ /* Only set it if it's not the default... */
+ if (g_value_get_enum (value) != G_UNIX_SOCKET_ADDRESS_PATH)
+ address->priv->address_type = g_value_get_enum (value);
break;
default:
if (!g_unix_socket_address_abstract_names_supported ())
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Abstract unix domain socket addresses not supported on this system"));
+ _("Abstract UNIX domain socket addresses not supported on this system"));
return FALSE;
}
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GSocketAddressClass *gsocketaddress_class = G_SOCKET_ADDRESS_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GUnixSocketAddressPrivate));
-
gobject_class->set_property = g_unix_socket_address_set_property;
gobject_class->get_property = g_unix_socket_address_get_property;
static void
g_unix_socket_address_init (GUnixSocketAddress *address)
{
- address->priv = G_TYPE_INSTANCE_GET_PRIVATE (address,
- G_TYPE_UNIX_SOCKET_ADDRESS,
- GUnixSocketAddressPrivate);
+ address->priv = g_unix_socket_address_get_instance_private (address);
memset (address->priv->path, 0, sizeof (address->priv->path));
address->priv->path_len = -1;
- address->priv->address_type = G_UNIX_SOCKET_ADDRESS_INVALID;
+ address->priv->address_type = G_UNIX_SOCKET_ADDRESS_PATH;
}
/**
/**
* g_unix_socket_address_new_abstract:
- * @path: the abstract name
+ * @path: (array length=path_len) (element-type gchar): the abstract name
* @path_len: the length of @path, or -1
*
* Creates a new %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED
/**
* g_unix_socket_address_new_with_type:
- * @path: the name
+ * @path: (array length=path_len) (element-type gchar): the name
* @path_len: the length of @path, or -1
* @type: a #GUnixSocketAddressType
*
* zero-padded buffer will be considered the name. (As above, if
* @path_len is -1, then @path is assumed to be NUL-terminated.) In
* this case, g_socket_address_get_native_size() will always return
- * the full size of a <literal>struct sockaddr_un</literal>, although
+ * the full size of a `struct sockaddr_un`, although
* g_unix_socket_address_get_path_len() will still return just the
* length of @path.
*
/**
* g_unix_socket_address_abstract_names_supported:
*
- * Checks if abstract unix domain socket names are supported.
+ * Checks if abstract UNIX domain socket names are supported.
*
* Returns: %TRUE if supported, %FALSE otherwise
*
return FALSE;
#endif
}
-
-#define __G_UNIX_SOCKET_ADDRESS_C__
-#include "gioaliasdef.c"