summaryrefslogtreecommitdiff
path: root/modules/abbrgen
diff options
context:
space:
mode:
Diffstat (limited to 'modules/abbrgen')
-rwxr-xr-xmodules/abbrgen/abbreviation_gen_Darwinbin0 -> 30896 bytes
-rwxr-xr-xmodules/abbrgen/abbreviation_gen_Linuxbin0 -> 19364 bytes
-rw-r--r--modules/abbrgen/abbrgen.js49
3 files changed, 49 insertions, 0 deletions
diff --git a/modules/abbrgen/abbreviation_gen_Darwin b/modules/abbrgen/abbreviation_gen_Darwin
new file mode 100755
index 0000000..7fd9596
--- /dev/null
+++ b/modules/abbrgen/abbreviation_gen_Darwin
Binary files differ
diff --git a/modules/abbrgen/abbreviation_gen_Linux b/modules/abbrgen/abbreviation_gen_Linux
new file mode 100755
index 0000000..dd151e7
--- /dev/null
+++ b/modules/abbrgen/abbreviation_gen_Linux
Binary files differ
diff --git a/modules/abbrgen/abbrgen.js b/modules/abbrgen/abbrgen.js
new file mode 100644
index 0000000..64a29b1
--- /dev/null
+++ b/modules/abbrgen/abbrgen.js
@@ -0,0 +1,49 @@
+var cmn=require("../$common.js"),
+ process=require("child_process");
+
+var moddir,uname;
+uname=String(process.execSync("uname")).trim();
+
+//PERFORMS NO VALIDATION!
+function get_abbreviations(abbr,num,cb){
+ var fname=moddir+"/abbreviation_gen_"+uname;
+ process.execFile(fname,[abbr,num],{},function(err,stdout,stderr){
+ //if(err)throw err;
+ if(err){
+ console.log(err.toString());
+ console.log(err.stack);
+ cb([]);
+ }
+ cb(stdout.split("\n"));
+ });
+}
+
+module.exports=function(app,io,_moddir){
+ moddir=_moddir;
+ app.get("/abbrgen/:abbr",function(req,res){
+ var abbr=req.params.abbr;
+ res.set("Content-Type","text/plain");
+ if(!abbr.match(/^[a-z]+$/i)){
+ res.send("ERROR: Invalid input value.");
+ return;
+ }
+ get_abbreviations(abbr,"1",function(answers){
+ res.send(answers.join("\n"));
+ });
+ });
+ app.get("/abbrgen/:abbr/:num",function(req,res){
+ var abbr=req.params.abbr,num=req.params.num;
+ res.set("Content-Type","text/plain");
+ if(num>5000){
+ res.send("ERROR: Number of abbreviations too large.");
+ return;
+ }
+ if(!abbr.match(/^[a-z]+$/i)||isNaN(+num)){
+ res.send("ERROR: Invalid input values.");
+ return;
+ }
+ get_abbreviations(abbr,num,function(answers){
+ res.send(answers.join("\n"));
+ });
+ });
+};