15,16 → 15,16 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
*/ |
|
/* Interface Plouffe's Inverter to wims */ |
/* Interface Plouffe's Inverter to wims */ |
|
/*************** Customization: change values hereafter ****************/ |
|
/* limit of parameter string */ |
/* limit of parameter string */ |
#define parmlim 131072 |
/* Address of Plouffe's Inverter */ |
/* Address of Plouffe's Inverter */ |
#define WebPlouffe "<a target=wims_external href=\"http://oldweb.cecm.sfu.ca/cgi-bin/isc/lookup?lookup_type=simple&number=%s\">" |
|
/* minimal and maximal lengths of a number to interface */ |
/* minimal and maximal lengths of a number to interface */ |
#define Plouffe_min 6 |
#define Plouffe_max 22 |
|
49,7 → 49,7 |
int i; |
p=getenv("w_module_language"); |
if(p==NULL || *p==0) p=getenv("w_lang"); |
if(p==NULL || *p==0) return 0; /* English is default */ |
if(p==NULL || *p==0) return 0; /* English is default */ |
for(i=0;i<lang_no && strcmp(p,langs[i])!=0;i++); |
if(i<lang_no) return i; else return 0; |
} |
59,44 → 59,44 |
char *p,*pp,*p2,*p3,*ps,*last; |
char buf[parmlim]; |
int i,got; |
|
|
parm=getenv("wims_exec_parm"); |
/* nothing to do if no parameter */ |
/* nothing to do if no parameter */ |
if(parm==NULL || *parm==0) return 0; |
i=strlen(parm); if(i<0 || i>parmlim) { |
fprintf(stderr,"Plouffe: parameter too long. \n"); exit(1); |
fprintf(stderr,"Plouffe: parameter too long. \n"); exit(1); |
} |
got=0; |
for(p=last=parm;*p!=0;p++) { |
if(*p=='<') { |
for(;*p!=0 && *p!='>'; p++); |
if(*p==0) p--; |
continue; |
} |
if(!isdigit(*p)) continue; |
for(i=0,pp=p;isdigit(*pp) || *pp=='.';pp++) if(*pp=='.') i++; |
if(i>1) { /* several decimal points. */ |
p=pp-1;continue; |
} |
for(p2=pp-1;p2>=p && (*p2=='.' || *p2=='0');p2--); |
p2++; |
for(i=0,p3=p;p3<p2 && *p3!='.';p3++); |
for(i=0,ps=p;ps<p2 && (*ps=='0' || *ps=='.'); ps++); |
if(p3>=p2 || p2<ps+Plouffe_min) { |
p=pp-1;continue; |
} |
memmove(buf,last,p-last);buf[p-last]=0; |
printf("%s",buf);last=p; |
i=p2-p;if(i>Plouffe_max) i=Plouffe_max; |
memmove(buf,p,i);buf[i]=0; |
printf(WebPlouffe,buf); |
memmove(buf,p,pp-p);buf[pp-p]=0; |
printf("%s</a>",buf);last=pp; |
got=1;p=pp-1; |
continue; |
if(*p=='<') { |
for(;*p!=0 && *p!='>'; p++); |
if(*p==0) p--; |
continue; |
} |
if(!isdigit(*p)) continue; |
for(i=0,pp=p;isdigit(*pp) || *pp=='.';pp++) if(*pp=='.') i++; |
if(i>1) { /* several decimal points. */ |
p=pp-1;continue; |
} |
for(p2=pp-1;p2>=p && (*p2=='.' || *p2=='0');p2--); |
p2++; |
for(i=0,p3=p;p3<p2 && *p3!='.';p3++); |
for(i=0,ps=p;ps<p2 && (*ps=='0' || *ps=='.'); ps++); |
if(p3>=p2 || p2<ps+Plouffe_min) { |
p=pp-1;continue; |
} |
memmove(buf,last,p-last);buf[p-last]=0; |
printf("%s",buf);last=p; |
i=p2-p;if(i>Plouffe_max) i=Plouffe_max; |
memmove(buf,p,i);buf[i]=0; |
printf(WebPlouffe,buf); |
memmove(buf,p,pp-p);buf[pp-p]=0; |
printf("%s</a>",buf);last=pp; |
got=1;p=pp-1; |
continue; |
} |
if(*last!=0) printf("%s",last); |
if(got) printf("%s",post_msg[getlang()]); |
return 0; |
return 0; |
} |
|