Code styling and remove spaces
Change-Id: I75b70c046f69ee5ccce8a5aea5d1db0d3548e206
diff --git a/channel_buffer.c b/channel_buffer.c
index 85c82bc..3a3d6fd 100644
--- a/channel_buffer.c
+++ b/channel_buffer.c
@@ -70,7 +70,7 @@
int i=0;
while ( i++<max_len && *s && *s != ' ' && *s != '\t' && *s != '\n' && *s != '\r')
*string++ = *s++;
-
+
*string = 0x0; //terminator
if ( next != NULL ) {
while ( *s && *s != ' ' && *s != '\t' && *s != '\n' && *s != '\r')
@@ -109,9 +109,9 @@
s++;
while ( i++<max_len && *s && *s != '\"' )
*string++ = *s++;
-
+
*string = 0x0; //terminator
-
+
if ( next != NULL) {
while ( *s && *s != '\"' )
s++;
diff --git a/hdhomerun_dev.c b/hdhomerun_dev.c
index 3d384c8..02b018a 100644
--- a/hdhomerun_dev.c
+++ b/hdhomerun_dev.c
@@ -42,7 +42,7 @@
do {
//remove &
p = strstr( txt, "&" );
- if ( p )
+ if ( p )
strcpy( p+1, p+1+4 );
} while ( p );
}
@@ -81,7 +81,7 @@
vt->vchan[i].guide_id = atoi( guide_num );
snprintf( vt->vchan[i].guide_name, sizeof(vt->vchan[i].guide_name), "\"%s\"", guide_name );
vt->channel_num++;
- }
+ }
pos += used_bytes;
//printf( "%s;\n", guide_name );
}
@@ -91,7 +91,7 @@
static int hdhomerun_parser( void* context, char* buf, int bytes )
{
char *p;
- struct hdhr_tuner_t *ht = (struct hdhr_tuner_t *)context;
+ struct hdhr_tuner_t *ht = (struct hdhr_tuner_t *)context;
p = strstr( buf, "Model:" );
if ( p != NULL ) {
if ( strlen( p+6 )<10 )
@@ -100,10 +100,10 @@
cleanup_txt( ht->model );
}
}
-
+
if ( strstr( buf, "CableCARD Menu" ) != NULL ) {
ht->cc_tuner = 1;
- }
+ }
return bytes;
}
@@ -119,6 +119,3 @@
return ret;
}
- //parse_http_page( "192.168.1.168", "/", hdhomerun_parser, NULL );
- //parse_http_page( "192.168.1.168", "/lineup.xml", program_parser, NULL );
-
diff --git a/hdhomerun_http.c b/hdhomerun_http.c
index 9ee9fca..9adbcac 100644
--- a/hdhomerun_http.c
+++ b/hdhomerun_http.c
@@ -77,11 +77,11 @@
return -1;
}
get = build_get_query(host, page);
-
+
//send the query to the server
int sent = 0;
while(sent < strlen(get))
- {
+ {
ret = send(sock, get+sent, strlen(get)-sent, 0);
if(ret == -1){
perror("Can't send query");
@@ -98,7 +98,7 @@
*(buf+remain+ret) = 0x0;
used_bytes = parser( context, buf, ret+remain );
remain = ret+remain - used_bytes;
- if ( remain > 0 )
+ if ( remain > 0 )
memcpy( buf, buf+used_bytes, remain );
}
if ( used_bytes < 0 )
@@ -132,14 +132,14 @@
if(argc == 1){
usage();
exit(2);
- }
+ }
host = argv[1];
if(argc > 2){
page = argv[2];
}else{
page = PAGE;
}
-
+
parse_http_page( host, page, noop_parser, NULL );
return 0;
}
diff --git a/hdhomerun_http.h b/hdhomerun_http.h
index 0708ff8..106ae1d 100644
--- a/hdhomerun_http.h
+++ b/hdhomerun_http.h
@@ -2,7 +2,7 @@
#ifndef _HDHOMERUN_HTTP_H_
#define _HDHOMERUN_HTTP_H_
-typedef int (*parser_f)( void*, char*, int );
+typedef int (*parser_f)( void*, char*, int );
int parse_http_page( char* host, char* page, parser_f parser, void* context );
#endif
diff --git a/hdhomerun_plugin.c b/hdhomerun_plugin.c
old mode 100644
new mode 100755
index b32abd5..573edf1
--- a/hdhomerun_plugin.c
+++ b/hdhomerun_plugin.c
@@ -8,8 +8,6 @@
#include <inttypes.h>
#include <assert.h>
#include "utility.h"
-//#include "../channel_srv/channel_device.h"
-//#include "../channel_srv/channel_buffer.h"
#include "hdhomerun_plugin.h"
#include "libhdhomerun/hdhomerun.h"
#include "hdhomerun_tuner.h"
@@ -32,7 +30,7 @@
ret = discover_device( ht, max_ht_num );
if ( ret > 0 ) {
for ( i = 0; i<ret; i++ ) {
- //if a unit shares a source input in a device, copy data.
+ //if a unit shares a source input in a device, copy data.
if ( i> 0 && tuner_input_sharing( &ht[i-1], &ht[i] ) ) {
ht[i].cc_tuner = ht[i-1].cc_tuner;
strncpy( ht[i].model, ht[i-1].model, sizeof(ht[i].model) );
@@ -119,7 +117,7 @@
sage_log(( _LOG_TRACE, 3, "hdhr:ERROR: invalid device handle." ));
return;
}
- stop_channel( hdhr->hd );
+ stop_channel( hdhr->hd );
close_hdhr( hdhr->hd );
}
@@ -151,7 +149,7 @@
char *ps, *pe;
map_str[0] = 0x0;
//if channel in format "map:xxx-yy|auto:zzz prog:ppp"
- if ( ( ps = strstr( channel, "map:" ))!= NULL &&
+ if ( ( ps = strstr( channel, "map:" ))!= NULL &&
( pe = strchr( ps+4, '|' )) != NULL ) {
strncpy( map_str, ps+4, pe-(ps+4) );
map_str[pe-(ps+4)] = 0x0;
@@ -166,7 +164,7 @@
if ( map_str[0] == 0x0 && prog > 0 && ch == -1 ) {
ch=atoi( channel );
if ( ch > 0 ) {
- int atsc = ( hdhr->type == 1 ); //TODO dvb
+ int atsc = ( hdhr->type == 1 ); //TODO dvb
snprintf( map_str, sizeof( map_str), "map:us-%s", atsc? "atsc":"cable" );
}
}
@@ -206,7 +204,7 @@
if ( hdhr->cc_tuner ) {
int vchannel;
char *p;
- if ( ( p = strstr( channel, "vchan:" ) ) == NULL )
+ if ( ( p = strstr( channel, "vchan:" ) ) == NULL )
vchannel = atoi(channel) ;
else
vchannel = atoi(p+6);
@@ -224,11 +222,11 @@
}
if ( cl_p != NULL )
*cl_p = cl;
- return ret;
+ return ret;
} else {
//TODO
- }
-
+ }
+
return 0;
}
@@ -246,7 +244,7 @@
cl->ce[i].state = 1;
snprintf( cl->ce[i].dev_tuning, sizeof(cl->ce[i].dev_tuning)-1, "vchan:%d", vt->vchan[i].guide_id );
snprintf( cl->ce[i].ch_name, sizeof(cl->ce[i].ch_name)-1, "%d", vt->vchan[i].guide_id );
- strncpy( cl->ce[i].ch_desc, vt->vchan[i].guide_name, sizeof(cl->ce[i].ch_desc)-1 );
+ strncpy( cl->ce[i].ch_desc, vt->vchan[i].guide_name, sizeof(cl->ce[i].ch_desc)-1 );
cl->ce[i].src_ip[0] = 0x0;
cl->ce[i].src_port = 0; //dynamic assigning
snprintf( cl->ce[i].dev_name, sizeof(cl->ce[i].dev_name)-1, "HDHR.%s", get_unit_name( hdhr, unit_name, sizeof(unit_name) ));
@@ -259,7 +257,7 @@
release_vchan_tbl( vt );
return cl;
} else { //TODO
-
+
}
return NULL;
}
@@ -277,7 +275,7 @@
*cl_p = cl;
if ( cl == NULL )
return 0;
- return cl->channel_num;
+ return cl->channel_num;
}
return 0;
}
@@ -295,7 +293,7 @@
hdhr->channel_table = NULL;
return 1;
} else { //TODO
-
+
}
return 0;
}
diff --git a/hdhomerun_tuner.c b/hdhomerun_tuner.c
index cae211c..aa47f90 100644
--- a/hdhomerun_tuner.c
+++ b/hdhomerun_tuner.c
@@ -57,7 +57,7 @@
hdhomerun_device_stream_stop( hd );
hdhomerun_device_destroy( hd );
}
-}
+}
int tune_channel( void* device, char *channel, char *program, char* stream_target )
{
@@ -67,14 +67,14 @@
struct hdhomerun_device_t *hd =(struct hdhomerun_device_t *)device;
struct hdhomerun_channel_list_t *channel_list=NULL;
int ret;
-
+
if ( hd == NULL ) {
printf( "hdhomerun invalid handle\n");
return -1;
}
-
+
if ( !get_string_by_name( channel, "vchan", vchannel_str, sizeof(vchannel_str), NULL ) ) {
- vchannel_str[0] = 0x0;
+ vchannel_str[0] = 0x0;
if ( !get_string_by_name( channel, "auto", channel_str+5, sizeof(channel_str)-5, NULL ) ) {
printf("hdhomerun %p invalid channel %s\n", device, channel );
@@ -118,7 +118,7 @@
}
if ( channel_list )
hdhomerun_channel_list_destroy( channel_list );
-
+
return ret;
}
@@ -158,14 +158,14 @@
strncpy( name, ht->name, len );
name[len] = 0x0;
return name;
- }
+ }
name[ 0 ] = 0x0;
return name;
}
static char* ip4_address( int ip4, char *buf, int size )
{
- snprintf( buf, size, "%u.%u.%u.%u",
+ snprintf( buf, size, "%u.%u.%u.%u",
(unsigned int)(ip4 >> 24) & 0xFF, (unsigned int)(ip4 >> 16) & 0xFF,
(unsigned int)(ip4 >> 8) & 0xFF, (unsigned int)(ip4 >> 0) & 0xFF );
return buf;
@@ -469,7 +469,7 @@
ret = parse_avinf( CHANNE_SCAN_SRC, CHANNEL_SCAN_PORT, ce_p->av_inf, sizeof(ce_p->av_inf), PARSE_TIMEOUT );
if ( ret > 0 )
ret = strstr( ce_p->av_inf, "ENCRYPTED" )==NULL && strstr( ce_p->av_inf, "NO-DATA" )==NULL ;
- if ( ret )
+ if ( ret )
if ( ++ce_channel_num > ce_num )
break;
}
@@ -509,13 +509,13 @@
if ( ret <= 0 ) {
ce->state = 0;
return 0;
- }
-
+ }
+
return 1;
}
static int _make_channel_entry_buffer( struct channel_entry_t *ce, char *buf, int size )
-{
+{
int pos = 0;
pos += snprintf( buf+pos, size-pos, "ch:%03d ", ce->ch );
if ( ce->ch_name[0] )
@@ -559,19 +559,19 @@
{
int i, ret = 0 ;
int tuner_count = 0;
- struct hdhr_tuner_t ht[16];
-
+ struct hdhr_tuner_t ht[16];
+
ret = discover_device( ht, 16 );
printf( "found tuners:%d\n", ret );
if ( ret > 0 ) {
for ( i = 0; i<ret; i++ ) {
- //if a unit shares a source input in a device, copy data.
+ //if a unit shares a source input in a device, copy data.
if ( i> 0 && tuner_input_sharing( &ht[i-1], &ht[i] ) ) {
ht[i].cc_tuner = ht[i-1].cc_tuner;
strncpy( ht[i].model, ht[i-1].model, sizeof(ht[i].model) );
} else
get_dev_model( &ht[i] );
-
+
printf( "%d tuner:%s ip:%s type:%d cc:%d model:%s\n", i, ht[i].name, ht[i].ip, ht[i].type, ht[i].cc_tuner, ht[i].model );
}
tuner_count = ret;
@@ -593,7 +593,7 @@
printf( "time:%ld\n", time( NULL) - t0 );
_save_channel_entry( "channel-scan.txt", ce, channel_num );
}
-
+
/*
//test vchannel scan
if ( 1 ) {
@@ -603,9 +603,9 @@
cc_ht = &ht[i];
break;
}
- }
-
-
+ }
+
+
if ( cc_ht != NULL ) {
time_t t0 = time( NULL );
struct vchan_tbl_t * vt = create_vchan_tbl( cc_ht );
@@ -631,10 +631,10 @@
}
}
*/
-
+
//test tune
- if ( 1 ) {
- //printf( "tuning %s \n", device[i] );
+ if ( 1 ) {
+ //printf( "tuning %s \n", device[i] );
char *dev_name = "1311A273-0"; //"101007FD-1";
//ret = tune_channel( dev_name, "map:us-cable|auto:68", "343", "udp://226.0.0.1:4096" );
ret = tune_channel( dev_name, "vchan:600", "", "udp://226.0.0.1:4096" );
@@ -642,7 +642,7 @@
getchar();
ret = stop_channel( dev_name );
}
-
+
return ret;
}
#endif
diff --git a/utility.c b/utility.c
index 24f77e2..60acc7a 100644
--- a/utility.c
+++ b/utility.c
@@ -198,7 +198,7 @@
free( cl->ce );
free( cl );
}
-}
+}
struct channel_list_t* _joint_channel_list( struct channel_list_t* cl1, struct channel_list_t* cl2 )
{
@@ -207,7 +207,7 @@
return cl2;
if ( cl2 == NULL )
return cl1;
-
+
channel_num = cl1->channel_num + cl2->channel_num;
if ( channel_num < cl1->num ) {
n = 0;
@@ -220,21 +220,21 @@
n = 0;
for ( i = cl2->channel_num; i<channel_num; i++ )
cl2->ce[i] = cl1->ce[n++];
- cl2->channel_num = channel_num;
+ cl2->channel_num = channel_num;
_release_channel_list( cl1 );
return cl2;
} else {
struct channel_list_t* cl = _create_channel_list( channel_num );
- for ( i = 0; i<cl1->channel_num; i++ )
+ for ( i = 0; i<cl1->channel_num; i++ )
cl->ce[i] = cl1->ce[i];
for ( n = 0; n<cl2->channel_num; n++ )
cl->ce[i++] = cl2->ce[n];
_release_channel_list( cl1 );
_release_channel_list( cl2 );
- cl->channel_num = channel_num;
+ cl->channel_num = channel_num;
return cl;
}
- return NULL;
+ return NULL;
}