aboutsummaryrefslogtreecommitdiffstats
path: root/dvb-t/ie-Maghera
blob: 11c08b7d2daeb777bab20c5de0f1eb7c8b33aebd (plain)
1
2
3
4
5
# Ireland, Maghera
# Generated from http://www.comreg.ie/_fileupload/Broadcast_Technical_Parameters.xlsx
# T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy
T 690000000 8MHz 3/4 NONE QAM64 8k 1/32 NONE # CH48: Saorview MUX1
T 746000000 8MHz 3/4 NONE QAM64 8k 1/32 NONE # CH55: Saorview MUX2
#003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# UK, Mendip
# Auto-generated from http://www.dtg.org.uk/retailer/dtt_channels.html
# and http://www.ofcom.org.uk/static/reception_advice/index.asp.html
# T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy
T 778167000 8MHz 3/4 NONE QAM16 2k 1/32 NONE
T 746167000 8MHz 2/3 NONE QAM64 2k 1/32 NONE
T 802167000 8MHz 2/3 NONE QAM64 2k 1/32 NONE
T 826167000 8MHz 3/4 NONE QAM16 2k 1/32 NONE
T 754167000 8MHz 3/4 NONE QAM16 2k 1/32 NONE
T 842000000 8MHz 3/4 NONE QAM16 2k 1/32 NONE
/a> 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
/* $Id: plugin_mysql.c,v 1.10 2006/01/20 15:58:05 reinelt Exp $
 *
 * plugin for execute SQL queries into a MySQL DBSM.
 *
 * Copyright (C) 2004 Javier Garcia <javi@gsmlandia.com>
 * Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
 *
 * 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_mysql.c,v $
 * Revision 1.10  2006/01/20 15:58:05  reinelt
 * MySQL::count() added again
 *
 * Revision 1.9  2006/01/20 15:43:25  reinelt
 * MySQL::query() returns a value, not the number of rows
 *
 * Revision 1.8  2006/01/16 15:39:58  reinelt
 * MySQL::queryvalue() extension from Harald Klemm
 *
 * Revision 1.7  2005/06/06 09:24:07  reinelt
 * two bugs in plugin_mysql.c fixed
 *
 * Revision 1.6  2005/05/08 04:32:44  reinelt
 * CodingStyle added and applied
 *
 * Revision 1.5  2005/04/01 05:16:04  reinelt
 * moved plugin init stuff to a seperate function called on first use
 *
 * Revision 1.4  2005/01/18 06:30:23  reinelt
 * added (C) to all copyright statements
 *
 * Revision 1.3  2004/03/21 22:05:53  reinelt
 * MySQL plugin fixes from Javi
 *
 * Revision 1.2  2004/03/20 23:09:01  reinelt
 * MySQL plugin fixes from Javi
 *
 * Revision 1.1  2004/03/10 07:16:15  reinelt
 * MySQL plugin from Javier added
 *
 */

/* DOC:
 * To compile the plugin remember to add -lmysqlclient option into Makefile. I.E: CC = gcc -lmysqlclient 
 * or run:
 * $ gcc -I/usr/include/mysql -L/usr/lib/mysql plugin_mysql.c -lmysqlclient -o plugin_mysql.o
 *
 * exported functions:
 *
 * int plugin_init_mysql (void)
 *
 *  adds various functions:
 *     MySQLquery(query) 
 *        Returns the number of rows in query.
 *     MySQLstatus()
 *        Returns the current server status:
 *        Uptime in seconds and the number of running threads,
 *        questions, reloads, and open tables.
 *
 */

#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "debug.h"
#include "plugin.h"
#include "cfg.h"

#ifdef HAVE_MYSQL_MYSQL_H
#include <mysql/mysql.h>
#else
#warning mysql/mysql.h not found: plugin deactivated
#endif

#ifdef WITH_DMALLOC
#include <dmalloc.h>
#endif


#ifdef HAVE_MYSQL_MYSQL_H
static MYSQL conex;

