home *** CD-ROM | disk | FTP | other *** search
- #define __USE_SYSBASE
- #include <proto/exec.h>
- #include <exec/memory.h>
- #include <proto/dos.h>
- #include <proto/BigNum.h>
- #include <proto/timer.h>
- #include <devices/timer.h>
- #include <string.h>
-
- #define MEM MEMF_FAST|MEMF_CLEAR
- #define TEMPLATE "Lucas exposant/N"
- #define TXT "I need an exponant !\n"
- #define WARN "Needs BigNum.library v37 !!\n"
-
- void maine(void)
- {
- struct DosLibrary *DOSBase;
- struct ExecBase *SysBase;
- struct Library *BigNumBase;
- struct Library *TimerBase;
- struct timerequest *tr;
- struct timeval aa,bb;
- struct RDArgs *rdargs;
- long opts[2];
- short ret;
-
- SysBase=*((struct ExecBase **)4);
- opts[0]=opts[1]=0;
- if(DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",37))
- {
- if(BigNumBase=OpenLibrary("BigNum.library",37))
- {
- if(tr=(struct timerequest *)AllocVec(sizeof(struct timerequest),MEM))
- {
- if(!(OpenDevice("timer.device",UNIT_MICROHZ,(struct IORequest *)tr,0)))
- {
- TimerBase=(struct Library *)tr->tr_node.io_Device;
- if(rdargs=ReadArgs(TEMPLATE,opts,NULL))
- {
- if(opts[0])
- {
- GetSysTime(&aa);
- ret=BigNumLucasLehmer(*((int *)opts[0]));
- GetSysTime(&bb);
- SubTime(&bb,&aa);
- Printf("\n(%ld.%05ld s)\n\n",bb.tv_secs,bb.tv_micro);
- if(ret)
- PutStr("Prime\n");
- else
- PutStr("Not Prime\n");
- }
- else
- Printf(TXT);
- FreeArgs(rdargs);
- }
- CloseDevice((struct IORequest *)tr);
- }
- else
- PrintFault(IoErr(),NULL);
- FreeVec(tr);
- }
- CloseLibrary(BigNumBase);
- }
- else
- Printf(WARN);
- CloseLibrary((struct Library *)DOSBase);
- }
- }
-