timer: add name/description, factor out "parse from epg event", fix some cases where...
[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                 case 3:
38                         m_time_create = atoi(line);
39                         break;
40                 default:
41                         break;
42                 }
43                 ++linecnt;
44         }
45         fclose(f);
46         return 0;
47 }