StreamNative.cpp File Reference
#include "oorexxapi.h"
#include "StreamNative.hpp"
#include "StreamCommandParser.h"
#include "Utilities.hpp"
#include <fcntl.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
Include dependency graph for StreamNative.cpp:

Go to the source code of this file.

Macros

#define CHAR_positional   "positional"
 
#define RDWR_CREAT   (RX_O_RDWR | RX_O_CREAT)
 
#define WR_CREAT   (RX_O_WRONLY | RX_O_CREAT)
 
#define IREAD_IWRITE   (RX_S_IREAD | RX_S_IWRITE)
 

Functions

StreamInfocheckStreamInfo (RexxMethodContext *context, void *streamPtr, RexxObjectPtr result)
 
int reclength_token (TokenDefinition *ttsp, StreamToken &tokenizer, void *userparms)
 
int position_offset (TokenDefinition *ttsp, StreamToken &tokenizer, void *userparms)
 
int unknown_tr (TokenDefinition *ttsp, StreamToken &tokenizer, void *userparms)
 
bool hasNoBufferOption (const char *opts)
 
 RexxMethod3 (RexxStringObject, stream_charin, CSELF, streamPtr, OPTIONAL_int64_t, position, OPTIONAL_size_t, read_length)
 
 RexxMethod3 (size_t, stream_charout, CSELF, streamPtr, OPTIONAL_RexxStringObject, data, OPTIONAL_int64_t, position)
 
 RexxMethod3 (RexxStringObject, stream_linein, CSELF, streamPtr, OPTIONAL_int64_t, position, OPTIONAL_size_t, count)
 
 RexxMethod2 (int, stream_arrayin, CSELF, streamPtr, RexxArrayObject, result)
 
 RexxMethod2 (int64_t, stream_lines, CSELF, streamPtr, OPTIONAL_CSTRING, option)
 
 RexxMethod1 (int64_t, stream_chars, CSELF, streamPtr)
 
 RexxMethod3 (int, stream_lineout, CSELF, streamPtr, OPTIONAL_RexxStringObject, string, OPTIONAL_int64_t, position)
 
 RexxMethod1 (CSTRING, stream_close, CSELF, streamPtr)
 
 RexxMethod1 (CSTRING, stream_uninit, CSELF, streamPtr)
 
 RexxMethod1 (CSTRING, stream_flush, CSELF, streamPtr)
 
 RexxMethod2 (CSTRING, stream_open, CSELF, streamPtr, OPTIONAL_CSTRING, options)
 
 RexxMethod2 (int, handle_set, CSELF, streamPtr, int, fh)
 
 RexxMethod1 (int, std_set, CSELF, streamPtr)
 
 RexxMethod2 (int64_t, stream_position, CSELF, streamPtr, CSTRING, options)
 
 RexxMethod2 (RexxObjectPtr, stream_query_position, CSELF, streamPtr, OPTIONAL_CSTRING, options)
 
 RexxMethod1 (CSTRING, qualify, CSELF, streamPtr)
 
 RexxMethod1 (CSTRING, query_exists, CSELF, streamPtr)
 
 RexxMethod1 (RexxObjectPtr, query_handle, CSELF, streamPtr)
 
 RexxMethod1 (CSTRING, query_streamtype, CSELF, streamPtr)
 
 RexxMethod1 (RexxObjectPtr, query_size, CSELF, streamPtr)
 
 RexxMethod1 (CSTRING, query_time, CSELF, streamPtr)
 
 RexxMethod1 (CSTRING, stream_state, CSELF, streamPtr)
 
 RexxMethod1 (RexxStringObject, stream_description, CSELF, streamPtr)
 
 RexxMethod2 (RexxObjectPtr, stream_init, OSELF, self, CSTRING, name)
 

Variables

const char * StreamInfoProperty = "CSELF"
 
const int operation_read = 0x01
 
const int operation_write = 0x02
 
const int operation_nocreate = 0x04
 
const int position_by_char = 0x04
 
const int position_by_line = 0x08
 
const int position_offset_specified = 0x10
 
