Big Integer as a Service
Server implementation for BigOperation (aka BigInteger - https://github.com/DoHITB/BigInteger.c).
- There's an Apache Custom Module (
mainh.c
), that gets each ".calc" request - For this, just add
AddHandler calc-handler .calc
on your Apache .htaccess file - This
calc-handler
will get the request and write a file on./f
(folder must exist befor execution). - There are two
kind
of operations to make: 1.makeOperation
, in order to enter an operation 2.getResult
, in order to get the result ofmakeOperation
. - The
BigInteger
service (plist
) will take the file, calculate, and write the result on/r
folder (appended withr_
).
You have to follow this rules:
- File name (
fileName
parameter) may not exceed 126 characters long. - File name (
fileName
parameter) may be set. - File name (
fileName
parameter) may be unique and non-existing. It will be searched among/f
and/r
folders. - Operation data (
operation
,op1
andop2
parameters) may be informed. - Operation data (
op1
andop2
parameters) may not exceed 1024 length (during beta; on release, will stand up to 4096). - Operation data (
operation
parameter) may be only 1 character long and be either+
,-
,/
,*
,^
,s
for adding, subtracting, dividing, multiplying, power, and get root of, respectively.
You have to follow this rules
- File name (
fileName
parameter) may not exceed 126 character long. - File name (
fileName
parameter) may be set. - File name (
fileName
parameter) may be unique and existing. It will be searched among/f
and/r
folders.
Getting a result will erase the /r
file.
- First, you may need to download all source code, including BigInteger (https://github.com/DoHITB/BigInteger.c).
- Edit your .htaccess file to get the handler
- Compile
mainh.c
by usingmakemain.sh
. You will needapsx
compiler from Apache developer package. Apache service will restart. - Compile
plist
by usingmakeplist.sh
. You will need to have all BigInteger source in the same folder. - Compile
plistStarter
with gcc. No special needs. - Move
plist
andplistStarter
objects to/var/www/c
. - Create folders
/var/www/c/f
and/var/www/c/r
. - Copy
plistClean.sh
(to keep/r
folder clean),plistStarter.sh
(script to run only one instance ofplist
) andwatchplist.sh
(scheduler forplistStarter
) to/var/www/c
folder. - Grant privileges to executable files.
- Run
./watchplist.sh
and./plistClean.sh
from/var/www/c
folder. - Your server is ready.
You can also do most of this steps by executing install_BIaaS.sh
(only need to edit .htaccess)
This service just opens /var/www/c/f
folder, iterate over it (storing up to 1024 files), and then treat them, storing results on /var/www/c/r
folder, appending a r_
to original file name.
It delegates to BOperation.c
main launcher to make all calculations.
This handler just gets GET data, and writes a file that plist
can understand.
+---------------------------------------------+
| |
+-------+ +----+-----------+ +----------------+ |
| | makeOperation | | | | |
| Web +---------------->| calc-handler +--------->| /var/www/c/f | |
| |<----------------+ | | | |
+---+---+ response +------------+---+ +----------------+ |
^ | ^ | ^ |
| +--------------------------+ | | |
| getResult | | |
+------------------------------------+ | |
response | |
+--------+ | read |
| +----------------------+ |
| plist | |
| +----------------------+ |
+--------+ | write |
| |
v |
+----------------+ |
| | |
| /var/www/c/r |<----+
| |
+----------------+