static char Section[] = "Plugin:MySQL";


static int configure_mysql(void)
{
    static int configured = 0;

    char server[256];
    unsigned int port;
    char user[128];
    char password[256];
    char database[256];
    char *s;

    if (configured != 0)
	return configured;

    s = cfg_get(Section, "server", "localhost");
    if (*s == '\0') {
	info("[MySQL] empty '%s.server' entry from %s, assuming 'localhost'", Section, cfg_source());
	strcpy(server, "localhost");
    } else
	strcpy(server, s);
    free(s);

    if (cfg_number(Section, "port", 0, 1, 65536, &port) < 1) {
	/* using 0 as default port because mysql_real_connect() will convert it to real default one */
	info("[MySQL] no '%s.port' entry from %s using MySQL's default", Section, cfg_source());
    }

    s = cfg_get(Section, "user", "");
    if (*s == '\0') {
	/* If user is NULL or the empty string "", the lcd4linux Unix user is assumed. */
	info("[MySQL] empty '%s.user' entry from %s, assuming lcd4linux owner", Section, cfg_source());
	strcpy(user, "");
    } else
	strcpy(user, s);
    free(s);

    s = cfg_get(Section, "password", "");
    /* Do not encrypt the password because encryption is handled automatically by the MySQL client API. */
    if (*s == '\0') {
	info("[MySQL] empty '%s.password' entry in %s, assuming none", Section, cfg_source());
	strcpy(password, "");
    } else
	strcpy(password, s);
    free(s);

    s = cfg_get(Section, "database", "");
    if (*s == '\0') {
	error("[MySQL] no '%s:database' entry from %s, specify one", Section, cfg_source());
	free(s);
	configured = -1;
	return configured;
    }
    strcpy(database, s);
    free(s);

    mysql_init(&conex);
    if (!mysql_real_connect(&conex, server, user, password, database, port, NULL, 0)) {
	error("[MySQL] conection error: %s", mysql_error(&conex));
	configured = -1;
	return configured;
    }

    configured = 1;
    return configured;
}

static void my_MySQLcount(RESULT * result, RESULT * query)
{
    char *q;
    double value;
    MYSQL_RES *res;
    
    if (configure_mysql() < 0) {
	value = -1;
	SetResult(&result, R_NUMBER, &value);
	return;
    }

    q = R2S(query);

    /* mysql_ping(MYSQL *mysql) checks whether the connection to the server is working. */
    /* If it has gone down, an automatic reconnection is attempted. */
    mysql_ping(&conex);
    if (mysql_real_query(&conex, q, (unsigned int) strlen(q))) {
	error("[MySQL] query error: %s", mysql_error(&conex));
	value = -1;
    } else {
	/* We don't use res=mysql_use_result();  because mysql_num_rows() will not */
	/* return the correct value until all the rows in the result set have been retrieved */
	/* with mysql_fetch_row(), so we use res=mysql_store_result(); instead */
	res = mysql_store_result(&conex);
	value = (double) mysql_num_rows(res);
	mysql_free_result(res);
    }

    SetResult(&result, R_NUMBER, &value);
}


static void my_MySQLquery(RESULT * result, RESULT * query)
{
    char *q;
    double value;
    MYSQL_RES *res;
    MYSQL_ROW row=NULL;

    if (configure_mysql() < 0) {
	value = -1;
	SetResult(&result, R_NUMBER, &value);
	return;
    }

    q = R2S(query);

    /* mysql_ping(MYSQL *mysql) checks whether the connection to the server is working. */
    /* If it has gone down, an automatic reconnection is attempted. */
    mysql_ping(&conex);
    if (mysql_real_query(&conex, q, (unsigned int) strlen(q))) {
	error("[MySQL] query error: %s", mysql_error(&conex));
	value = -1;
    } else {
	/* We don't use res=mysql_use_result();  because mysql_num_rows() will not */
	/* return the correct value until all the rows in the result set have been retrieved */
	/* with mysql_fetch_row(), so we use res=mysql_store_result(); instead */
	res = mysql_store_result(&conex);
	row = mysql_fetch_row(res);
	mysql_free_result(res);
    }

    SetResult(&result, R_STRING, row[0]);
}


