aboutsummaryrefslogtreecommitdiffstats
path: root/console/scantv.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2010-04-01 11:24:39 +0200
committerGerd Hoffmann <kraxel@redhat.com>2010-04-01 11:24:39 +0200
commitbc7f101b0c874e21473aca15d9b08de8bd164392 (patch)
tree878e2a671f9bd0b3401383406a513c8056f25e17 /console/scantv.c
parenta4a3e6b21da7d11e66364ab9ab67795a3f78020a (diff)
v3.75
Diffstat (limited to 'console/scantv.c')
-rw-r--r--console/scantv.c117
1 files changed, 30 insertions, 87 deletions
diff --git a/console/scantv.c b/console/scantv.c
index 118704a..9447eef 100644
--- a/console/scantv.c
+++ b/console/scantv.c
@@ -21,21 +21,13 @@
#include "grab-ng.h"
#include "commands.h"
-/* libvbi */
-#include "vt.h"
-#include "misc.h"
-#include "fdset.h"
-#include "vbi.h"
-#include "lang.h"
-#include "dllist.h"
+#include "vbi-data.h"
int debug = 0;
int have_dga = 0;
int timeout = 3;
-char xpacket[64];
-char header[64];
-char scratch[1024*256];
+char *tvname;
/*---------------------------------------------------------------------*/
@@ -52,80 +44,36 @@ grabber_init(void)
}
static void
-event(struct dl_head *reqs, struct vt_event *ev)
+event(struct vbi_event *ev, void *user)
{
- unsigned char *p;
- struct vt_page *vtp;
-
switch (ev->type) {
- case EV_HEADER:
- p = ev->p1;
- if (debug)
- fprintf(stderr,"header %.32s\n", p+8);
- memcpy(header,p+8,32);
- header[32] = 0;
- break;
- case EV_PAGE:
- vtp = ev->p1;
- if (debug)
- fprintf(stderr,"vtx page %x.%02x \r", vtp->pgno, vtp->subno);
- break;
- case EV_XPACKET:
- p = ev->p1;
- if (debug)
- fprintf(stderr,"xpacket %x %x %x %x - %.20s\n",
- p[0],p[1],p[3],p[5],p+20);
- memcpy(xpacket,p+20,20);
- xpacket[20] = 0;
+ case VBI_EVENT_NETWORK:
+ if (NULL != tvname)
+ free(tvname);
+ if (strlen(ev->ev.network.name) > 0)
+ tvname = strdup(ev->ev.network.name);
break;
}
}
static char*
-get_vbi_name(void)
+get_vbi_name(struct vbi_state *vbi)
{
int start;
- char *name,*h;
- xpacket[0] = 0;
- header[0] = 0;
+ vbi_hasdata(vbi);
+ if (NULL != tvname)
+ free(tvname);
+ tvname = NULL;
start = time(NULL);
for (;;) {
- if (fdset_select(fds, 1000 * timeout) == 0) {
- break;
- }
- if (time(NULL) > start+timeout) {
- break;
- }
- if (xpacket[0] && header[0]) {
- break;
- }
- }
- if (xpacket[0]) {
- for (h = xpacket+19; h >= xpacket; h--) {
- if (32 != *h)
- break;
- *h = 0;
- }
- for (name = xpacket; *name == 32; name++)
- ;
- return name;
- }
-#if 0
- if (header[0]) {
- for (name = header; *name && name < header+20; name++)
- if (isalpha(*name))
- break;
- for (h = name; *name && name < header+20; name++)
- if (!isalpha(*h)) {
- *h = 0;
- break;
- }
- if (*name)
- return name;
+ vbi_hasdata(vbi);
+ if (time(NULL) > start+timeout)
+ break;
+ if (tvname)
+ break;
}
-#endif
- return NULL;
+ return tvname;
}
static int
@@ -181,7 +129,7 @@ usage(FILE *out, char *prog, char *outfile)
int
main(int argc, char **argv)
{
- struct vbi *vbi;
+ struct vbi_state *vbi;
struct ng_attribute *attr;
int c,f,f1,f2,fc,fi,on,tuned,i,j,scan=1,fullscan=0;
char *name,dummy[32];
@@ -190,8 +138,6 @@ main(int argc, char **argv)
char *outfile = NULL;
FILE *conf = stdout;
- setprgname(argv[0]);
-
/* parse options */
ng_init();
for (;;) {
@@ -275,11 +221,13 @@ main(int argc, char **argv)
do_va_cmd(2,"setfreqtab",chanlist_names[j].str);
/* vbi */
- fdset_init(fds);
- if (not(vbi = vbi_open(ng_dev.vbi, 0, 0, -1)))
- fatal("cannot open %s", ng_dev.vbi);
- vbi_add_handler(vbi, event, NULL);
-
+ vbi = vbi_open(ng_dev.vbi,0,0);
+ if (NULL == vbi) {
+ fprintf(stderr,"open %s: %s\n",ng_dev.vbi,strerror(errno));
+ exit(1);
+ }
+ vbi_event_handler_add(vbi->dec,~0,event,vbi);
+
if (!fullscan) {
/* scan channels */
fprintf(stderr,"\nscanning channel list %s...\n",
@@ -293,9 +241,8 @@ main(int argc, char **argv)
fprintf(stderr,"no station\n");
continue;
}
- fdset_select(fds, 1000 * timeout);
- name = get_vbi_name();
- fprintf(stderr,"%s\n",name ? name : "???");
+ name = get_vbi_name(vbi);
+ fprintf(stderr, "%s\n", name ? name : "???");
if (NULL == name) {
sprintf(dummy,"unknown (%s)",chanlist[i].name);
name = dummy;
@@ -354,8 +301,7 @@ main(int argc, char **argv)
(-1 != fi) ? chanlist[fi].name : "-");
drv->setfreq(h_drv,fc);
- fdset_select(fds, 1000 * timeout);
- name = get_vbi_name();
+ name = get_vbi_name(vbi);
fprintf(stderr,"%s\n",name ? name : "???");
if (NULL == name) {
sprintf(dummy,"unknown (%s)",chanlist[fi].name);
@@ -388,8 +334,5 @@ main(int argc, char **argv)
audio_off();
drv->close(h_drv);
- vbi_del_handler(vbi, event, NULL);
- vbi_close(vbi);
-
exit(0);
}

Privacy Policy