aboutsummaryrefslogtreecommitdiffstats
path: root/tools/mpicalc.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2000-01-31 16:48:54 +0000
committerWerner Koch <[email protected]>2000-01-31 16:48:54 +0000
commitf00d949f8798530c6042734b8013554cc82ffe10 (patch)
treeadd7140501b9f2361a0b3d5c3dd61a78eb8b505d /tools/mpicalc.c
parentSee ChangeLog: Mon Jan 31 16:37:34 CET 2000 Werner Koch (diff)
downloadgnupg-f00d949f8798530c6042734b8013554cc82ffe10.tar.gz
gnupg-f00d949f8798530c6042734b8013554cc82ffe10.zip
See ChangeLog: Mon Jan 31 17:48:10 CET 2000 Werner Koch
Diffstat (limited to 'tools/mpicalc.c')
-rw-r--r--tools/mpicalc.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/tools/mpicalc.c b/tools/mpicalc.c
index 95ab47c29..aedb27ecf 100644
--- a/tools/mpicalc.c
+++ b/tools/mpicalc.c
@@ -28,9 +28,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
+#include <gcrypt.h>
#include "util.h"
-#include "mpi.h"
#include "i18n.h"
#define STACKSIZE 100
@@ -38,8 +38,8 @@ static MPI stack[STACKSIZE];
static int stackidx;
-const char *
-strusage( int level )
+static const char *
+my_strusage( int level )
{
const char *p;
switch( level ) {
@@ -56,7 +56,7 @@ strusage( int level )
"\nSyntax: mpicalc [options] [files]\n"
"MPI RPN calculator\n";
break;
- default: p = default_strusage(level);
+ default: p = NULL;
}
return p;
}
@@ -71,11 +71,35 @@ i18n_init(void)
#else
setlocale( LC_ALL, "" );
#endif
- bindtextdomain( PACKAGE, G10_LOCALEDIR );
+ bindtextdomain( PACKAGE, GNUPG_LOCALEDIR );
textdomain( PACKAGE );
#endif
}
+int
+mpi_print( FILE *fp, MPI a, int mode )
+{
+ int n=0;
+
+ if( !a )
+ return fprintf(fp, "[MPI_NULL]");
+ if( !mode ) {
+ unsigned int n1;
+ n1 = gcry_mpi_get_nbits(a);
+ n += fprintf(fp, "[%u bits]", n1);
+ }
+ else {
+ int rc;
+ char *buffer;
+
+ rc = gcry_mpi_aprint( GCRYMPI_FMT_HEX, (void **)&buffer, NULL, a );
+ fputs( buffer, fp );
+ n += strlen(buffer);
+ gcry_free( buffer );
+ }
+ return n;
+}
+
static void
do_add(void)
@@ -233,6 +257,7 @@ main(int argc, char **argv)
pargs.argv = &argv;
pargs.flags = 0;
+ set_strusage( my_strusage );
i18n_init();
while( arg_parse( &pargs, opts) ) {
switch( pargs.r_opt ) {