static void my_MySQLstatus(RESULT * result)
{
    const char *value = "";
    const char *status;

    if (configure_mysql() > 0) {

	mysql_ping(&conex);
	status = mysql_stat(&conex);
	if (!status) {
	    error("[MySQL] status error: %s", mysql_error(&conex));
	    value = "error";
	} else {
	    value = status;
	}
    }

    SetResult(&result, R_STRING, value);
}


#endif


int plugin_init_mysql(void)
{
#ifdef HAVE_MYSQL_MYSQL_H
    AddFunction("MySQL::count", 1, my_MySQLcount);
    AddFunction("MySQL::query", 1, my_MySQLquery);
    AddFunction("MySQL::status", 0, my_MySQLstatus);
#endif
    return 0;
}

void plugin_exit_mysql(void)
{
#ifdef HAVE_MYSQL_MYSQL_H
    mysql_close(&conex);
#endif
}
ss="n">class); break; case WIDGET_TYPE_XY: error(" Widgetclass %s is placed by X/Y", class); break; case WIDGET_TYPE_GPO: case WIDGET_TYPE_TIMER: case WIDGET_TYPE_KEYPAD: default: error(" Widgetclass %s has unknown type %d", class, Class->type); } free(class); return -1; } if (class) free(class); /* do NOT use realloc here because there may be pointers to the old */ /* memory area, which would point to nowhere if realloc moves the area */ if (Widgets == NULL) { Widgets = malloc(MAX_WIDGETS * sizeof(WIDGET)); if (Widgets == NULL) { error("internal error: allocation of widget buffer failed: %s", strerror(errno)); return -1; } } /* another sanity check */ if (nWidgets >= MAX_WIDGETS) { error("internal error: widget buffer full! Tried to allocate %d widgets (max: %d)", nWidgets, MAX_WIDGETS); return -1; } /* look up parent widget (widget with the same name) */ Parent = NULL; for (i = 0; i < nWidgets; i++) { if (strcmp(name, Widgets[i].name) == 0) { Parent = &(Widgets[i]); break; } } Widget = &(Widgets[nWidgets]); nWidgets++; Widget->name = strdup(name); Widget->class = Class; Widget->parent = Parent; Widget->fg_color = FG; Widget->bg_color = BG; Widget->fg_valid = fg_valid; Widget->bg_valid = bg_valid; Widget->layer = layer; Widget->row = row; Widget->col = col; if (Class->init != NULL) { Class->init(Widget); } info(" widget '%s': Class '%s', Parent '%s', Layer %d, %s %d, %s %d (to %d,%d)", name, (NULL == Class) ? "<none>" : Class->name, (NULL == Parent) ? "<root>" : Parent->name, layer, (WIDGET_TYPE_XY == Class->type) ? "Y" : "Row", row, (WIDGET_TYPE_XY == Class->type) ? "X" : "Col", col, Widget->y2, Widget->x2); /* sanity check: look for overlapping widgets */ for (i = 0; i < nWidgets - 1; i++) { if (Widgets[i].layer == layer) { if (intersect(&(Widgets[i]), Widget)) { info("WARNING widget %s(%i,%i) intersects with %s(%i,%i) on layer %d", Widgets[i].name, Widgets[i].row, Widgets[i].col, name, row, col, layer); } } } return 0; } /* return the found widget, or else NULL */ WIDGET *widget_find(int type, void *needle) { WIDGET *widget = NULL; int i; for (i = 0; i < nWidgets; i++) { widget = &(Widgets[i]); if (widget->class->type == type) { if (widget->class->find != NULL && widget->class->find(widget, needle) == 0) break; } widget = NULL; } return widget; }