New option -U: default source number for outgoing calls.

This commit is contained in:
tobiasb 2004-12-16 21:30:50 +00:00
parent f3b36e3011
commit 7130a5ba40
5 changed files with 73 additions and 8 deletions

View File

@ -1,3 +1,10 @@
2004-12-16 Tobias Becker <tobiasb@isdn4linux.de>
* rep_main.c (parse_options, main): New option `-U', sets default
source number for outgoing calls if missing in log entry.
* isdnrep.h (defsrc): New global variable for `-U' option.
* isdnrep.c (repair): Apply `-U' option.
2004-07-25 Tobias Becker <tobiasb@isdn4linux.de>
* rep_main.c (parse_options): New option `-m', multiplies or divides

View File

@ -1,5 +1,5 @@
.\" $Id: isdnrep.1.in,v 1.8 2004/07/25 14:21:13 tobiasb Exp $
.\" CHECKIN $Date: 2004/07/25 14:21:13 $
.\" $Id: isdnrep.1.in,v 1.9 2004/12/16 21:30:50 tobiasb Exp $
.\" CHECKIN $Date: 2004/12/16 21:30:50 $
.TH isdnrep 1 "@MANDATE_ISDNREP@" "ISDN 4 Linux @I4LVERSION@" "Linux System Commands"
.PD 0
@ -116,6 +116,14 @@ If the flag 'n' is given, the given number is
.B not
to be displayed.
.TP
.B \-U [_][.]'number' default source number
Use 'number' as source number for outgoing calls with an unknown source
number ("?"). '.' is replaced by country and area code from @CONFFILE@.
With '_' the default source number is used internally (e.g. for fetching
the right zone names from the ratefile) but it is not displayed.
.TP
.B \-i incoming
Only incoming connections are displayed.

View File

@ -1,4 +1,4 @@
/* $Id: isdnrep.c,v 1.101 2004/07/25 14:21:13 tobiasb Exp $
/* $Id: isdnrep.c,v 1.102 2004/12/16 21:30:50 tobiasb Exp $
*
* ISDN accounting for isdn4linux. (Report-module)
*
@ -24,6 +24,9 @@
*
*
* $Log: isdnrep.c,v $
* Revision 1.102 2004/12/16 21:30:50 tobiasb
* New option -U: default source number for outgoing calls.
*
* 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
@ -2426,7 +2429,12 @@ static void repair(one_call *cur_call)
TELNUM srcnum, destnum;
int have_z; /* Zone Rate.z from getZone valid or not */
int best_zone; /* =Rate.z if valid or =Rate.zone if Rate.z invalid */
int is_defsrc = 0; /* default source number used or not */
if (cur_call->dir == DIALOUT && !*cur_call->num[CALLING] && defsrc.mode > 0) {
Strncpy(cur_call->num[CALLING], defsrc.number, NUMSIZE);
++is_defsrc;
}
if (*cur_call->num[CALLING]) {
normalizeNumber(cur_call->num[CALLING],&srcnum,TN_ALL);
strcpy(cur_call->sarea[CALLING], srcnum.sarea);
@ -2576,6 +2584,8 @@ static void repair(one_call *cur_call)
} /* if valid zones_.. index */
} /* if getRate sucessful */
} /* if DIALOUT && duration > && num[CALLED] */
if (is_defsrc && defsrc.mode == 2) /* do not display default source number */
*cur_call->num[CALLING] = 0;
} /* repair */
/*****************************************************************************/
@ -2730,7 +2740,7 @@ static int set_caller_infos(one_call *cur_call, char *string, time_t from)
/* repair() recalculates the connection cost for entries with LOG_VERSION
* older than the current and sets cur_call->zone for outgoing calls with
* recorded one of -1 (=UNKNWON). The necessary information is taken from
* the current rate-file. The -r option is also handled there.
* the current rate-file. The -r and -U options are also handled there.
*/
repair(cur_call);

View File

