Commit 7c9c6fec authored by Liang Guo's avatar Liang Guo

New upstream version 0.17.0

parent 3aedc0aa
......@@ -26,7 +26,7 @@ spice-vdagent-0.12.1
spice-vdagent-0.12.0
--------------------
* Full multi-monitor and arbritary resolution support, this requires a new
* Full multi-monitor and arbritary resolution support, this requires a new
enough xorg-x11-drv-qxl driver, as well as a new enough host
* systemd service support, using systemd hardware acivation
* Use syslog for logging, rather then logging to private log files
......
......@@ -4,9 +4,14 @@ NULL =
bin_PROGRAMS = src/spice-vdagent
sbin_PROGRAMS = src/spice-vdagentd
src_spice_vdagent_CFLAGS = $(X_CFLAGS) $(SPICE_CFLAGS) $(GLIB2_CFLAGS)
src_spice_vdagent_LDADD = $(X_LIBS) $(SPICE_LIBS) $(GLIB2_LIBS)
src_spice_vdagent_SOURCES = src/vdagent.c src/vdagent-x11.c src/vdagent-x11-randr.c src/vdagent-file-xfers.c src/udscs.c
src_spice_vdagent_CFLAGS = $(X_CFLAGS) $(SPICE_CFLAGS) $(GLIB2_CFLAGS) $(ALSA_CFLAGS) -DUDSCS_NO_SERVER
src_spice_vdagent_LDADD = $(X_LIBS) $(SPICE_LIBS) $(GLIB2_LIBS) $(ALSA_LIBS)
src_spice_vdagent_SOURCES = src/vdagent.c \
src/vdagent-x11.c \
src/vdagent-x11-randr.c \
src/vdagent-file-xfers.c \
src/vdagent-audio.c \
src/udscs.c
src_spice_vdagentd_CFLAGS = $(DBUS_CFLAGS) $(LIBSYSTEMD_LOGIN_CFLAGS) \
$(PCIACCESS_CFLAGS) $(SPICE_CFLAGS) $(GLIB2_CFLAGS) $(PIE_CFLAGS)
......@@ -27,9 +32,9 @@ src_spice_vdagentd_SOURCES += src/dummy-session-info.c
endif
endif
noinst_HEADERS = src/glib-compat.h \
src/session-info.h \
noinst_HEADERS = src/session-info.h \
src/udscs.h \
src/vdagent-audio.h \
src/vdagent-file-xfers.h \
src/vdagent-virtio-port.h \
src/vdagent-x11.h \
......@@ -42,15 +47,15 @@ noinst_HEADERS = src/glib-compat.h \
xdgautostartdir = $(sysconfdir)/xdg/autostart
xdgautostart_DATA = $(top_srcdir)/data/spice-vdagent.desktop
gdmautostartdir = $(datadir)/gdm/autostart/LoginWindow
gdmautostartdir = $(datadir)/gdm/greeter/autostart
gdmautostart_DATA = $(top_srcdir)/data/spice-vdagent.desktop
gdmautostart2dir = $(datadir)/gdm/autostart/LoginWindow
gdmautostart2_DATA = $(top_srcdir)/data/spice-vdagent.desktop
install-data-local:
$(mkdir_p) $(DESTDIR)$(localstatedir)/run/spice-vdagentd
rsyslogdir = $(sysconfdir)/rsyslog.d
rsyslog_DATA = $(top_srcdir)/data/rsyslog.d/spice-vdagentd.conf
if INIT_SCRIPT_RED_HAT
initdir = $(sysconfdir)/rc.d/init.d
init_SCRIPTS = $(top_srcdir)/data/spice-vdagentd
......@@ -74,9 +79,9 @@ manpage_DATA = data/spice-vdagent.1 \
data/spice-vdagentd.1
EXTRA_DIST = \
NEWS \
README.RHEL-5 \
data/70-spice-vdagentd.rules \
data/rsyslog.d/spice-vdagentd.conf \
data/spice-vdagent.desktop \
data/spice-vdagentd \
data/spice-vdagentd.service \
......
This diff is collapsed.
Overview of changes in SPICE vdagent 0.17.0
===========================================
- Denies file-transfer in locked sessions
* systems under systemd (rhbz#1323623)
* systems under console-kit (rhbz#1323630)
- Denies file-transfer in login screen
* systems under systemd (rhbz#1328761)
* systems under console-kit (rhbz#1323640)
- Bump glib version to 2.28
- Set exit code to 1 instead of 0 when virtio device cannot be opened
- Fix double-free on uinput->screen_info (rhbz#1262635)
- Code improvement over unix domain client server support (udcs)
- Fix build compatiblity with different libsystemd versions (fdo#94209)
Overview of changes in SPICE vdagent 0.16.0
===========================================
- Add audio volume synchronization support
- Add support for maximum clipboard size
- Add support for more clipboard targets (STRING and TIMESTAMP)
- Improve handling of transfers of multiple files
- Fix transfer of >2GB files on 32 bit systems
- XSpice improvements
- Various bug fixes related to resolution changes
This diff is collapsed.
......@@ -3,7 +3,7 @@
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
......
This diff is collapsed.
AC_PREREQ(2.59)
AC_INIT([spice-vdagent], [0.15.0])
AC_INIT([spice-vdagent], [0.17.0])
AC_CONFIG_SRCDIR([configure.ac])
AM_CONFIG_HEADER([src/config.h])
......@@ -10,6 +10,7 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AC_PROG_CC
AM_PROG_CC_C_O
AC_HEADER_STDC
AC_SYS_LARGEFILE
AC_PROG_INSTALL
AC_PROG_LN_S
AC_DEFINE(_GNU_SOURCE, [1], [Enable GNU extensions])
......@@ -76,15 +77,24 @@ AC_ARG_ENABLE([static-uinput],
[enable_static_uinput="$enableval"],
[enable_static_uinput="no"])
PKG_CHECK_MODULES([GLIB2], [glib-2.0 >= 2.12])
PKG_CHECK_MODULES([GLIB2], [glib-2.0 >= 2.28])
PKG_CHECK_MODULES(X, [xfixes xrandr >= 1.3 xinerama x11])
PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.12.5])
PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.12.8])
PKG_CHECK_MODULES(ALSA, [alsa >= 1.0.22])
PKG_CHECK_MODULES([DBUS], [dbus-1])
if test "$with_session_info" = "auto" || test "$with_session_info" = "systemd"; then
PKG_CHECK_MODULES([LIBSYSTEMD_LOGIN],
[libsystemd-login >= 42],
[libsystemd >= 209],
[have_libsystemd_login="yes"],
[have_libsystemd_login="no"])
if test "$have_libsystemd_login" = "no"; then
# for backward compatibility with older systemd versions
PKG_CHECK_MODULES([LIBSYSTEMD_LOGIN],
[libsystemd-login >= 42],
[have_libsystemd_login="yes"],
[have_libsystemd_login="no"])
fi
if test x"$have_libsystemd_login" = "xno" && test "$with_session_info" = "systemd"; then
AC_MSG_ERROR([libsystemd-login support explicitly requested, but some required packages are not available])
fi
......@@ -98,19 +108,9 @@ fi
AM_CONDITIONAL(HAVE_LIBSYSTEMD_LOGIN, test x"$have_libsystemd_login" = "xyes")
if test "$with_session_info" = "auto" || test "$with_session_info" = "console-kit"; then
PKG_CHECK_MODULES([DBUS],
[dbus-1],
[have_console_kit="yes"],
[have_console_kit="no"])
if test x"$have_console_kit" = "xno" && test "$with_session_info" = "console-kit"; then
AC_MSG_ERROR([console-kit support explicitly requested, but some required packages are not available])
fi
if test x"$have_console_kit" = "xyes"; then
AC_DEFINE([HAVE_CONSOLE_KIT], [1], [If defined, vdagentd will be compiled with ConsoleKit support])
with_session_info="console-kit"
else
with_session_info="none"
fi
AC_DEFINE([HAVE_CONSOLE_KIT], [1], [If defined, vdagentd will be compiled with ConsoleKit support])
have_console_kit="yes"
with_session_info="console-kit"
else
have_console_kit="no"
fi
......@@ -128,7 +128,7 @@ fi
# If no CFLAGS are set, set some sane default CFLAGS
if test "$ac_test_CFLAGS" != set; then
DEFAULT_CFLAGS="-Wall -Werror -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4"
DEFAULT_CFLAGS="-Wall -Werror -Wp,-D_FORTIFY_SOURCE=2 -fno-strict-aliasing -fstack-protector --param=ssp-buffer-size=4"
for F in $DEFAULT_CFLAGS; do
AC_MSG_CHECKING([whether $CC supports $F])
save_CFLAGS="$CFLAGS"
......
# A template to for higher precision timestamps + severity logging
$template SpiceTmpl,"%TIMESTAMP%.%TIMESTAMP:::date-subseconds% %syslogtag% %syslogseverity-text%:%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
:programname, startswith, "spice-vdagent" /var/log/spice-vdagent.log;SpiceTmpl
......@@ -29,6 +29,13 @@ Print a short description of all command line options
\fB-d\fP
Log debug messages (use twice for extra info)
.TP
\fB-f\fP
Treat uinput device as fake; no ioctls.
This is useful in combination with Xspice.
.TP
\fB-o\fP
The daemon will exit after processing a single session.
.TP
\fB-s\fP \fIport\fR
Set virtio serial \fIport\fR (default: /dev/virtio-ports/com.redhat.spice.0)
.TP
......
......@@ -3,7 +3,7 @@
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
This diff is collapsed.
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2012-06-26.16; # UTC
scriptversion=2013-10-28.13; # UTC
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
......@@ -160,7 +160,7 @@ give_advice ()
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'automa4te' program to be rebuilt."
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
......
......@@ -9,9 +9,6 @@
/* If defined, vdagentd will be compiled with pciaccess support */
#undef HAVE_PCIACCESS
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Name of package */
#undef PACKAGE
......@@ -42,5 +39,16 @@
/* If defined, vdagentd will use a static uinput device */
#undef WITH_STATIC_UINPUT
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Enable GNU extensions */
#undef _GNU_SOURCE
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
This diff is collapsed.
......@@ -7,12 +7,12 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
......@@ -44,3 +44,13 @@ char *session_info_session_for_pid(struct session_info *si, uint32_t pid)
{
return NULL;
}
gboolean session_is_locked(struct session_info *ck)
{
return FALSE;
}
gboolean session_info_is_user(struct session_info *si)
{
return TRUE;
}
......@@ -7,12 +7,12 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
......@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdint.h>
#include <glib.h>
struct session_info;
......@@ -36,4 +37,7 @@ const char *session_info_get_active_session(struct session_info *ck);
/* Note result must be free()-ed by caller */
char *session_info_session_for_pid(struct session_info *ck, uint32_t pid);
gboolean session_info_session_is_locked(struct session_info *si);
gboolean session_info_is_user(struct session_info *si);
#endif
......@@ -7,12 +7,12 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
......@@ -25,13 +25,206 @@
#include <string.h>
#include <syslog.h>
#include <systemd/sd-login.h>
#include <dbus/dbus.h>
struct session_info {
int verbose;
sd_login_monitor *mon;
char *session;
struct {
DBusConnection *system_connection;
char *match_session_signals;
} dbus;
gboolean session_is_locked;
gboolean session_locked_hint;
};
#define LOGIND_INTERFACE "org.freedesktop.login1"
#define LOGIND_SESSION_INTERFACE "org.freedesktop.login1.Session"
#define LOGIND_SESSION_OBJ_TEMPLATE "/org/freedesktop/login1/session/_3%s"
#define DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
#define SESSION_SIGNAL_LOCK "Lock"
#define SESSION_SIGNAL_UNLOCK "Unlock"
#define SESSION_PROP_LOCKED_HINT "LockedHint"
/* dbus related */
static DBusConnection *si_dbus_get_system_bus(void)
{
DBusConnection *connection;
DBusError error;
dbus_error_init(&error);
connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
if (connection == NULL || dbus_error_is_set(&error)) {
if (dbus_error_is_set(&error)) {
syslog(LOG_WARNING, "Unable to connect to system bus: %s",
error.message);
dbus_error_free(&error);
} else {
syslog(LOG_WARNING, "Unable to connect to system bus");
}
return NULL;
}
return connection;
}
static void si_dbus_match_remove(struct session_info *si)
{
DBusError error;
if (si->dbus.match_session_signals == NULL)
return;
dbus_error_init(&error);
dbus_bus_remove_match(si->dbus.system_connection,
si->dbus.match_session_signals,
&error);
g_free(si->dbus.match_session_signals);
si->dbus.match_session_signals = NULL;
}
static void si_dbus_match_rule_update(struct session_info *si)
{
DBusError error;
if (si->dbus.system_connection == NULL ||
si->session == NULL)
return;
si_dbus_match_remove(si);
si->dbus.match_session_signals =
g_strdup_printf ("type='signal',interface='%s',path='"
LOGIND_SESSION_OBJ_TEMPLATE"'",
LOGIND_SESSION_INTERFACE,
si->session);
if (si->verbose)
syslog(LOG_DEBUG, "logind match: %s", si->dbus.match_session_signals);
dbus_error_init(&error);
dbus_bus_add_match(si->dbus.system_connection,
si->dbus.match_session_signals,
&error);
if (dbus_error_is_set(&error)) {
syslog(LOG_WARNING, "Unable to add dbus rule match: %s",
error.message);
dbus_error_free(&error);
g_free(si->dbus.match_session_signals);
si->dbus.match_session_signals = NULL;
}
}
static void
si_dbus_read_properties(struct session_info *si)
{
dbus_bool_t locked_hint, ret;
DBusMessageIter iter, iter_variant;
gint type;
DBusError error;
DBusMessage *message = NULL;
DBusMessage *reply = NULL;
gchar *session_object;
const gchar *interface, *property;
if (si->session == NULL)
return;
session_object = g_strdup_printf(LOGIND_SESSION_OBJ_TEMPLATE, si->session);
message = dbus_message_new_method_call(LOGIND_INTERFACE,
session_object,
DBUS_PROPERTIES_INTERFACE,
"Get");
g_free (session_object);
if (message == NULL) {
syslog(LOG_ERR, "Unable to create dbus message");
goto exit;
}
interface = LOGIND_SESSION_INTERFACE;
property = SESSION_PROP_LOCKED_HINT;
ret = dbus_message_append_args(message,
DBUS_TYPE_STRING, &interface,
DBUS_TYPE_STRING, &property,
DBUS_TYPE_INVALID);
if (!ret) {
syslog(LOG_ERR, "Unable to request locked-hint");
goto exit;
}
dbus_error_init(&error);
reply = dbus_connection_send_with_reply_and_block(si->dbus.system_connection,
message,
-1,
&error);
if (reply == NULL) {
if (dbus_error_is_set(&error)) {
syslog(LOG_ERR, "Properties.Get failed (locked-hint) due %s", error.message);
dbus_error_free(&error);
} else {
syslog(LOG_ERR, "Properties.Get failed (locked-hint)");
}
goto exit;
}
dbus_message_iter_init(reply, &iter);
type = dbus_message_iter_get_arg_type(&iter);
if (type != DBUS_TYPE_VARIANT) {
syslog(LOG_ERR, "expected a variant, got a '%c' instead", type);
goto exit;
}
dbus_message_iter_recurse(&iter, &iter_variant);
type = dbus_message_iter_get_arg_type(&iter_variant);
if (type != DBUS_TYPE_BOOLEAN) {
syslog(LOG_ERR, "expected a boolean, got a '%c' instead", type);
goto exit;
}
dbus_message_iter_get_basic(&iter_variant, &locked_hint);
si->session_locked_hint = (locked_hint) ? TRUE : FALSE;
exit:
if (reply != NULL) {
dbus_message_unref(reply);
}
if (message != NULL) {
dbus_message_unref(message);
}
}
static void
si_dbus_read_signals(struct session_info *si)
{
DBusMessage *message = NULL;
dbus_connection_read_write(si->dbus.system_connection, 0);
message = dbus_connection_pop_message(si->dbus.system_connection);
while (message != NULL) {
const char *member;
member = dbus_message_get_member (message);
if (g_strcmp0(member, SESSION_SIGNAL_LOCK) == 0) {
si->session_is_locked = TRUE;
} else if (g_strcmp0(member, SESSION_SIGNAL_UNLOCK) == 0) {
si->session_is_locked = FALSE;
} else {
if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL) {
syslog(LOG_WARNING, "(systemd-login) received non signal message");
} else if (si->verbose) {
syslog(LOG_DEBUG, "(systemd-login) Signal not handled: %s", member);
}
}
dbus_message_unref(message);
dbus_connection_read_write(si->dbus.system_connection, 0);
message = dbus_connection_pop_message(si->dbus.system_connection);
}
}
struct session_info *session_info_create(int verbose)
{
struct session_info *si;
......@@ -42,6 +235,7 @@ struct session_info *session_info_create(int verbose)
return NULL;
si->verbose = verbose;
si->session_is_locked = FALSE;
r = sd_login_monitor_new("session", &si->mon);
if (r < 0) {
......@@ -50,6 +244,7 @@ struct session_info *session_info_create(int verbose)
return NULL;
}
si->dbus.system_connection = si_dbus_get_system_bus();
return si;
}
......@@ -58,6 +253,8 @@ void session_info_destroy(struct session_info *si)
if (!si)
return;
si_dbus_match_remove(si);
dbus_connection_close(si->dbus.system_connection);
sd_login_monitor_unref(si->mon);
free(si->session);
free(si);
......@@ -87,6 +284,7 @@ const char *session_info_get_active_session(struct session_info *si)
sd_login_monitor_flush(si->mon);
free(old_session);
si_dbus_match_rule_update(si);
return si->session;
}
......@@ -104,3 +302,46 @@ char *session_info_session_for_pid(struct session_info *si, uint32_t pid)
return session;
}
gboolean session_info_session_is_locked(struct session_info *si)
{
gboolean locked;
g_return_val_if_fail (si != NULL, FALSE);
si_dbus_read_signals(si);
si_dbus_read_properties(si);
locked = (si->session_is_locked || si->session_locked_hint);
if (si->verbose) {
syslog(LOG_DEBUG, "(systemd-login) session is locked: %s",
locked ? "yes" : "no");
}
return locked;
}
/* This function should only be called after session_info_get_active_session
* in order to verify if active session belongs to user (non greeter) */
gboolean session_info_is_user(struct session_info *si)
{
gchar *class = NULL;
gboolean ret;
g_return_val_if_fail (si != NULL, TRUE);
g_return_val_if_fail (si->session != NULL, TRUE);
if (sd_session_get_class(si->session, &class) != 0) {
syslog(LOG_WARNING, "Unable to get class from session: %s",
si->session);
return TRUE;
}
if (si->verbose)
syslog(LOG_DEBUG, "(systemd-login) class for %s is %s",
si->session, class);
ret = (g_strcmp0(class, "user") == 0);
g_free(class);
return ret;
}
This diff is collapsed.
......@@ -7,12 +7,12 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
......@@ -27,98 +27,118 @@
#include <sys/select.h>
#include <sys/socket.h>
/* ---------- Generic bits and client-side API ---------- */
struct udscs_connection;
struct udscs_server;
struct udscs_message_header {
uint32_t type;
uint32_t arg1;
uint32_t arg2;
uint32_t size;
uint32_t size;
};
/* Callbacks with this type will be called when a new connection to a
server is accepted. */
typedef void (*udscs_connect_callback)(struct udscs_connection *conn);
/* Callbacks with this type will be called when a complete message has been
received. The callback may call udscs_destroy_connection, in which case
*connp must be made NULL (which udscs_destroy_connection takes care of) */
* received. The callback may call udscs_destroy_connection, in which case
* *connp must be made NULL (which udscs_destroy_connection takes care of).
*/
typedef void (*udscs_read_callback)(struct udscs_connection **connp,
struct udscs_message_header *header, uint8_t *data);
/* Callback type for udscs_server_for_all_clients. Clients can be disconnected
from this callback just like with a read callback. */
typedef int (*udscs_for_all_clients_callback)(struct udscs_connection **connp,
void *priv);
/* Callbacks with this type will be called when the connection is disconnected.
Note:
1) udscs will destroy the connection in question itself after
this callback has completed!
2) This callback is always called, even if the disconnect is initiated
by the udscs user through returning -1 from a read callback, or
by explictly calling udscs_destroy_connection */
* Note:
* 1) udscs will destroy the connection in question itself after
* this callback has completed!
* 2) This callback is always called, even if the disconnect is initiated
* by the udscs user through returning -1 from a read callback, or
* by explictly calling udscs_destroy_connection.
*/
typedef void (*udscs_disconnect_callback)(struct udscs_connection *conn);
/* Create a unix domain socket named name and start listening on it. */
struct udscs_server *udscs_create_server(const char *socketname,
udscs_connect_callback connect_callback,
udscs_read_callback read_callback,
udscs_disconnect_callback disconnect_callback,
const char * const type_to_string[], int no_types, int debug);
void udscs_destroy_server(struct udscs_server *server);
/* Connect to a unix domain socket named name. */
struct udscs_connection *udscs_connect(const char *socketname,
udscs_read_callback read_callback,
udscs_disconnect_callback disconnect_callback,
const char * const type_to_string[], int no_types, int debug);
/* The contents of connp will be made NULL */
/* The contents of connp will be made NULL. */
void udscs_destroy_connection(struct udscs_connection **connp);
/* Given an udscs server or client fill the fd_sets pointed to by readfds and
writefds for select() usage.
Return value: value of the highest fd + 1 */
int udscs_server_fill_fds(struct udscs_server *server, fd_set *readfds,
fd_set *writefds);
int udscs_client_fill_fds(struct udscs_connection *conn, fd_set *readfds,
fd_set *writefds);
/* Handle any events flagged by select for the given udscs server or client. */
void udscs_server_handle_fds(struct udscs_server *server, fd_set *readfds,
fd_set *writefds);
fd_set *writefds);
/* Note the connection may be destroyed (when disconnected) by this call
in this case the disconnect calllback will get called before the
destruction and the contents of connp will be made NULL */
* in this case the disconnect calllback will get called before the
* destruction and the contents of connp will be made NULL.
*/
void udscs_client_handle_fds(struct udscs_connection **connp, fd_set *readfds,
fd_set *writefds);
fd_set *writefds);
/* Queue a message for delivery to the client connected through conn.
Returns 0 on success -1 on error (only happens when malloc fails) */
* Returns 0 on success -1 on error (only happens when malloc fails).
*/
int udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t arg1,
uint32_t arg2, const uint8_t *data, uint32_t size);
/* To associate per connection data with a connection. */
void udscs_set_user_data(struct udscs_connection *conn, void *data);
void *udscs_get_user_data(struct udscs_connection *conn);
#ifndef UDSCS_NO_SERVER
/* ---------- Server-side API ---------- */
struct udscs_server;
/* Callbacks with this type will be called when a new connection to a
* server is accepted.
*/
typedef void (*udscs_connect_callback)(struct udscs_connection *conn);