libudev-ctrl.c revision 7b3a52f4999fa66914868f92b6ef139ba636648b
/*
* libudev - interface to udev device information
*
* Copyright (C) 2008 Kay Sievers <kay.sievers@vrfy.org>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include "libudev.h"
#include "libudev-private.h"
#define UDEV_CTRL_MAGIC "udevd-128"
enum udev_ctrl_msg_type {
};
struct ctrl_msg_wire {
char magic[32];
enum udev_ctrl_msg_type type;
union {
int intval;
char buf[256];
};
};
struct udev_ctrl_msg {
int refcount;
struct ctrl_msg_wire ctrl_msg_wire;
};
struct udev_ctrl {
int refcount;
int sock;
struct sockaddr_un saddr;
};
{
return NULL;
return NULL;
}
/* translate leading '@' to abstract namespace */
return uctrl;
}
{
int err;
const int feature_on = 1;
if (err < 0) {
return err;
}
/* enable receiving of the sender credentials */
return 0;
}
{
}
{
return NULL;
return uctrl;
}
{
return;
return;
}
{
return -1;
}
static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int intval, const char *buf)
{
struct ctrl_msg_wire ctrl_msg_wire;
int err;
else
err = sendto(uctrl->sock, &ctrl_msg_wire, sizeof(ctrl_msg_wire), 0, (struct sockaddr *)&uctrl->saddr, uctrl->addrlen);
if (err == -1) {
}
return err;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
struct udev_ctrl_msg *uctrl_msg;
return NULL;
if (size < 0) {
goto err;
}
goto err;
}
goto err;
}
goto err;
}
return uctrl_msg;
err:
return NULL;
}
{
return NULL;
return ctrl_msg;
}
{
return;
return;
}
{
return -1;
}
{
return 1;
return -1;
}
{
return 1;
return -1;
}
{
return 1;
return -1;
}
{
return NULL;
}
{
return -1;
}