aboutsummaryrefslogtreecommitdiff
path: root/include/tgeb.h
blob: 1c18bf0faccc03a54ab61a7c4afb59ad1b72246e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* $Id$ */
/*
 * Copyright (c) 2004 Dimitri Sokolyuk <demon@vhost.dyndns.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#define TGEB_PATH "/.tgeb"

/*
 * anbieter.c
 */

#define T_CC	0x00		/* calling card */
#define T_CBC	0x01		/* call by call */
#define T_CBCR	0x02		/* call by call with registration */
#define T_RTR	0x03		/* router */
#define T_PRES	0x04		/* preselection */
#define T_TDA	0x05		/* deutsche telekom analog */
#define T_TDI	0x06		/* deutsche telekom isdn */
#define T_0190	0x08		/* 0190 */

typedef struct an_d {
	struct an_hdr *h;	/* back-pointer to header */
	char   *serv;		/* service (e.g. string "call by call") */
	char   *pref;		/* prefix */
	unsigned int id;	/* ID */
	char   *valf;		/* valid from */
	char   *valt;		/* valid to */
	unsigned short type;	/* type of service (int value) */
	float   mvol;		/* mindest volume (Euro) */
	float   bfee;		/* base fee (0.001 Euro) */
	float   afee;		/* arrangement fee (0.001 Euro) */
	char   *url;
	char   *url2;
	char   *phone;
	char   *mail;
	char   *x;		/* XXX */
	unsigned short reg;	/* registration (TRUE/FALSE) */
	char   *rurl;		/* registration url */
	char   *rfax;		/* registration fax */
}       AN_D;

typedef struct an_hdr {
	unsigned int off;	/* offset */
	unsigned short q;	/* entry quantity */
	char   *name;		/* name */
	char   *mail;		/* e-mail */
	char   *url;		/* url */
	struct an_d *d;
}       AN_HDR;

typedef struct an {
	unsigned short q;	/* provider quantity */
	struct an_hdr *h;	/* header */
	unsigned short e_q;	/* entries qantity */
	struct an_d *e;		/* entries (id-sorted) */
}       AN;

AN     *tgeb_read_an(char *file);
void    tgeb_free_an(AN *);

/*
 * ausland.c
 */

typedef struct au_d {
	unsigned short *id;
	char   *land;
	char   *dial;
}       AU_D;

typedef struct au_hdr {
	struct an_d *d;
	char   *land;
	char   *dial;
}       AU_HDR;

typedef struct au {
	unsigned short q;	/* quantity */
	unsigned short l;
	struct au_d *d;
	unsigned short *max;
}       AU;

AU     *tgeb_read_au(char *file);
void    tgeb_free_au(AU *);

/*
 * tarife.c
 */

#define	NAH_W	0x00
#define	NAH_E	0x01
#define	REG_W	0x02
#define	REG_E	0x03
#define	FERN_W	0x04
#define	FERN_E	0x05
#define	ORT_W	0x06
#define	ORT_E	0x07
#define	D1_W	0x08
#define	D1_E	0x09
#define	D2_W	0x0A
#define	D2_E	0x0B
#define	EP_W	0x0C
#define	EP_E	0x0D
#define	O2_W	0x0E
#define	O2_E	0x0F

#define AUS_W	0x00
#define AUS_E	0x01
#define Q_IN	16

typedef struct ta_d {
	unsigned short time;	/* valid till */
	float   dfee;		/* dial-in fee */
	float   fee;		/* fee (Brutto) */
	unsigned short t1;	/* timing 1 */
	unsigned short t2;	/* timing 2 */
	struct ta_d *next;	/* next data block in chain */
	struct ta_d *prev;	/* prevision data block in chain */
}       TA_D;

typedef struct ta_idx {
	unsigned int off;	/* region / day-of-week offset */
	struct ta_d *data;
}       TA_IDX;

typedef struct ta_hdr {
	struct ta_idx *in;
	unsigned int off_in;
	struct ta_idx *aus;
	unsigned int off_aus;
}       TA_HDR;

typedef struct ta {		/* file offset 0 */
	unsigned short q;	/* quantity provider */
	unsigned short *q_aus;	/* entrys quantity per provider */
	struct ta_hdr *h;
}       TA;

TA     *tgeb_read_ta(char *file, struct au *);
void    tgeb_free_ta(TA *);

/*
 *common.c
 */

typedef struct sorted {
	int     q;
	int    *id;
	struct ta_d **data;
}       SORTED;

void    _tgeb_sread(char **, FILE *);	/* read string */
SORTED *tgeb_select(TA *, AN *, int reg, int flags, int time);
void    tgeb_free_mem(AN *, AU *, TA *);
void    tgeb_free_sd(SORTED *);
char   *tgeb_read_date(char *file);