rtxBigInt.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2003-2010 Objective Systems, Inc.
00003  *
00004  * This software is furnished under a license and may be used and copied
00005  * only in accordance with the terms of such license and with the
00006  * inclusion of the above copyright notice. This software or any other
00007  * copies thereof may not be provided or otherwise made available to any
00008  * other person. No title to and ownership of the software is hereby
00009  * transferred.
00010  *
00011  * The information in this software is subject to change without notice
00012  * and should not be construed as a commitment by Objective Systems, Inc.
00013  *
00014  * PROPRIETARY NOTICE
00015  *
00016  * This software is an unpublished work subject to a confidentiality agreement
00017  * and is protected by copyright and trade secret law.  Unauthorized copying,
00018  * redistribution or other use of this work is prohibited.
00019  *
00020  * The above notice of copyright on this source code product does not indicate
00021  * any actual or intended publication of such source code.
00022  *
00023  *****************************************************************************/
00028 #ifndef _RTXBIGINT_H_
00029 #define _RTXBIGINT_H_
00030 
00031 #include "rtxsrc/rtxContext.h"
00032 
00033 /* Big Integer */
00034 
00035 typedef struct OSBigInt {
00036    int       numocts;           /* number of used octets in mag         */
00037    OSOCTET   *mag;              /* magnitude                            */
00038    int       sign;              /* sign, can be -1, 0, 1                */
00039 
00040    int       allocated;         /* number of allocated octets for mag   */
00041    OSBOOL    dynamic;           /* is buffer dynamic?                   */
00042 } OSBigInt;
00043 
00044 
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif
00048 
00049 /* BigInt functions */
00050 
00051 EXTERNRT void rtxBigIntInit (OSBigInt* pInt);
00052 EXTERNRT int  rtxBigIntSetStr (OSCTXT* pCtxt, OSBigInt* pInt,
00053                                 const char* value, int radix);
00054 EXTERNRT int  rtxBigIntSetInt64 (OSCTXT* pCtxt, OSBigInt* pInt,
00055                                   OSINT64 value);
00056 EXTERNRT int  rtxBigIntSetUInt64 (OSCTXT* pCtxt, OSBigInt* pInt,
00057                                    OSUINT64 value);
00058 EXTERNRT int  rtxBigIntSetBytes (OSCTXT* pCtxt, OSBigInt* pInt,
00059                                   OSOCTET* value, int vallen);
00060 EXTERNRT int  rtxBigIntGetDataLen (const OSBigInt* pInt);
00061 EXTERNRT int  rtxBigIntGetData (OSCTXT* pCtxt, const OSBigInt* pInt,
00062                                  OSOCTET* buffer, int bufSize);
00063 EXTERNRT int  rtxBigIntDigitsNum (const OSBigInt* pInt, int radix);
00064 EXTERNRT int  rtxBigIntCopy (OSCTXT* pCtxt, const OSBigInt* pSrc, OSBigInt* pDst);
00065 EXTERNRT int  rtxBigIntFastCopy (OSCTXT* pCtxt, const OSBigInt* pSrc, OSBigInt* pDst);
00066 EXTERNRT int  rtxBigIntToString (OSCTXT* pCtxt, const OSBigInt* pInt, int radix,
00067                                   char* str, int strSize);
00068 EXTERNRT int  rtxBigIntPrint (const OSUTF8CHAR* name, const OSBigInt* bigint, int radix);
00069 EXTERNRT int  rtxBigIntCompare (const OSBigInt* arg1, const OSBigInt* arg2);
00070 EXTERNRT int  rtxBigIntStrCompare (OSCTXT* pCtxt, const char* arg1,
00071                                     const char* arg2);
00072 EXTERNRT void rtxBigIntFree (OSCTXT* pCtxt, OSBigInt* pInt);
00073 
00074 /* Arithmetic */
00075 EXTERNRT int rtxBigIntAdd
00076    (OSCTXT* pctxt,
00077     OSBigInt* result, const OSBigInt* arg1, const OSBigInt* arg2);
00078 
00079 EXTERNRT int rtxBigIntSubtract
00080    (OSCTXT* pctxt,
00081     OSBigInt* result, const OSBigInt* arg1, const OSBigInt* arg2);
00082 
00083 EXTERNRT int rtxBigIntMultiply
00084    (OSCTXT* pctxt,
00085     OSBigInt* result, const OSBigInt* arg1, const OSBigInt* arg2);
00086 
00087 /* Common */
00088 EXTERNRT unsigned short rtxBigIntBitsPerDigit (int radix);
00089 EXTERNRT short rtxBigIntDigitsPerByte (int halfRadix);
00090 EXTERNRT short rtxBigIntByteRadix (int halfRadix);
00091 
00092 #ifdef __cplusplus
00093 }
00094 #endif
00095 
00096 #endif /* RTXBIGINT */
00097