drop all isdnlog/isdnlog/ora* files

the copyright holders forbid commercial use of the code which makes it
non-free
This commit is contained in:
Rolf Leggewie 2012-03-31 21:08:22 +02:00
parent 3a0e53fd6c
commit f70ec5b736
6 changed files with 0 additions and 615 deletions

View File

@ -1,208 +0,0 @@
/*
* Copyright (C) 1999 Jan Bolt
*
* Permission to use, copy and distribute this software for
* non-commercial purposes is hereby granted without fee,
* provided that this copyright and permission notice appears
* in all copies.
*
* This software is provided "as-is", without ANY WARRANTY.
*
* ora_load.c 1999/01/07 Jan Bolt
*
* $Log: ora_load.c,v $
* Revision 1.2 2002/03/11 16:17:10 paul
* DM -> EUR
*
* Revision 1.1 1999/12/31 13:30:02 akool
* isdnlog-4.00 (Millenium-Edition)
* - Oracle support added by Jan Bolt (Jan.Bolt@t-online.de)
*
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdarg.h>
#include "policy.h"
#include "oracle.h"
static const char rcsid[] = "$Id: ora_load.c,v 1.2 2002/03/11 16:17:10 paul Exp $";
extern const char *db_load_error;
static const char *logfile;
static int debug, rowsInserted, insErrors;
/* overwrite syslog for console output */
void syslog(int pri, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, "\n");
}
static
char *trim(char *s)
{
char *p;
while (*s == ' ') s++;
if (!*s) return s;
p = s;
while (*p) p++;
p--;
while (*p == ' ') *p-- = '\0';
return s;
}
static
int isdngeb(FILE *fp)
{
oracle_DbStrIn call;
int row = 0, i;
char buf[256];
rowsInserted = 0;
for ( ; fgets(buf, sizeof(buf), fp); )
{
char *p;
row++;
/*printf("%s", buf);*/
memset(&call, 0, sizeof(call));
for (i = 0, p = buf; (p = strtok(p, "|")); p = 0)
{
i++;
/*printf("%d \"%s\"\n", p);*/
switch (i)
{
case 1: /* Datum (ctime(&t)+4, Nov 1 10:25:21 1998) */
/*struct tm tm;*/
/*strptime(p, "%b %d %H:%M:%S %Y", &tm);*/
/*call.connect = mktime(&tm);*/
break;
case 2: /* Anrufer */
strncpy(call.calling, trim(p), sizeof(call.calling));
call.calling[sizeof(call.calling)-1] = '\0';
break;
case 3: /* Angerufener */
strncpy(call.called, trim(p), sizeof(call.called));
call.called[sizeof(call.called)-1] = '\0';
break;
case 4: /* Dauer der Verbindung in Sekunden */
call.duration = atol(p);
break;
case 5: /* Dauer der Verbindung in 1/100 Sekunden */
call.hduration = atol(p);
break;
case 6: /* Zeitpunkt des Verbindungsaufbaues in UTC */
call.connect = atol(p);
break;
case 7: /* Gebuehreneinheiten (-1 == keine Meldung) */
call.aoce = atoi(p);
break;
case 8: /* "I" fuer incoming call, "O" fuer outgoing call */
call.dialin[0] = *trim(p);
call.dialin[1] = '\0';
break;
case 9: /* Status Verbindungsende */
call.cause = atoi(p);
break;
case 10: /* Summe der uebertragenen Byte (incoming) */
call.ibytes = atol(p);
break;
case 11: /* Summe der uebertragenen Byte (outgoing) */
call.obytes = atol(p);
break;
case 12: /* Versionsnummer der "isdn.log" Eintragung */
strncpy(call.version, trim(p), sizeof(call.version));
call.version[sizeof(call.version)-1] = '\0';
break;
case 13: /* Dienstkennung (1=Speech, 7=Data usw.) */
call.si1 = atoi(p);
break;
case 14: /* 0 = ISDN, 1 = analog */
call.si11 = atoi(p);
break;
case 15: /* Currency Factor (0.121) */
call.currency_factor = atof(p);
break;
case 16: /* Waehrung (EUR) */
strncpy(call.currency, trim(p), sizeof(call.currency));
call.currency[sizeof(call.currency)-1] = '\0';
break;
case 17: /* Gebuehrensumme (xx.xx) */
call.pay = atof(p);
break;
case 18: /* Providercode (ab 3.1) */
call.provider = atoi(p);
break;
case 19: /* Zone (ab 3.2) */
call.zone = atoi(p);
break;
}
}
if (i >= 17)
{
if (!oracle_dbAdd(&call))
rowsInserted++;
else
insErrors++;
}
else
{
fprintf(stderr, "%s: #%d: corrupted record.\n", logfile, row);
insErrors++;
}
}
return row;
}
/*********************************************************************/
int main(int argc, const char *argv[])
{
int i, rows;
FILE *fp;
for (i = 1; i < argc; i++)
{
if (!strcmp(argv[i], "--help"))
{
fprintf(stderr, "Usage: %s [ -debug ] [ logfile ]\n",
basename(argv[0]));
return 0;
}
else
if (!strcmp(argv[i], "-debug"))
debug = 1;
else
if (!logfile)
logfile = argv[i];
}
db_load_error = "ora_load.sql";
unlink(db_load_error);
if (!logfile) logfile = LOGFILE; /*"/var/log/isdn.log"*/
if (!(fp = fopen(logfile, "r")))
{
perror(logfile);
return 1;
}
if (oracle_dbOpen()) return 1;
rows = isdngeb(fp);
fclose(fp);
oracle_dbClose();
fprintf(stderr, "%s: %d rows, %d inserted, %d errors\n",
logfile, rows, rowsInserted, insErrors);
if (insErrors)
fprintf(stderr, "look at %s for loader errors\n", db_load_error);
return insErrors;
}

