New isdnrep option -m [*|/]number. It multiplies or divide the cost of
each call by the given number. `-m/1.16' for example displays the costs without the German `Umsatzsteuer'.
This commit is contained in:
parent
13385b9e26
commit
d769b7b4ad
|
@ -1,3 +1,10 @@
|
||||||
|
2004-07-25 Tobias Becker <tobiasb@isdn4linux.de>
|
||||||
|
|
||||||
|
* rep_main.c (parse_options): New option `-m', multiplies or divides
|
||||||
|
connection costs before displaying
|
||||||
|
* isdnrep.h (modcost): New global variable for `-m' option.
|
||||||
|
* isdnrep.c (print_header, set_caller_infos): Apply `-m' option.
|
||||||
|
|
||||||
2004-07-24 Tobias Becker <tobiasb@isdn4linux.de>
|
2004-07-24 Tobias Becker <tobiasb@isdn4linux.de>
|
||||||
|
|
||||||
* rep_main.c (parse_options): New option `-x', selects calls by hour
|
* rep_main.c (parse_options): New option `-x', selects calls by hour
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.\" $Id: isdnrep.1.in,v 1.7 2004/07/24 17:58:06 tobiasb Exp $
|
.\" $Id: isdnrep.1.in,v 1.8 2004/07/25 14:21:13 tobiasb Exp $
|
||||||
.\" CHECKIN $Date: 2004/07/24 17:58:06 $
|
.\" CHECKIN $Date: 2004/07/25 14:21:13 $
|
||||||
.TH isdnrep 1 "@MANDATE_ISDNREP@" "ISDN 4 Linux @I4LVERSION@" "Linux System Commands"
|
.TH isdnrep 1 "@MANDATE_ISDNREP@" "ISDN 4 Linux @I4LVERSION@" "Linux System Commands"
|
||||||
|
|
||||||
.PD 0
|
.PD 0
|
||||||
|
@ -241,6 +241,12 @@ B
|
||||||
Like b but allow all providers, not only the booked.
|
Like b but allow all providers, not only the booked.
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
|
.TP
|
||||||
|
\fB\-m\fR[\fB*\fR|\fB/\fR]\fInumber\fB modify call costs\fR
|
||||||
|
Multiply (*) or divide (/) the stored or recalculated call costs
|
||||||
|
by number before displaying them. If neither * nor / is given,
|
||||||
|
multiply.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-wX WWW
|
.B \-wX WWW
|
||||||
isdnrep can give its output in HTML format; this is switched on with
|
isdnrep can give its output in HTML format; this is switched on with
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: isdnrep.c,v 1.100 2004/07/24 17:58:06 tobiasb Exp $
|
/* $Id: isdnrep.c,v 1.101 2004/07/25 14:21:13 tobiasb Exp $
|
||||||
*
|
*
|
||||||
* ISDN accounting for isdn4linux. (Report-module)
|
* ISDN accounting for isdn4linux. (Report-module)
|
||||||
*
|
*
|
||||||
|
@ -24,6 +24,11 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $Log: isdnrep.c,v $
|
* $Log: isdnrep.c,v $
|
||||||
|
* Revision 1.101 2004/07/25 14:21:13 tobiasb
|
||||||
|
* New isdnrep option -m [*|/]number. It multiplies or divide the cost of
|
||||||
|
* each call by the given number. `-m/1.16' for example displays the costs
|
||||||
|
* without the German `Umsatzsteuer'.
|
||||||
|
*
|
||||||
* Revision 1.100 2004/07/24 17:58:06 tobiasb
|
* Revision 1.100 2004/07/24 17:58:06 tobiasb
|
||||||
* New isdnrep options: `-L:' controls the displayed call summaries in the
|
* New isdnrep options: `-L:' controls the displayed call summaries in the
|
||||||
* report footer. `-x' displays only call selected or not deselected by
|
* report footer. `-x' displays only call selected or not deselected by
|
||||||
|
@ -2200,6 +2205,11 @@ static int print_header(int lday)
|
||||||
}
|
}
|
||||||
print_line2(F_TEXT_LINE, "%s", s);
|
print_line2(F_TEXT_LINE, "%s", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: consistent terminology. fees vs. costs (tobiasb|200407) */
|
||||||
|
if (modcost.mode)
|
||||||
|
print_line2(F_TEXT_LINE, "All displayed costs have been %s by %s.",
|
||||||
|
modcost.mode == 2 ? "divided" : "multiplied", modcost.numstr);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2724,6 +2734,14 @@ static int set_caller_infos(one_call *cur_call, char *string, time_t from)
|
||||||
*/
|
*/
|
||||||
repair(cur_call);
|
repair(cur_call);
|
||||||
|
|
||||||
|
if (cur_call->pay != 0.0 && modcost.mode)
|
||||||
|
{
|
||||||
|
if (modcost.mode == 1)
|
||||||
|
cur_call->pay *= modcost.number;
|
||||||
|
else if (modcost.mode == 2)
|
||||||
|
cur_call->pay /= modcost.number;
|
||||||
|
}
|
||||||
|
|
||||||
return(rc);
|
return(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: isdnrep.h,v 1.23 2004/07/24 17:58:06 tobiasb Exp $
|
/* $Id: isdnrep.h,v 1.24 2004/07/25 14:21:13 tobiasb Exp $
|
||||||
*
|
*
|
||||||
* ISDN accounting for isdn4linux.
|
* ISDN accounting for isdn4linux.
|
||||||
*
|
*
|
||||||
|
@ -20,6 +20,11 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*
|
*
|
||||||
* $Log: isdnrep.h,v $
|
* $Log: isdnrep.h,v $
|
||||||
|
* Revision 1.24 2004/07/25 14:21:13 tobiasb
|
||||||
|
* New isdnrep option -m [*|/]number. It multiplies or divide the cost of
|
||||||
|
* each call by the given number. `-m/1.16' for example displays the costs
|
||||||
|
* without the German `Umsatzsteuer'.
|
||||||
|
*
|
||||||
* Revision 1.23 2004/07/24 17:58:06 tobiasb
|
* Revision 1.23 2004/07/24 17:58:06 tobiasb
|
||||||
* New isdnrep options: `-L:' controls the displayed call summaries in the
|
* New isdnrep options: `-L:' controls the displayed call summaries in the
|
||||||
* report footer. `-x' displays only call selected or not deselected by
|
* report footer. `-x' displays only call selected or not deselected by
|
||||||
|
@ -218,6 +223,14 @@ typedef struct {
|
||||||
char *input; /* input from command line after -r[vp] */
|
char *input; /* input from command line after -r[vp] */
|
||||||
} RECALC;
|
} RECALC;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int mode; /* 0 no action, 1 multiply, 2 divide */
|
||||||
|
char *numstr; /* number as string, part of given option */
|
||||||
|
double number; /* number for multiplication or division */
|
||||||
|
} MODCOST;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* isdnrep.c defines _REP_FUNC_C_, rep_main.c defines _ISDNREP_C_, ... */
|
/* isdnrep.c defines _REP_FUNC_C_, rep_main.c defines _ISDNREP_C_, ... */
|
||||||
#ifdef _REP_FUNC_C_
|
#ifdef _REP_FUNC_C_
|
||||||
|
@ -270,6 +283,7 @@ _EXTERN int preselect _SET_33;
|
||||||
#endif
|
#endif
|
||||||
_EXTERN int summary _SET_0;
|
_EXTERN int summary _SET_0;
|
||||||
_EXTERN RECALC recalc; /* initiation done in main */
|
_EXTERN RECALC recalc; /* initiation done in main */
|
||||||
|
_EXTERN MODCOST modcost; /* initiation done in main */
|
||||||
_EXTERN int sel_sums[3] _SET_ARRAY_0;
|
_EXTERN int sel_sums[3] _SET_ARRAY_0;
|
||||||
_EXTERN bitfield days[2] _SET_ARRAY_0;
|
_EXTERN bitfield days[2] _SET_ARRAY_0;
|
||||||
_EXTERN bitfield hours[2] _SET_ARRAY_0;
|
_EXTERN bitfield hours[2] _SET_ARRAY_0;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: rep_main.c,v 1.18 2004/07/24 17:58:06 tobiasb Exp $
|
/* $Id: rep_main.c,v 1.19 2004/07/25 14:21:13 tobiasb Exp $
|
||||||
*
|
*
|
||||||
* ISDN accounting for isdn4linux. (Report-module)
|
* ISDN accounting for isdn4linux. (Report-module)
|
||||||
*
|
*
|
||||||
|
@ -20,6 +20,11 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*
|
*
|
||||||
* $Log: rep_main.c,v $
|
* $Log: rep_main.c,v $
|
||||||
|
* Revision 1.19 2004/07/25 14:21:13 tobiasb
|
||||||
|
* New isdnrep option -m [*|/]number. It multiplies or divide the cost of
|
||||||
|
* each call by the given number. `-m/1.16' for example displays the costs
|
||||||
|
* without the German `Umsatzsteuer'.
|
||||||
|
*
|
||||||
* Revision 1.18 2004/07/24 17:58:06 tobiasb
|
* Revision 1.18 2004/07/24 17:58:06 tobiasb
|
||||||
* New isdnrep options: `-L:' controls the displayed call summaries in the
|
* New isdnrep options: `-L:' controls the displayed call summaries in the
|
||||||
* report footer. `-x' displays only call selected or not deselected by
|
* report footer. `-x' displays only call selected or not deselected by
|
||||||
|
@ -306,7 +311,7 @@ static char fnbuff[512] = "";
|
||||||
static char usage[] = "%s: usage: %s [ -%s ]\n";
|
static char usage[] = "%s: usage: %s [ -%s ]\n";
|
||||||
static char wrongdate[] = "unknown date: %s\n";
|
static char wrongdate[] = "unknown date: %s\n";
|
||||||
static char wrongxopt[] = "error in -x option starting at: %s\n";
|
static char wrongxopt[] = "error in -x option starting at: %s\n";
|
||||||
static char options[] = "abcd:f:hinop:r:s:t:uvw:x:EF:L:M:NR:SV";
|
static char options[] = "abcd:f:him:nop:r:s:t:uvw:x:EF:L:M:NR:SV";
|
||||||
static char *linefmt = "";
|
static char *linefmt = "";
|
||||||
static char *htmlreq = NULL;
|
static char *htmlreq = NULL;
|
||||||
static char *phonenumberarg = NULL;
|
static char *phonenumberarg = NULL;
|
||||||
|
@ -326,6 +331,7 @@ int main(int argc, char *argv[], char *envp[])
|
||||||
|
|
||||||
recalc.mode = '\0'; recalc.prefix = UNKNOWN; recalc.input = NULL;
|
recalc.mode = '\0'; recalc.prefix = UNKNOWN; recalc.input = NULL;
|
||||||
recalc.count = recalc.unknown = recalc.cheaper = 0;
|
recalc.count = recalc.unknown = recalc.cheaper = 0;
|
||||||
|
modcost.mode = 0;
|
||||||
select_summaries(sel_sums, NULL); /* default: all summaries */
|
select_summaries(sel_sums, NULL); /* default: all summaries */
|
||||||
|
|
||||||
/* we don't need this at the moment:
|
/* we don't need this at the moment:
|
||||||
|
@ -340,6 +346,8 @@ int main(int argc, char *argv[], char *envp[])
|
||||||
* set_msnlist after readconfig.
|
* set_msnlist after readconfig.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* TODO: parse_options may print to stdout regardless a missing
|
||||||
|
* Content-Type header. (tobiasb|200407) */
|
||||||
if ((c=parse_options(argc, argv, myname) > 0))
|
if ((c=parse_options(argc, argv, myname) > 0))
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
|
@ -532,6 +540,26 @@ static int parse_options(int argc, char *argv[], char *myname)
|
||||||
case 'c' : do_defopts = 0;
|
case 'c' : do_defopts = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'm' : modcost.mode = (*optarg =='/') ? 2 : 1;
|
||||||
|
modcost.numstr = strdup(optarg);
|
||||||
|
if (*optarg == '*' || *optarg == '/')
|
||||||
|
modcost.numstr++;
|
||||||
|
ptr = NULL;
|
||||||
|
modcost.number = strtod(modcost.numstr, &ptr);
|
||||||
|
if (modcost.numstr == ptr)
|
||||||
|
{
|
||||||
|
printf("no number in -m option: %s\n", modcost.numstr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (modcost.mode == 2 && modcost.number == 0.0)
|
||||||
|
{
|
||||||
|
printf("division by 0 as requested in -m option not allowed.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (ptr && *ptr)
|
||||||
|
*ptr = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case '?' : printf(usage, argv[0], argv[0], options);
|
case '?' : printf(usage, argv[0], argv[0], options);
|
||||||
return(1);
|
return(1);
|
||||||
} /* switch */
|
} /* switch */
|
||||||
|
|
Loading…
Reference in New Issue