Back to index

wims  3.65+svn20090927
Defines | Functions | Variables
common.c File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ch_root   "bin/ch..root"
#define hnameno   (sizeof(hname)/sizeof(hname[0]))

Functions

void check_parm (char *p)
void output (char *p)
void about (void)
char * dynsetup (char *p, char *end)
void * xmalloc (size_t n)
char * strip_trailing_spaces (char *p)
char * find_word_end (char *p)
char * find_word_start (char *p)
char * wordchr (char *p, char *w)
char * varchr (char *p, char *v)
char * find_matching (char *p, char c)
int search_list (void *list, int items, size_t item_size, const char *str)
void accessfile (char *content, char *type, char *s,...)
void getstdin (void)
void addpid (int pid)
void rmpid (int pid)
int execredirected (char *cmdf, char *inf, char *outf, char *errf, char *args)
void find_illegal (char *p)
void strip_zeros (char *p)
void putheader (void)
void putparm (void)
void prepare1 (void)
void prepabout (char *cmd, char *outf, char *errf)
int readabout (void)
void readresult (void)
void dopipes (void)
void run (void)

Variables

int mypid
int must_chroot = 0
char inputfname [256]
char outputfname [256]
char pidfname [256]
char parmbuf [parmlim+16]
char * inpf
char * outpf
char * errorf
char * parm
char * tmp_dir
char cmdbuf [1024]
char inputbuf [inputlim]
char * inputptr
char * inputend
char stdinbuf [MAX_LINELEN+1]
char * cmdparm
int isabout = 0
char * multiexec_random
int multiexec = 0
int mxpid
int notfirst
int pipe_in [2]
int pipe_out [2]
int debug = 0
FILE * goin
unsigned int seed
char aboutbuf [aboutlen]
char * tmpdir = "/tmp"
char startstring [256]
char endstring [256]
char * obuf
char * hname [] = {"", "_1","_2","_3","_4","_5","_6","_7","_8"}

Define Documentation

#define ch_root   "bin/ch..root"

Definition at line 20 of file common.c.

#define hnameno   (sizeof(hname)/sizeof(hname[0]))

Definition at line 361 of file common.c.


Function Documentation

void about ( void  )

Definition at line 106 of file gap.c.

{
/*    char *p;
*/
    printf("<A HREF=\"%s\">GAP4</A>",homepage); return;
/*    prepabout(quitstring,outputfname,NULL);
    if(readabout()>0) {
       p=strchr(aboutbuf,'\n'); if(p!=NULL) *p=0;
       strip_trailing_spaces(aboutbuf);
       printf("<A HREF=\"%s\">%s</A>",homepage,aboutbuf);
    }
*/
}

Here is the call graph for this function:

Here is the caller graph for this function:

void accessfile ( char *  content,
char *  type,
char *  s,
  ... 
)

Definition at line 165 of file common.c.

{
    va_list vp;
    char buf[MAX_LINELEN+1];
    FILE *f;
    int l;

    va_start(vp,s);
    vsnprintf(buf,sizeof(buf),s,vp);
    va_end(vp);
    f=fopen(buf,type); if(f==NULL) {
       if(*type=='r') content[0]=0; return;
    }
    switch(*type) {
       case 'a':
       case 'w': {
           l=strlen(content); fwrite(content,1,l,f); break;
       }
       case 'r': {
           l=fread(content,1,MAX_LINELEN-1,f);
           if(l>0 && l<MAX_LINELEN) content[l]=0;
           else content[0]=0;
           break;
       }
       default: {
           content[0]=0; break;
       }
    }
    fclose(f);
}

Here is the caller graph for this function:

void addpid ( int  pid)

Definition at line 212 of file common.c.

