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 .calcon your Apache .htaccess file - This
calc-handlerwill get the request and write a file on./f(folder must exist befor execution). - There are two
kindof operations to make: 1.makeOperation, in order to enter an operation 2.getResult, in order to get the result ofmakeOperation. - The
BigIntegerservice (plist) will take the file, calculate, and write the result on/rfolder (appended withr_).
You have to follow this rules:
- File name (
fileNameparameter) may not exceed 126 characters long. - File name (
fileNameparameter) may be set. - File name (
fileNameparameter) may be unique and non-existing. It will be searched among/fand/rfolders. - Operation data (
operation,op1andop2parameters) may be informed. - Operation data (
op1andop2parameters) may not exceed 1024 length (during beta; on release, will stand up to 4096). - Operation data (
operationparameter) may be only 1 character long and be either+,-,/,*,^,sfor adding, subtracting, dividing, multiplying, power, and get root of, respectively.
You have to follow this rules
- File name (
fileNameparameter) may not exceed 126 character long. - File name (
fileNameparameter) may be set. - File name (
fileNameparameter) may be unique and existing. It will be searched among/fand/rfolders.
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.cby usingmakemain.sh. You will needapsxcompiler from Apache developer package. Apache service will restart. - Compile
plistby usingmakeplist.sh. You will need to have all BigInteger source in the same folder. - Compile
plistStarterwith gcc. No special needs. - Move
plistandplistStarterobjects to/var/www/c. - Create folders
/var/www/c/fand/var/www/c/r. - Copy
plistClean.sh(to keep/rfolder clean),plistStarter.sh(script to run only one instance ofplist) andwatchplist.sh(scheduler forplistStarter) to/var/www/cfolder. - Grant privileges to executable files.
- Run
./watchplist.shand./plistClean.shfrom/var/www/cfolder. - 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 |<----+
| |
+----------------+