Home > Support > Documentation

rtxBigInt.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2003-2007 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 EXTERNRTX void rtxBigIntInit (OSBigInt* pInt);
00052 EXTERNRTX int  rtxBigIntSetStr (OSCTXT* pCtxt, OSBigInt* pInt, 
00053                                 const char* value, int radix);
00054 EXTERNRTX int  rtxBigIntSetInt64 (OSCTXT* pCtxt, OSBigInt* pInt, 
00055                                   OSINT64 value);
00056 EXTERNRTX int  rtxBigIntSetUInt64 (OSCTXT* pCtxt, OSBigInt* pInt, 
00057                                    OSUINT64 value);
00058 EXTERNRTX int  rtxBigIntSetBytes (OSCTXT* pCtxt, OSBigInt* pInt, 
00059                                   OSOCTET* value, int vallen);
00060 EXTERNRTX int  rtxBigIntGetDataLen (const OSBigInt* pInt);
00061 EXTERNRTX int  rtxBigIntGetData (OSCTXT* pCtxt, const OSBigInt* pInt, 
00062                                  OSOCTET* buffer, int bufSize);
00063 EXTERNRTX int  rtxBigIntDigitsNum (const OSBigInt* pInt, int radix);
00064 EXTERNRTX int  rtxBigIntCopy (OSCTXT* pCtxt, const OSBigInt* pSrc, OSBigInt* pDst);
00065 EXTERNRTX int  rtxBigIntFastCopy (OSCTXT* pCtxt, const OSBigInt* pSrc, OSBigInt* pDst);
00066 EXTERNRTX int  rtxBigIntToString (OSCTXT* pCtxt, const OSBigInt* pInt, int radix, 
00067                                   char* str, int strSize);
00068 EXTERNRTX int  rtxBigIntPrint (const OSUTF8CHAR* name, const OSBigInt* bigint, int radix);
00069 EXTERNRTX int  rtxBigIntCompare (const OSBigInt* arg1, const OSBigInt* arg2);
00070 EXTERNRTX int  rtxBigIntStrCompare (OSCTXT* pCtxt, const char* arg1, 
00071                                     const char* arg2);
00072 EXTERNRTX void rtxBigIntFree (OSCTXT* pCtxt, OSBigInt* pInt);
00073 
00074 /* Arithmetic */
00075 EXTERNRTX int rtxBigIntAdd 
00076    (OSCTXT* pctxt, 
00077     OSBigInt* result, const OSBigInt* arg1, const OSBigInt* arg2);
00078 
00079 EXTERNRTX int rtxBigIntSubtract 
00080    (OSCTXT* pctxt, 
00081     OSBigInt* result, const OSBigInt* arg1, const OSBigInt* arg2);
00082 
00083 EXTERNRTX int rtxBigIntMultiply 
00084    (OSCTXT* pctxt, 
00085     OSBigInt* result, const OSBigInt* arg1, const OSBigInt* arg2);
00086 
00087 #ifdef __cplusplus
00088 }
00089 #endif
00090 
00091 #endif /* RTXBIGINT */
00092