const int query_read_position = 0x01
 
const int query_write_position = 0x02
 
const int query_char_position = 0x04
 
const int query_line_position = 0x08
 
const int query_system_position = 0x10
 

Macro Definition Documentation

◆ CHAR_positional

#define CHAR_positional   "positional"

Definition at line 55 of file StreamNative.cpp.

◆ IREAD_IWRITE

#define IREAD_IWRITE   (RX_S_IREAD | RX_S_IWRITE)

Definition at line 91 of file StreamNative.cpp.

◆ RDWR_CREAT

#define RDWR_CREAT   (RX_O_RDWR | RX_O_CREAT)

Definition at line 89 of file StreamNative.cpp.

◆ WR_CREAT

#define WR_CREAT   (RX_O_WRONLY | RX_O_CREAT)

Definition at line 90 of file StreamNative.cpp.

Function Documentation

◆ checkStreamInfo()

StreamInfo* checkStreamInfo ( RexxMethodContext context,
void *  streamPtr,
RexxObjectPtr  result 
)

Helper routine for the method stubs to validate the stream info pointer to ensure that the stream has not been uninited already. This can occur when an uninit method for another object attempts to use a stream.

Parameters
contextThe method context
streamPtrThe CSELF value
resultA potential result object set into the context.
Returns
The StreamInfo object instance. Throws an exception if this is not valid.

Definition at line 106 of file StreamNative.cpp.

References Rexx_Error_System_service, and StreamInfo::setContext().

Referenced by RexxMethod1(), RexxMethod2(), and RexxMethod3().

◆ hasNoBufferOption()

bool hasNoBufferOption ( const char *  opts)

Helper function to determine if opts contains the no buffer option.

Parameters
optsString to search in for NOBUFFER.
Returns
True if nobuffer, caseless, is in opts, otherwise false.

Definition at line 558 of file StreamNative.cpp.

References Utilities::strupper().

Referenced by StreamInfo::openStd().

◆ position_offset()

int position_offset ( TokenDefinition ttsp,
StreamToken tokenizer,
void *  userparms 
)

Token parsing routine for position offsets.

Parameters
ttspThe token action definition associated with this parse.
tokenThe current token.
userparmsAn opaque user parameter info.
Returns
0 for success, 1 for any failure.

Definition at line 160 of file StreamNative.cpp.

References StreamToken::nextToken(), and StreamToken::toNumber().

Referenced by StreamInfo::streamPosition().

◆ reclength_token()

int reclength_token ( TokenDefinition ttsp,
StreamToken tokenizer,
void *  userparms 
)

Token parsing routine for record length parsing.

Parameters
ttspThe token action definition associated with this parse.
tokenThe current token.
userparmsAn opaque user parameter info.
Returns
0 for success, 1 for any failure.

Definition at line 129 of file StreamNative.cpp.

References StreamToken::nextToken(), StreamToken::previousToken(), and StreamToken::toNumber().

Referenced by StreamInfo::handleOpen(), and StreamInfo::streamOpen().

◆ RexxMethod1() [1/13]

RexxMethod1 ( CSTRING  ,
qualify  ,
CSELF  ,
streamPtr   
)

Definition at line 3385 of file StreamNative.cpp.

References StreamInfo::getQualifiedName(), and StreamInfo::setContext().

◆ RexxMethod1() [2/13]

RexxMethod1 ( CSTRING  ,
query_exists  ,
CSELF  ,
streamPtr   
)

Definition at line 3436 of file StreamNative.cpp.

References StreamInfo::setContext(), and StreamInfo::streamExists().

◆ RexxMethod1() [3/13]

RexxMethod1 ( CSTRING  ,
query_streamtype  ,
CSELF  ,
streamPtr   
)

Definition at line 3494 of file StreamNative.cpp.

References StreamInfo::getStreamType().

◆ RexxMethod1() [4/13]

RexxMethod1 ( CSTRING  ,
query_time  ,
CSELF  ,
streamPtr   
)

Definition at line 3571 of file StreamNative.cpp.

