//// debug tool
+#ifdef DEBUG
static void dump_mem(const char *string, const unsigned char *p, int len, int linelen){
int i;
for(i=0;i<len;i++){
}
if(i%linelen==0) fprintf(stderr,"\n");
}
+#endif
//////////////////////////////////////////////////////////////////////////////////
sys=0; filter=0; ecm=0; ecmPri=0; mode=-1; sid=-1;
trigger=false; triggerMode=-1;
filterSource=filterTransponder=0; filterCwIndex=-1; filterSid=-1;
- asprintf(&id,"%d.%d",cardNum,cwindex);
+ id=bprintf("%d.%d",cardNum,cwindex);
}
cEcmHandler::~cEcmHandler()
if(cwIndex!=cwindex) {
PRINTF(L_CORE_PIDS,"%s: shifting cwIndex from %d to %d",id,cwIndex,cwindex);
free(id);
- asprintf(&id,"%d.%d",cardNum,cwindex);
+ id=bprintf("%d.%d",cardNum,cwindex);
dataMutex.Lock();
trigger=true;
cwIndex=cwindex;
char *s;
if(pk) {
pk->type=Type; pk->id=Id; pk->keynr=Keynr;
- asprintf(&s,"%c %.*X %s",Type,pk->IdSize(),Id,*pk->PrintKeyNr());
+ s=bprintf("%c %.*X %s",Type,pk->IdSize(),Id,*pk->PrintKeyNr());
delete pk;
}
else s=strdup("unknown");
dvbNum=DvbNum;
idleTime=IdleTime;
id=0; fd=-1; active=false; forceRun=false; userData=0;
- asprintf(&id,"%s/%d",Id,Num);
+ id=bprintf("%s/%d",Id,Num);
PRINTF(L_CORE_ACTION,"new filter '%s' on card %d (%d ms)",id,dvbNum,idleTime);
}
cAction::cAction(const char *Id, int DvbNum)
{
- asprintf(&id,"%s %d",Id,DvbNum);
+ id=bprintf("%s %d",Id,DvbNum);
dvbNum=DvbNum;
unique=0; pri=-1;
SetDescription("%s filter",id);
fprintf(logfile,"%s [%s] %s\n",lh->stamp,lh->tag,"logfile closed, filesize limit reached");
fclose(logfile);
logfile=0; logfileShutup=false;
- char *name;
- asprintf(&name,"%s.old",logcfg.logFilename);
+ char *name=bprintf("%s.old",logcfg.logFilename);
if(rename(logcfg.logFilename,name)) {
logfileShutup=true;
PRINTF(L_GEN_ERROR,"failed to rotate logfile: %s",strerror(errno));
return cs;
}
+char *bprintf(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap,fmt);
+ char *str=0;
+ if(vasprintf(&str,fmt,ap)<0);
+ va_end(ap);
+ return str;
+}
+
// crc stuff taken from linux-2.6.0/lib/crc32.c
/*
* There are multiple 16-bit CRC polynomials in common use, but this is
unsigned char XorSum(const unsigned char *mem, int len);
unsigned int crc32_le(unsigned int crc, unsigned char const *p, int len);
+char *bprintf(const char *fmt, ...) __attribute__ ((format (printf,1,2)));
+
// ----------------------------------------------------------------
class cLineBuff {
int cNetWatcher::RunCommand(const char *cmd, const char *state)
{
- char *tmp;
- asprintf(&tmp,"%s %s",cmd,state);
+ char *tmp=bprintf("%s %s",cmd,state);
PRINTF(L_CORE_NET,"netwatch cmd exec '%s'",tmp);
int res=SystemExec(tmp);
free(tmp);
void cScInfoItem::SetValue(const char *Name, const char *Value)
{
- char *buff;
- asprintf(&buff,Value ? "%s:\t%s":"%s",Name,Value);
+ char *buff=bprintf(Value ? "%s:\t%s":"%s",Name,Value);
SetText(buff,false);
cStatus::MsgOsdCurrentItem(buff);
ident=-1;
{
if(PreStr) {
free(fullname);
- asprintf(&fullname,"%s.%s",PreStr,name);
+ fullname=bprintf("%s.%s",PreStr,name);
return fullname;
}
else return name;
static char *help_str=0;
free(help_str); // for easier orientation, this is column 80|
- asprintf(&help_str," -B N --budget=N forces DVB device N to budget mode (using FFdecsa)\n"
+ help_str=bprintf( " -B N --budget=N forces DVB device N to budget mode (using FFdecsa)\n"
" -d CMD --dialup=CMD call CMD to start/stop dialup-network\n"
" (default: %s)\n"
" -t SECS --timeout=SECS shutdown timeout for dialup-network\n"
bool cEmu::Init(int RomNr, int Id)
{
romNr=RomNr; id=Id;
- asprintf(&romName,"ROM%d.bin",romNr);
- asprintf(&romExtName,"ROM%dext.bin",romNr);
- asprintf(&eepromName,"eep%i_%02x.bin",romNr,(id&0xff00)>>8);
+ romName=bprintf("ROM%d.bin",romNr);
+ romExtName=bprintf("ROM%dext.bin",romNr);
+ eepromName=bprintf("eep%i_%02x.bin",romNr,(id&0xff00)>>8);
if(InitSetup()) {
ForceSet(EnsIrdChk, 0x81,true);
ForceSet(Cmd83Chk+0,0x98,true);
int off=WORD(hashDW,0,0x3FFF);
xxor(buffE,8,&MT[off],&MT[0x3FFF-off]);
xxor(buffE,8,&MT[( ((buffE[0] ^ hashDW[6])<<8)
- + buffE[7] ^ hashDW[7] )&0x3FFF],buffE);
+ + (buffE[7] ^ hashDW[7]) )&0x3FFF],buffE);
LDUMP(L_SYS_VERBOSE,buffE,8,"0f: buffE:");
unsigned char buffC[16];