Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

wsstream_data.c File Reference

#include "wmlscript/wsint.h"

Include dependency graph for wsstream_data.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  WsStreamDataInputCtxRec

Typedefs

typedef WsStreamDataInputCtxRec WsStreamDataInputCtx

Functions

size_t data_input (void *context, WsUInt32 *buf, size_t buflen)
void data_close (void *context)
WsStreamws_stream_new_data_input (const unsigned char *data, size_t data_len)


Typedef Documentation

typedef struct WsStreamDataInputCtxRec WsStreamDataInputCtx
 

Definition at line 81 of file wsstream_data.c.

Referenced by data_close(), data_input(), and ws_stream_new_data_input().


Function Documentation

void data_close void *  context  )  [static]
 

Definition at line 99 of file wsstream_data.c.

References ws_free(), and WsStreamDataInputCtx.

Referenced by ws_stream_new_data_input().

00100 {
00101     WsStreamDataInputCtx *ctx = (WsStreamDataInputCtx *) context;
00102 
00103     ws_free(ctx);
00104 }

Here is the call graph for this function:

size_t data_input void *  context,
WsUInt32 buf,
size_t  buflen
[static]
 

Definition at line 85 of file wsstream_data.c.

References WsStreamDataInputCtxRec::data, WsStreamDataInputCtxRec::data_len, WsStreamDataInputCtxRec::data_pos, and WsStreamDataInputCtx.

Referenced by ws_stream_new_data_input().

00086 {
00087     WsStreamDataInputCtx *ctx = (WsStreamDataInputCtx *) context;
00088     size_t read;
00089 
00090     for (read = 0;
00091          read < buflen && ctx->data_pos < ctx->data_len;
00092          read++, ctx->data_pos++)
00093         buf[read] = ctx->data[ctx->data_pos];
00094 
00095     return read;
00096 }

WsStream* ws_stream_new_data_input const unsigned char *  data,
size_t  data_len
 

Definition at line 108 of file wsstream_data.c.

References WsStreamDataInputCtxRec::data, data_close(), data_input(), WsStreamDataInputCtxRec::data_len, ws_calloc(), ws_stream_new(), WsStream, and WsStreamDataInputCtx.

Referenced by ws_compile_data().

00109 {
00110     WsStreamDataInputCtx *ctx = ws_calloc(1, sizeof(*ctx));
00111     WsStream *stream;
00112 
00113     if (ctx == NULL)
00114         return NULL;
00115 
00116     ctx->data = data;
00117     ctx->data_len = data_len;
00118 
00119     stream = ws_stream_new(ctx, data_input, NULL, data_close);
00120 
00121     if (stream == NULL)
00122         /* The stream creation failed.  Close the stream context. */
00123         data_close(ctx);
00124 
00125     return stream;
00126 }

Here is the call graph for this function:

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.