Changeset 8438
- Timestamp:
- 02/27/13 15:26:08 (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-webif-tpl.c
r8437 r8438 17 17 const char *tpl_name; 18 18 const char *tpl_data; 19 const char *tpl_deps; 19 20 uint32_t tpl_data_len; 20 21 }; … … 35 36 tpls[i].tpl_name = templates[i].tpl_name; 36 37 tpls[i].tpl_data = templates[i].tpl_data; 38 tpls[i].tpl_deps = templates[i].tpl_deps; 37 39 tpls[i].tpl_data_len = templates[i].tpl_data_len; 38 40 } … … 228 230 } 229 231 232 #define check_conf(CONFIG_VAR, text) \ 233 if (config_enabled(CONFIG_VAR) && strncmp(#CONFIG_VAR, text, len) == 0) { ok = 1; break; } 234 230 235 /* Returns an unparsed template either from disk or from internal templates. 231 236 Note: You must free() the result after using it and you may get NULL if an error occured!*/ 232 237 char *tpl_getUnparsedTpl(const char* name, int8_t removeHeader, const char* subdir) { 233 238 int32_t i; 234 const struct tpl *tpl = NULL;235 239 char *result; 236 240 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) { 241 if (cfg.http_tpl) { 246 242 char path[255]; 247 243 if ((strlen(tpl_getFilePathInSubdir(cfg.http_tpl, subdir, name, ".tpl", path, 255)) > 0 && file_exists(path)) … … 271 267 readen -= offset; 272 268 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 } // for 329 if (ok == 0) return result; 330 break; 331 } // if 332 } // for 273 333 } // if 274 334 } // if … … 288 348 } // if 289 349 290 if (tpl) { 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]; 291 361 if (!cs_malloc(&result, tpl->tpl_data_len + 1)) return NULL; // +1 to accomodate \0 at the end 292 362 memcpy(result, tpl->tpl_data, tpl->tpl_data_len); … … 361 431 if (strlen(tpl_getTplPath(tpl->tpl_name, path, tmp, 256)) > 0 && (fp = fopen(tmp,"w")) != NULL) { 362 432 if (strncmp(tpl->tpl_name, "IC", 2) != 0) { 363 fprintf(fp, "<!--OSCam;%lu;%s;%s -->\n", crc32(0L, (unsigned char *)tpl->tpl_data, tpl->tpl_data_len), CS_VERSION, CS_SVN_VERSION);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); 364 434 } 365 435 fwrite(tpl->tpl_data, tpl->tpl_data_len, 1, fp); … … 383 453 char *tplorg = tpl_getUnparsedTpl(tpl->tpl_name, 0, subdir); 384 454 unsigned long checksum = 0, curchecksum = crc32(0L, (unsigned char*)tpl->tpl_data, tpl->tpl_data_len); 385 char * pch1 = strstr(tplorg,"<!--OSCam");455 char *ifdefs = "", *pch1 = strstr(tplorg,"<!--OSCam"); 386 456 if (pch1 != NULL) { 387 457 char *version = "?", *revision = "?"; … … 395 465 else if (j == 1) version = ptr1; 396 466 else if (j == 2) revision = ptr1; 467 else if (j == 3) ifdefs = ptr1; 397 468 } 398 469 } … … 401 472 } else error = 0; 402 473 } else cs_log("WARNING: Your http disk template %s is in the old template format without revision info. Please consider upgrading it!", path); 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);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); 404 475 free(tplorg); 405 476 } -
trunk/webif/pages_gen.c
r8435 r8438 241 241 } 242 242 243 fprintf(output_file, "\t{ .tpl_name=\"%s\", .tpl_data=%s%s, .tpl_d ata_len=%u },\n",243 fprintf(output_file, "\t{ .tpl_name=\"%s\", .tpl_data=%s%s, .tpl_deps=\"%s\", .tpl_data_len=%u },\n", 244 244 ident, 245 245 templates.data[tpl_idx].type == TXT ? "TPL" : "", ident, 246 deps, 246 247 templates.data[tpl_idx].data_len 247 248 ); … … 316 317 fprintf(output_file, " char *tpl_name;\n"); 317 318 fprintf(output_file, " char *tpl_data;\n"); 319 fprintf(output_file, " char *tpl_deps;\n"); 318 320 fprintf(output_file, " uint32_t tpl_data_len;\n"); 319 321 fprintf(output_file, "};\n");
Note:
See TracChangeset
for help on using the changeset viewer.