References StreamInfo::getTimeStamp(), and StreamInfo::setContext().

◆ RexxMethod1() [5/13]

RexxMethod1 ( CSTRING  ,
stream_close  ,
CSELF  ,
streamPtr   
)

Definition at line 2123 of file StreamNative.cpp.

References StreamInfo::setContext(), and StreamInfo::streamClose().

◆ RexxMethod1() [6/13]

RexxMethod1 ( CSTRING  ,
stream_flush  ,
CSELF  ,
streamPtr   
)

Definition at line 2214 of file StreamNative.cpp.

References checkStreamInfo(), and StreamInfo::streamFlush().

◆ RexxMethod1() [7/13]

RexxMethod1 ( CSTRING  ,
stream_state  ,
CSELF  ,
streamPtr   
)

Definition at line 3608 of file StreamNative.cpp.

References StreamInfo::getState(), and StreamInfo::setContext().

◆ RexxMethod1() [8/13]

RexxMethod1 ( CSTRING  ,
stream_uninit  ,
CSELF  ,
streamPtr   
)

Definition at line 2154 of file StreamNative.cpp.

References StreamInfo::setContext(), and StreamInfo::streamClose().

◆ RexxMethod1() [9/13]

RexxMethod1 ( int  ,
std_set  ,
CSELF  ,
streamPtr   
)

Definition at line 2609 of file StreamNative.cpp.

References StreamInfo::setStandard().

◆ RexxMethod1() [10/13]

RexxMethod1 ( int64_t  ,
stream_chars  ,
CSELF  ,
streamPtr   
)

Definition at line 1968 of file StreamNative.cpp.

References StreamInfo::chars(), and checkStreamInfo().

◆ RexxMethod1() [11/13]

RexxMethod1 ( RexxObjectPtr  ,
query_handle  ,
CSELF  ,
streamPtr   
)

Definition at line 3461 of file StreamNative.cpp.

References StreamInfo::queryHandle(), and StreamInfo::setContext().

◆ RexxMethod1() [12/13]

RexxMethod1 ( RexxObjectPtr  ,
query_size  ,
CSELF  ,
streamPtr   
)

Definition at line 3559 of file StreamNative.cpp.

References StreamInfo::getStreamSize(), and StreamInfo::setContext().

◆ RexxMethod1() [13/13]

RexxMethod1 ( RexxStringObject  ,
stream_description  ,
CSELF  ,
streamPtr   
)

Definition at line 3692 of file StreamNative.cpp.

References StreamInfo::getDescription(), and StreamInfo::setContext().

◆ RexxMethod2() [1/7]

RexxMethod2 ( CSTRING  ,
stream_open  ,
CSELF  ,
streamPtr  ,
OPTIONAL_CSTRING  ,
options   
)

Definition at line 2555 of file StreamNative.cpp.

References checkStreamInfo(), and StreamInfo::streamOpen().

◆ RexxMethod2() [2/7]

RexxMethod2 ( int  ,
handle_set  ,
CSELF  ,
streamPtr  ,
int  ,
fh   
)

Definition at line 2588 of file StreamNative.cpp.

References checkStreamInfo(), and StreamInfo::setHandle().

◆ RexxMethod2() [3/7]

RexxMethod2 ( int  ,
stream_arrayin  ,
CSELF  ,
streamPtr  ,
RexxArrayObject  ,
result   
)

Definition at line 1788 of file StreamNative.cpp.

References StreamInfo::arrayin(), and checkStreamInfo().

◆ RexxMethod2() [4/7]

RexxMethod2 ( int64_t  ,
stream_lines  ,
CSELF  ,
streamPtr  ,
OPTIONAL_CSTRING  ,
option   
)

◆ RexxMethod2() [5/7]

RexxMethod2 ( int64_t  ,
stream_position  ,
CSELF  ,
streamPtr  ,
CSTRING  ,
options   
)

Definition at line 2993 of file StreamNative.cpp.

References checkStreamInfo(), and StreamInfo::streamPosition().

◆ RexxMethod2() [6/7]

