/* $Id$ */ /* * Copyright (c) 2004 Dimitri Sokolyuk * * 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);