| 1 | |
|---|
| 2 | /* setup |
|---|
| 3 | */ |
|---|
| 4 | parmdocumentsdb=NULL; |
|---|
| 5 | *docvdb ='\0'; |
|---|
| 6 | *docydb ='\0'; |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | jk_n=0; //init eval/jk/jd parms |
|---|
| 10 | jkv_n=0; //init eval/jkv/jdv parms |
|---|
| 11 | |
|---|
| 12 | /* get parameters - doc */ |
|---|
| 13 | for (iarg=1; iarg < argc; iarg++) { |
|---|
| 14 | p=argv[iarg]; |
|---|
| 15 | if (strncmp(p,"documents?",10) == 0 || strncmp(p,"documents=",10) == 0) { |
|---|
| 16 | parmdocumentsdb=p+10; |
|---|
| 17 | if (!*parmdocumentsdb) { sprintf(reply,"+++ %s\n",p); return -1; } |
|---|
| 18 | continue; |
|---|
| 19 | } |
|---|
| 20 | if (strncmp(p,"d?",2) == 0 || strncmp(p,"d=",2) == 0) { |
|---|
| 21 | parmdocumentsdb=p+2; |
|---|
| 22 | if (!*parmdocumentsdb) { sprintf(reply,"+++ %s\n",p); return -1; } |
|---|
| 23 | continue; |
|---|
| 24 | } |
|---|
| 25 | if (strncmp(p,"text?",5) == 0 || strncmp(p,"text=",5) == 0) { |
|---|
| 26 | parmtext=p+5; |
|---|
| 27 | if (!*parmtext) { sprintf(reply,"+++ %s\n",p); return -1; } |
|---|
| 28 | continue; |
|---|
| 29 | } |
|---|
| 30 | if (strncmp(p,"show?",5) == 0 || strncmp(p,"show=",5) == 0) { |
|---|
| 31 | parmdisp=p+5; |
|---|
| 32 | //returns jv_n or 0 |
|---|
| 33 | if (w2docjv (cmd, awtfp, coll, parmdisp) < 0) { sprintf(reply,"+++ %s\n",p); return -1; } |
|---|
| 34 | continue; |
|---|
| 35 | } |
|---|
| 36 | if (strncmp(p,"eval?",5) == 0 || strncmp(p,"eval=",5) == 0) { |
|---|
| 37 | parmeval=p+5; |
|---|
| 38 | //returns jk_n or 0 |
|---|
| 39 | if (w2docjk (cmd, awtfp, coll, parmeval) < 0) { sprintf(reply,"+++ %s\n",p); return -1; } |
|---|
| 40 | continue; |
|---|
| 41 | } |
|---|
| 42 | if (strncmp(p,"jd?",3) == 0 || strncmp(p,"jd=",3) == 0) { |
|---|
| 43 | joinjd=atoi(p+3); |
|---|
| 44 | if (joinjd < 0) { sprintf(reply,"+++ %s\n",p); return -1; } |
|---|
| 45 | continue; |
|---|
| 46 | } |
|---|
| 47 | if (strncmp(p,"v?",2) == 0 || strncmp(p,"v=",2) == 0) { |
|---|
| 48 | showv3=atoi(p+2); |
|---|
| 49 | if (showv3 < 0) { sprintf(reply,"+++ %s\n",p); return -1; } |
|---|
| 50 | continue; |
|---|
| 51 | } |
|---|
| 52 | if (strncmp(p,"id?",3) == 0 || strncmp(p,"id=",3) == 0) { |
|---|
| 53 | showid=atoi(p+3); |
|---|
| 54 | if (showid < 0) { sprintf(reply,"+++ %s\n",p); return -1; } |
|---|
| 55 | continue; |
|---|
| 56 | } |
|---|
| 57 | if (strncmp(p,"doc.v?",6) == 0 || strncmp(p,"doc.v=",6) == 0) { |
|---|
| 58 | q=p+6; if (!*q) { sprintf(reply,"+++ %s\n",p); return -1; } |
|---|
| 59 | strcpy(docvdb,q); |
|---|
| 60 | continue; |
|---|
| 61 | } |
|---|
| 62 | if (strncmp(p,"out.y?",6) == 0 || strncmp(p,"out.y=",6) == 0) { |
|---|
| 63 | q=p+6; if (!*q) { sprintf(reply,"+++ %s\n",p); return -1; } |
|---|
| 64 | strcpy(docydb,q); |
|---|
| 65 | continue; |
|---|
| 66 | } |
|---|
| 67 | if (strncmp(p,"dmfn?",5) == 0 || strncmp(p,"dmfn=",5) == 0) { |
|---|
| 68 | if (sscanf(p+5,"%d",&parmcollapse) != 1) { sprintf(reply,"+++ %s\n",p); return -1; } |
|---|
| 69 | if (parmcollapse < 0) { sprintf(reply,"+++ %s\n",p); return -1; } |
|---|
| 70 | continue; |
|---|
| 71 | } |
|---|
| 72 | if (strcmp(p,"w2all") == 0) { |
|---|
| 73 | parmwsoma=1; |
|---|
| 74 | continue; |
|---|
| 75 | } |
|---|
| 76 | if (strcmp(p,"-w2all") == 0) { |
|---|
| 77 | parmwsoma=0; |
|---|
| 78 | continue; |
|---|
| 79 | } |
|---|
| 80 | } |
|---|