RexxMethod2 ( RexxObjectPtr  ,
stream_init  ,
OSELF  ,
self  ,
CSTRING  ,
name   
)

Definition at line 3725 of file StreamNative.cpp.

References NULLOBJECT.

◆ RexxMethod2() [7/7]

RexxMethod2 ( RexxObjectPtr  ,
stream_query_position  ,
CSELF  ,
streamPtr  ,
OPTIONAL_CSTRING  ,
options   
)

Definition at line 3229 of file StreamNative.cpp.

References checkStreamInfo(), and StreamInfo::queryStreamPosition().

◆ RexxMethod3() [1/4]

RexxMethod3 ( int  ,
stream_lineout  ,
CSELF  ,
streamPtr  ,
OPTIONAL_RexxStringObject  ,
string  ,
OPTIONAL_int64_t  ,
position   
)

Definition at line 2083 of file StreamNative.cpp.

References argumentExists, checkStreamInfo(), and StreamInfo::lineout().

◆ RexxMethod3() [2/4]

RexxMethod3 ( RexxStringObject  ,
stream_charin  ,
CSELF  ,
streamPtr  ,
OPTIONAL_int64_t  ,
position  ,
OPTIONAL_size_t  ,
read_length   
)

◆ RexxMethod3() [3/4]

RexxMethod3 ( RexxStringObject  ,
stream_linein  ,
CSELF  ,
streamPtr  ,
OPTIONAL_int64_t  ,
position  ,
OPTIONAL_size_t  ,
count   
)

◆ RexxMethod3() [4/4]

RexxMethod3 ( size_t  ,
stream_charout  ,
CSELF  ,
streamPtr  ,
OPTIONAL_RexxStringObject  ,
data  ,
OPTIONAL_int64_t  ,
position   
)

Definition at line 1632 of file StreamNative.cpp.

References argumentExists, StreamInfo::charout(), and checkStreamInfo().

◆ unknown_tr()

int unknown_tr ( TokenDefinition ttsp,
StreamToken tokenizer,
void *  userparms 
)

Token parsing routine for unknown tokens. This just forces a parsing error.

Parameters
ttspThe token action definition associated with this parse.
tokenThe current token.
userparmsAn opaque user parameter info.
Returns
0 for success, 1 for any failure.

Definition at line 190 of file StreamNative.cpp.

Referenced by StreamInfo::handleOpen(), StreamInfo::queryStreamPosition(), and StreamInfo::streamOpen().

Variable Documentation

◆ operation_nocreate

◆ operation_read

const int operation_read = 0x01

Definition at line 70 of file StreamNative.cpp.

Referenced by StreamInfo::streamPosition().

◆ operation_write

const int operation_write = 0x02

◆ position_by_char

const int position_by_char = 0x04

Definition at line 73 of file StreamNative.cpp.

Referenced by StreamInfo::streamPosition().

◆ position_by_line

const int position_by_line = 0x08

Definition at line 74 of file StreamNative.cpp.

Referenced by StreamInfo::streamPosition().

◆ position_offset_specified

const int position_offset_specified = 0x10

Definition at line 75 of file StreamNative.cpp.

◆ query_char_position

const int query_char_position = 0x04

Definition at line 83 of file StreamNative.cpp.

Referenced by StreamInfo::queryStreamPosition().

◆ query_line_position

const int query_line_position = 0x08

Definition at line 84 of file StreamNative.cpp.

Referenced by StreamInfo::queryStreamPosition().

◆ query_read_position

const int query_read_position = 0x01

Definition at line 81 of file StreamNative.cpp.

Referenced by StreamInfo::queryStreamPosition().

◆ query_system_position

const int query_system_position = 0x10

Definition at line 85 of file StreamNative.cpp.

Referenced by StreamInfo::queryStreamPosition().

◆ query_write_position

const int query_write_position = 0x02

Definition at line 82 of file StreamNative.cpp.

Referenced by StreamInfo::queryStreamPosition().

◆ StreamInfoProperty

const char* StreamInfoProperty = "CSELF"

Definition at line 64 of file StreamNative.cpp.