Ignore:
Timestamp:
12/02/10 21:11:49 (10 years ago)
Author:
alno
Message:

WebIf: finally fix CSS transmission of external style

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/oscam-http-helpers.c

    r4028 r4030  
    429429}
    430430
    431 void send_css(FILE *f){
    432     if(strlen(cfg->http_css) > 0 && file_exists(cfg->http_css) == 1){
     431
     432/*
     433 * function for sending files. 1 = CSS, 2 = JS
     434 */
     435void send_file(FILE *f, int fileno){
     436
     437    char *filename;
     438
     439    if (fileno == 1)
     440        filename = cfg->http_css;
     441    else if (fileno == 2)
     442        filename = cfg->http_jscript;
     443    else
     444        return;
     445
     446    if(strlen(filename) > 0 && file_exists(filename) == 1){
    433447        FILE *fp;
    434448        char buffer[1024];
    435 
    436         if((fp = fopen(cfg->http_css,"r"))==NULL) return;
    437         while(fgets(buffer, 1024, fp) != 0) webif_write(buffer, f);
     449        int read;
     450
     451        if((fp = fopen(filename, "r"))==NULL) return;
     452        while((read = fread(buffer,sizeof(char), 1024, fp)) > 0) {
     453            buffer[read] = '\0';
     454            webif_write(buffer, f);
     455        }
    438456
    439457        fclose (fp);
    440458    } else {
    441459        webif_write(CSS, f);
    442     }
    443 }
    444 
    445 void send_js(FILE *f){
    446     if(strlen(cfg->http_jscript) > 0 && file_exists(cfg->http_jscript) == 1){
    447         FILE *fp;
    448         char buffer[1024];
    449 
    450         if((fp = fopen(cfg->http_jscript,"r"))==NULL) return;
    451         while(fgets(buffer, 1024, fp) != 0) webif_write(buffer, f);
    452 
    453         fclose (fp);
    454     } else {
    455         webif_write(JSCRIPT, f);
    456460    }
    457461}
Note: See TracChangeset for help on using the changeset viewer.