Changeset 1628
- Timestamp:
- 02/20/10 08:35:13 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/oscam.c
r1627 r1628 1405 1405 char srvname[128]; 1406 1406 /* %s / %s _I %04X _ %s .cwl */ 1407 char buf[ sizeof(cfg->cwlogdir)+1+6+2+4+1+sizeof(srvname)+5];1407 char buf[256+sizeof(srvname)]; 1408 1408 char date[7]; 1409 1409 unsigned char i, parity, writeheader = 0; … … 1412 1412 struct s_srvid *this; 1413 1413 1414 if (cfg->cwlogdir != NULL) /* CWL logging only if cwlogdir is set in config */ 1415 { 1416 /* search service name for that id and change characters 1417 causing problems in file name */ 1418 srvname[0] = 0; 1419 for (this=cfg->srvid; this; this=this->next) { 1420 if (this->srvid==er->srvid) { 1421 strncpy(srvname, this->name, sizeof(srvname)); 1422 srvname[sizeof(srvname)-1] = 0; 1423 for (i=0;srvname[i];i++) 1424 if (srvname[i]==' ') srvname[i]='_'; 1425 break; 1426 } 1414 /* search service name for that id and change characters 1415 causing problems in file name */ 1416 srvname[0] = 0; 1417 for (this=cfg->srvid; this; this=this->next) { 1418 if (this->srvid==er->srvid) { 1419 strncpy(srvname, this->name, sizeof(srvname)); 1420 srvname[sizeof(srvname)-1] = 0; 1421 for (i=0;srvname[i];i++) 1422 if (srvname[i]==' ') srvname[i]='_'; 1423 break; 1427 1424 } 1428 1429 /* calc log file name */ 1430 time(&t); 1431 timeinfo = localtime(&t); 1432 strftime(date,sizeof(date),"%y%m%d",timeinfo); 1433 sprintf(buf, "%s/%s_I%04X_%s.cwl", cfg->cwlogdir, date, er->srvid, srvname); 1434 1435 if((pfCWL=fopen(buf,"r")) == NULL) 1436 { 1437 /* open failed, assuming file does not exist, yet */ 1438 writeheader = 1; 1439 } else 1440 { 1441 /* we need to close the file if it was opened correctly */ 1442 fclose(pfCWL); 1443 } 1444 1445 if ((pfCWL=fopen(buf, "a+")) == NULL) 1446 { 1447 /* maybe this fails because the subdir does not exist. Is there a common function to create it? */ 1448 /* for the moment do not print to log on every ecm 1449 cs_log(""error opening cw logfile for writing: %s (errno %d)", buf, errno); */ 1450 return; 1451 } 1452 if (writeheader) 1453 { 1454 /* no global macro for cardserver name :( */ 1455 fprintf(pfCWL, "# OSCam cardserver v%s - http://streamboard.gmc.to:8001/wiki\n", CS_VERSION_X); 1456 fprintf(pfCWL, "# control word log file for use with tsdec offline decrypter\n"); 1457 strftime(buf,sizeof(buf),"DATE %Y-%m-%d, TIME %H:%M:%S, TZ %Z\n",timeinfo); 1458 fprintf(pfCWL, "# %s",buf); 1459 fprintf(pfCWL, "# CAID 0x%04X, SID 0x%04X, SERVICE \"%s\"\n", er->caid, er->srvid, srvname); 1460 } 1461 1462 parity = er->ecm[0]&1; 1463 fprintf(pfCWL, "%d ",parity); 1464 for (i=parity*8; i<8+parity*8; i++) 1465 fprintf(pfCWL, "%02X ",er->cw[i]); 1466 /* better use incoming time er->tps rather than current time? */ 1467 strftime(buf,sizeof(buf),"%H:%M:%S\n",timeinfo); 1425 } 1426 1427 /* calc log file name */ 1428 time(&t); 1429 timeinfo = localtime(&t); 1430 strftime(date,sizeof(date),"%y%m%d",timeinfo); 1431 sprintf(buf, "%s/%s_I%04X_%s.cwl", cfg->cwlogdir, date, er->srvid, srvname); 1432 1433 if((pfCWL=fopen(buf,"r")) == NULL) 1434 { 1435 /* open failed, assuming file does not exist, yet */ 1436 writeheader = 1; 1437 } else 1438 { 1439 /* we need to close the file if it was opened correctly */ 1440 fclose(pfCWL); 1441 } 1442 1443 if ((pfCWL=fopen(buf, "a+")) == NULL) 1444 { 1445 /* maybe this fails because the subdir does not exist. Is there a common function to create it? */ 1446 /* for the moment do not print to log on every ecm 1447 cs_log(""error opening cw logfile for writing: %s (errno %d)", buf, errno); */ 1448 return; 1449 } 1450 if (writeheader) 1451 { 1452 /* no global macro for cardserver name :( */ 1453 fprintf(pfCWL, "# OSCam cardserver v%s - http://streamboard.gmc.to:8001/wiki\n", CS_VERSION_X); 1454 fprintf(pfCWL, "# control word log file for use with tsdec offline decrypter\n"); 1455 strftime(buf,sizeof(buf),"DATE %Y-%m-%d, TIME %H:%M:%S, TZ %Z\n",timeinfo); 1468 1456 fprintf(pfCWL, "# %s",buf); 1469 fflush(pfCWL); 1470 fclose(pfCWL); 1471 } /* if (cfg->pidfile[0]) */ 1457 fprintf(pfCWL, "# CAID 0x%04X, SID 0x%04X, SERVICE \"%s\"\n", er->caid, er->srvid, srvname); 1458 } 1459 1460 parity = er->ecm[0]&1; 1461 fprintf(pfCWL, "%d ",parity); 1462 for (i=parity*8; i<8+parity*8; i++) 1463 fprintf(pfCWL, "%02X ",er->cw[i]); 1464 /* better use incoming time er->tps rather than current time? */ 1465 strftime(buf,sizeof(buf),"%H:%M:%S\n",timeinfo); 1466 fprintf(pfCWL, "# %s",buf); 1467 fflush(pfCWL); 1468 fclose(pfCWL); 1472 1469 } 1473 1470 … … 1492 1489 store_ecm(er); 1493 1490 1491 /* CWL logging only if cwlogdir is set in config */ 1494 1492 if (cfg->cwlogdir != NULL) 1495 1493 logCWtoFile(er); 1494 1496 1495 } 1497 1496
Note:
See TracChangeset
for help on using the changeset viewer.