67eb3d421242f3314ad8ca732de5f66cfe2783b0
[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         m_time_create = 0;
16         
17         while (1)
18         {
19                 char line[1024];
20                 if (!fgets(line, 1024, f))
21                         break;
22                 if (*line && line[strlen(line)-1] == '\n')
23                         line[strlen(line)-1] = 0;
24
25                 if (*line && line[strlen(line)-1] == '\r')
26                         line[strlen(line)-1] = 0;
27
28                 switch (linecnt)
29                 {
30                 case 0:
31                         m_ref = (const eServiceReferenceDVB&)eServiceReference(line);
32                         break;
33                 case 1:
34                         m_name = line;
35                         break;
36                 case 2:
37                         m_description = line;
38                         break;
39                 case 3:
40                         m_time_create = atoi(line);
41                         break;
42                 default:
43                         break;
44                 }
45                 ++linecnt;
46         }
47         fclose(f);
48         return 0;
49 }