33 #include "rtxsrc/rtxSList.h" 36 #define MIN_STREAM_BACKOFF 0 51 EXTERNRT
int rtxCheckBuffer (
OSCTXT* pctxt,
size_t nbytes);
109 EXTERNRT
int rtxCheckInputBuffer (
OSCTXT* pctxt,
size_t nbytes);
111 EXTERNRT
int rtxCopyAsciiText (
OSCTXT* pctxt,
const char* text);
113 EXTERNRT
int rtxCopyUTF8Text (
OSCTXT* pctxt,
const OSUTF8CHAR* text);
115 EXTERNRT
int rtxCopyUnicodeText (
OSCTXT* pctxt,
const OSUNICHAR* text);
130 (
OSCTXT* pctxt, OSOCTET* buffer,
size_t bufsize,
size_t nocts);
160 (
OSCTXT* pctxt, OSOCTET** ppdata,
size_t nocts, OSBOOL* pMemAlloc);
171 (
OSCTXT* pctxt,
const OSOCTET* pdata,
size_t nocts);
245 #define OSRTPUTCHAR(pctxt,ch) rtxWriteBytes (pctxt, (OSOCTET*)&ch, 1) 247 #define OSRTPUTCHARREV(pctxt,ch) \ 248 (pctxt)->buffer.data[--(pctxt)->buffer.byteIndex]=(OSOCTET)ch; 250 #define OSRTZTERM(pctxt) \ 251 (pctxt)->buffer.data[(pctxt)->buffer.byteIndex]=(OSOCTET)0; 253 #define OSRTSAFEZTERM(pctxt) \ 255 if (rtxCheckOutputBuffer (pctxt, 1) == 0) \ 256 (pctxt)->buffer.data[(pctxt)->buffer.byteIndex]=(OSOCTET)0; \ 257 else return LOG_RTERRNEW (pctxt, RTERR_BUFOVFLW); \ 260 #define OSRTSAFEPUTCHAR(pctxt,ch) \ 262 if (rtxCheckOutputBuffer (pctxt, 1) == 0) \ 264 (pctxt)->buffer.data[(pctxt)->buffer.byteIndex++]=(OSOCTET)ch; \ 265 else return LOG_RTERRNEW (pctxt, RTERR_BUFOVFLW); \ 268 #define OSRTSAFEPUTCHAR1(pctxt,ch,stat) \ 270 OSOCTET b = (OSOCTET)ch; \ 271 rtxWriteBytes (pctxt, &b, 1); \ 275 #define OSRTSAFEPUTCHAR2(pctxt,ch,prealloc) \ 277 if (rtxCheckOutputBuffer (pctxt, ((prealloc > 1)?prealloc:1)) == 0) \ 279 (pctxt)->buffer.data[(pctxt)->buffer.byteIndex++]=(OSOCTET)ch; \ 280 else return LOG_RTERRNEW (pctxt, RTERR_BUFOVFLW); \ 284 #define OSRTMEMCPY(pctxt,bdata,len) \ 286 OSCRTLSAFEMEMCPY (&(pctxt)->buffer.data[(pctxt)->buffer.byteIndex], \ 287 (pctxt)->buffer.size-(pctxt)->buffer.byteIndex, bdata, len); \ 288 (pctxt)->buffer.byteIndex += len; \ 289 (pctxt)->lastChar = (pctxt)->buffer.data[(pctxt)->buffer.byteIndex-1]; \ 292 #define OSRTMEMCPYREV(pctxt,bdata,len) \ 294 (pctxt)->buffer.byteIndex -= len; \ 295 OSCRTLSAFEMEMCPY (&(pctxt)->buffer.data[(pctxt)->buffer.byteIndex], \ 296 (pctxt)->buffer.size-(pctxt)->buffer.byteIndex, bdata, len); \ 299 #define OSRTSAFEMEMCPY(pctxt,bdata,len) \ 301 if (rtxCheckOutputBuffer (pctxt, len) == 0) { \ 302 OSCRTLMEMCPY (&(pctxt)->buffer.data[(pctxt)->buffer.byteIndex], bdata, len); \ 303 (pctxt)->buffer.byteIndex += len; \ 304 (pctxt)->lastChar = (pctxt)->buffer.data[(pctxt)->buffer.byteIndex-1]; } \ 305 else return LOG_RTERRNEW (pctxt, RTERR_BUFOVFLW); \ 308 #define OSRTSAFEMEMCPY1(pctxt,bdata,len,stat) \ 310 if (rtxCheckOutputBuffer (pctxt, len) == 0) { \ 311 OSCRTLMEMCPY (&(pctxt)->buffer.data[(pctxt)->buffer.byteIndex], bdata, len); \ 312 (pctxt)->buffer.byteIndex += len; \ 313 (pctxt)->lastChar = (pctxt)->buffer.data[(pctxt)->buffer.byteIndex-1]; \ 315 else stat = RTERR_BUFOVFLW; \ 318 #define OSRTGETBUFUTF8LEN(pctxt) \ 319 rtxCalcUTF8Len (OSRTBUFPTR (pctxt), OSRTBUFSIZE (pctxt)) 321 #define OSRTCHKBUFUTF8LEN(pctxt,lower,upper,stat) \ 322 do { size_t nchars = OSRTGETBUFUTF8LEN (pctxt); \ 323 stat = (nchars >= lower && nchars <= upper) ? 0 : RTERR_CONSVIO; } while(0) 325 #define OSRTENDOFBUF(pctxt) ((pctxt)->buffer.byteIndex >= (pctxt)->buffer.size) EXTERNRT int rtxReadBytes(OSCTXT *pctxt, OSOCTET *pdata, size_t nocts)
This function reads bytes from the currently open stream or memory buffer.
EXTERNRT int rtxFlushOutputBuffer(OSCTXT *pctxt)
This function flushes the buffer to a stream.
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...
Buffer location descriptor.
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 rtxExpandOutputBuffer(OSCTXT *pctxt, size_t nbytes)
This function attempts to ensure the output buffer has at least the given number of bytes available...
EXTERNRT int rtxWriteBytes(OSCTXT *pctxt, const OSOCTET *pdata, size_t nocts)
This function writes bytes to the currently open stream or memory buffer.
Common run-time context definitions.
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 OSBOOL rtxIsOutputBufferFlushable(OSCTXT *pctxt)
This function returns true if the context buffer can be flushed to a stream by calling rtxFlushOutput...
struct _OSRTBufLocDescr OSRTBufLocDescr
Buffer location descriptor.
EXTERNRT void rtxGetBufLocDescr(OSCTXT *pctxt, OSRTBufLocDescr *pDescr)
Set the buffer location description's offset (pDescr->offset) to the current position in pCtxt's buff...
EXTERNRT OSBOOL rtxCanonicalSort(OSOCTET *refPoint, OSRTSList *pList, OSBOOL normal)
Sort a list of buffer locations, referring to component encodings, by comparing the referenced encodi...
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 void rtxAddBufLocDescr(OSCTXT *pctxt, OSRTSList *pElemList, OSRTBufLocDescr *pDescr)
Create a new Asn1BufLocDescr for an element just encoded and append it to pElemList.
Run-time context structure.