Back to index

wims  3.65+svn20090927
Defines | Functions | Variables
Plouffe.c File Reference
#include "../wims.h"

Go to the source code of this file.

Defines

#define parmlim   131072
#define WebPlouffe   "<a target=wims_external href=\"http://www.cecm.sfu.ca/cgi-bin/isc/lookup?lookup_type=simple&number=%s\">"
#define Plouffe_min   6
#define Plouffe_max   22
#define lang_no   (sizeof(langs)/sizeof(langs[0]))

Functions

int getlang (void)
int main (int argc, char *argv[])

Variables

char * langs [] = {"en","fr","cn"}
char * post_msg [lang_no]
char * parm

Define Documentation

#define lang_no   (sizeof(langs)/sizeof(langs[0]))

Definition at line 32 of file Plouffe.c.

#define parmlim   131072

Definition at line 23 of file Plouffe.c.

#define Plouffe_max   22

Definition at line 29 of file Plouffe.c.

Definition at line 28 of file Plouffe.c.

#define WebPlouffe   "<a target=wims_external href=\"http://www.cecm.sfu.ca/cgi-bin/isc/lookup?lookup_type=simple&number=%s\">"

Definition at line 25 of file Plouffe.c.


Function Documentation

int getlang ( void  )

Definition at line 46 of file Plouffe.c.

{
    char *p;
    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 */
    for(i=0;i<lang_no && strcmp(p,langs[i])!=0;i++);
    if(i<lang_no) return i; else return 0;
}

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 57 of file Plouffe.c.

{
    char *p,*pp,*p2,*p3,*ps,*last;
    char buf[parmlim];
    int i,got;
    
    parm=getenv("wims_exec_parm");
       /* 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);
    }
    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(*last!=0) printf("%s",last);
    if(got) printf("%s",post_msg[getlang()]);
    return 0;    
}

Here is the call graph for this function:


Variable Documentation

char* langs[] = {"en","fr","cn"}

Definition at line 31 of file Plouffe.c.

char* parm

Definition at line 44 of file Plouffe.c.

char* post_msg[lang_no]
Initial value:
{
    " <small>(click on a value to check its meaning in another window)</small> ",
    " <small>(cliquez sur une valeur pour voir sa signification dans une autre fen阾re)</small> ",
    " <small>(在数字上单击可供你在另一视窗内查阅其意义)</small> "
}

Definition at line 34 of file Plouffe.c.