View File

@ -1,61 +0,0 @@
/*
* Copyright (C) 1999 Jan Bolt
*
* Permission to use, copy and distribute this software for
* non-commercial purposes is hereby granted without fee,
* provided that this copyright and permission notice appears
* in all copies.
*
* This software is provided "as-is", without ANY WARRANTY.
*
* oracle.h 1999/01/07 Jan Bolt
*
* $Log: oracle.h,v $
* Revision 1.2 2002/03/11 16:17:10 paul
* DM -> EUR
*
* Revision 1.1 1999/12/31 13:30:02 akool
* isdnlog-4.00 (Millenium-Edition)
* - Oracle support added by Jan Bolt (Jan.Bolt@t-online.de)
*
*/
#ifndef __ORACLE_H
#define __ORACLE_H
static const char oracle_h[] = "$Id: oracle.h,v 1.2 2002/03/11 16:17:10 paul Exp $";
typedef struct
{
time_t connect; /* Zeitpunkt des Verbindungsaufbaues */
char calling[31]; /* Telefonnummer des Anrufers */
char called[31]; /* Telefonnummer des Gegners */
int duration; /* Dauer der Verbindung in Sekunden */
int hduration; /* Dauer der Verbindung in 1/100 Sekunden */
int aoce; /* Anzahl Gebuehreneinheiten (AOC-D) */
char dialin[2]; /* "I" incoming call, "O" outgoing call */
int cause; /* Status der Verbindung */
long ibytes; /* uebertragene Byte incoming */
long obytes; /* uebertragenen Byte outgoing */
char version[6]; /* Versionsnummer dieses Eintrages */
int si1; /* Dienstkennung (1=Speech, 7=Data usw.) */
int si11; /* analog oder digital ? */
double currency_factor; /* Currency Factor (0,121) */
char currency[4]; /* Waehrung (in Europa "EUR") */
double pay; /* Endbetrag in Landeswaehrung */
int provider; /* Providercode */
char provider_name[31]; /* Provider */
int zone; /* CityCall, RegioCall, ... */
} oracle_DbStrIn;
/* Oracle Connect-String */
#define DB_CONNECT_STRING "isdn/isdn"
/* where to log failed inserts */
#define DB_LOAD_ERROR "/var/log/isdn-fail.sql"
extern int oracle_dbOpen();
extern int oracle_dbClose();
extern int oracle_dbAdd(const oracle_DbStrIn *);
extern int oracle_dbStatus();
#endif

