CRI Middleware Library Reference Manual : SJ

Constants

[Menu]

SJ_LIN_~
Data Line

Description

Line type for get or put data.

Define | Remarks
--- | ---
SJ_LIN_DATA | Data Line(for valid data)
SJ_LIN_FREE | Free Line(for used data)

[Menu]

SJ_ERR_~
Error code

Description

The value of SJ_ERR_OK is "0". the other error codes have negative values.

Define | Remarks
--- | ---
SJ_ERR_OK | Normal end
SJ_ERR_FATAL | Fatal error (does not normally occur)
SJ_ERR_INTERNAL | Internal error (does not normally occur)
SJ_ERR_PRM | Parameter error

[Menu]

SJUNI_MODE_~
Linking mode

Description

This parameter is specified when creating a general-purpose stream joint. This parameter determines whether or not to link data chunks that are supplied by the SJ_PutChunk function.

Define | Remarks
--- | ---
SJUNI_MODE_SEPA | Do not link data chunks
SJUNI_MODE_JOIN | Link data chunks

Process Macros

[Menu]

SJUNI_CALC_WORK
Calculates work buffer size

Format
int SJUNI_CALC_WORK(nck);
Input

nck: The number of chunks

Output

None.

Return Value

Work area size (bytes)

Description

Calculates the work area size for a general-purpose stream joint.

Data Types

[Menu]

UUID
Library identifier

Description

This is a library identifier that is uniquely defined in terms of time and space. Executing UUIDGEN.EXE or some similar function of Visual C++ yields a code; these codes are defined within each library for each of the following members.

Member | Type | Remarks
--- | --- | ---
Data1 | Uint32 | ID1
Data2 | Uint16 | ID2
Data3 | Uint16 | ID3
Data4[8] | Uint8 | ID4

Example

    C:\>uuidgen
    211b2800-a6a9-11d1-8f3f-0060089448bc
    #define SmD_LID { \
    0x211b2800, 0xa6a9, 0x11d1, 0x8f, 0x3f, 0x00, 0x60, 0x08, 0x94, 0x48, 0xbc\
    }\

[Menu]

SJ
Stream joint handle

Description This handle is used to control the stream joint.

[Menu]

SJCK
Data chunk

Description

Data structure is used for data streaming by SJ.

Member | Type | Remarks
--- | --- | ---
data | Sint8 * | Starting address
len | Sint32 | Number of bytes

Functions

[Menu]

SJ_Destroy
Deletes stream joint

Format
void SJ_Destroy(SJ sj);
Inputs

sj : Stream joint

Outputs

None

Return Value

None

Description

Deletes a stream joint.

[Menu]

SJ_Reset
Resets stream joint

Format
void SJ_Reset(SJ sj);
Inputs

sj : Stream joint

Outputs

None

Return Value

None

Description

Resets a stream joint.

[Menu]

SJ_GetChunk
Gets data chunk

Format
void SJ_GetChunk(SJ sj, Sint32 id, Sint32 nbyte, SJCK *ck);
Inputs

sj : Stream joint

id : Chunk input/output ID (SJ_LIN_DATA / SJ_LIN_FREE)

nbyte : Amount of data requested (unit: bytes)

Outputs

ck : Data chunk (data starting address/size)

Return Value

None

Description

This function gets the area (data chunk) that can be read or written from a stream joint when writing or reading a buffer.

[Menu]

SJ_UngetChunk
Returns data chunk

Format
void SJ_UngetChunk(SJ sj, Sint32 id, SJCK *ck);
Inputs

sj : Stream joint

id : Chunk input/output ID (SJ_LIN_DATA / SJ_LIN_FREE)

ck : Data chunk (data starting address/size)

Outputs

None

Return Value

None

Description

When a data chunk that was gotten could not actually be written or read, this function returns the area (data chunk) that could not be read/written back to the stream joint.

[Menu]

SJ_PutChunk
Puts data chunk

Format
void SJ_PutChunk(SJ sj, Sint32 id, SJCK *ck);
Inputs

sj : Stream joint

id : Chunk input/output ID (SJ_LIN_DATA / SJ_LIN_FREE)

ck : Data chunk (data starting address/size)

Outputs

None

Return Value

None

Description

When a data chunk that was gotten was actually written or read, this function puts the area (data chunk) that was read/written back to the stream joint.

[Menu]

SJ_GetNumData
Gets the amount of data that can be read/written

Format
Sint32 SJ_GetNumData(SJ sj, Sint32 id);
Inputs

