aboutsummaryrefslogtreecommitdiffstats
path: root/util/dvbscan/dvbscan_structutils.c
diff options
context:
space:
mode:
authorMark Purcell <msp@debian.org>2008-06-22 11:00:40 +1000
committeretobi <git@e-tobi.net>2013-09-03 09:48:42 +0200
commit891c51ff368ed700dec6025eeb47ce4d96f76418 (patch)
tree3729664829e4faa691d403274f38eb10890b533c /util/dvbscan/dvbscan_structutils.c
parent1c6e1f28f54ec2606c23936c1d8689f2be55a86c (diff)
parentab959d7b4194715870128e616b8e29d4a101e488 (diff)
downloadlinux-dvb-apps-891c51ff368ed700dec6025eeb47ce4d96f76418.tar.gz
Imported Debian patch 1.1.1+rev1207-1debian/1.1.1+rev1207-1
Diffstat (limited to 'util/dvbscan/dvbscan_structutils.c')
-rw-r--r--util/dvbscan/dvbscan_structutils.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/util/dvbscan/dvbscan_structutils.c b/util/dvbscan/dvbscan_structutils.c
new file mode 100644
index 0000000..6fe3124
--- /dev/null
+++ b/util/dvbscan/dvbscan_structutils.c
@@ -0,0 +1,99 @@
+/*
+ dvbscan utility
+
+ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net)
+
+ This program 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 of the License, or
+ (at your option) any later version.
+
+ This program 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 <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "dvbscan.h"
+
+void append_transponder(struct transponder *t, struct transponder **tlist, struct transponder **tlist_end)
+{
+ if (*tlist_end == NULL) {
+ *tlist = t;
+ } else {
+ (*tlist_end)->next = t;
+ }
+ *tlist_end = t;
+ t->next = NULL;
+}
+
+struct transponder *new_transponder(void)
+{
+ struct transponder *t = (struct transponder *) malloc(sizeof(struct transponder));
+ if (t == NULL) {
+ fprintf(stderr, "Out of memory\n");
+ exit(1);
+ }
+ memset(t, 0, sizeof(struct transponder));
+
+ return t;
+}
+
+void free_transponder(struct transponder *t)
+{
+ if (t->frequencies)
+ free(t->frequencies);
+ // FIXME: free services
+ free(t);
+}
+
+int seen_transponder(struct transponder *t, struct transponder *checklist)
+{
+ uint32_t i;
+
+ struct transponder *cur_check = checklist;
+ while(cur_check) {
+ uint32_t freq1 = cur_check->params.frequency / 2000;
+ for(i=0; i < t->frequency_count; i++) {
+ uint32_t freq2 = t->frequencies[i] / 2000;
+ if (freq1 == freq2) {
+ return 1;
+ }
+ }
+ cur_check = cur_check->next;
+ }
+
+ return 0;
+}
+
+void add_frequency(struct transponder *t, uint32_t frequency)
+{
+ uint32_t *tmp;
+
+ tmp = (uint32_t*) realloc(t->frequencies, sizeof(uint32_t) * (t->frequency_count + 1));
+ if (tmp == NULL) {
+ fprintf(stderr, "Out of memory\n");
+ exit(1);
+ }
+ tmp[t->frequency_count++] = frequency;
+ t->frequencies = tmp;
+}
+
+struct transponder *first_transponder(struct transponder **tlist, struct transponder **tlist_end)
+{
+ struct transponder *t = *tlist;
+
+ *tlist = t->next;
+ if (*tlist == NULL)
+ *tlist_end = NULL;
+
+ return t;
+}