src/mn-slaved/client.c
static int
update_ft_attr(struct client *cl,
               char *attr, int attr_len,
               char *val, int val_len)
{
    int  e_len;
    int  len;
    char *q = malloc(128+(val_len*2)+attr_len);
    if (!q)
        return -1;
    /* we allocate val_len*2 because mysql_real_escape_string
     * could theoretically create a string double in size */

    len = sprintf(q, "UPDATE ft_%.64s SET %.*s = '",
            cl->filetype_name,
            attr_len,
            nol_s_str_filter_name(attr, attr_len));

    len += mysql_real_escape_string(cl->mysql, q+len, val, val_len);
    len += sprintf(q+len, "' WHERE id=%ld LIMIT 1;", cl->target_id);

    if (mysql_real_query(cl->mysql, q, len) != 0) {
        free(q);
        syslog(LOG_ERR, "updating attributes failed: %s",
                mysql_error(cl->mysql));
        return -1;
    }

    free(q);
    return 0;
}
/** 
 * update the attribute with the given
 * value
 **/
update the attribute with the given
value
update the attribute with the given value
static int
update_ft_attr(struct client *cl,
               char *attr, int attr_len,
               char *val, int val_len)
{
    int  e_len;
    int  len;
    char *q = malloc(128+(val_len*2)+attr_len);
    if (!q)
        return -1;
    len = sprintf(q, "UPDATE ft_%.64s SET %.*s = '",
            cl->filetype_name,
            attr_len,
            nol_s_str_filter_name(attr, attr_len));
    len += mysql_real_escape_string(cl->mysql, q+len, val, val_len);
    len += sprintf(q+len, "' WHERE id=%ld LIMIT 1;", cl->target_id);
    if (mysql_real_query(cl->mysql, q, len) != 0) {
        free(q);
        syslog(LOG_ERR, "updating attributes failed: %s",
                mysql_error(cl->mysql));
        return -1;
    }
    free(q);
    return 0;
}
static int update_ft_attr ( struct client * cl , char * attr , int attr_len , char * val , int val_len ) { int e_len ; int len ; char * q = malloc ( 128 + ( val_len * 2 ) + attr_len ) ; if ( ! q ) return -1 ; len = sprintf ( q , " " , cl -> filetype_name , attr_len , nol_s_str_filter_name ( attr , attr_len ) ) ; len += mysql_real_escape_string ( cl -> mysql , q + len , val , val_len ) ; len += sprintf ( q + len , " " , cl -> target_id ) ; if ( mysql_real_query ( cl -> mysql , q , len ) != 0 ) { free ( q ) ; syslog ( LOG_ERR , " " , mysql_error ( cl -> mysql ) ) ; return -1 ; } free ( q ) ; return 0 ; }
update the attribute with the given
 value
update the attribute with the given value
/* we allocate val_len*2 because mysql_real_escape_string
     * could theoretically create a string double in size */