{
    char buf[MAX_LINELEN+1], pidbuf[32];
    int l;
    snprintf(pidbuf,sizeof(pidbuf),"%u",pid);
    accessfile(buf,"r",pidfname); l=strlen(buf);
    if(l>=MAX_LINELEN-64) return;
    if(wordchr(buf,pidbuf)==NULL) {
       snprintf(buf+l,sizeof(buf)-l," %s",pidbuf);
       accessfile(buf,"w",pidfname);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void check_parm ( char *  p)

Definition at line 60 of file gap.c.

{
    char *pp; int l;
         /* Underscore replacement */
    for(pp=strchr(pm,'_'); pp!=NULL; pp=strchr(pp+1,'_')) *pp='K';
    strip_trailing_spaces(pm); l=strlen(pm);
    if(l>0 && pm[l-1]!=';') strcat(pm,";");
    find_illegal(pm);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dopipes ( void  )

Definition at line 564 of file common.c.

{
    long int i, k, l;
    int interval=20000;     /* in microseconds */
    int timeout =300;       /* in intervals */
    char *outptr;
    char *p1, *p2, *inp, *pw;
    struct timeval t;
    fd_set rset, wset;

    *obuf=0; if(mxpid<0) return;
    outptr=obuf; inp=inputbuf; k=0; 
    while(inp<inputptr) {
       t.tv_sec=0; t.tv_usec=interval;
       FD_ZERO(&rset); FD_SET(pipe_out[0],&rset);
       FD_ZERO(&wset); FD_SET(pipe_in[1],&wset);
       i=pipe_out[0]; if(i<pipe_in[1]) i=pipe_in[1];
       i=select(i+1,&rset,&wset,NULL,&t);
       if(i<=0) {
           k++; if(k>=timeout) return;    /* time out */
       }
       if(FD_ISSET(pipe_in[1],&wset)) {
              /* Writing must be line by line, for otherwise
               * it will block when the input is large. */
           for(pw=inp; pw<inputptr && *pw!='\n'; pw++);
           if(pw<inputptr) pw++;
           l=write(pipe_in[1],inp,pw-inp);
           if(l<0 || l>inputptr-inp) return;
           inp+=l;
       }
       if(FD_ISSET(pipe_out[0],&rset)) {
           l=read(pipe_out[0],outptr,fsizelim-(outptr-obuf)-1);
           if(l<=0 || l>fsizelim-(outptr-obuf)-1) {
              *outptr=0; break;
           }
           outptr+=l; *outptr=0;
       }
    }
    p2=NULL;
    p1=strstr(obuf,startstring);
    if(p1) {
       p1+=strlen(startstring);
       p2=strstr(p1,endstring);
    }
    while(!p2) {
       t.tv_sec=0; t.tv_usec=interval;
       FD_ZERO(&rset); FD_SET(pipe_out[0],&rset);
       i=select(pipe_out[0]+1,&rset,NULL,NULL,&t);
       if(i>0) {
           l=read(pipe_out[0],outptr,fsizelim-(outptr-obuf)-1);
           if(l<=0 || l>fsizelim-(outptr-obuf)-1) {
              *outptr=0; break;
           }
           outptr+=l; *outptr=0;
       }
       else {
           k++; if(k>=timeout) break;
       }
       if(!p1) {
           p1=strstr(obuf,startstring);
           if(p1) p1+=strlen(startstring);
       }
       if(p1) p2=strstr(p1,endstring);
    }
}

Here is the caller graph for this function:

char* dynsetup ( char *  p,
char *  end 
)

Definition at line 120 of file gap.c.

{
    int i;
    char *p, *pp;
    for(i=0;i<SETUP_NO;i++) {
       p=getenv(setups[i].wname);
       if(p!=NULL) for(pp=p;*pp;pp++) if(!isspace(*pp) && !isalnum(*pp)) p="";
       if(p==NULL || *p==0) p=setups[i].defaultval;
    }
    return ptr;
}

Here is the caller graph for this function:

int execredirected ( char *  cmdf,
char *  inf,
char *  outf,
char *  errf,
char *  args 
)

Definition at line 238 of file common.c.

{
    pid_t pid;
    int i;
    struct stat st;
    char *cm, *p, *p2, abuf[MAX_LINELEN+1];
    char *arg[1024];

    for(cm=cmdf; isspace(*cm); cm++); if(*cmdf==0) return -1;
    fflush(NULL);    /* flush all output streams before forking
                      * otherwise they will be doubled */
    pid=fork(); if(pid==-1) return -1;
    if(!pid) {       /* child */
       if(!inf) {
           dup2(pipe_in[0],0); close(pipe_in[1]);
       }
       else freopen(inf,"r",stdin);
       if(!outf) {
           dup2(pipe_out[1],1); close(pipe_out[0]);
       }
       else freopen(outf,"w",stdout);
       if(errf) freopen(errf,"w",stderr);
       snprintf(abuf,sizeof(abuf),"%s",find_word_start(args));
       if(stat("../chroot/tmp/sessions/.chroot",&st)==0 || must_chroot) {
           arg[0]=ch_root; i=1;
       }
       else {
           i=0;
           setreuid(getuid(),getuid());setregid(getgid(),getgid());
       }
       arg[i++]=cmdf;
       for(p=abuf; *p && i<1000; i++, p=find_word_start(p2)) {
           arg[i]=p; p2=find_word_end(p); if(*p2) *p2++=0;
       }
       arg[i]=NULL;
       if(strchr(arg[0],'/')) execv(arg[0],arg);
       else execvp(arg[0],arg);
       fprintf(stderr,"%s not_INStalled",progname);
       exit(127);
    }
    else {    /* parent */
       addpid(pid); mxpid=pid;
       if(outf) {
           int status;
           close(pipe_in[1]);
           if(waitpid(pid,&status,0)==pid) {
              rmpid(pid); mxpid=-1;
           }
       }
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void find_illegal ( char *  p)

Definition at line 293 of file common.c.

{
    char *pp, *pe;
    int i, l;
    for(pp=p;*pp;pp++) {
       if((*pp<' ' && *pp!='\n' && *pp!=' ') || *pp>=127) *pp=' ';
    }
    for(i=0;i<illpart_no;i++) {
       pe=illpart[i]; l=strlen(pe);
       for(pp=strstr(p,pe); pp; pp=strstr(pp+1,pe)) {
           if(!isupper(pe[0]) || !islower(*(pp+l))) {
              if(pp[1]!='j' && pp[1]!='J') pp[1]='J';
              else pp[1]='Z';
           }
       }
    }
    for(i=0;i<illegal_no;i++) {
       pe=illegal[i]; l=strlen(pe);
       for(pp=strstr(p,pe); pp; pp=strstr(pp+1,pe)) {
           if((pp==p || !isalnum(*(pp-1))) && !isalnum(*(pp+l))) {
              if(pp[1]!='j' && pp[1]!='J') pp[1]='J';
              else pp[1]='Z';
           }
       }
    }
}

Here is the caller graph for this function:

char* find_matching ( char *  p,
char  c 
)

Definition at line 113 of file common.c.

{
    char *pp;
    int parenth, brak, brace;
    parenth=brak=brace=0;
    for(pp=p; *pp!=0; pp++) {
       switch(*pp) {
           case '[': brak++; break;
           case ']': brak--; break;
           case '(': parenth++; break;
           case ')': parenth--; break;
           case '{': brace++; break;
           case '}': brace--; break;
           default: continue;
       }
       if(parenth<0 || brak<0 || brace<0) {
           if(*pp!=c || parenth>0 || brak>0 || brace>0) return NULL;
           else break;
       }
    }
    if(*pp!=c) return NULL;
    return pp;
}
char* find_word_end ( char *  p)

Definition at line 74 of file common.c.

{
    int i;
    for(i=0;!isspace(*p) && *p!=0 && i<MAX_LINELEN; p++,i++);
    return p;
}
char* find_word_start ( char *  p)

Definition at line 82 of file common.c.

{
    int i;
    for(i=0; isspace(*p) && i<MAX_LINELEN; p++,i++);
    return p;
}
void getstdin ( void  )

Definition at line 196 of file common.c.

{
    char *p;
    int i,j,k;
    i=0; k=MAX_LINELEN; stdinbuf[0]=0;
    do {
       j=read(0,stdinbuf+i,k);
       if(j<0 || j>k) exit(1);
       i+=j; k-=j; stdinbuf[i]=0;
       p=strstr(stdinbuf,multiexec_random);
       if(p) {*p=0; break;}
    }
    while(k>0);
}

Here is the caller graph for this function:

void output ( char *  p)

Definition at line 71 of file gap.c.

{
    int i,n;
    char *pp, *pe, *pt;

    pp=strstr(p,gapprompt); if(pp==NULL) return;
    while((pt=strstr(pp,"\\\n"))!=NULL) strcpy(pt,pt+2);
    while(pp!=NULL) {
       pp+=strlen(gapprompt);
       pe=strstr(pp,gapprompt);
       if(pe>=pp) *pe=0;
       if(pe!=NULL && pp>=pe) {
           emptyline:
           puts(""); pp=pe; continue;
       }
       n=strlen(pp);
       if(n==0) goto emptyline;
              /* make every output one-line */
       for(i=0;i<n;i++) {
           if(*(pp+i)=='\n') {
              if(*(pp+i+1)!='%') *(pp+i)=' ';
              else {*(pp+i)=0; break;}
           }
       }
         /* strip leading and trailing spaces */
       while(isspace(*pp) && pp<pe) pp++;
       pt=pp+strlen(pp)-1;
       while(isspace(*pt) && pt>pp) *pt--=0;
       if(*pp=='[' && *pt==']') {
           *(pt--)=0; pp++;
       }
       puts(pp); pp=pe;
    }
}

Here is the call graph for this function:

void prepabout ( char *  cmd,
char *  outf,
char *  errf 
)

Definition at line 447 of file common.c.

{
    write(pipe_in[1],cmd,strlen(cmd));
    execredirected(nameofcmd,NULL,outf,errf,cmdparm);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void prepare1 ( void  )

Definition at line 398 of file common.c.

{
    char *p, buf[256];
    int i;
    unsigned int r[4];
    struct timeval t;

    parm=getenv("wims_exec_parm");
       /* nothing to do if no calling parameter */
    if(parm==NULL || *parm==0) exit(0);
    inputptr=inputbuf; inputend=inputbuf+inputlim-1;
    multiexec_random=getenv("multiexec_random");
    if(multiexec_random==NULL) multiexec_random="";
    if(*parm && strcmp(parm,multiexec_random)==0) {
       multiexec=1;
       getstdin(); parm=stdinbuf;
       if(parm[0]==0) exit(0);
    }
    if(pipe(pipe_in)<0 || pipe(pipe_out)<0) {
       fprintf(stderr,"%s: unable to create pipe.\n",progname);
       exit(1);
    }
/*    i=fcntl(pipe_in[1],F_GETFL); if(i>=0) fcntl(pipe_in[1],F_SETFL,i|O_NONBLOCK);
    i=fcntl(pipe_out[0],F_GETFL); if(i>=0) fcntl(pipe_out[0],F_SETFL,i|O_NONBLOCK);
*/    tmp_dir=getenv("tmp_dir"); if(tmp_dir==NULL || *tmp_dir==0) tmp_dir=tmpdir;
    setenv("TMPDIR",tmp_dir,1);
    mypid=getpid();
    gettimeofday(&t,NULL); seed=t.tv_usec*t.tv_sec+mypid;
    srandom(seed);
    for(i=0;i<4;i++) r[i]=random();
    snprintf(startstring,sizeof(startstring),
            "Start line %s %u %u %u %u",progname,r[0],r[1],r[2],r[3]);
    snprintf(endstring,sizeof(endstring),
            "End line %s %u %u %u %u",progname,r[0],r[1],r[2],r[3]);
    snprintf(buf,sizeof(buf),"%s_command",progname); p=getenv(buf);
    if(p!=NULL && *find_word_start(p)!=0) nameofcmd=find_word_start(p);
    snprintf(cmdbuf,sizeof(cmdbuf),"%s",nameofcmd); nameofcmd=cmdbuf;
    cmdparm=find_word_end(nameofcmd); if(*cmdparm) *cmdparm++=0;
    cmdparm=find_word_start(cmdparm);
    snprintf(pidfname,sizeof(pidfname),"%s/exec.pid",tmp_dir); addpid(mypid);
    snprintf(inputfname,sizeof(inputfname),"%s/%s_input.%d",tmp_dir,progname,mypid);
    snprintf(outputfname,sizeof(outputfname),"%s/%s_output.%d",tmp_dir,progname,mypid);
    errorf=NULL;
    inpf=inputfname; outpf=outputfname;
    isabout=0; p=find_word_start(parm); i=strlen("about");
    if(memcmp(p,"about",i)==0 && *find_word_start(p+i)==0) isabout=1;
    p=getenv("multiexec_debug"); if(p && strcmp(p,"yes")==0) debug=1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void putheader ( void  )

Definition at line 363 of file common.c.

{
    char hbuf[64];
    char *p;
    int i;
    
    inputptr=dynsetup(inputptr,inputend);
    snprintf(inputptr,inputend-inputptr,"%s",header);
    inputptr+=strlen(inputptr);
    for(i=0;i<hnameno;i++) {
       snprintf(hbuf,sizeof(hbuf),"w_%s_header%s",progname,hname[i]);
       p=getenv(hbuf); if(p!=NULL && *p!=0) {
           snprintf(parmbuf,parmlim,"%s",p);
           check_parm(parmbuf); 
           snprintf(inputptr,inputend-inputptr,"%s\n",parmbuf);
           inputptr+=strlen(inputptr);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void putparm ( void  )

Definition at line 383 of file common.c.

{
    snprintf(parmbuf,parmlim,"%s",parm); check_parm(parmbuf);
    snprintf(inputptr,inputend-inputptr,stringprinter,startstring);
    inputptr+=strlen(inputptr);
    snprintf(inputptr,inputend-inputptr,"%s",parmbuf);
    inputptr+=strlen(inputptr);
    if(inputptr<inputend && inputptr>inputbuf && inputptr[-1]!='\n')
      *inputptr++='\n';
    snprintf(inputptr,inputend-inputptr,stringprinter,endstring);
    inputptr+=strlen(inputptr);
    *inputptr=0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int readabout ( void  )

Definition at line 454 of file common.c.

{
    FILE *ff;
    long int l;
    char *p;
    
    aboutbuf[0]=0; ff=fopen(outputfname,"r");
    if(ff!=NULL) {
       fseek(ff,0,SEEK_END); l=ftell(ff); fseek(ff,0,SEEK_SET);
       l=fread(aboutbuf,1,aboutlen-10,ff); fclose(ff);
       if(l>0 && l<aboutlen) aboutbuf[l]=0; else aboutbuf[0]=0;
       p=find_word_start(aboutbuf); if(p>aboutbuf) strcpy(aboutbuf,p);
    }
    return strlen(aboutbuf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void readresult ( void  )

Definition at line 471 of file common.c.

{
    FILE *ff;
    char *p, *pp, *pe;

    if(debug) {
       ff=fopen(outputfname,"a"); if(ff) {
           fputs(obuf,ff); fclose(ff);
       }
    }
    pe=NULL;
    p=strstr(obuf,startstring);
    if(p) {
       p+=strlen(startstring);
       pe=strstr(p,endstring);
       if(pe) {
           for(pp=pe-1; pp>=p && pp>pe-64 && *pp!='\n'; pp--);
           if(pp>=p && *pp=='\n') pe=pp;
       }
    }
    if(pe) {
       *pe=0;
       while((pe=strstr(p,startstring))!=NULL) {
           p=pe+strlen(startstring);
       }
       output(p);
    }
    else {
       if(mxpid>=0) {
           if(kill(mxpid,0)<0 && errno==ESRCH) { /* this doesn't work */
              fprintf(stderr,"%s not_INStalled",progname);
           }
           else {
              fprintf(stderr,"%s: execution error or time out.\n",progname);
              kill(mxpid,SIGKILL);
           }
           rmpid(mxpid); mxpid=-1;
       }
       else {
           fprintf(stderr,"%s: aborted on earlier error.\n",progname);
       }
    }
    if(multiexec && *multiexec_random) printf("%s\n",multiexec_random);
    fflush(stdout);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void rmpid ( int  pid)

Definition at line 226 of file common.c.

{
    char buf[MAX_LINELEN+1], pidbuf[32], *p;
    snprintf(pidbuf,sizeof(pidbuf),"%u",pid);
    accessfile(buf,"r",pidfname);
    p=wordchr(buf,pidbuf);
    if(p!=NULL) {
       strcpy(p,find_word_start(find_word_end(p)));
       accessfile(buf,"w",pidfname);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void run ( void  )

Definition at line 632 of file common.c.

{
    FILE *ff;
    
    if(isabout) {about(); goto end;}
    execredirected(nameofcmd,NULL,NULL,NULL,cmdparm);
    putheader();
    obuf=xmalloc(fsizelim); if(!obuf) return;
    rep:
    putparm();
    if(!multiexec) {
       snprintf(inputptr,inputend-inputptr,"%s",quitstring);
       inputptr+=strlen(inputptr);
    }
    if(debug) {
       ff=fopen(inputfname,"a"); if(ff) {
           fputs(inputbuf,ff); fclose(ff);
       }
    }
    dopipes();
    readresult();
    if(multiexec) {
       getstdin(); inputptr=inputbuf; inputbuf[0]=0;
       goto rep;
    }
    end: if(strstr(tmp_dir,"tmp/sessions/")==NULL) {
       unlink(inputfname); unlink(outputfname);
    }
    free(obuf); rmpid(mypid);
    if(mxpid>0) {kill(mxpid,SIGKILL); rmpid(mxpid);}
}

Here is the call graph for this function:

Here is the caller graph for this function:

int search_list ( void *  list,
int  items,
size_t  item_size,
const char *  str 
)

Definition at line 139 of file common.c.

{
    int i1,i2,j,k;
    char **p;
    char c;
    
    if(items<=0) return -1;
    j=0; c=*str;
    p=list;
    k=**p-c; if(k==0) k=strcmp(*p,str);
    if(k==0) return k; if(k>0) return -1;
    p=list+(items-1)*item_size; 
    k=**p-c; if(k==0) k=strcmp(*p,str);
    if(k==0) return items-1; if(k<0) return -1;
    for(i1=0,i2=items-1;i2>i1+1;) {
       j=i1+(i2-i1)/2;
       p=list+(j*item_size);
       k=**p-c; if(k==0) k=strcmp(*p,str);
       if(k==0) return j;
       if(k>0) {i2=j; continue;}
       if(k<0) {i1=j; continue;}   
    }
    return -1;
}

Here is the caller graph for this function:

char* strip_trailing_spaces ( char *  p)

Definition at line 65 of file common.c.

{
    char *pp;
    if(*p==0) return p;
    for(pp=p+strlen(p)-1; pp>=p && isspace(*pp); *(pp--)=0);
    return pp;
}
void strip_zeros ( char *  p)

Definition at line 321 of file common.c.

{
    char *pp, *p2, *numend, *ee;
    int i;
    for(pp=p;*pp!=0;pp++) {
       if(!isdigit(*pp)) continue;
       i=0;
       for(numend=pp;isdigit(*numend) || *numend=='.';numend++)
         if(*numend=='.') i=1;
       if(i==0) {
           pp=numend-1;continue;
       }
       for(p2=numend;p2>pp && *(p2-1)=='0';p2--);
       for(ee=numend;isspace(*ee);ee++);
       if(*(pp+1)=='.' && (*ee=='E' || *ee=='e') 
          && *(ee+1)=='-') {
           int k=0;
           char *pt=ee+2;
           while(isdigit(*pt)) {
              k*=10;k+=*pt-'0';pt++;
           }
           if(precision>8 && (k>precision*2 || (k>precision && *pp=='0'))) {
              
              sprintf(pp,"0.0%s",pt);
              
              pp+=strlen("0.0")-1;
              continue;
           }
       }
       
       if(*(p2-1)=='.' && p2<numend) p2++; 
       
       if(p2<numend) {
           strcpy(p2,numend);numend=p2;
       }
       pp=numend-1;
    }
}

Here is the caller graph for this function:

char* varchr ( char *  p,
char *  v 
)

Definition at line 102 of file common.c.

{
        char *pp; int n=strlen(v);
        for(pp=strstr(p,v); pp!=NULL; pp=strstr(pp+1,v)) {
           if((pp==p || (!isalnum(*(pp-1)) && *(pp-1)!='_')) &&
              ((!isalnum(*(pp+n)) && *(pp+n)!='_') || *(pp+n)==0)) break;
       }
        return pp;
}

Here is the caller graph for this function:

char* wordchr ( char *  p,
char *  w 
)

Definition at line 90 of file common.c.

{
    char *r;

    if(*w==0) return NULL;
    for(r=strstr(p,w);r!=NULL && 
       ( (r>p && !isspace(*(r-1))) || (!isspace(*(r+strlen(w))) && *(r+strlen(w))!=0) );
       r=strstr(r+1,w));
    return r;
}
void* xmalloc ( size_t  n)

Definition at line 53 of file common.c.

{
    void *p;
    p=malloc(n);
    if(p==NULL) {
       fprintf(stderr, "%s: Malloc failure.\n",progname);
       exit(1);
    }
    return p;
}

Variable Documentation

Definition at line 42 of file common.c.

char cmdbuf[1024]

Definition at line 30 of file common.c.

char* cmdparm

Definition at line 34 of file common.c.

int debug = 0

Definition at line 39 of file common.c.

char endstring[256]

Definition at line 45 of file common.c.

char * errorf

Definition at line 27 of file common.c.

FILE* goin

Definition at line 40 of file common.c.

char* hname[] = {"", "_1","_2","_3","_4","_5","_6","_7","_8"}

Definition at line 360 of file common.c.

char* inpf

Definition at line 27 of file common.c.

Definition at line 31 of file common.c.

char * inputend

Definition at line 32 of file common.c.

char inputfname[256]

Definition at line 24 of file common.c.

char* inputptr

Definition at line 32 of file common.c.

int isabout = 0

Definition at line 35 of file common.c.

int multiexec = 0

Definition at line 37 of file common.c.

Definition at line 36 of file common.c.

int must_chroot = 0

Definition at line 23 of file common.c.

int mxpid

Definition at line 37 of file common.c.

int mypid

Definition at line 22 of file common.c.

int notfirst

Definition at line 37 of file common.c.

char* obuf

Definition at line 46 of file common.c.

char * outpf

Definition at line 27 of file common.c.

char outputfname[256]

Definition at line 24 of file common.c.

char* parm

Definition at line 28 of file common.c.

char parmbuf[parmlim+16]

Definition at line 26 of file common.c.

char pidfname[256]

Definition at line 25 of file common.c.

int pipe_in[2]

Definition at line 38 of file common.c.

int pipe_out[2]

Definition at line 38 of file common.c.

unsigned int seed

Definition at line 41 of file common.c.

char startstring[256]

Definition at line 45 of file common.c.

Definition at line 33 of file common.c.

char* tmp_dir

Definition at line 29 of file common.c.

char* tmpdir = "/tmp"

Definition at line 44 of file common.c.