Ignore:
Timestamp:
01/11/11 23:05:11 (10 years ago)
Author:
Admin
Message:

Fix saving of boxkey even it begins with zeros. Add some Null checking to template functions

File:
1 edited

Legend:

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

    r4402 r4413  
    66/* Adds a name->value-mapping or appends to it. You will get a reference back which you may freely
    77   use (but you should not call free/realloc on this!)*/
    8 char *tpl_addVar(struct templatevars *vars, int append, char *name, char *value){
     8char *tpl_addVar(struct templatevars *vars, int append, char *name, char *value){   
     9    if(name == NULL || value == NULL) return "";
    910    int i;
    1011    char *tmp,*result = NULL;
     
    5253  it after having added the array here! */
    5354char *tpl_addTmp(struct templatevars *vars, char *value){
     55    if(value == NULL) return "";
    5456    if((*vars).tmpalloc <= (*vars).tmpcnt){     
    5557        if(!cs_realloc (&(*vars).tmp, (*vars).tmpalloc * 2 * sizeof(char**), -1)) return value;
     
    6264
    6365/* Allows to do a dynamic printf without knowing and defining the needed memory size. If you specify
    64    varname, the printf-result will be added/appended to the varlist. You will always get a reference
    65    back which you may freely use (but you should not call free/realloc on this!)*/
     66   varname, the printf-result will be added/appended to the varlist, if varname=NULL it will only be returned.
     67   In either case you will always get a reference back which you may freely use (but you should not call
     68   free/realloc on this as it will be automatically cleaned!)*/
    6669char *tpl_printf(struct templatevars *vars, int append, char *varname, char *fmtstring, ...){
    6770    unsigned int needed;
     
    149152    char *pch;
    150153    if((strlen(path) + strlen(name) + 6) <= resultsize){
    151         strcpy(result, path);
    152         strcat(result, name);
    153         strcat(result, ".tpl");
    154         result[resultsize - 1] = '\0';
     154        snprintf(result, resultsize, "%s%s.tpl", path, name);
    155155        for(pch = result + strlen(path); pch[0] != '\0'; ++pch){
    156156            if(pch[0] == '/' || pch[0] == '\\') pch[0] = ' ';
Note: See TracChangeset for help on using the changeset viewer.