View File

@ -1,217 +0,0 @@
/*
* Copyright (C) 1999 Jan Bolt
*
* Permission to use, copy and distribute this software for
* non-commercial purposes is hereby granted without fee,
* provided that this copyright and permission notice appears
* in all copies.
*
* This software is provided "as-is", without ANY WARRANTY.
*
* oracle.pc 1999/01/07 Jan Bolt
*
* $Log: oracle.pc,v $
* Revision 1.1 1999/12/31 13:30:02 akool
* isdnlog-4.00 (Millenium-Edition)
* - Oracle support added by Jan Bolt (Jan.Bolt@t-online.de)
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <syslog.h>
/*#define SQLCA_STORAGE_CLASS extern*/
/*#include <sqlca.h>*/
#include <sqlcpr.h>
#include "oracle.h"
static const char rcsid[] = "$Id: oracle.pc,v 1.1 1999/12/31 13:30:02 akool Exp $";
static int debug, connected;
const char *db_load_error = DB_LOAD_ERROR;
static
void sql_error(const char *msg)
{
char buf[128];
size_t buf_len = sizeof(buf), msg_len;
sqlglm(buf, &buf_len, &msg_len);
buf[msg_len] = '\0';
if (buf[msg_len-1] == '\n') buf[msg_len-1] = '\0';
syslog(LOG_ERR, "%s: %s", msg, buf);
}
static
void prtDbStrIn(const oracle_DbStrIn *call)
{
char buf[80];
strftime(buf, sizeof(buf), "%d.%m.%Y %H:%M:%S", localtime(&call->connect));
syslog(LOG_DEBUG, "connect=%s", buf);
syslog(LOG_DEBUG, "calling=\"%s\"", call->calling);
syslog(LOG_DEBUG, "called=\"%s\"", call->called);
syslog(LOG_DEBUG, "duration=%d", call->duration);
syslog(LOG_DEBUG, "hduration=%d", call->hduration);
syslog(LOG_DEBUG, "aoce=%d", call->aoce);
syslog(LOG_DEBUG, "dialin='%s'", call->dialin);
syslog(LOG_DEBUG, "cause=%d", call->cause);
syslog(LOG_DEBUG, "ibytes=%d", call->ibytes);
syslog(LOG_DEBUG, "obytes=%d", call->obytes);
syslog(LOG_DEBUG, "version=\"%s\"", call->version);
syslog(LOG_DEBUG, "si1=%d", call->si1);
syslog(LOG_DEBUG, "si11=%d", call->si11);
syslog(LOG_DEBUG, "currency_factor=%5.4f", call->currency_factor);
syslog(LOG_DEBUG, "currency=\"%s\"", call->currency);
syslog(LOG_DEBUG, "pay=%g", call->pay);
syslog(LOG_DEBUG, "provider=%d", call->provider);
syslog(LOG_DEBUG, "provider_name=\"%s\"", call->provider_name);
syslog(LOG_DEBUG, "zone=%d", call->zone);
}
static
void sqlDbStrIn(FILE *fp, const oracle_DbStrIn *call)
{
char buf[80];
strftime(buf, sizeof(buf), "%d.%m.%Y %H:%M:%S", localtime(&call->connect));
fprintf(fp,
"insert into isdn"
"(sdate, calling, called, msec, sec, charge, dir, status,"
" in_bytes, out_bytes, vrsion, service, source, currency, "
"factor, pay, provider, provider_name, zone)"
" values ("
"to_date('%s', 'dd.mm.yyyy hh24:mi:ss'), "
"'%s', '%s', %d, %d, %d, '%s', %d, %ld, %ld, '%s', %d, %d, '%s', "
"%g, %g, %d, '%s', %d"
");\n",
buf,
call->calling,
call->called,
call->hduration,
call->duration,
call->aoce,
call->dialin,
call->cause,
call->ibytes,
call->obytes,
call->version,
call->si1,
call->si11,
call->currency,
call->currency_factor,
call->pay,
call->provider,
call->provider_name,
call->zone);
/* call->aoce == -1 ? "null" : call->aoce */
}
int loadError(const oracle_DbStrIn *call)
{
FILE *fp;
if (!db_load_error) return 0;
if (!(fp = fopen(db_load_error, "a")))
{
syslog(LOG_ERR, "%s: %s", db_load_error, strerror(errno));
return -1;
}
sqlDbStrIn(fp, call);
fclose(fp);
return 0;
}
/*****************************************************************************
*
*****************************************************************************/
int oracle_dbAdd(const oracle_DbStrIn *call)
{
char buf[80];
short aoce_ind;
int rv;
if (debug)
{
syslog(LOG_DEBUG, "oracle_dbAdd");
prtDbStrIn(call);
}
if (!connected && oracle_dbOpen())
{
loadError(call);
return -1;
}
strftime(buf, sizeof(buf), "%d.%m.%Y %H:%M:%S", localtime(&call->connect));
aoce_ind = /*call->aoce == -1 ? -1 : */0;
exec sql insert into isdn
(sdate,
calling, called,
charge, dir, in_bytes, out_bytes,
msec, sec, status, service, source, vrsion, factor,
currency, pay, provider, provider_name, zone) values
(to_date(:buf, 'dd.mm.yyyy hh24:mi:ss'),
:call->calling, :call->called,
:call->aoce:aoce_ind, :call->dialin, :call->ibytes, :call->obytes,
:call->hduration, :call->duration, :call->cause, :call->si1, :call->si11,
:call->version, :call->currency_factor, :call->currency, :call->pay,
:call->provider, :call->provider_name, :call->zone);
if ((rv = sqlca.sqlcode))
{
sql_error("oracle_dbAdd");
loadError(call);
}
exec sql commit work;
return rv;
}
/*****************************************************************************
*
*****************************************************************************/
int oracle_dbOpen()
{
const char *login = getenv("DB_CONNECT_STRING");
if (!login) login = DB_CONNECT_STRING;
exec sql connect :login;
if (sqlca.sqlcode)
{
syslog(LOG_ERR, "%s", "Login to Oracle failed");
sql_error("oracle_dbOpen");
connected = 0;
return -1;
}
connected = 1;
if (debug) syslog(LOG_DEBUG, "oracle_dbOpen: connected as %s", login);
return 0;
}
/*****************************************************************************
*
*****************************************************************************/
int oracle_dbClose()
{
exec sql commit work release;
if (sqlca.sqlcode) sql_error("oracle_dbClose");
connected = 0;
if (debug) syslog(LOG_DEBUG, "oracle_dbClose: disconnected");
return sqlca.sqlcode;
}
int oracle_dbStatus() /* returns -1 when not open */
{
return connected ? 0 : -1;
}

