33 #include "rtxsrc/rtxSList.h" 36 #define MIN_STREAM_BACKOFF 0 60 EXTERNRT
int rtxCheckBuffer (
OSCTXT* pctxt,
size_t nbytes);
133 EXTERNRT
int rtxCopyAsciiText (
OSCTXT* pctxt,
const char* text);
135 EXTERNRT
int rtxCopyUTF8Text (
OSCTXT* pctxt,
const OSUTF8CHAR* text);
137 EXTERNRT
int rtxCopyUnicodeText (
OSCTXT* pctxt,
const OSUNICHAR* text);
185 OSSIZE nocts, OSSIZE* pactual);
200 (
OSCTXT* pctxt, OSOCTET* buffer,
size_t bufsize,
size_t nocts);
230 (
OSCTXT* pctxt, OSOCTET** ppdata,
size_t nocts, OSBOOL* pMemAlloc);
241 (
OSCTXT* pctxt,
const OSOCTET* pdata,
size_t nocts);
373 #define OSRTPUTCHAR(pctxt,ch) rtxWriteBytes (pctxt, (OSOCTET*)&ch, 1) 375 #define OSRTPUTCHARREV(pctxt,ch) \ 376 (pctxt)->buffer.data[--(pctxt)->buffer.byteIndex]=(OSOCTET)ch; 378 #define OSRTZTERM(pctxt) \ 379 (pctxt)->buffer.data[(pctxt)->buffer.byteIndex]=(OSOCTET)0; 381 #define OSRTSAFEZTERM(pctxt) \ 383 if (rtxCheckOutputBuffer (pctxt, 1) == 0) \ 384 (pctxt)->buffer.data[(pctxt)->buffer.byteIndex]=(OSOCTET)0; \ 385 else return LOG_RTERRNEW (pctxt, RTERR_BUFOVFLW); \ 388 #define OSRTSAFEPUTCHAR(pctxt,ch) \ 390 if (rtxCheckOutputBuffer (pctxt, 1) == 0) \ 392 (pctxt)->buffer.data[(pctxt)->buffer.byteIndex++]=(OSOCTET)ch; \ 393 else return LOG_RTERRNEW (pctxt, RTERR_BUFOVFLW); \ 400 #define OSRTSAFEPUTCHAR_ZTERM(pctxt,ch) \ 402 if (rtxCheckOutputBuffer (pctxt, 2) == 0) { \ 404 (pctxt)->buffer.data[(pctxt)->buffer.byteIndex++]=(OSOCTET)ch; \ 405 (pctxt)->buffer.data[(pctxt)->buffer.byteIndex]=(OSOCTET)0; } \ 406 else return LOG_RTERRNEW (pctxt, RTERR_BUFOVFLW); \ 410 #define OSRTSAFEPUTCHAR1(pctxt,ch,stat) \ 412 OSOCTET b = (OSOCTET)ch; \ 413 rtxWriteBytes (pctxt, &b, 1); \ 417 #define OSRTSAFEPUTCHAR2(pctxt,ch,prealloc) \ 419 if (rtxCheckOutputBuffer (pctxt, ((prealloc > 1)?prealloc:1)) == 0) \ 421 (pctxt)->buffer.data[(pctxt)->buffer.byteIndex++]=(OSOCTET)ch; \ 422 else return LOG_RTERRNEW (pctxt, RTERR_BUFOVFLW); \ 426 #define OSRTMEMCPY(pctxt,bdata,len) \ 428 OSCRTLSAFEMEMCPY (&(pctxt)->buffer.data[(pctxt)->buffer.byteIndex], \ 429 (pctxt)->buffer.size-(pctxt)->buffer.byteIndex, bdata, len); \ 430 (pctxt)->buffer.byteIndex += len; \ 431 (pctxt)->lastChar = (pctxt)->buffer.data[(pctxt)->buffer.byteIndex-1]; \ 434 #define OSRTMEMCPYREV(pctxt,bdata,len) \ 436 (pctxt)->buffer.byteIndex -= len; \ 437 OSCRTLSAFEMEMCPY (&(pctxt)->buffer.data[(pctxt)->buffer.byteIndex], \ 438 (pctxt)->buffer.size-(pctxt)->buffer.byteIndex, bdata, len); \ 441 #define OSRTSAFEMEMCPY(pctxt,bdata,len) \ 443 if (rtxCheckOutputBuffer (pctxt, len) == 0) { \ 444 OSCRTLMEMCPY (&(pctxt)->buffer.data[(pctxt)->buffer.byteIndex], bdata, len); \ 445 (pctxt)->buffer.byteIndex += len; \ 446 (pctxt)->lastChar = (pctxt)->buffer.data[(pctxt)->buffer.byteIndex-1]; } \ 447 else return LOG_RTERRNEW (pctxt, RTERR_BUFOVFLW); \ 450 #define OSRTSAFEMEMCPY1(pctxt,bdata,len,stat) \ 452 if (rtxCheckOutputBuffer (pctxt, len) == 0) { \ 453 OSCRTLMEMCPY (&(pctxt)->buffer.data[(pctxt)->buffer.byteIndex], bdata, len); \ 454 (pctxt)->buffer.byteIndex += len; \ 455 (pctxt)->lastChar = (pctxt)->buffer.data[(pctxt)->buffer.byteIndex-1]; \ 457 else stat = RTERR_BUFOVFLW; \ 460 #define OSRTGETBUFUTF8LEN(pctxt) \ 461 rtxCalcUTF8Len (OSRTBUFPTR (pctxt), OSRTBUFSIZE (pctxt)) 463 #define OSRTCHKBUFUTF8LEN(pctxt,lower,upper,stat) \ 464 do { size_t nchars = OSRTGETBUFUTF8LEN (pctxt); \ 465 stat = (nchars >= lower && nchars <= upper) ? 0 : RTERR_CONSVIO; } while(0) 467 #define OSRTENDOFBUF(pctxt) ((pctxt)->buffer.byteIndex >= (pctxt)->buffer.size) 469 #define OSRTByteAlign(pctxt) \ 470 if ((pctxt)->buffer.bitOffset != 8) { \ 471 (pctxt)->buffer.byteIndex++; \ 472 (pctxt)->buffer.bitOffset = 8; } \ EXTERNRT size_t rtxGetIndentLevels(OSCTXT *pctxt)
This returns the number of levels of indentation set in the given context.
EXTERNRT int rtxExpandOutputBuffer(OSCTXT *pctxt, size_t nbytes)
This function attempts to ensure the output buffer has at least the given number of bytes available...
struct _OSRTBufLocDescr OSRTBufLocDescr
Buffer location descriptor.
EXTERNRT int rtxReadBytes(OSCTXT *pctxt, OSOCTET *pdata, size_t nocts)
This function reads bytes from the currently open stream or memory buffer.
EXTERNRT OSBOOL rtxIsOutputBufferFlushable(OSCTXT *pctxt)
This function returns true if the context buffer can be flushed to a stream by calling rtxFlushOutput...
EXTERNRT int rtxFlushOutputBuffer(OSCTXT *pctxt)
This function flushes the buffer to a stream.
EXTERNRT int rtxCheckOutputBuffer(OSCTXT *pctxt, size_t nbytes)
This function checks to ensure that the output buffer has sufficient space to hold an additional nbyt...
EXTERNRT int rtxWriteBytes(OSCTXT *pctxt, const OSOCTET *pdata, size_t nocts)
This function writes bytes to the currently open stream or memory buffer.
EXTERNRT int rtxReadBytesSafe(OSCTXT *pctxt, OSOCTET *buffer, size_t bufsize, size_t nocts)
This function safely reads bytes from the currently open stream or memory buffer into the given stati...
EXTERNRT int rtxPeekBytes(OSCTXT *pctxt, OSOCTET *pdata, OSSIZE bufsize, OSSIZE nocts, OSSIZE *pactual)
This function peeks at the next nocts bytes of input, peeking at fewer bytes if EOF is encountered fi...
Buffer location descriptor.
EXTERNRT OSBOOL rtxCanonicalSort(OSOCTET *refPoint, OSRTSList *pList, OSBOOL normal)
Sort a list of buffer locations, referring to component encodings, by comparing the referenced encodi...
Common run-time context definitions.
EXTERNRT void rtxIndentReset(OSCTXT *pctxt)
This resets the indentation level in the given context to zero.
EXTERNRT int rtxReadBytesDynamic(OSCTXT *pctxt, OSOCTET **ppdata, size_t nocts, OSBOOL *pMemAlloc)
This function reads bytes from the currently open stream or memory buffer.
EXTERNRT int rtxCheckInputBuffer(OSCTXT *pctxt, size_t nbytes)
Ensures the given number of bytes are available in the context buffer.
EXTERNRT void rtxIndentIncr(OSCTXT *pctxt)
This increases the indentation level set in the given context by updating the indent member...
EXTERNRT int rtxWriteIndent(OSCTXT *pctxt)
This function writes a newline followed by indentation whitespace to the buffer.
EXTERNRT int rtxEncCanonicalSort(OSCTXT *pctxt, OSCTXT *pMemCtxt, OSRTSList *pList)
Encode the encodings held in pMemCtxt into pctxt, first sorting them as required for canonical BER (a...
EXTERNRT void rtxGetBufLocDescr(OSCTXT *pctxt, OSRTBufLocDescr *pDescr)
Set the buffer location description's offset (pDescr->offset) to the current position in pCtxt's buff...
Run-time context structure.
EXTERNRT int rtxPeekByte(OSCTXT *pctxt, OSOCTET *pbyte)
This function peeks at the next byte of input, if there is one before EOF.
EXTERNRT void rtxAddBufLocDescr(OSCTXT *pctxt, OSRTSList *pElemList, OSRTBufLocDescr *pDescr)
Create a new Asn1BufLocDescr for an element just encoded and append it to pElemList.
EXTERNRT void rtxIndentDecr(OSCTXT *pctxt)
This decreases the indentation level set in the given context by updating the indent member...
EXTERNRT int rtxLoadInputBuffer(OSCTXT *pctxt, OSSIZE nbytes)
This is for meant for internal use by the runtime.