OSSP CVS Repository

ossp - ossp-pkg/sio/sio_hole.c 1.1
Not logged in
[Honeypot]  [Browse]  [Directory]  [Home]  [Login
[Reports]  [Search]  [Ticket]  [Timeline
  [Raw

ossp-pkg/sio/sio_hole.c 1.1
#include <stddef.h>
#include <stdlib.h>

#include "al.h"
#include "sio.h"
#include "sio_module.h"

typedef struct {
} private_t;

/*
 * create stage
 *
 * allocate private instance data
 */
static
sio_rc_t hole_init(sio_t *sio, void **u)
{
    private_t *mydata;
    
    mydata = (private_t *)malloc(sizeof(private_t));
    if (mydata == NULL)
        return SIO_ERR_MEM;

    *u = mydata;

    return SIO_OK;
}

/*
 * configure stage
 *
 * pass two void pointers
 */
static
sio_rc_t hole_configure(sio_t *sio, void *u, void *obj, void *val)
{
    return SIO_ERR_ARG;
}

/*
 * destroy stage
 */
static
sio_rc_t hole_cleanup(sio_t *sio, void *u)
{
    private_t *mydata = (private_t *)u;

    free(mydata);

    return SIO_OK;
}

static
sio_rc_t hole_openr(sio_t *sio, al_t *al, void *u)
{
    return SIO_OK;
}

static
sio_rc_t hole_closer(sio_t *sio, al_t *al, void *u)
{
    return SIO_OK;
}

static
sio_rc_t hole_openw(sio_t *sio, al_t *al, void *u)
{
    return SIO_OK;
}

static
sio_rc_t hole_closew(sio_t *sio, al_t *al, void *u)
{
    return SIO_OK;
}

static
sio_rc_t hole_input(sio_t *sio, al_t *al, void *u)
{
    size_t feed = al_bytes(al);

    /* drop all data into the bit bucket */
    if (feed > 0) {
        al_splice(al, 0, feed, NULL, NULL);
        return SIO_DOWNSTREAM;
    }

    return SIO_UPSTREAM;
}

static
sio_rc_t hole_output(sio_t *sio, al_t *al, void *u)
{
    /* drop all data into the bit bucket */
    al_splice(al, 0, al_bytes(al), NULL, NULL);

    return SIO_DOWNSTREAM;
}

sio_module_t sio_module_hole = {
    "hole",
    hole_init,
    hole_configure,
    hole_cleanup,
    hole_openr,
    hole_closer,
    hole_openw,
    hole_closew,
    hole_input,
    hole_output
};


CVSTrac 2.0.1