forked from Imagelibrary/rtems
redirector: Rename rtems_stdio_redirect_t
Rename rtems_stdio_redirect_t to rtems_stdio_redirect since the namespace *_t is reserved by POSIX, see also The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 Edition, 2.2.2 The Name Space.
This commit is contained in:
@@ -31,7 +31,7 @@
|
|||||||
#define RTEMS_STDIO_REDIRECT_FINISHED (1 << 1)
|
#define RTEMS_STDIO_REDIRECT_FINISHED (1 << 1)
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
rtems_stdio_redirect_lock(rtems_stdio_redirect_t* sr)
|
rtems_stdio_redirect_lock(rtems_stdio_redirect* sr)
|
||||||
{
|
{
|
||||||
rtems_status_code sc = rtems_semaphore_obtain (sr->lock,
|
rtems_status_code sc = rtems_semaphore_obtain (sr->lock,
|
||||||
RTEMS_WAIT,
|
RTEMS_WAIT,
|
||||||
@@ -45,7 +45,7 @@ rtems_stdio_redirect_lock(rtems_stdio_redirect_t* sr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
rtems_stdio_redirect_unlock(rtems_stdio_redirect_t* sr)
|
rtems_stdio_redirect_unlock(rtems_stdio_redirect* sr)
|
||||||
{
|
{
|
||||||
rtems_status_code sc = rtems_semaphore_release (sr->lock);
|
rtems_status_code sc = rtems_semaphore_release (sr->lock);
|
||||||
if (sc != RTEMS_SUCCESSFUL)
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
@@ -57,7 +57,7 @@ rtems_stdio_redirect_unlock(rtems_stdio_redirect_t* sr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
rtems_stdio_redirect_write (rtems_stdio_redirect_t* sr, const char* buf, ssize_t len)
|
rtems_stdio_redirect_write (rtems_stdio_redirect* sr, const char* buf, ssize_t len)
|
||||||
{
|
{
|
||||||
if (!rtems_stdio_redirect_lock(sr))
|
if (!rtems_stdio_redirect_lock(sr))
|
||||||
return false;
|
return false;
|
||||||
@@ -99,7 +99,7 @@ rtems_stdio_redirect_write (rtems_stdio_redirect_t* sr, const char* buf, ssize_t
|
|||||||
static rtems_task
|
static rtems_task
|
||||||
rtems_stdio_redirect_reader(rtems_task_argument arg)
|
rtems_stdio_redirect_reader(rtems_task_argument arg)
|
||||||
{
|
{
|
||||||
rtems_stdio_redirect_t* sr = (rtems_stdio_redirect_t*) arg;
|
rtems_stdio_redirect* sr = (rtems_stdio_redirect*) arg;
|
||||||
|
|
||||||
while (sr->state & RTEMS_STDIO_REDIRECT_RUNNING)
|
while (sr->state & RTEMS_STDIO_REDIRECT_RUNNING)
|
||||||
{
|
{
|
||||||
@@ -120,7 +120,7 @@ rtems_stdio_redirect_reader(rtems_task_argument arg)
|
|||||||
rtems_task_delete(RTEMS_SELF);
|
rtems_task_delete(RTEMS_SELF);
|
||||||
}
|
}
|
||||||
|
|
||||||
rtems_stdio_redirect_t*
|
rtems_stdio_redirect*
|
||||||
rtems_stdio_redirect_open(int fd,
|
rtems_stdio_redirect_open(int fd,
|
||||||
rtems_task_priority priority,
|
rtems_task_priority priority,
|
||||||
size_t stack_size,
|
size_t stack_size,
|
||||||
@@ -129,11 +129,11 @@ rtems_stdio_redirect_open(int fd,
|
|||||||
bool echo,
|
bool echo,
|
||||||
rtems_stdio_redirect_handler handler)
|
rtems_stdio_redirect_handler handler)
|
||||||
{
|
{
|
||||||
rtems_stdio_redirect_t* sr;
|
rtems_stdio_redirect* sr;
|
||||||
rtems_name name;
|
rtems_name name;
|
||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
|
|
||||||
sr = malloc(sizeof(rtems_stdio_redirect_t));
|
sr = malloc(sizeof(*sr));
|
||||||
if (!sr)
|
if (!sr)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "error: stdio-redirect: no memory\n");
|
fprintf(stderr, "error: stdio-redirect: no memory\n");
|
||||||
@@ -248,7 +248,7 @@ rtems_stdio_redirect_open(int fd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rtems_stdio_redirect_close(rtems_stdio_redirect_t* sr)
|
rtems_stdio_redirect_close(rtems_stdio_redirect* sr)
|
||||||
{
|
{
|
||||||
if (rtems_stdio_redirect_lock(sr))
|
if (rtems_stdio_redirect_lock(sr))
|
||||||
{
|
{
|
||||||
@@ -278,9 +278,9 @@ rtems_stdio_redirect_close(rtems_stdio_redirect_t* sr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
rtems_stdio_redirect_read(rtems_stdio_redirect_t* sr,
|
rtems_stdio_redirect_read(rtems_stdio_redirect* sr,
|
||||||
char* buffer,
|
char* buffer,
|
||||||
ssize_t length)
|
ssize_t length)
|
||||||
{
|
{
|
||||||
ssize_t written = 0;
|
ssize_t written = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ typedef struct
|
|||||||
bool full; /**< The buffer is full. */
|
bool full; /**< The buffer is full. */
|
||||||
bool echo; /**< Echo the data out the existing path. */
|
bool echo; /**< Echo the data out the existing path. */
|
||||||
rtems_stdio_redirect_handler handler; /**< Redirected data handler. */
|
rtems_stdio_redirect_handler handler; /**< Redirected data handler. */
|
||||||
} rtems_stdio_redirect_t;
|
} rtems_stdio_redirect;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open a redirector returning the handle to it.
|
* Open a redirector returning the handle to it.
|
||||||
@@ -83,18 +83,18 @@ typedef struct
|
|||||||
* @param fd The file descriptor to redirect.
|
* @param fd The file descriptor to redirect.
|
||||||
* @param priority The priority of the reader thread.
|
* @param priority The priority of the reader thread.
|
||||||
*/
|
*/
|
||||||
rtems_stdio_redirect_t* rtems_stdio_redirect_open(int fd,
|
rtems_stdio_redirect* rtems_stdio_redirect_open(int fd,
|
||||||
rtems_task_priority priority,
|
rtems_task_priority priority,
|
||||||
size_t stack_size,
|
size_t stack_size,
|
||||||
ssize_t input_size,
|
ssize_t input_size,
|
||||||
ssize_t buffer_size,
|
ssize_t buffer_size,
|
||||||
bool echo,
|
bool echo,
|
||||||
rtems_stdio_redirect_handler handler);
|
rtems_stdio_redirect_handler handler);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close the redirector.
|
* Close the redirector.
|
||||||
*/
|
*/
|
||||||
void rtems_stdio_redirect_close(rtems_stdio_redirect_t* sr);
|
void rtems_stdio_redirect_close(rtems_stdio_redirect* sr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get data from the capture buffer. Data read is removed from the buffer.
|
* Get data from the capture buffer. Data read is removed from the buffer.
|
||||||
@@ -104,9 +104,9 @@ void rtems_stdio_redirect_close(rtems_stdio_redirect_t* sr);
|
|||||||
* @param length The size of the buffer.
|
* @param length The size of the buffer.
|
||||||
* @return ssize_t The amount of data written and -1 or an error.
|
* @return ssize_t The amount of data written and -1 or an error.
|
||||||
*/
|
*/
|
||||||
ssize_t rtems_stdio_redirect_read(rtems_stdio_redirect_t* sr,
|
ssize_t rtems_stdio_redirect_read(rtems_stdio_redirect* sr,
|
||||||
char* buffer,
|
char* buffer,
|
||||||
ssize_t length);
|
ssize_t length);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user