src/sock_fifo.c
author Tero Marttila <terom@fixme.fi>
Sun, 19 Apr 2009 04:52:12 +0300
changeset 142 dc2bb09d412c
parent 139 55b9dcc2b73a
permissions -rw-r--r--
implement table-as-argument for lua_arg_*
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
/**
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
 * @file
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
 *
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
 * A read-only sock_stream implementation for linux fifo(7).
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
 */
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
#include "sock_fd.h"
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
#include <stdlib.h>
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
#include <sys/types.h>
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
#include <sys/stat.h>
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
#include <fcntl.h>
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
#include <string.h>
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
struct fifo {
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
    /** The base fd operations */
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
    struct sock_fd base_fd;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    17
    
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
    /** The path to the fifo */
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
    char *path;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
};
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
/**
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    23
 * Get a sock_fd pointer from a sock_fifo pointer
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    24
 */
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    25
#define FIFO_FD(sock_ptr) (&(sock_ptr)->base_fd)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    26
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    27
/**
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
 * Get a sock_base pointer from a sock_fifo pointer
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    29
 */
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    30
#define FIFO_BASE(sock_ptr) SOCK_FD_BASE(FIFO_FD(sock_ptr))
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    32
/**
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    33
 * Get the sock_stream.err pointer from a sock_fifo pointer
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    34
 */
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
#define FIFO_ERR(sock_ptr) SOCK_ERR(FIFO_BASE(sock_ptr))
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
/**
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
 * (re)open the fifo, closing it if already open, and keeping any event callbacks registered.
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
 */
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
static err_t fifo_open (struct fifo *fifo, struct error_info *err)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    43
{
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    44
    int fd;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    45
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    46
    // open(2) the path in non-blocking mode
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    47
    // XXX: hardoded read-only
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    48
    if ((fd = open(fifo->path, O_RDONLY | O_NONBLOCK)) < 0)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    49
        RETURN_SET_ERROR_ERRNO(err, ERR_OPEN);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    50
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    51
    // set the new fd
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    52
    if ((ERROR_CODE(err) = sock_fd_set(FIFO_FD(fifo), fd)))
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    53
        return ERROR_CODE(err);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    54
    
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    55
    // ok
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    56
    return SUCCESS;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    57
}
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    58
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    59
/**
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    60
 * Destroy the fifo, releasing all resources
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    61
 */
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    62
static void fifo_destroy (struct fifo *fifo)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    63
{
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    64
    // close if open
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    65
    if (FIFO_FD(fifo)->fd >= 0)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    66
        sock_fd_close(FIFO_FD(fifo));
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    67
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    68
    // release the path
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    69
    free(fifo->path);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    70
    free(fifo);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    71
}
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    72
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    73
/**
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    74
 * sock_stream_methods::read implementation.
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    75
 *
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    76
 * Try and do a normal sock_fd_read call, but re-open with EAGAIN on EOF
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    77
 */
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    78
err_t fifo_read (struct sock_stream *base_sock, void *buf, size_t *len, struct error_info *err)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    79
{
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    80
    struct fifo *fifo = SOCK_FROM_BASE(base_sock, struct fifo);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    81
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    82
    // passthru ERR_READ_EOF unless it's READ_EOF
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    83
    if (sock_fd_read(base_sock, buf, len, err) != ERR_READ_EOF)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    84
        return ERROR_CODE(err);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    85
    
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    86
    // re-open it
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    87
    // XXX: re-add events?
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    88
    if (fifo_open(fifo, err))
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    89
        goto error;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    90
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    91
    // ok, act as if it was EAGAIN
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    92
    *len = 0;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    93
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    94
    return SUCCESS;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    95
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    96
error:
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    97
    return ERROR_CODE(err);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    98
}
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    99
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   100
/**
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   101
 * sock_stream_methods::release implementation
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   102
 */
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   103
static void fifo_release (struct sock_stream *base_sock)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   104
{
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   105
    struct fifo *fifo = SOCK_FROM_BASE(base_sock, struct fifo);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   106
    
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   107
    fifo_destroy(fifo);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   108
}
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   109
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   110
/*
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   111
 * Our sock_stream_type
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   112
 */
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   113
static struct sock_stream_type fifo_stream_type = {
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   114
    .methods                = {
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   115
        .read               = &fifo_read,
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   116
        .write              = NULL,
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   117
        .event_init         = &sock_fd_event_init,
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   118
        .event_enable       = &sock_fd_event_enable,
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   119
        .release            = &fifo_release,
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   120
    },
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   121
};
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   122
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   123
err_t fifo_open_read (struct sock_stream **stream_ptr, const char *path, struct error_info *err)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   124
{
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   125
    struct fifo *fifo;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   126
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   127
    // alloc
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   128
    if ((fifo = calloc(1, sizeof(*fifo))) == NULL)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   129
        return SET_ERROR(err, ERR_CALLOC);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   130
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   131
    // copy the path
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   132
    if ((fifo->path = strdup(path)) == NULL)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   133
        return SET_ERROR(err, ERR_STRDUP);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   134
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   135
    // init
139
55b9dcc2b73a implement sock_ssl_connect_async (the old sock_ssl_connect exists no more)
Tero Marttila <terom@fixme.fi>
parents: 118
diff changeset
   136
    sock_stream_init(FIFO_BASE(fifo), &fifo_stream_type, NULL, NULL);
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   137
    sock_fd_init(FIFO_FD(fifo), -1);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   138
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   139
    // open the fifo
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   140
    if (fifo_open(fifo, err))
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   141
        goto error;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   142
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   143
    // ok
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   144
    *stream_ptr = FIFO_BASE(fifo);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   145
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   146
    return SUCCESS;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   147
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   148
error:
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   149
    // cleanup
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   150
    fifo_destroy(fifo);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   151
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   152
    return ERROR_CODE(err);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   153
}