-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlrs.c
67 lines (46 loc) · 1.38 KB
/
lrs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <stdlib.h>
#include <limits.h>
#include "lrsdriver.h"
int
main (int argc, char *argv[])
{
#ifndef MA
lrs_main(argc,argv); /* legacy lrs */
return 0;
#else
/* multiple arithmetic lrs */
char** newargv;
char* tmp; /* when overflow occurs a new input file name is returned */
long overfl=0; /* =0 no overflow =1 restart overwrite =2 restart append */
int lrs_stdin=0;
int i;
if(argc == 1)
lrs_stdin=1;
tmp = malloc(PATH_MAX * sizeof (char));
if ( (overfl=lrs1_main(argc,argv,0,tmp)) == 0)
goto byebye;
/* overflow condition triggered: a temporary file was created for restart */
/* create new argv for the remaining calls */
newargv = makenewargv(&argc,argv,tmp);
#ifdef B128
fprintf(stderr,"\n*lrs:overflow possible: restarting with 128 bit arithmetic\n");
if ( (overfl=lrs2_main(argc,newargv,overfl,tmp)) == 0)
goto done;
#endif
fprintf(stderr,"\n*lrs:overflow possible: restarting with GMP arithmetic\n");
/* if you change tmp file name update newargv[1] */
overfl=lrsgmp_main(argc,newargv,overfl,tmp);
done:
for(i = 0; i < argc; ++i)
free(newargv[i]);
free(newargv);
byebye:
if(lrs_stdin==1) /* get rid of temporary file for stdin */
remove(tmp);
free(tmp);
return overfl;
#endif
}