if((fh1=fopen(FLG_FILE,"r"))==NULL)
{
// system("ping -c 5 google.com &");
- fb = open(FB_DEVICE, O_RDWR);
-// rc = open(RC_DEVICE, O_RDONLY);
-// fcntl(rc, F_SETFL, (fcntl(rc, F_GETFL) | O_EXCL) & ~O_NONBLOCK);
+
+ /* open Framebuffer */
+ fb=open(FB_DEVICE, O_RDWR);
+ if (fb < 0)
+ fb=open(FB_DEVICE_FALLBACK, O_RDWR);
+ if (fb < 0) {
+ perror("Blockads <open framebuffer>");
+ exit(1);
+ }
+
InitRC();
read_neutrino_osd_conf ( &ex,&sx,&ey, &sy);
- if ( ( ex == -1 ) || ( sx == -1 ) || ( ey == -1 ) || ( sy == -1 ) )\r
- {\r
- sx = 100;\r
- ex = 1180;\r
- sy = 100;\r
- ey = 620;\r
+ if ( ( ex == -1 ) || ( sx == -1 ) || ( ey == -1 ) || ( sy == -1 ) )
+ {
+ sx = 100;
+ ex = 1180;
+ sy = 100;
+ ey = 620;
}
for(index=CMCST; index<=CMH; index++)
{
if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
{
- while((fgets(line_buffer, sizeof(line_buffer), fh1)>0) && (strlen(line_buffer)<4));
+ while((fgets(line_buffer, sizeof(line_buffer), fh1)) && (strlen(line_buffer)<4));
if(strlen(line_buffer)>1)
{
Trim_String(line_buffer);
{
if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
{
- while((fgets(line_buffer, sizeof(line_buffer), fh1)>0) && !strlen(line_buffer));
+ while((fgets(line_buffer, sizeof(line_buffer), fh1)) && !strlen(line_buffer));
if(strlen(line_buffer)>=1)
{
Trim_String(line_buffer);
{
if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
{
- while((fgets(line_buffer, sizeof(line_buffer), fh1)>0) && !strlen(line_buffer));
+ while((fgets(line_buffer, sizeof(line_buffer), fh1)) && !strlen(line_buffer));
if(strlen(line_buffer)>=1)
{
Trim_String(line_buffer);
//freetype stuff
-#define FONT2 "/share/fonts/pakenham.ttf"
+#define FONT FONTDIR "/neutrino.ttf"
// if font is not in usual place, we look here:
-#define FONT "/share/fonts/neutrino.ttf"
+#define FONT2 FONTDIR "/pakenham.ttf"
+
enum {FILL, GRID};
enum {LEFT, CENTER, RIGHT};
extern int startx, starty, sx, ex, sy, ey;
extern unsigned char *proxyadress, *proxyuserpwd;
-
-#define FB_DEVICE "/dev/fb/0"
-/*
-#if HAVE_DVB_API_VERSION < 3
-#define RC_DEVICE "/dev/dbox/rc0"
-#else
-#define RC_DEVICE "/dev/input/event0"
-#endif
-*/
-
#endif
}
}
-void read_neutrino_osd_conf(int *ex, int *sx, int *ey, int *sy)\r
+void read_neutrino_osd_conf(int *ex, int *sx, int *ey, int *sy)
{
const char *filename="/var/tuxbox/config/neutrino.conf";
const char spres[][4]={"","crt","lcd"};
{
if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
{
- while((fgets(zstr, sizeof(zstr), fh1)>0) && !strlen(zstr));
+ while((fgets(zstr, sizeof(zstr), fh1)) && !strlen(zstr));
if(strlen(zstr)>=1)
{
Trim_String(zstr);
{
if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
{
- while((fgets(zstr, sizeof(zstr), fh1)>0) && !strlen(zstr));
+ while((fgets(zstr, sizeof(zstr), fh1)) && !strlen(zstr));
if(strlen(zstr)>=1)
{
Trim_String(zstr);
#define P_VERSION "0.79"
+#ifndef FB_DEVICE
+#define FB_DEVICE "/dev/fb/0"
+#endif
+#ifndef FB_DEVICE_FALLBACK
+#define FB_DEVICE_FALLBACK "/dev/fb0"
+#endif
+#ifndef CONFIGDIR
+#define CONFIGDIR "/var/tuxbox/config"
+#endif
+#ifndef FONTDIR
+#define FONTDIR "/share/fonts"
+#endif
+
#define ADS_FILE "/tmp/blockads.ads"
#define ZAP_FILE "/tmp/blockads.zap"
#define LST_FILE "/tmp/blockads.lst"
#define FLG_FILE "/tmp/blockads.flg"
#define MSG_FILE "/tmp/blockads.msg"
#define STS_FILE "/tmp/blockads.sts"
-#define CFG_FILE "/var/tuxbox/config/blockads.conf"
-#define NCF_FILE "/var/tuxbox/config/neutrino.conf"
+#define CFG_FILE CONFIGDIR "/blockads.conf"
+#define NCF_FILE CONFIGDIR "/neutrino.conf"
#define NUM_CHANNELS 12
//#include <linux/delay.h>
#include "blockads.h"
-int HTTP_downloadFile(char *host, int port, char *page, char *downloadTarget, int tmo, int repeats)
+int HTTP_downloadFile(char *host, int port, char *page, char *downloadTarget, int tmo __attribute__((unused)), int repeats __attribute__((unused)))
{
char tstr[256];
#include "io.h"
#include "blockads.h"
+#include "rc_device.h"
struct input_event ev;
static unsigned short rccode=-1;
int InitRC(void)
{
- rc = open(RC_DEVICE, O_RDONLY);
+ /* open Remote Control */
+ rc = open(RC_DEVICE, O_RDONLY | O_CLOEXEC);
+ if(rc == -1)
+ rc = open(RC_DEVICE_FALLBACK, O_RDONLY | O_CLOEXEC);
if(rc == -1)
{
perror("Blockads <open remote control>");
if(read(rc, &ev, sizeof(ev)) == sizeof(ev))
{
- if(ev.value > 0 && ev.code != rc_last_key)
+ if(ev.value)
{
- if ( ev.value == 2 )
+ if (ev.code == rc_last_key)
{
while ( count < REPEAT_TIMER )
{
count++;
rccode = -1;
- usleep(15000L);
+ usleep(1000000/100);
return rccode;
}
}
#define __IO_H__
-#define RC_DEVICE "/dev/input/nevis_ir"
-
int InitRC(void);
int CloseRC(void);
int RCKeyPressed(void);
--- /dev/null
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if HAVE_COOL_HARDWARE
+#define RC_DEVICE "/dev/input/nevis_ir"
+#define RC_DEVICE_FALLBACK "/dev/input/event0"
+
+#elif HAVE_SPARK_HARDWARE
+#define RC_DEVICE "/dev/input/nevis_ir"
+#define RC_DEVICE_FALLBACK "/dev/input/event1"
+
+#elif HAVE_DUCKBOX_HARDWARE
+#define RC_DEVICE "/dev/input/event0"
+#define RC_DEVICE_FALLBACK "/dev/input/event1"
+#else
+#define RC_DEVICE "/dev/input/event1"
+#define RC_DEVICE_FALLBACK "/dev/input/event0"
+
+#endif
+
* MyFaceRequester
******************************************************************************/
-FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface)
+FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library _library, FT_Pointer request_data, FT_Face *aface)
{
FT_Error result;
+ (void)request_data;
- result = FT_New_Face(library, face_id, 0, aface);
+ result = FT_New_Face(_library, face_id, 0, aface);
if(!result) printf("<Font \"%s\" loaded>\n", (char*)face_id);
else printf("<Font \"%s\" failed>\n", (char*)face_id);
* GetStringLen
******************************************************************************/
-int GetStringLen(unsigned char *string)
+int GetStringLen(char *string)
{
int stringlen = 0;
FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface);
void RenderString(char *string, int sx, int sy, int maxwidth, int layout, int size, int color);
void ShowMessage(char *message, int wait);
-int GetStringLen(unsigned char *string);
+int GetStringLen(char *string);
#endif