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