Back to index

lightning-sunbird  0.9+nobinonly
Functions
makeprime.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "mpi.h"
#include "mpprime.h"

Go to the source code of this file.

Functions

mp_err make_prime (mp_int *p, int nr)
int main (int argc, char *argv[])

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 70 of file makeprime.c.

{
  mp_int    start;
  mp_err    res;

  if(argc < 2) {
    fprintf(stderr, "Usage: %s <start-value>\n", argv[0]);
    return 1;
  }
           
  mp_init(&start);
  if(argv[1][0] == '0' && tolower(argv[1][1]) == 'x') {
    mp_read_radix(&start, argv[1] + 2, 16);
  } else {
    mp_read_radix(&start, argv[1], 10);
  }
  mp_abs(&start, &start);

  if((res = make_prime(&start, 5)) != MP_OKAY) {
    fprintf(stderr, "%s: error: %s\n", argv[0], mp_strerror(res));
    mp_clear(&start);

    return 1;

  } else {
    char  *buf = malloc(mp_radix_size(&start, 10));

    mp_todecimal(&start, buf);
    printf("%s\n", buf);
    free(buf);
    
    mp_clear(&start);

    return 0;
  }
  
} /* end main() */

Here is the call graph for this function:

mp_err make_prime ( mp_int p,
int  nr 
)