@ -1,4 +1,4 @@
/* $Id: isdnrep.h,v 1.24 2004/07/25 14:21:13 tobiasb Exp $
/* $Id: isdnrep.h,v 1.25 2004/12/16 21:30:50 tobiasb Exp $
*
* ISDN accounting for isdn4linux.
*
@ -20,6 +20,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: isdnrep.h,v $
* Revision 1.25 2004/12/16 21:30:50 tobiasb
* New option -U: default source number for outgoing calls.
*
* 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
@ -231,6 +234,13 @@ typedef struct {
double number; /* number for multiplication or division */
} MODCOST;
/*****************************************************************************/
typedef struct {
int mode; /* 0 no action, 1 use and show, 2 only use */
char *number; /* replacement for missing source numbers */
} DEFSRC;
/*****************************************************************************/
/* isdnrep.c defines _REP_FUNC_C_, rep_main.c defines _ISDNREP_C_, ... */
#ifdef _REP_FUNC_C_
@ -284,6 +294,7 @@ _EXTERN int preselect _SET_33;
_EXTERN int summary _SET_0;
_EXTERN RECALC recalc; /* initiation done in main */
_EXTERN MODCOST modcost; /* initiation done in main */
_EXTERN DEFSRC defsrc; /* initiation done in main */
_EXTERN int sel_sums[3] _SET_ARRAY_0;
_EXTERN bitfield days[2] _SET_ARRAY_0;
_EXTERN bitfield hours[2] _SET_ARRAY_0;

View File

@ -1,4 +1,4 @@
/* $Id: rep_main.c,v 1.19 2004/07/25 14:21:13 tobiasb Exp $
/* $Id: rep_main.c,v 1.20 2004/12/16 21:30:50 tobiasb Exp $
*
* ISDN accounting for isdn4linux. (Report-module)
*
@ -20,6 +20,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: rep_main.c,v $
* Revision 1.20 2004/12/16 21:30:50 tobiasb
* New option -U: default source number for outgoing calls.
*
* 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
@ -311,7 +314,7 @@ static char fnbuff[512] = "";
static char usage[] = "%s: usage: %s [ -%s ]\n";
static char wrongdate[] = "unknown date: %s\n";
static char wrongxopt[] = "error in -x option starting at: %s\n";
static char options[] = "abcd:f:him:nop: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:SU:V";
static char *linefmt = "";
static char *htmlreq = NULL;
static char *phonenumberarg = NULL;
@ -331,7 +334,7 @@ int main(int argc, char *argv[], char *envp[])
recalc.mode = '\0'; recalc.prefix = UNKNOWN; recalc.input = NULL;
recalc.count = recalc.unknown = recalc.cheaper = 0;
modcost.mode = 0;
modcost.mode = defsrc.mode = 0;
select_summaries(sel_sums, NULL); /* default: all summaries */
/* we don't need this at the moment:
@ -390,6 +393,21 @@ int main(int argc, char *argv[], char *envp[])
free(phonenumberarg);
}
if (defsrc.mode > 0 && *defsrc.number == '.') {
/* prefix country and area code from isdn.conf */
ptr = calloc(strlen(mycountry) + strlen(myarea) + strlen(defsrc.number),
sizeof(char));
if (ptr == NULL) {
printf("No memory for complete default source number (-U)\n");
return 1;
}
strcat(ptr, mycountry);
strcat(ptr, myarea);
strcat(ptr, defsrc.number + 1);
free(defsrc.number);
defsrc.number = ptr;
}
if (htmlreq)
{
send_html_request(myname,htmlreq);
@ -560,6 +578,17 @@ static int parse_options(int argc, char *argv[], char *myname)
*ptr = 0;
break;
case 'U' : defsrc.mode = (*optarg == '_') ? 2 : 1;
ptr = optarg - 1 + defsrc.mode;
/* mycountry and myarea may not yet known */
defsrc.number = calloc(strlen(ptr) + 1, sizeof(char));
if (!defsrc.number) {
printf("No memory for default source number (-U)\n");
return 1;
}
strcat(defsrc.number, ptr);
break;
case '?' : printf(usage, argv[0], argv[0], options);
return(1);
} /* switch */