View File

@ -1,63 +0,0 @@
# Oracle proc
#
# %W% %E% %U%
#
.SUFFIXES: .pc
RM = \rm -f
PC = proc
CPPFLAGS =
CFLAGS = -Wall
PCFLAGS = mode=oracle ireclen=160 lines=yes lname=/dev/null
.pc.o:
$(PC) $(PCFLAGS) code=ansi_c iname=$< oname=_kgw.c
$(CC) -I$(ORACLE_HOME)/precomp/public $(CPPFLAGS) -o $@ -c _kgw.c
$(RM) _kgw.c
SRC.c = ora_load.c
SRC.pc = oracle.pc
SRC = $(SRC.c) $(SRC.pc)
SRC.h =
OBJ = $(SRC.c:.c=.o) $(SRC.pc:.pc=.o)
LDFLAGS = -L$(ORACLE_HOME)/lib
ORALIBS = -lclntsh $(ORACLE_HOME)/lib/scorept.o $(ORACLE_HOME)/lib/sscoreed.o \
$(ORACLE_HOME)/rdbms/lib/kpudfo.o \
-lclient -lsql $(ORACLE_HOME)/lib/nautab.o $(ORACLE_HOME)/lib/naeet.o \
$(ORACLE_HOME)/lib/naect.o $(ORACLE_HOME)/lib/naedhs.o \
`cat $(ORACLE_HOME)/lib/naldflgs` \
-lnetv2 -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork \
-lclient -lvsn -lcommon -lgeneric -lmm -lnlsrtl3 -lcore4 \
-lnlsrtl3 -lcore4 -lnlsrtl3 -lnetv2 -lnttcp -lnetwork -lncr \
-lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon -lgeneric \
$(ORACLE_HOME)/lib/libplsf.a $(ORACLE_HOME)/lib/libplsb.a \
$(ORACLE_HOME)/lib/libextp.a \
-lepc -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lclient \
-lvsn -lcommon -lgeneric -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 \
`cat $(ORACLE_HOME)/lib/sysliblist` -ldl -lm
LDLIBS = $(ORALIBS)
ora_load: $(OBJ)
$(CC) -o $@ $(LDFLAGS) $(OBJ) $(LDLIBS)
ifeq (.depend,$(wildcard .depend))
include .depend
endif
clean:
$(RM) $(OBJ)
tags: $(SRC)
ctags *.c *.pc
dep depend:
./makedep.g++ $(SRC) > .depend

