small enhancement's and fixes
This commit is contained in:
parent
89ec6b7eea
commit
c48900c6b9
|
@ -1,4 +1,4 @@
|
|||
/* $Id: processor.c,v 1.76 1999/07/11 15:30:55 akool Exp $
|
||||
/* $Id: processor.c,v 1.77 1999/07/15 16:41:32 akool Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (log-module)
|
||||
*
|
||||
|
@ -19,6 +19,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: processor.c,v $
|
||||
* Revision 1.77 1999/07/15 16:41:32 akool
|
||||
* small enhancement's and fixes
|
||||
*
|
||||
* Revision 1.76 1999/07/11 15:30:55 akool
|
||||
* Patch from Karsten (thanks a lot!)
|
||||
*
|
||||
|
@ -3621,54 +3624,13 @@ static void prepareRate(int chan, char **msg, char **tip, int viarep)
|
|||
call[chan].Rate.src[1] = "";
|
||||
call[chan].Rate.src[2] = mynum;
|
||||
} else {
|
||||
#if 0
|
||||
static char src[BUFSIZ], *text;
|
||||
auto int l;
|
||||
|
||||
l = getAreacode(49, call[chan].num[CALLING] + 3, &text);
|
||||
print_msg(PRT_NORMAL, "getAreacode(49,%s,\"%s\")=%d\n", call[chan].num[CALLING] + 3, text, l);
|
||||
|
||||
if ((get_areacode(call[chan].num[CALLING], &l, C_NO_WARN | C_NO_EXPAND | C_NO_ERROR)))
|
||||
Strncpy(src, call[chan].num[CALLING], l + 1);
|
||||
else
|
||||
strcpy(src, call[chan].num[CALLING]);
|
||||
|
||||
call[chan].Rate.src = src;
|
||||
#else
|
||||
call[chan].Rate.src[0] = call[chan].areacode[CALLING];
|
||||
call[chan].Rate.src[1] = call[chan].vorwahl[CALLING];
|
||||
call[chan].Rate.src[2] = call[chan].rufnummer[CALLING];
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
static char dst[BUFSIZ];
|
||||
auto int l;
|
||||
|
||||
#if 0
|
||||
auto char *text;
|
||||
|
||||
l = getAreacode(myicountry, call[chan].num[CALLED] + 3, &text);
|
||||
|
||||
print_msg(PRT_NORMAL, "getAreacode(%d, %s,\"%s\")=%d\n", myicountry, call[chan].num[CALLED] + 3, text, l);
|
||||
|
||||
if (text)
|
||||
free(text);
|
||||
#endif
|
||||
|
||||
if ((get_areacode(call[chan].num[CALLED], &l, C_NO_WARN | C_NO_EXPAND | C_NO_ERROR)))
|
||||
Strncpy(dst, call[chan].num[CALLED], l + 1);
|
||||
else
|
||||
strcpy(dst, call[chan].num[CALLED]);
|
||||
|
||||
call[chan].Rate.dst = dst;
|
||||
}
|
||||
#else
|
||||
call[chan].Rate.dst[0] = call[chan].areacode[CALLED];
|
||||
call[chan].Rate.dst[1] = call[chan].vorwahl[CALLED];
|
||||
call[chan].Rate.dst[2] = call[chan].rufnummer[CALLED];
|
||||
#endif
|
||||
|
||||
if (getRate(&call[chan].Rate, msg) == UNKNOWN)
|
||||
return;
|
||||
|
@ -3691,7 +3653,7 @@ static void prepareRate(int chan, char **msg, char **tip, int viarep)
|
|||
return;
|
||||
|
||||
if (msg && call[chan].tarifknown)
|
||||
showRates(&call[chan].Rate, message);
|
||||
showRates(&call[chan].Rate, *msg=message);
|
||||
|
||||
if ((call[chan].hint = getLeastCost(&call[chan].Rate, &lcRate, 1, -1)) != UNKNOWN) {
|
||||
if (tip) {
|
||||
|
@ -4991,7 +4953,7 @@ void processcint()
|
|||
info(chan, PRT_SHOWCONNECT, STATE_CONNECT, sx);
|
||||
|
||||
processLCR(chan, h);
|
||||
while (*h)
|
||||
while (h)
|
||||
info(chan, PRT_SHOWHANGUP, STATE_HANGUP, strsep(&h,"\n"));
|
||||
|
||||
huptime(chan, 0);
|
||||
|
|
|
@ -1763,7 +1763,7 @@ A:Moldau, Neuseeland, Niederl
|
|||
A:Russische Föderation, Reunion, St. Pierre und Miquelon, Singapur, Südafrika
|
||||
A:Südkorea, Saipan
|
||||
Z:9 Welt 3
|
||||
T:*/*=19.66(60)/0.92/1 rund um die Uhr
|
||||
T:*/*=19.66(60)/1 rund um die Uhr
|
||||
A:Ägypten, Angola, Argentinien, Aruba, Ascension, Bahrain, Barbados, Belize
|
||||
A:Benin, Bermuda, Bhutan, Bolivien, Botsuana, Brasilien, Brunei, Burkina Faso
|
||||
A:Burundi, Caymaninseln, China, Costa Rica, Dschibuti, Dominica, Ecuador
|
||||
|
@ -1779,7 +1779,7 @@ A:Saint Vincent und die Grenadinen, Sudan, Syrien, Tadschikistan, Tansania
|
|||
A:Taiwan, Thailand, Trinidad und Tobago, Turkmenistan, Uruguay, Usbekistan
|
||||
A:Vanuatu, Venezuela, Vereinigte Arabische Emirate
|
||||
Z:10 Welt 4
|
||||
T:*/*=26.66(60)/0.68/1 rund um die Uhr
|
||||
T:*/*=26.66(60)/1 rund um die Uhr
|
||||
A:Afghanistan, Algerien, Anguilla, Antigua und Barbuda, Äquatorial-Guinea
|
||||
A:Äthiopien, Bangladesch, Cook-Inseln, Cote d'Ivoire, Diego Garcia, Eritrea
|
||||
A:Guam, Guantanamo, Guinea, Guinea-Bissau, Guyana, Irak, Jemen, Kambodscha
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: holiday.c,v 1.14 1999/06/22 19:41:19 akool Exp $
|
||||
/* $Id: holiday.c,v 1.15 1999/07/15 16:41:49 akool Exp $
|
||||
*
|
||||
* Feiertagsberechnung
|
||||
*
|
||||
|
@ -19,6 +19,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: holiday.c,v $
|
||||
* Revision 1.15 1999/07/15 16:41:49 akool
|
||||
* small enhancement's and fixes
|
||||
*
|
||||
* Revision 1.14 1999/06/22 19:41:19 akool
|
||||
* zone-1.1 fixes
|
||||
*
|
||||
|
@ -433,39 +436,62 @@ static int isHoliday(struct tm *tm, char **name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static char *staticString (char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char buffer[BUFSIZ];
|
||||
int i;
|
||||
|
||||
static char **Table=NULL;
|
||||
static int Size=0;
|
||||
|
||||
va_start (ap, fmt);
|
||||
vsnprintf (buffer, BUFSIZ, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
for (i=0; i<Size; i++)
|
||||
if (strcmp (buffer, Table[i])==0)
|
||||
return Table[i];
|
||||
|
||||
Size++;
|
||||
Table=realloc(Table, Size*sizeof(char*));
|
||||
Table[Size-1]=strdup(buffer);
|
||||
|
||||
return Table[Size-1];
|
||||
}
|
||||
|
||||
int isDay(struct tm *tm, bitfield mask, char **name)
|
||||
{
|
||||
julian day;
|
||||
int holiday;
|
||||
char *holiname;
|
||||
static char buffer[BUFSIZ];
|
||||
|
||||
holiday=isHoliday(tm, &holiname);
|
||||
|
||||
if ((mask & (1<<HOLIDAY)) && holiday) {
|
||||
if (name) sprintf (*name=buffer, "%s (%s)", Weekday[HOLIDAY], holiname);
|
||||
if (name) *name=staticString("%s (%s)", Weekday[HOLIDAY], holiname);
|
||||
return HOLIDAY;
|
||||
}
|
||||
|
||||
day=(date2julian(tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday)-6)%7+MONDAY;
|
||||
|
||||
if ((mask & (1<<WEEKEND)) && (day==SATURDAY || day==SUNDAY)) {
|
||||
if (name) sprintf (*name=buffer, "%s (%s)", Weekday[WEEKEND], Weekday[day]);
|
||||
if (name) *name=staticString("%s (%s)", Weekday[WEEKEND], Weekday[day]);
|
||||
return WEEKEND;
|
||||
}
|
||||
|
||||
if ((mask & (1<<WORKDAY)) && day!=SATURDAY && day!=SUNDAY && !holiday) {
|
||||
if (name) sprintf (*name=buffer, "%s (%s)", Weekday[WORKDAY], Weekday[day]);
|
||||
if (name) *name=staticString("%s (%s)", Weekday[WORKDAY], Weekday[day]);
|
||||
return WORKDAY;
|
||||
}
|
||||
|
||||
if (mask & (1<<day)) {
|
||||
if (name) sprintf(*name=buffer, "%s", Weekday[day]);
|
||||
if (name) *name=staticString("%s", Weekday[day]);
|
||||
return day;
|
||||
}
|
||||
|
||||
if (mask & (1<<EVERYDAY)) {
|
||||
if (name) sprintf(*name=buffer, "%s", Weekday[day]);
|
||||
if (name) *name=staticString("%s", Weekday[day]);
|
||||
return day;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: isdnrate.c,v 1.10 1999/07/07 19:44:07 akool Exp $
|
||||
/* $Id: isdnrate.c,v 1.11 1999/07/15 16:42:04 akool Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (rate evaluation)
|
||||
*
|
||||
|
@ -19,6 +19,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: isdnrate.c,v $
|
||||
* Revision 1.11 1999/07/15 16:42:04 akool
|
||||
* small enhancement's and fixes
|
||||
*
|
||||
* Revision 1.10 1999/07/07 19:44:07 akool
|
||||
* patches from Michael and Leo
|
||||
*
|
||||
|
@ -62,7 +65,7 @@
|
|||
#define ZAUNPFAHL 1 /* FIXME: Michi: Offset */
|
||||
|
||||
static char *myname, *myshortname;
|
||||
static char options[] = "Vvd:hb:s:txu";
|
||||
static char options[] = "Vvd:h:l:Hb:s:tx::u";
|
||||
static char usage[] = "%s: usage: %s [ -%s ] Destination ...\n";
|
||||
|
||||
static int verbose = 0, header = 0, best = MAXPROVIDER, table = 0, explain = 0;
|
||||
|
@ -167,39 +170,43 @@ static int opts(int argc, char *argv[])
|
|||
case 'v' : verbose++;
|
||||
break;
|
||||
|
||||
case 'd' : duration = strtol(optarg, NIL, 0);
|
||||
case 'l' : duration = strtol(optarg, NIL, 0); /* l wie lt */
|
||||
break;
|
||||
|
||||
case 'h' : header++;
|
||||
case 'H' : header++;
|
||||
break;
|
||||
|
||||
case 'b' : best = strtol(optarg, NIL, 0);
|
||||
break;
|
||||
|
||||
case 's' : day = atoi(optarg);
|
||||
case 'd' : day = atoi(optarg);
|
||||
if ((p = strchr(optarg, '/'))) {
|
||||
month = atoi(p + 1);
|
||||
|
||||
if ((p = strchr(p + 1, '/'))) {
|
||||
year = atoi(p + 1);
|
||||
|
||||
if (year < 100)
|
||||
year += 1900; /* JA, JA!! */
|
||||
|
||||
if ((p = strchr(p + 1, '/'))) {
|
||||
hour = atoi(p + 1);
|
||||
|
||||
if ((p = strchr(p + 1, '/')))
|
||||
min = atoi(p + 1);
|
||||
}
|
||||
if (year < 50)
|
||||
year += 2000;
|
||||
else if (year < 100)
|
||||
year += 1900;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'h': hour = atoi(optarg);
|
||||
if ((p = strchr(p + 1, ':')))
|
||||
min = atoi(p + 1);
|
||||
break;
|
||||
|
||||
case 't' : table++;
|
||||
break;
|
||||
|
||||
case 'x' : explain++;
|
||||
{
|
||||
int x;
|
||||
if (optarg && (x=atoi(optarg)))
|
||||
explain=x;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'u' : usestat++;
|
||||
|
@ -228,6 +235,27 @@ static int compare2(const void *s1, const void *s2)
|
|||
return(((SORT2 *)s1)->weight < ((SORT2 *)s2)->weight);
|
||||
} /* compare2 */
|
||||
|
||||
char *short_explainRate (RATE *Rate)
|
||||
{
|
||||
static char buffer[BUFSIZ];
|
||||
char *p=buffer;
|
||||
|
||||
if (Rate->Zone && *Rate->Zone)
|
||||
p+=sprintf (p, "%s", Rate->Zone);
|
||||
else
|
||||
p+=sprintf (p, "Zone %d", Rate->zone);
|
||||
|
||||
if (!Rate->domestic && Rate->Country && *Rate->Country)
|
||||
p+=sprintf (p, " (%s)", Rate->Country);
|
||||
|
||||
if (Rate->Day && *Rate->Day)
|
||||
p+=sprintf (p, ", %s", Rate->Day);
|
||||
|
||||
if (Rate->Hour && *Rate->Hour)
|
||||
p+=sprintf (p, ", %s", Rate->Hour);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static char *printrate(RATE *Rate)
|
||||
{
|
||||
|
@ -235,19 +263,19 @@ static char *printrate(RATE *Rate)
|
|||
|
||||
|
||||
if (Rate->Basic > 0)
|
||||
sprintf(message, "%s + %s/%3.1fs = %s + %s/Min (%s)",
|
||||
sprintf(message, "%s + %s/%.4fs = %s + %s/Min (%s)",
|
||||
printRate(Rate->Basic),
|
||||
printRate(Rate->Price),
|
||||
Rate->Duration,
|
||||
printRate(Rate->Basic),
|
||||
printRate(60 * Rate->Price / Rate->Duration),
|
||||
explainRate(Rate));
|
||||
short_explainRate(Rate));
|
||||
else
|
||||
sprintf(message, "%s/%3.1fs = %s/Min (%s)",
|
||||
sprintf(message, "%s/%.4fs = %s/Min (%s)",
|
||||
printRate(Rate->Price),
|
||||
Rate->Duration,
|
||||
printRate(60 * Rate->Price / Rate->Duration),
|
||||
explainRate(Rate));
|
||||
short_explainRate(Rate));
|
||||
|
||||
return(message);
|
||||
} /* printrate */
|
||||
|
@ -350,6 +378,7 @@ static void numsplit(char *num)
|
|||
|
||||
if (1 /* l3 != UNKNOWN */) {
|
||||
print_msg(PRT_NORMAL, "getAreacode(%d, %s, %s)=%d\n", atoi(p), num + l1, s, l3);
|
||||
if (l3 != UNKNOWN)
|
||||
free(s);
|
||||
zone = getZone(DTAG, myarea, num + l1);
|
||||
print_msg(PRT_NORMAL, "getZone(%d,%s,%s)=%d\n", DTAG, myarea, num + l1, zone);
|
||||
|
@ -477,10 +506,14 @@ static int compute()
|
|||
sort[n].prefix = Rate.prefix;
|
||||
sort[n].rate = Rate.Charge;
|
||||
|
||||
if (explain) {
|
||||
if (explain == 2) {
|
||||
sprintf(s, " (%s)", printrate(&Rate));
|
||||
sort[n].explain = strdup(s);
|
||||
}
|
||||
else if (explain == 1) {
|
||||
sprintf(s, " (%s)", Rate.Zone);
|
||||
sort[n].explain = strdup(s);
|
||||
}
|
||||
else
|
||||
sort[n].explain = strdup("");
|
||||
|
||||
|
@ -773,12 +806,14 @@ int main(int argc, char *argv[], char *envp[])
|
|||
print_msg(PRT_NORMAL, "\n");
|
||||
print_msg(PRT_NORMAL, "\t-V\t\tshow version infos\n");
|
||||
print_msg(PRT_NORMAL, "\t-v\t\tverbose\n");
|
||||
print_msg(PRT_NORMAL, "\t-d duration\t duration of call in seconds (default %d seconds)\n", LCR_DURATION);
|
||||
print_msg(PRT_NORMAL, "\t-h\t\tshow a header\n");
|
||||
print_msg(PRT_NORMAL, "\t-l duration\t duration of call in seconds (default %d seconds)\n", LCR_DURATION);
|
||||
print_msg(PRT_NORMAL, "\t-H\t\tshow a header\n");
|
||||
print_msg(PRT_NORMAL, "\t-t\t\tshow a table\n");
|
||||
print_msg(PRT_NORMAL, "\t-b best\tshow only the first <best> provider(s) (default %d)\n", MAXPROVIDER);
|
||||
print_msg(PRT_NORMAL, "\t-s d/m/y/h/m\tstart of call (default now)\n");
|
||||
print_msg(PRT_NORMAL, "\t-d d/m/y\tstart date of call (default now)\n");
|
||||
print_msg(PRT_NORMAL, "\t-h h:/m\tstart time of call (default now)\n");
|
||||
print_msg(PRT_NORMAL, "\t-x\texplain each rate\n");
|
||||
print_msg(PRT_NORMAL, "\t-x2\texplain more\n");
|
||||
print_msg(PRT_NORMAL, "\t-u\tshow usage stats\n");
|
||||
} /* else */
|
||||
|
||||
|
|
|
@ -925,11 +925,22 @@ void rate_1066(void) {
|
|||
for (z=0; z<COUNT(Zone); z++) {
|
||||
rprintf (Zone[z][0], "Z:%d", z+1);
|
||||
if (Tarif[z][0]==Tarif[z][1]) {
|
||||
rprintf ("rund um die Uhr", "T:*/*=%.2f(60)/%.2f/1", Tarif[z][0], 18.0/Tarif[z][0]);
|
||||
if (18.0/Tarif[z][0]>1.0)
|
||||
rprintf ("rund um die Uhr", "T:*/*=%.2f(60)/%.2f/1", Tarif[z][0], 18.0/Tarif[z][0]);
|
||||
else
|
||||
rprintf ("rund um die Uhr", "T:*/*=%.2f(60)/1", Tarif[z][0]);
|
||||
} else {
|
||||
if (18.0/Tarif[z][0]>1.0)
|
||||
rprintf ("Tag", "T:1-5/8-18=%.2f(60)/%.2f/1", Tarif[z][0], 18.0/Tarif[z][0]);
|
||||
else
|
||||
rprintf ("Tag", "T:1-5/8-18=%.2f(60)/1", Tarif[z][0]);
|
||||
if (18.0/Tarif[z][1]>1.0) {
|
||||
rprintf ("Nacht", "T:1-5/18-8=%.2f(60)/%.2f/1", Tarif[z][1], 18.0/Tarif[z][1]);
|
||||
rprintf ("Weekend", "T:E,H/*=%.2f(60)/%.2f/1", Tarif[z][1], 18.0/Tarif[z][1]);
|
||||
} else {
|
||||
rprintf ("Nacht", "T:1-5/18-8=%.2f(60)/1", Tarif[z][1]);
|
||||
rprintf ("Weekend", "T:E,H/*=%.2f(60)/1", Tarif[z][1]);
|
||||
}
|
||||
}
|
||||
print_area(Zone[z][1]);
|
||||
}
|
||||
|
@ -1023,7 +1034,7 @@ int main (int argc, char *argv[])
|
|||
printf ("U:%%.3f öS\n");
|
||||
|
||||
#if 0
|
||||
rate_1001();
|
||||
rate_1066();
|
||||
#else
|
||||
rate_1001_old();
|
||||
rate_1002();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: rate.c,v 1.34 1999/07/12 18:50:06 akool Exp $
|
||||
/* $Id: rate.c,v 1.35 1999/07/15 16:42:10 akool Exp $
|
||||
*
|
||||
* Tarifdatenbank
|
||||
*
|
||||
|
@ -19,6 +19,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: rate.c,v $
|
||||
* Revision 1.35 1999/07/15 16:42:10 akool
|
||||
* small enhancement's and fixes
|
||||
*
|
||||
* Revision 1.34 1999/07/12 18:50:06 akool
|
||||
* replace "0" by "+49"
|
||||
*
|
||||
|
@ -806,7 +809,7 @@ int initRate(char *conf, char *dat, char *dom, char **msg)
|
|||
|
||||
if (*c == '0' && (*(c + 1) != '0')) {
|
||||
sprintf(sx, "%s%s", mycountry, c + 1);
|
||||
print_msg(PRT_NORMAL, "WARNING: Replacing %s by %s\n", c, sx);
|
||||
warning(dat, "Replacing %s by %s\n", c, sx);
|
||||
c = sx;
|
||||
} /* if */
|
||||
|
||||
|
|
Loading…
Reference in New Issue