comparison src/recpt1.c @ 155:5d010d0ff6a1

Change line number of the CSV file to be used for ID management.
author Naoya OYAMA <naoya.oyama@gmail.com>
date Sun, 02 Sep 2012 20:52:45 +0900
parents 578ebda88997
children 159a729b90eb
comparison
equal deleted inserted replaced
154:578ebda88997 155:5d010d0ff6a1
56 /* prototypes */ 56 /* prototypes */
57 int tune(char *channel, thread_data *tdata, char *device); 57 int tune(char *channel, thread_data *tdata, char *device);
58 int close_tuner(thread_data *tdata); 58 int close_tuner(thread_data *tdata);
59 static int get_device_id_by_name ( const char *name ); 59 static int get_device_id_by_name ( const char *name );
60 60
61 static struct channel_info_list *open_list_file(char *type) 61 static struct channel_info_list *open_list_file(
62 char *type,
63 struct channel_info_list *info_list)
62 { 64 {
63 char *buf = NULL; 65 char *buf = NULL;
64 char filename[PATH_MAX]; 66 char filename[PATH_MAX];
65 char *home = NULL; 67 char *home = NULL;
66 char *p = NULL; 68 char *p = NULL;
72 snprintf(filename, PATH_MAX, "%s/.recpt1_%s", home, type); 74 snprintf(filename, PATH_MAX, "%s/.recpt1_%s", home, type);
73 f = fopen(filename, "r"); 75 f = fopen(filename, "r");
74 if(!f) { 76 if(!f) {
75 return channel_info_list; 77 return channel_info_list;
76 } 78 }
77 channel_info_list = malloc(sizeof(*channel_info_list)); 79 if(!info_list) {
78 if(!channel_info_list) 80 channel_info_list = malloc(sizeof(*channel_info_list));
79 return NULL; 81 if(!channel_info_list)
80 channel_info_list->nr_channel = 0; 82 return NULL;
83 channel_info_list->nr_channel = 0;
84 } else
85 channel_info_list = info_list;
81 while(1) { 86 while(1) {
82 buf = NULL; 87 buf = NULL;
83 buf = malloc(256); 88 buf = malloc(256);
84 if(!buf) 89 if(!buf)
85 break; 90 break;
95 100
96 channel_info->sid = NULL; 101 channel_info->sid = NULL;
97 channel_info->tp = NULL; 102 channel_info->tp = NULL;
98 channel_info->name = NULL; 103 channel_info->name = NULL;
99 104
105 channel_info->id = channel_info_list->nr_channel;
100 channel_info->sid = buf; 106 channel_info->sid = buf;
101 107
102 p = strchr(buf, C_CHAR_COMMA); 108 p = strchr(buf, C_CHAR_COMMA);
103 if (p == NULL) { 109 if (p == NULL) {
104 /* FILE ERROR */ 110 /* FILE ERROR */
1516 } 1522 }
1517 1523
1518 /* initialize DLNA */ 1524 /* initialize DLNA */
1519 if(use_dlna) { 1525 if(use_dlna) {
1520 do { 1526 do {
1521 if(use_splitter) 1527 if(use_splitter && tdata.table->type == CHTYPE_GROUND)
1522 channel_list = open_list_file("ISDB"); 1528 channel_list = open_list_file("ISDB", NULL);
1529 else {
1530 channel_list = open_list_file("BS", NULL);
1531 channel_list = open_list_file("CS", channel_list);
1532 }
1523 tdata.stream_queue = stream_queue; 1533 tdata.stream_queue = stream_queue;
1524 tdata.streamer = malloc(sizeof(streamer)); 1534 tdata.streamer = malloc(sizeof(streamer));
1525 if ( tdata.streamer == NULL ) { 1535 if ( tdata.streamer == NULL ) {
1526 use_dlna = FALSE; 1536 use_dlna = FALSE;
1527 break; 1537 break;