View File

@ -1,31 +0,0 @@
-- run as isdn
--drop table isdn;
create table isdn
(
sdate date, -- Zeitpunkt des Verbindungsaufbaues
calling varchar2(30), -- Telefonnummer des Anrufers
called varchar2(30), -- Telefonnummer des Gegners
charge number(5), -- Gebuehreneinheiten (AOC-D)
dir char(1), -- "I" incoming call, "O" outgoing call
in_bytes number(10), -- Summe der uebertragenen Byte (incoming)
out_bytes number(10), -- Summe der uebertragenen Byte (outgoing)
msec number(10), -- Dauer der Verbindung in 1/100 Sekunden
sec number(8), -- Dauer der Verbindung in Sekunden
status number(3), -- Ursache nicht zustande gekommener Verbindung
service number(3), -- Dienstkennung (1=Speech, 7=Data usw.)
source number(1), -- 1=ISDN, 0=analog
vrsion varchar2(5), -- Versionsnummer isdnlog
factor number(6,4), -- Preis einer Gebuehreneinheit (0.121)
currency varchar2(3), -- Waehrung (DM)
pay number(9,4), -- Gebuehren
provider number(3), -- Providercode
provider_name varchar2(30), -- Provider (Telekom)
zone number(3) -- CityCall, RegioCall, GermanCall, GlobalCall
);
grant select on isdn to public;
--create index isdn_i on isdn(connect, dir, calling, called);
quit;

View File

@ -1,35 +0,0 @@
-- run as isdn
--drop table isdn_zone;
create table isdn_zone
(
zone number(3), -- Zone
name varchar2(30), -- Name
primary key(zone)
);
grant select on isdn_zone to public;
insert into isdn_zone(zone, name) values(0, 'S0-Bus');
insert into isdn_zone(zone, name) values(1, 'CityCall');
insert into isdn_zone(zone, name) values(2, 'RegioCall');
insert into isdn_zone(zone, name) values(3, 'GermanCall');
insert into isdn_zone(zone, name) values(4, 'C-Netz');
insert into isdn_zone(zone, name) values(5, 'C-Mobilbox');
insert into isdn_zone(zone, name) values(6, 'D1-Netz');
insert into isdn_zone(zone, name) values(7, 'D2-Netz');
insert into isdn_zone(zone, name) values(8, 'E-plus-Netz');
insert into isdn_zone(zone, name) values(9, 'E2-Netz');
insert into isdn_zone(zone, name) values(10, 'Euro City');
insert into isdn_zone(zone, name) values(11, 'Euro 1');
insert into isdn_zone(zone, name) values(12, 'Euro 2');
insert into isdn_zone(zone, name) values(13, 'Welt 1');
insert into isdn_zone(zone, name) values(14, 'Welt 2');
insert into isdn_zone(zone, name) values(15, 'Welt 3');
insert into isdn_zone(zone, name) values(16, 'Welt 4');
insert into isdn_zone(zone, name) values(17, 'Internet');
commit;
quit;