Changeset 8435 for trunk/module-webif-tpl.c
- Timestamp:
- 02/27/13 14:34:37 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-webif-tpl.c
r8434 r8435 17 17 const char *tpl_name; 18 18 const char *tpl_data; 19 const char *tpl_deps;20 19 uint32_t tpl_data_len; 21 20 }; … … 36 35 tpls[i].tpl_name = templates[i].tpl_name; 37 36 tpls[i].tpl_data = templates[i].tpl_data; 38 tpls[i].tpl_deps = templates[i].tpl_deps;39 37 tpls[i].tpl_data_len = templates[i].tpl_data_len; 40 38 } … … 230 228 } 231 229 232 #define check_conf(CONFIG_VAR, text) \233 if (config_enabled(CONFIG_VAR) && strncmp(#CONFIG_VAR, text, len) == 0) { ok = 1; break; }234 235 230 /* Returns an unparsed template either from disk or from internal templates. 236 231 Note: You must free() the result after using it and you may get NULL if an error occured!*/ 237 232 char *tpl_getUnparsedTpl(const char* name, int8_t removeHeader, const char* subdir) { 238 233 int32_t i; 234 const struct tpl *tpl = NULL; 239 235 char *result; 240 236 241 if (cfg.http_tpl) { 237 uint32_t name_hash = jhash(name, strlen(name)); 238 for(i = 0; i < tpls_count; i++) { 239 if (tpls[i].tpl_name_hash == name_hash) { 240 tpl = &tpls[i]; 241 break; 242 } 243 } 244 245 if (tpl && cfg.http_tpl) { 242 246 char path[255]; 243 247 if ((strlen(tpl_getFilePathInSubdir(cfg.http_tpl, subdir, name, ".tpl", path, 255)) > 0 && file_exists(path)) … … 267 271 readen -= offset; 268 272 pch2[0] = '\0'; 269 char *ptr1, *ptr2, *saveptr1 = NULL, *saveptr2 = NULL;270 for (i = 0, ptr1 = strtok_r(pch1 + 10, ";", &saveptr1); (ptr1) && i < 4 ; ptr1 = strtok_r(NULL, ";", &saveptr1), i++)271 {272 if (i == 3 && strlen(ptr1) > 2) {273 int8_t ok = 0;274 for (ptr2 = strtok_r(ptr1, ",", &saveptr2); (ptr2) && ok == 0 ; ptr2 = strtok_r(NULL, ",", &saveptr2))275 {276 size_t len = strlen(ptr2);277 check_conf(WITH_CARDREADER, ptr2);278 check_conf(CARDREADER_PHOENIX, ptr2);279 check_conf(CARDREADER_INTERNAL_AZBOX, ptr2);280 check_conf(CARDREADER_INTERNAL_COOLAPI, ptr2);281 check_conf(CARDREADER_INTERNAL_SCI, ptr2);282 check_conf(CARDREADER_SC8IN1, ptr2);283 check_conf(CARDREADER_MP35, ptr2);284 check_conf(CARDREADER_SMARGO, ptr2);285 check_conf(CARDREADER_PCSC, ptr2);286 check_conf(CARDREADER_SMART, ptr2);287 check_conf(CARDREADER_DB2COM, ptr2);288 check_conf(CARDREADER_STAPI, ptr2);289 check_conf(TOUCH, ptr2);290 check_conf(CS_ANTICASC, ptr2);291 check_conf(CS_CACHEEX, ptr2);292 check_conf(HAVE_DVBAPI, ptr2);293 check_conf(IPV6SUPPORT, ptr2);294 check_conf(IRDETO_GUESSING, ptr2);295 check_conf(LCDSUPPORT, ptr2);296 check_conf(LEDSUPPORT, ptr2);297 check_conf(MODULE_CAMD33, ptr2);298 check_conf(MODULE_CAMD35, ptr2);299 check_conf(MODULE_CAMD35_TCP, ptr2);300 check_conf(MODULE_CCCAM, ptr2);301 check_conf(MODULE_CCCSHARE, ptr2);302 check_conf(MODULE_CONSTCW, ptr2);303 check_conf(MODULE_GBOX, ptr2);304 check_conf(MODULE_GHTTP, ptr2);305 check_conf(MODULE_MONITOR, ptr2);306 check_conf(MODULE_NEWCAMD, ptr2);307 check_conf(MODULE_PANDORA, ptr2);308 check_conf(MODULE_RADEGAST, ptr2);309 check_conf(MODULE_SERIAL, ptr2);310 check_conf(READER_BULCRYPT, ptr2);311 check_conf(READER_CONAX, ptr2);312 check_conf(READER_CRYPTOWORKS, ptr2);313 check_conf(READER_GRIFFIN, ptr2);314 check_conf(READER_DGCRYPT, ptr2);315 check_conf(READER_DRE, ptr2);316 check_conf(READER_IRDETO, ptr2);317 check_conf(READER_NAGRA, ptr2);318 check_conf(READER_SECA, ptr2);319 check_conf(READER_TONGFANG, ptr2);320 check_conf(READER_VIACCESS, ptr2);321 check_conf(READER_VIDEOGUARD, ptr2);322 check_conf(WITH_CARDREADER, ptr2);323 check_conf(WITH_DEBUG, ptr2);324 check_conf(WITH_LB, ptr2);325 check_conf(WITH_LIBCRYPTO, ptr2);326 check_conf(WITH_SSL, ptr2);327 check_conf(WITH_STAPI, ptr2);328 } // for329 if (ok == 0) return result;330 break;331 } // if332 } // for333 273 } // if 334 274 } // if … … 348 288 } // if 349 289 350 bool found = 0; 351 uint32_t name_hash = jhash(name, strlen(name)); 352 for(i = 0; i < tpls_count; i++) { 353 if (tpls[i].tpl_name_hash == name_hash) { 354 found = 1; 355 break; 356 } 357 } 358 359 if (found) { 360 const struct tpl *tpl = &tpls[i]; 290 if (tpl) { 361 291 if (!cs_malloc(&result, tpl->tpl_data_len + 1)) return NULL; // +1 to accomodate \0 at the end 362 292 memcpy(result, tpl->tpl_data, tpl->tpl_data_len); … … 431 361 if (strlen(tpl_getTplPath(tpl->tpl_name, path, tmp, 256)) > 0 && (fp = fopen(tmp,"w")) != NULL) { 432 362 if (strncmp(tpl->tpl_name, "IC", 2) != 0) { 433 fprintf(fp, "<!--OSCam;%lu;%s;%s ;%s-->\n", crc32(0L, (unsigned char *)tpl->tpl_data, tpl->tpl_data_len), CS_VERSION, CS_SVN_VERSION, tpl->tpl_deps);363 fprintf(fp, "<!--OSCam;%lu;%s;%s-->\n", crc32(0L, (unsigned char *)tpl->tpl_data, tpl->tpl_data_len), CS_VERSION, CS_SVN_VERSION); 434 364 } 435 365 fwrite(tpl->tpl_data, tpl->tpl_data_len, 1, fp); … … 453 383 char *tplorg = tpl_getUnparsedTpl(tpl->tpl_name, 0, subdir); 454 384 unsigned long checksum = 0, curchecksum = crc32(0L, (unsigned char*)tpl->tpl_data, tpl->tpl_data_len); 455 char * ifdefs = "", *pch1 = strstr(tplorg,"<!--OSCam");385 char *pch1 = strstr(tplorg,"<!--OSCam"); 456 386 if (pch1 != NULL) { 457 387 char *version = "?", *revision = "?"; … … 465 395 else if (j == 1) version = ptr1; 466 396 else if (j == 2) revision = ptr1; 467 else if (j == 3) ifdefs = ptr1;468 397 } 469 398 } … … 472 401 } else error = 0; 473 402 } else cs_log("WARNING: Your http disk template %s is in the old template format without revision info. Please consider upgrading it!", path); 474 if (error) cs_log("If you are sure that it is current, add the following line at the beginning of the template to suppress this warning: <!--OSCam;%lu;%s;%s ;%s-->", curchecksum, CS_VERSION, CS_SVN_VERSION, ifdefs);403 if (error) cs_log("If you are sure that it is current, add the following line at the beginning of the template to suppress this warning: <!--OSCam;%lu;%s;%s-->", curchecksum, CS_VERSION, CS_SVN_VERSION); 475 404 free(tplorg); 476 405 }
Note:
See TracChangeset
for help on using the changeset viewer.