Changeset 5361 for trunk/oscam-log.c
- Timestamp:
- 06/06/11 01:52:08 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/oscam-log.c
r5309 r5361 348 348 } 349 349 #endif 350 351 void log_emm_request(struct s_reader *rdr){ 352 cs_log("%s emm-request sent (reader=%s, caid=%04X, auprovid=%06lX)", 353 username(cur_client()), rdr->label, rdr->caid, 354 rdr->auprovid ? rdr->auprovid : b2i(4, rdr->prid[0])); 355 } 356 357 /* 358 * This function writes the current CW from ECM struct to a cwl file. 359 * The filename is re-calculated and file re-opened every time. 360 * This will consume a bit cpu time, but nothing has to be stored between 361 * each call. If not file exists, a header is prepended 362 */ 363 void logCWtoFile(ECM_REQUEST *er){ 364 FILE *pfCWL; 365 char srvname[128]; 366 /* %s / %s _I %04X _ %s .cwl */ 367 char buf[256 + sizeof(srvname)]; 368 char date[7]; 369 unsigned char i, parity, writeheader = 0; 370 time_t t; 371 struct tm timeinfo; 372 373 /* 374 * search service name for that id and change characters 375 * causing problems in file name 376 */ 377 378 get_servicename(cur_client(), er->srvid, er->caid, srvname); 379 380 for (i = 0; srvname[i]; i++) 381 if (srvname[i] == ' ') srvname[i] = '_'; 382 383 /* calc log file name */ 384 time(&t); 385 localtime_r(&t, &timeinfo); 386 strftime(date, sizeof(date), "%Y%m%d", &timeinfo); 387 snprintf(buf, sizeof(buf), "%s/%s_I%04X_%s.cwl", cfg.cwlogdir, date, er->srvid, srvname); 388 389 /* open failed, assuming file does not exist, yet */ 390 if((pfCWL = fopen(buf, "r")) == NULL) { 391 writeheader = 1; 392 } else { 393 /* we need to close the file if it was opened correctly */ 394 fclose(pfCWL); 395 } 396 397 if ((pfCWL = fopen(buf, "a+")) == NULL) { 398 /* maybe this fails because the subdir does not exist. Is there a common function to create it? 399 for the moment do not print32_t to log on every ecm 400 cs_log(""error opening cw logfile for writing: %s (errno=%d %s)", buf, errno, strerror(errno)); */ 401 return; 402 } 403 if (writeheader) { 404 /* no global macro for cardserver name :( */ 405 fprintf(pfCWL, "# OSCam cardserver v%s - http://streamboard.gmc.to/oscam/\n", CS_VERSION); 406 fprintf(pfCWL, "# control word log file for use with tsdec offline decrypter\n"); 407 strftime(buf, sizeof(buf),"DATE %Y-%m-%d, TIME %H:%M:%S, TZ %Z\n", &timeinfo); 408 fprintf(pfCWL, "# %s", buf); 409 fprintf(pfCWL, "# CAID 0x%04X, SID 0x%04X, SERVICE \"%s\"\n", er->caid, er->srvid, srvname); 410 } 411 412 parity = er->ecm[0]&1; 413 fprintf(pfCWL, "%d ", parity); 414 for (i = parity * 8; i < 8 + parity * 8; i++) 415 fprintf(pfCWL, "%02X ", er->cw[i]); 416 /* better use incoming time er->tps rather than current time? */ 417 strftime(buf,sizeof(buf),"%H:%M:%S\n", &timeinfo); 418 fprintf(pfCWL, "# %s", buf); 419 fflush(pfCWL); 420 fclose(pfCWL); 421 } 422 423 void cs_log_config() 424 { 425 uchar buf[20]; 426 427 if (cfg.nice!=99) 428 snprintf((char *)buf, sizeof(buf), ", nice=%d", cfg.nice); 429 else 430 buf[0]='\0'; 431 cs_log("version=%s, build #%s, system=%s-%s-%s%s", CS_VERSION, CS_SVN_VERSION, CS_OS_CPU, CS_OS_HW, CS_OS_SYS, buf); 432 cs_log("client max. idle=%d sec, debug level=%d", cfg.cmaxidle, cs_dblevel); 433 434 if( cfg.max_log_size ) 435 snprintf((char *)buf, sizeof(buf), "%d Kb", cfg.max_log_size); 436 else 437 cs_strncpy((char *)buf, "unlimited", sizeof(buf)); 438 cs_log("max. logsize=%s, loghistorysize=%d bytes", buf, cfg.loghistorysize); 439 cs_log("client timeout=%lu ms, fallback timeout=%lu ms, cache delay=%d ms", 440 cfg.ctimeout, cfg.ftimeout, cfg.delay); 441 } 442 350 443 int32_t cs_init_statistics(void) 351 444 {
Note:
See TracChangeset
for help on using the changeset viewer.