--- ifmail-2.14tx8.10.orig/ifcico/call.c +++ ifmail-2.14tx8.10/ifcico/call.c @@ -14,6 +14,7 @@ #include "session.h" #include "callstat.h" #include "Txy.h" +#include "setproctitle.h" extern int forcedcalls; extern char *forcedphone; @@ -39,7 +40,127 @@ extern void rdoptions(node*); extern int nodelock(faddr*); extern int nodeulock(faddr*); -extern void setproctitle(char*); + +#ifdef HIDDEN + +extern fa_list *Hidden; +extern fa_list *Override; + +#define MAXLINES 16 + +struct s_hidden { + char *phone; + char *txy; + }; + +int parsehidden(char *str,struct s_hidden *hidden) +{ + char *tmp,*p; + + hidden->phone=NULL; + hidden->txy=NULL; + + debug(6,"Hidden string %s\n",str); + + tmp=strdup(str); + p=strtok(tmp," "); + if(p) + { + if(p[0]!='-') hidden->phone=strdup(p); + p=strtok(NULL," "); + if(p) hidden->txy=strdup(p); + } + free(tmp); + return 1; +} + +int override(faddr *addr,node *nlent,fa_list *FromWhere) +{ + int i; + static char TXY[3]; + struct s_hidden hidden; + + hidden.phone=NULL; + hidden.txy=NULL; + + parsehidden(FromWhere->addr->name,&hidden); + if(hidden.phone) strncpy(nlent->phone,hidden.phone,strlen(nlent->phone)); + if(hidden.txy) + if(strcasecmp(hidden.txy,"CM")==0) nlent->flags |= CM; + else + { + strncpy(TXY,hidden.txy,3); + if(nlent->flags & CM) + { + i=0;while(nlent->uflags[i] && iuflags[i]=TXY; + if(i+1uflags[i+1]=NULL; + nlent->flags&=~CM; + } + else + { + i=0; + while(nlent->uflags[i] && iuflags[i][0]=='T' || + (nlent->uflags[i][0]=='U' && nlent->uflags[i][1]=='T')) + { + nlent->uflags[i]=TXY; + i=MAXUFLAGS+1; + } + i++; + } + if(i<=MAXUFLAGS) + { + if(iuflags[i]=TXY; + else loginf("Can't change call time for %s",ascinode(addr,0x1f)); + if(i+1uflags[i+1]=NULL; + } + } + } /* Not CM */ + free(hidden.phone); + free(hidden.txy); + return 0; +} + +int setline(faddr *addr,node *nlent,callstat *st) +{ + fa_list *tmp,*Lines[MAXLINES]; + int i,TryLine,LineCount=1; + + Lines[0]=NULL; /* First Line - from nodelist. May be override */ + + for (tmp=Override;tmp;tmp=tmp->next) + if ((tmp->addr->net == addr->net) && + (tmp->addr->node == addr->node)) Lines[0]=tmp; + + for (tmp=Hidden;tmp;tmp=tmp->next) + if ((tmp->addr->net == addr->net) && (tmp->addr->node == addr->node)) + if(LineCounttryno % LineCount; + + debug(6,"--- First TryLine = %d from %d lines --- \n", TryLine,LineCount); + + for(i=TryLine;i