Statistics
| Branch: | Tag: | Revision:

dvbd / dvbchannels.cpp @ bfdb7446

History | View | Annotate | Download (1.72 KB)

1
/*
2
  Copyright 2003 John Knottenbelt
3
  
4
  This program is free software; you can redistribute it and/or modify
5
  it under the terms of the GNU General Public License as published by
6
  the Free Software Foundation; either version 2 of the License, or
7
  (at your option) any later version.
8
 
9
  This program is distributed in the hope that it will be useful,
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
  GNU General Public License for more details.
13
 
14
  You should have received a copy of the GNU General Public License
15
  along with this program; if not, write to the Free Software
16
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
17
*/
18

    
19
#include "config.h"
20
#include "tuneparams.h"
21
#include "dvbd.h"
22
#include "stringutil.h"
23

    
24
#include <cstdlib>
25
#include <string>
26
#include <iostream>
27
#include <fstream>
28
#include <cassert>
29

    
30
/* Read in the channels.conf file */
31
bool readChannelsConf(const std::string &type, const std::string &filename, std::map<std::string, TuneParams *> &channels)
32
{
33
  std::ifstream input(filename.c_str());
34
  if (!input) {
35
    std::cerr << "Failed to open " << filename << " for reading\n";
36
    return false;
37
  }
38

    
39
  std::string line;
40
  while (getline(input, line, '\n')) {
41
    line = stripTrailingWS(stripLeadingWS(stripLineComment(line)));
42
    
43
    // Skip blank lines
44
    if (line == "")
45
      continue;
46
    
47
    TuneParams *p = NULL;
48

    
49
    if (type == "dvb-t") 
50
      p = DVBTTuneParams::createFromTZAP(line);
51
    else {
52
      std::cerr << "Type " << type << " not implemented (yet)" << std::endl;
53
      input.close();
54
      return false;
55
    }
56

    
57
    assert(p != NULL);
58
    channels[p->getName()] = p;
59
  }
60

    
61
  input.close();
62
  return true;
63
}