90b02c0670c69d37431e7fad76b02b16cbfaee2a
[openblackhole/openblackhole-enigma2.git] / lib / dvb / metaparser.cpp
1 #include <lib/dvb/metaparser.h>
2 #include <errno.h>
3
4 int eDVBMetaParser::parseFile(const std::string &tsname)
5 {
6                 /* if it's a PVR channel, recover service id. */
7         std::string filename = tsname + ".meta";
8                 
9         FILE *f = fopen(filename.c_str(), "r");
10         if (!f)
11                 return -ENOENT;
12
13         int linecnt = 0;
14         
15         while (1)
16         {
17                 char line[1024];
18                 if (!fgets(line, 1024, f))
19                         break;
20                 if (*line && line[strlen(line)-1] == '\n')
21                         line[strlen(line)-1] = 0;
22
23                 if (*line && line[strlen(line)-1] == '\r')
24                         line[strlen(line)-1] = 0;
25
26                 switch (linecnt)
27                 {
28                 case 0:
29                         m_ref = (const eServiceReferenceDVB&)eServiceReference(line);
30                         break;
31                 case 1:
32                         m_name = line;
33                         break;
34                 case 2:
35                         m_description = line;
36                         break;
37                 default:
38                         break;
39                 }
40                 ++linecnt;
41         }
42         fclose(f);
43         return 0;
44 }