/* * Copyright (c) 2006, John P. T. Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. Neither the name of the author nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include "encode.h" #include "decode.h" int writeMessage(int fd, char *buf, int bufsize); int readMessage(int fd, char *buf, int bufsize); void encodeBoolean(packedEncode *memBuf, int flag); int decodeBoolean(packedDecode *memBuf); void encodeConstrainedBitString(packedEncode *memBuf, char *s, int lb, int ub); char *decodeConstrainedBitString(packedDecode *memBuf, char *s, int lb, int ub); void encodeFixedLengthBitString(packedEncode *memBuf, char *s, int len); char *decodeFixedLengthBitString(packedDecode *memBuf, char *s, int len); void encodeSemiConstrainedBitString(packedEncode *memBuf, char *s); char *decodeSemiConstrainedBitString(packedDecode *memBuf, char *s); void encodeFixedLengthHexString(packedEncode *memBuf, char *s, int len); char *decodeFixedLengthHexString(packedDecode *memBuf, char *s, int len); void encodeConstrainedHexString(packedEncode *memBuf, char *s, int lb, int ub); char *decodeConstrainedHexString(packedDecode *memBuf, char *s, int lb, int ub); void encodeSemiConstrainedHexString(packedEncode *memBuf, char *s); char *decodeSemiConstrainedHexString(packedDecode *memBuf, char *s); void encodeFixedLengthNumericString(packedEncode *memBuf, char *s, int len); char *decodeFixedLengthNumericString(packedDecode *memBuf, char *s, int len); void encodeConstrainedNumericString(packedEncode *memBuf, char *s, int lb, int ub); char *decodeConstrainedNumericString(packedDecode *memBuf, char *s, int lb, int ub); void encodeSemiConstrainedNumericString(packedEncode *memBuf, char *s); char *decodeSemiConstrainedNumericString(packedDecode *memBuf, char *s); void encodeFixedLengthString(packedEncode *membuf, char *s, int len); char *decodeFixedLengthString(packedDecode *memBuf, char *s, int len); void encodeConstrainedString(packedEncode *memBuf, char *s, int lb, int ub); char *decodeConstrainedString(packedDecode *memBuf, char *s, int lb, int ub); void encodeSemiConstrainedString(packedEncode *memBuf, char *s); char *decodeSemiConstrainedString(packedDecode *memBuf, char *s); void encodeFixedLengthOctetString(packedEncode *membuf, char *s, int len); char *decodeFixedLengthOctetString(packedDecode *memBuf, char *s, int len); void encodeConstrainedOctetString(packedEncode *memBuf, char *s, int lb, int ub); char *decodeConstrainedOctetString(packedDecode *memBuf, char *s, int lb, int ub); void encodeSemiConstrainedOctetString(packedEncode *memBuf, char *s); char *decodeSemiConstrainedOctetString(packedDecode *memBuf, char *s); void encodeUnconstrainedInteger(packedEncode *memBuf, signed long int n); signed long int decodeUnconstrainedInteger(packedDecode *memBuf); void encodeUnsignedConstrainedInteger(packedEncode *memBuf, unsigned long int n, unsigned lb, unsigned ub); unsigned long int decodeUnsignedConstrainedInteger(packedDecode *memBuf, unsigned lb, unsigned ub); void encodeSignedConstrainedInteger(packedEncode *memBuf, signed long int n, int lb, int ub); signed long int decodeSignedConstrainedInteger(packedDecode *memBuf, int lb, int ub); void encodeSignedSemiConstrainedInteger(packedEncode *memBuf, signed long int n, int lb); signed long int decodeSignedSemiConstrainedInteger(packedDecode *memBuf, int lb); void encodeUnsignedSemiConstrainedInteger(packedEncode *memBuf, unsigned long int n, unsigned lb); unsigned long int decodeUnsignedSemiConstrainedInteger(packedDecode *memBuf, unsigned lb); void encodeEnumerated(packedEncode *memBuf, unsigned long int n, unsigned len); unsigned long int decodeEnumerated(packedDecode *memBuf, unsigned len); void encodeSetBitmap(packedEncode *memBuf, char *bitmap, int len); char *decodeSetBitmap(packedDecode *memBuf, char *s, int len); void encodeChoiceIndex(packedEncode *memBuf, unsigned long int n, unsigned len); unsigned long int decodeChoiceIndex(packedDecode *memBuf, unsigned len); void encodeSequenceOfLength(packedEncode *memBuf, int len); int decodeSequenceOfLength(packedDecode *memBuf);