Changeset 1141


Ignore:
Timestamp:
01/09/10 14:40:43 (12 years ago)
Author:
alno
Message:

WebIf:

  • compilerwarnings fixed
Location:
branches/monitor-improvement
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/monitor-improvement/oscam-config.c

    r1139 r1141  
    10021002        fprintf_conf(f, CONFVARWIDTH, "serverip", "%s\n", inet_ntoa(*(struct in_addr *)&cfg->c33_srvip));
    10031003        fprintf_conf(f, CONFVARWIDTH, "passive", "%d\n", cfg->c33_passive);
    1004         fprintf_conf(f, CONFVARWIDTH, "key", ""); for (i = 0; i < sizeof(cfg->c33_key); ++i) fprintf(f,"%02X", cfg->c33_key[i]); fputc((int)'\n', f);
     1004        unsigned int ui;
     1005        fprintf_conf(f, CONFVARWIDTH, "key", ""); for (ui = 0; ui < sizeof(cfg->c33_key); ++ui) fprintf(f,"%02X", cfg->c33_key[ui]); fputc((int)'\n', f);
    10051006        fprintf_conf(f, CONFVARWIDTH, "nocrypt", "");
    10061007        dot="";
  • branches/monitor-improvement/oscam-http-helpers.c

    r1028 r1141  
    11#include "oscam-http.h"
    22
    3 /* Adds a name->value-mapping or appends to it. You will get a reference back which you may freely 
     3/* Adds a name->value-mapping or appends to it. You will get a reference back which you may freely
    44   use (but you should not call free/realloc on this!)*/
    55char *tpl_addVar(struct templatevars *vars, int append, char *name, char *value){
     
    3737        }
    3838        free((*vars).values[i]);
    39         (*vars).values[i] = tmp;       
    40     }   
     39        (*vars).values[i] = tmp;
     40    }
    4141    return tmp;
    4242}
    4343
    44 /* Allows to add a char array which has been allocated by malloc. It will automatically get 
    45   freed when calling tpl_create(). Please do NOT free the memory yourself or realloc 
     44/* Allows to add a char array which has been allocated by malloc. It will automatically get
     45  freed when calling tpl_create(). Please do NOT free the memory yourself or realloc
    4646  it after having added the array here! */
    4747char *tpl_addTmp(struct templatevars *vars, char *value){
     
    5959   back which you may freely use (but you should not call free/realloc on this!)*/
    6060char *tpl_printf(struct templatevars *vars, int append, char *varname, char *fmtstring, ...){
    61     int allocated = strlen(fmtstring) - (strlen(fmtstring)%16) + 16;
    62     char *result, *tmp = (char *) malloc(allocated * sizeof(char)); 
     61    unsigned int allocated = strlen(fmtstring) - (strlen(fmtstring)%16) + 16;
     62    char *result, *tmp = (char *) malloc(allocated * sizeof(char));
    6363    va_list argptr;
    64    
     64
    6565    va_start(argptr,fmtstring);
    6666    vsnprintf(tmp ,allocated, fmtstring, argptr);
     
    7272        vsnprintf(tmp, allocated, fmtstring, argptr);
    7373        va_end(argptr);
    74     }   
     74    }
    7575    result = (char *) malloc(strlen(tmp) + 1 * sizeof(char));
    7676    strcpy(result, tmp);
     
    8181        free(result);
    8282        result = tmp;
    83     }   
     83    }
    8484    return result;
    8585}
     
    9999}
    100100
    101 /* Initializes all variables vor a templatevar-structure and returns a pointer to it. Make 
     101/* Initializes all variables vor a templatevar-structure and returns a pointer to it. Make
    102102   sure to call tpl_clear() when you are finished or you'll run into a memory leak! */
    103103struct templatevars *tpl_create(){
     
    118118    for(i = (*vars).varscnt-1; i >= 0; --i){
    119119        free((*vars).names[i]);
    120         free((*vars).values[i]);       
     120        free((*vars).values[i]);
    121121    }
    122122    free((*vars).names);
    123123    free((*vars).values);
    124124    for(i = (*vars).tmpcnt-1; i >= 0; --i){
    125         free((*vars).tmp[i]);   
     125        free((*vars).tmp[i]);
    126126    }
    127127    free((*vars).tmp);
     
    130130
    131131/* Creates a path to a template file. You need to set the resultsize to the correct size of result. */
    132 char *tpl_getTplPath(const char *name, const char *path, char *result, int resultsize){
     132char *tpl_getTplPath(const char *name, const char *path, char *result, unsigned int resultsize){
    133133    char *pch;
    134134    if((strlen(path) + strlen(name) + 5) <= resultsize){
     
    144144}
    145145
    146 /* Returns an unparsed template either from disk or from internal templates. 
     146/* Returns an unparsed template either from disk or from internal templates.
    147147   Note: You must free() the result after using it!*/
    148148char *tpl_getUnparsedTpl(const char* name){
     
    151151  int tplmapcnt = sizeof(tplmap)/sizeof(char *);
    152152  char *result;
    153  
     153
    154154  for(i = 0; i < tplcnt; ++i){
    155155    if(strcmp(name, tpl[i]) == 0) break;
    156156  }
    157  
     157
    158158  if(strlen(cfg->http_tpl) > 0){
    159159    char path[200];
     
    162162            char buffer[1024];
    163163            int read, allocated = 1025, size = 1;
    164             result = (char *) malloc(allocated * sizeof(char)); 
     164            result = (char *) malloc(allocated * sizeof(char));
    165165            if((fp = fopen(path,"r"))!=NULL){
    166166            while((read = fread(&buffer,sizeof(char),1024,fp)) > 0){
     
    180180    if(i >= 0 && i < tplmapcnt){
    181181        int len = (strlen(tplmap[i])) + 1;
    182         result = (char *) malloc(len * sizeof(char));   
     182        result = (char *) malloc(len * sizeof(char));
    183183        memcpy(result, tplmap[i], len);
    184184    } else {
    185         result = (char *) malloc(1 * sizeof(char)); 
     185        result = (char *) malloc(1 * sizeof(char));
    186186        result[0] = '\0';
    187   } 
     187  }
    188188    return result;
    189189}
    190190
    191 /* Returns the specified template with all variables/other templates replaced or an 
     191/* Returns the specified template with all variables/other templates replaced or an
    192192   empty string if the template doesn't exist*/
    193193char *tpl_getTpl(struct templatevars *vars, const char* name){
     
    196196    char *pch, *pch2, *tpl=tplorg;
    197197    char varname[33];
    198    
     198
    199199    int tmp,respos = 0;
    200200    int allocated = 2 * strlen(tpl) + 1;
    201     char *result = (char *) malloc(allocated * sizeof(char));   
    202    
     201    char *result = (char *) malloc(allocated * sizeof(char));
     202
    203203    while(tpl < tplend){
    204         if(tpl[0] == '#' && tpl[1] == '#' && tpl[2] != '#'){           
     204        if(tpl[0] == '#' && tpl[1] == '#' && tpl[2] != '#'){
    205205            pch2 = tpl;
    206206            pch = tpl + 2;
     
    213213                } else {
    214214                    pch2 = tpl_getVar(vars, varname);
    215                 }               
     215                }
    216216                tmp = strlen(pch2);
    217217                if(tmp + respos + 2 >= allocated){
     
    222222                respos += tmp;
    223223                tpl = pch + 2;
    224             }               
     224            }
    225225        } else {
    226226            if(respos + 2 >= allocated){
     
    231231            ++respos;
    232232            ++tpl;
    233         }       
     233        }
    234234    }
    235235    free(tplorg);
     
    325325        pch2 = uri;
    326326        for(pch = uri; pch[0] != '\0'; ++pch) {
    327             if(pch[0] == '/') pch2 = pch;           
     327            if(pch[0] == '/') pch2 = pch;
    328328        }
    329329        if(strncmp(pch2, path, strlen(path)) == 0) uriok = 1;
     
    420420    for(i=(*params).paramcount-1; i>=0; --i){
    421421        if(strcmp((*params).params[i], name) == 0) return (*params).values[i];
    422     }   
     422    }
    423423    return "";
    424424}
  • branches/monitor-improvement/oscam-http.c

    r1139 r1141  
    114114    tpl_printf(vars, 0, "PASSIVE", "%d",  cfg->c33_passive);
    115115
    116     for (i = 0; i < sizeof(cfg->c33_key); ++i) tpl_printf(vars, 1, "KEY", "%02X",cfg->c33_key[i]);
     116    unsigned int ui;
     117    for (ui = 0; ui < sizeof(cfg->c33_key); ++ui) tpl_printf(vars, 1, "KEY", "%02X",cfg->c33_key[ui]);
    117118      struct s_ip *cip;
    118119      char *dot="";
Note: See TracChangeset for help on using the changeset viewer.