evl/proxy: introduce file proxy interface

This commit is contained in:
Philippe Gerum 2019-02-23 15:31:28 +01:00
parent 70912c1712
commit 4314ff1bb1
3 changed files with 61 additions and 0 deletions

View File

@ -17,6 +17,7 @@
#include <evenless/thread.h>
#include <evenless/xbuf.h>
#include <evenless/poll.h>
#include <evenless/proxy.h>
#define __EVL__ 0 /* API revision */

25
include/evenless/proxy.h Normal file
View File

@ -0,0 +1,25 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019 Philippe Gerum <rpm@xenomai.org>
*/
#ifndef _EVENLESS_PROXY_H
#define _EVENLESS_PROXY_H
#include <sys/types.h>
#include <linux/types.h>
#include <uapi/evenless/proxy.h>
#ifdef __cplusplus
extern "C" {
#endif
int evl_new_proxy(int fd, size_t bufsz,
const char *fmt, ...);
#ifdef __cplusplus
}
#endif
#endif /* _EVENLESS_PROXY_H */

35
lib/proxy.c Normal file
View File

@ -0,0 +1,35 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019 Philippe Gerum <rpm@xenomai.org>
*/
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <evenless/proxy.h>
#include <evenless/syscall.h>
#include "internal.h"
int evl_new_proxy(int fd, size_t bufsz, const char *fmt, ...)
{
struct evl_proxy_attrs attrs;
int ret, efd;
va_list ap;
char *name;
va_start(ap, fmt);
ret = vasprintf(&name, fmt, ap);
va_end(ap);
if (ret < 0)
return -ENOMEM;
attrs.fd = fd;
attrs.bufsz = bufsz;
efd = create_evl_element("proxy", name, &attrs, NULL);
free(name);
return efd;
}