/* $Id: plugin_exec.c,v 1.9 2005/05/08 04:32:44 reinelt Exp $ * * plugin for external processes * * Copyright (C) 2004 Michael Reinelt * Copyright (C) 2004 The LCD4Linux Team * * based on the old 'exec' client which is * Copyright (C) 2001 Leopold Tötsch * * * 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. * * * $Log: plugin_exec.c,v $ * Revision 1.9 2005/05/08 04:32:44 reinelt * CodingStyle added and applied * * Revision 1.8 2005/01/18 06:30:23 reinelt * added (C) to all copyright statements * * Revision 1.7 2004/09/24 21:41:00 reinelt * new driver for the BWCT USB LCD interface board. * * Revision 1.6 2004/06/26 12:05:00 reinelt * * uh-oh... the last CVS log message messed up things a lot... * * Revision 1.5 2004/06/26 09:27:21 reinelt * * added '-W' to CFLAGS * changed all C++ comments to C ones * cleaned up a lot of signed/unsigned mistakes * * Revision 1.4 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source * * Revision 1.3 2004/06/17 06:23:43 reinelt * * hash handling rewritten to solve performance issues * * Revision 1.2 2004/04/08 10:48:25 reinelt * finished plugin_exec * modified thread handling * added '%x' format to qprintf (hexadecimal) * * Revision 1.1 2004/03/20 11:49:40 reinelt * forgot to add plugin_exec.c ... * */ /* * exported functions: * * int plugin_init_exec (void) * adds functions to start external pocesses * */ #include "config.h" #include #include #include #include #include #include "debug.h" #include "plugin.h" #include "hash.h" #include "cfg.h" #include "thread.h" #include "qprintf.h" #define NUM_THREADS 16 #define SHM_SIZE 4096 typedef struct { int delay; int mutex; pid_t pid; int shmid; char *cmd; char *key; char *ret; } EXEC_THREAD; static EXEC_THREAD Thread[NUM_THREADS]; static int max_thread = -1; static HASH EXEC; /* x^0 + x^5 + x^12 */ #define CRCPOLY 0x8408 static unsigned short CRC(const char *s) { int i; unsigned short crc; /* seed value */ crc = 0xffff; while (*s != '\0') { crc ^= *s++; for (i = 0; i < 8; i++) crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY : 0); } return crc; } static void exec_thread(void *data) { EXEC_THREAD *Thread = (EXEC_THREAD *) data; FILE *pipe; char buffer[SHM_SIZE]; int len; /* use a safe path */ putenv("PATH=/usr/local/bin:/usr/bin:/bin"); /* forever... */ while (1) { pipe = popen(Thread->cmd, "r"); if (pipe == NULL) { error("exec error: could not run pipe '%s': %s", Thread->cmd, strerror(errno)); len = 0; } else { len = fread(buffer, 1, SHM_SIZE - 1, pipe); if (len <= 0) { error("exec error: could not read from pipe '%s': %s", Thread->cmd, strerror(errno)); len = 0; } pclose(pipe); } /* force trailing zero */ buffer[len] = '\0'; /* remove trailing CR/LF */ while (len > 0 && (buffer[len - 1] == '\n' || buffer[len - 1] == '\r')) { buffer[--len] = '\0'; } /* lock shared memory */ mutex_lock(Thread->mutex); /* write data */ strncpy(Thread->ret, buffer, SHM_SIZE); /* unlock shared memory */ mutex_unlock(Thread->mutex); usleep(Thread->delay); } } static void destroy_exec_thread(const int n) { if (Thread[n].mutex != 0) mutex_destroy(Thread[n].mutex); if (Thread[n].cmd) free(Thread[n].cmd); if (Thread[n].key) free(Thread[n].key); if (Thread[n].ret) shm_destroy(Thread[n].shmid, Thread[n].ret); Thread[n].delay = 0; Thread[n].mutex = 0; Thread[n].pid = 0; Thread[n].shmid = 0; Thread[n].cmd = NULL; Thread[n].key = NULL; Thread[n].ret = NULL; } static int create_exec_thread(const char *cmd,
# 2014-04-18 Antti Palosaari <crope@iki.fi>
# generated from http://www.digita.fi/kuluttajat/tv/nakyvyysalueet/kanavanumerot_ja_taajuudet

[Joutseno]
	DELIVERY_SYSTEM = DVBT
	FREQUENCY = 682000000
	BANDWIDTH_HZ = 8000000

[Joutseno]
	DELIVERY_SYSTEM = DVBT
	FREQUENCY = 586000000
	BANDWIDTH_HZ = 8000000

[Joutseno]
	DELIVERY_SYSTEM = DVBT
	FREQUENCY = 762000000
	BANDWIDTH_HZ = 8000000

[Joutseno]
	DELIVERY_SYSTEM = DVBT
	FREQUENCY = 562000000
	BANDWIDTH_HZ = 8000000

[Joutseno]
	DELIVERY_SYSTEM = DVBT2
	FREQUENCY = 514000000
	BANDWIDTH_HZ = 8000000