/* $Id$ * $URL$ * * imond/telmond data processing * * Copyright (C) 2003 Nico Wallmeier * * This file is part of LCD4Linux. * * LCD4Linux is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * LCD4Linux is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "config.h" #include "debug.h" #include "plugin.h" #include "qprintf.h" #include "cfg.h" #include "hash.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* decl of inet_addr() */ #include static HASH TELMON; static HASH IMON; static char thost[256]; static int tport; static char phoneb[256]; static char ihost[256]; static char ipass[256]; static int iport; static int fd = 0; static int err = 0; /*---------------------------------------------------------------------------- * service_connect (host_name, port) - connect to tcp-service *---------------------------------------------------------------------------- */ static int service_connect(const char *host_name, const int port) { struct sockaddr_in addr; struct hostent *host_p; int fd; int opt = 1; (void) memset((char *) &addr, 0, sizeof(addr)); if ((addr.sin_addr.s_addr = inet_addr((char *) host_name)) == INADDR_NONE) { host_p = gethostbyname(host_name); if (!host_p) { error("%s: host not found\n", host_name); return (-1); } (void) memcpy((char *) (&addr.sin_addr), host_p->h_addr, host_p->h_length); } addr.sin_family = AF_INET; addr.sin_port = htons((unsigned short) port); /* open socket */ if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("socket"); return (-1); } (void) setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *) &opt, sizeof(opt)); if (connect(fd, (struct sockaddr *) &addr, sizeof(addr)) != 0) { (void) close(fd); perror(host_name); return (-1); } return (fd); } /* service_connect (char * host_name, int port) */ /*---------------------------------------------------------------------------- * send_command (int fd, char * str) - send command to imond *---------------------------------------------------------------------------- */ static void send_command(const int fd, const char *str) { char buf[256]; int len = strlen(str); sprintf(buf, "%s\r\n", str); write(fd, buf, len + 2); return; } /* send_command (int fd, char * str) */ /*---------------------------------------------------------------------------- * get_answer (int fd) - get answer from imond *---------------------------------------------------------------------------- */ static char *get_answer(const int fd) { static char buf[8192]; int len; len = read(fd, buf, 8192); if (len <= 0) { return ((char *) NULL); } while (len > 1 && (buf[len - 1] == '\n' || buf[len - 1] == '\r')) { buf[len - 1] = '\0'; len--; } if (!strncmp(buf, "OK ", 3)) { /* OK xxxx */ return (buf + 3); } else if (len > 2 && !strcmp(buf + len - 2, "OK")) { *(buf + len - 2) = '\0'; return (buf); } else if (len == 2 && !strcmp(buf + len - 2, "OK")) { return (buf); } return ((char *) NULL); /* ERR xxxx */ } /* get_answer (int fd) */ /*---------------------------------------------------------------------------- * get_value (char * cmd) - send command, get value *---------------------------------------------------------------------------- */ static char *get_value(const char *cmd) { char *answer; send_command(fd, cmd); answer = get_answer(fd); if (answer) { return (answer); } return (""); } /* get_value (char * cmd, int arg) */ static void phonebook(char *number) { FILE *fp; char line[256]; fp = fopen(phoneb, "r"); if (!fp) return; while (fgets(line, sizeof(line), fp)) { if (*line == '#') continue; if (!strncmp(line, number, strlen(number))) { char *komma = strchr(line, ','); char *beginn = strchr(line, '='); if (!beginn) return; while (strrchr(line, '\r')) strrchr(line, '\r')[0] = '\0'; while (strrchr(line, '\n')) strrchr(line, '\n')[0] = '\0'; if (komma) komma[0] = '\0'; strcpy(number, beginn + 1); break; } } fclose(fp); } static int parse_telmon() { static int telmond_fd = -2; static char oldanswer[128]; int age; /* reread every 1 sec only */ age = hash_age(&TELMON, NULL); if (age > 0 && age <= 1000) return 0; if (telmond_fd != -1) { char telbuf[128]; telmo
#----------------------------------------------------------------------------------------------
# Auto-generated from:
# <https://www.freeview.co.uk/help/coverage-checker/detailed-view/download/BB12 9PW>
#----------------------------------------------------------------------------------------------
# location and provider: UK, Pendle Forest
# date (yyyy-mm-dd)    : 2020-07-10
#
#----------------------------------------------------------------------------------------------
[C28+ BBC A]
	DELIVERY_SYSTEM = DVBT
	FREQUENCY = 530167000
	BANDWIDTH_HZ = 8000000
	CODE_RATE_HP = 2/3
	CODE_RATE_LP = NONE
	MODULATION = QAM/64
	TRANSMISSION_MODE = 8K
	GUARD_INTERVAL = 1/32
	HIERARCHY = NONE
	INVERSION = AUTO

[C25+ D3&4]
	DELIVERY_SYSTEM = DVBT
	FREQUENCY = 506167000
	BANDWIDTH_HZ = 8000000
	CODE_RATE_HP = 2/3
	CODE_RATE_LP = NONE
	MODULATION = QAM/64
	TRANSMISSION_MODE = 8K
	GUARD_INTERVAL = 1/32
	HIERARCHY = NONE
	INVERSION = AUTO

[C22+ BBC B HD]
	DELIVERY_SYSTEM = DVBT2
	FREQUENCY = 482167000
	BANDWIDTH_HZ = 8000000
	CODE_RATE_HP = 2/3
	CODE_RATE_LP = NONE
	MODULATION = QAM/256
	TRANSMISSION_MODE = 32K
	GUARD_INTERVAL = 1/128
	HIERARCHY = NONE
	STREAM_ID = 0
	INVERSION = AUTO

[C27- SDN]
	DELIVERY_SYSTEM = DVBT
	FREQUENCY = 521833000
	BANDWIDTH_HZ = 8000000
	CODE_RATE_HP = 3/4
	CODE_RATE_LP = NONE
	MODULATION = QAM/64
	TRANSMISSION_MODE = 8K
	GUARD_INTERVAL = 1/32
	HIERARCHY = NONE
	INVERSION = AUTO

[C21+ ARQ A]
	DELIVERY_SYSTEM = DVBT
	FREQUENCY = 474167000
	BANDWIDTH_HZ = 8000000
	CODE_RATE_HP = 3/4
	CODE_RATE_LP = NONE
	MODULATION = QAM/64
	TRANSMISSION_MODE = 8K
	GUARD_INTERVAL = 1/32
	HIERARCHY = NONE
	INVERSION = AUTO

[C24- ARQ B]
	DELIVERY_SYSTEM = DVBT
	FREQUENCY = 497833000
	BANDWIDTH_HZ = 8000000
	CODE_RATE_HP = 3/4
	CODE_RATE_LP = NONE
	MODULATION = QAM/64
	TRANSMISSION_MODE = 8K
	GUARD_INTERVAL = 1/32
	HIERARCHY = NONE
	INVERSION = AUTO
, cmd, NULL); if (val == NULL) val = ""; SetResult(&result, R_STRING, val); } int plugin_init_imon(void) { AddFunction("imon", 1, my_imon); AddFunction("imon::version", 0, my_imon_version); AddFunction("imon::rates", 2, my_imon_rates); AddFunction("imon::quantity", 2, my_imon_quantity); AddFunction("imon::status", 1, my_imon_status); AddFunction("imon::telmon", 1, my_telmon); return 0; } void plugin_exit_imon(void) { if (fd > 0) { send_command(fd, "quit"); close(fd); } hash_destroy(&TELMON); hash_destroy(&IMON); }