sj : Stream joint

id : Chunk input/output ID (SJ_LIN_DATA / SJ_LIN_FREE)

Outputs

None

Return Value

Amount of data that can be read/written (unit: bytes)

- When writing: Amount of free space.

- When reading: Amount of data.

Description

When writing data to a stream joint, this function gets the free space in the buffer; when reading data, this function gets the amount of data in the buffer.

[Menu]

SJ_GetUuid
Gets the stream joint UUID

Format
UUID *SJ_GetUuid(SJ sj);
Inputs

sj : Stream joint

Outputs

None

Return Value

Stream joint UUID

Description

This function gets the stream joint UUID.

[Menu]

SJ_EntryErrFunc
Registers an error processing function

Format
void SJ_EntryErrFunc(SJ sj, Sint32 id,

void (*func)(void *obj, Sint32 ecode), void *obj);

Inputs

sj : Stream joint

id : Chunk input/output ID (SJ_LIN_DATA / SJ_LIN_FREE)

func : Function to be called when an error occurs

obj : First parameter of "func" function

Outputs

None

Return Value

None

Description

This function registers which function is to be called when an error is generated.

If "NULL" is set for "func", no error processing function is registered.

[Menu]

SJ_SplitChunk
Splits a data chunk

Format
void SJ_SplitChunk(SJCK *ck, Sint32 nbyte, SJCK *ck1, SJCK *ck2);
Inputs

ck : Data chunk to be split

nbyte : Size of ck1 (unit: bytes)

Outputs

ck1 : First half of data chunk that was split

ck2 : Second half of data chunk that was split

Return Value

Size of data chunk ck2 (unit: bytes)

Description

This function splits the data chunk ck into data chunks ck1 and ck2.

ck1 has a length indicated by "nbyte".

If the size of ck1 is less than the value of "nbyte", the chunk is not split and ck is substituted into ck1. The size of ck2 is then "0".

The same value may be specified for ck1 and ck.

To simply split a chunk, use the following description.

Example

    	SJ_SplitChunk(&ck, 100, &ck, &ck2);

[Menu]

SJRBF_Init
Initialization

Format
void SJRBF_Init(void);
Inputs

None

Outputs

None

Return Value

None

Description

This function initializes a ring buffer-type stream joint.

[Menu]

SJRBF_Create
Stream joint creation

Format
SJ SJRBF_Create(Sint8 *buf, Sint32 bsize, Sint32 xsize);
Inputs

buf : Ring buffer

bsize : Size of ring buffer (unit: bytes)

xsize : Size of extra buffer (unit: bytes)

Outputs

None

Return Value

Stream joint

Description

This function creates a ring buffer-type stream joint.

The buffer allocated by 'bsize+xsize' is specified to 'buf'.

[Menu]

SJMEM_Init
Initialization

Format
void SJMEM_Init(void);
Inputs

None

Outputs

None

Return Value

None

Description

This function initializes a memory-type stream joint.

[Menu]

SJMEM_Create
Stream joint creation

Format
SJ SJMEM_Create(Sint8 *data, Sint32 bsize);
Inputs

data : Data area

bsize : Data size (unit: bytes)

Outputs

None

Return Value

Stream joint

Description

This function creates a memory-type stream joint.

[Menu]

SJUNI_Init
Initialization

Format
void SJUNI_Init(void);
Inputs

None

Outputs

None

Return Value

None

Description

This function initializes a general-purpose stream joint.

[Menu]

SJUNI_Create
Stream joint creation

Format
SJ SJUNI_Create(Sint32 mode, Sint8 *work, Sint32 wksize);
Inputs

mode : Linking mode (SJUNI_MODE_SEPA, SJUNI_MODE_JOIN)

work : Work area

wksize : Size of work area

Outputs

None

Return Value

Stream joint

Description

This function creates a general-purpose stream joint.

If this stream joint will handle separated data chunks, specify SJUNI_MODE_SEPA. If this stream joint will handle linked data chunks, specify SJUNI_MODE_JOIN.

Allocate a work area that can accommodate the maximum number of data chunks that the stream joint will handle, and pass "work" and "wksize" as parameters.

Example

    #define MAX_NCK    (256)
    Sint8 work[SJUNI_CALC_WORK(MAX_NCK)];
    sj = SJUNI_Create(SJUNI_MODE_SEPA, work, sizeof(work));

Copyright (c) 2001-2006 CRI Middleware Co.,LTD.