35 assert(
isWritePtr( length,
sizeof(
long ) ) );
40 *indefiniteLength =
FALSE;
44 localLength = sgetc( stream );
46 return( localLength );
49 if( localLength <= 191 )
51 *length = localLength;
57 if( localLength <= 223 )
59 const int value = sgetc( stream );
62 localLength = ( ( localLength - 192 ) << 8 ) + value + 192;
63 if( localLength < 192 || localLength > 8383 )
65 *length = localLength;
75 if( localLength < 255 )
87 *indefiniteLength =
TRUE;
88 localLength = 1 << ( localLength & 0x1F );
91 *length = localLength;
98 localLength = readUint32( stream );
100 return( localLength );
101 *length = localLength;
114 assert(
isWritePtr( length,
sizeof(
long ) ) );
123 localLength = sgetc( stream );
127 localLength = readUint16( stream );
131 localLength = readUint32( stream );
141 return( localLength );
144 *length = localLength;
167 assert(
isWritePtr( length,
sizeof(
long ) ) );
182 status = readOpenPGPLength( stream, &localLength,
183 &indefiniteLength, indefOK );
186 status = readPGP2Length( stream, &localLength, ctb );
189 if( localLength < minLength || localLength > maxLength )
191 *length = localLength;
207 assert( ctb == NULL ||
isWritePtr( ctb,
sizeof(
int ) ) );
208 assert( length == NULL ||
isWritePtr( length,
sizeof(
long ) ) );
221 localCTB = sgetc( stream );
253 status = pgpReadLength( stream, &localLength, localCTB,
254 minLength, maxLength, indefOK );
274 *length = localLength;
289 status = pgpReadLength( stream, &localLength, ctb, 0,
293 *length = ( int ) localLength;
304 assert( ctb == NULL ||
isWritePtr( ctb,
sizeof(
int ) ) );
305 assert( length == NULL ||
isWritePtr( length,
sizeof(
long ) ) );
309 return( readPacketHeader( stream, ctb, length, minLength,
MAX_INTLENGTH,
319 assert( ctb == NULL ||
isWritePtr( ctb,
sizeof(
int ) ) );
320 assert( length == NULL ||
isWritePtr( length,
sizeof(
long ) ) );
324 return( readPacketHeader( stream, ctb, length, minLength,
MAX_INTLENGTH,
333 assert(
isWritePtr( length,
sizeof(
long ) ) );
351 return( sputc( stream, length ) );
354 const long adjustedLength = length - 192;
356 sputc( stream, ( ( adjustedLength >> 8 ) & 0xFF ) + 192 );
357 return( sputc( stream, ( adjustedLength & 0xFF ) ) );
359 sputc( stream, 0xFF );
360 sputc( stream, ( length >> 24 ) & 0xFF );
361 sputc( stream, ( length >> 16 ) & 0xFF );
362 sputc( stream, ( length >> 8 ) & 0xFF );
363 return( sputc( stream, ( length & 0xFF ) ) );
378 return( pgpWriteLength( stream, length ) );