All tables are now using DVBv5 format. That allows suporting all standards available on a standard way. GENERATING FILES TO THE LEGACY DVBV3 FORMAT =========================================== A Makefile target is provided to convert to the legacy channel format. For it to work, you need to have v4l-utils installed (specifically, the v4l-utils package that contains the dvbv5 utils). Be sure that you have at least version 1.4.0 installed, or, if you're compiling v4l-utils from its source. Versions below may work too, but some DVB files won't be properly parsed with earlier versions. This is the minimal changeset of v4l-utils required for it to work: commit 64751eb98a15b9c0077d8c2e4409b9b69ac80448 Date: Fri Sep 5 15:50:43 2014 -0300 Subject: libdvbv5: make sure that all needed properties are filled You can download and install v4l-utils from: http://git.linuxtv.org/cgit.cgi/v4l-utils.git/ Once having it installed, generating all the tables usind DVBv3 channel format is as easy as running: $ make clean $ make dvbv3 The files can also be individually converted from DVBv5 to DVBv3 with: $ dvb-format-convert -I dvbv5 -O channel dvb-c/ch-Rega-Sense legacy-format-ch-Rega-Sense And converting back into DVBv5 format with: $ dvb-format-convert -I channel -O dvbv5 legacy-format-ch-Rega-Sense dvb-c/ch-Rega-Sense Plese notice that comments are not preserved when doing the conversions. PS.: If you're willing to submit new entries and/or corrections, please be sure to send them at the DVBv5 format and sending them via e-mail to linux-media@vger.kernel.org. INSTALL ======= In order to install the files, use: $ make install By default, it will install the files at /usr/local/share/dvbv5. In order to install the legacy v3 formatted files, use: $ make install_v3 Don't forget to run "make dvbv3" before running the above command, in order to convert the files to the legacy format. By default, it will install the files at /usr/local/share/dvbv3. There are a few extra parameters that could be used to define where the files will be stored: PREFIX= (default: /usr/local) DATADIR= (default: $(PREFIX/share) DVBV5DIR= (default: dvbv3) DVBV3DIR= (default: dvbv5) So, if it is desired to install both v3 and v5 files at a tmp file, under the current dir, the install command would be: $ make install install_v3 PREFIX=`pwd`/tmp Installing dvbv5-formatted files at /home/myuser/dtv-scan-tables/tmp/share/dvbv5...done. Installing dvbv3-formatted files at /home/myuser/dtv-scan-tables/tmp/share/dvbv3...done. Please also note that install takes some time, as there are lots of files to be copied. lass='blob'>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/* $Id: plugin_mysql.c 771 2007-02-25 12:27:26Z michael $
 * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/plugin_mysql.c $
 *
 * 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.
 *
 */

/* 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];
    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
}