src/mn-slaved/client.c
static int
on_target_recv(nolp_t *no, char *buf,
               int size)
{
    char *p = buf,
         *e = buf+size,
         *attr,
         *value;
    struct client *cl;
    int value_len, attr_len;
    cl = (struct client *)no->private;

    while (p<e) {
        attr = p;
        if (!(p = memchr(p, ' ', e-p))) {
            syslog(LOG_ERR, "error: invalid TARGET data syntax");
            return -1;
        }
        attr_len = p-attr;
        p++;
        value_len = atoi(p);
        if (!(p = memchr(p, ' ', e-p))) {
            syslog(LOG_ERR, "error: invalid TARGET data syntax");
            return -1;
        }
        p++;
        value = p;
        if (p+value_len > e) {
            syslog(LOG_ERR, "error: invalid TARGET data syntax");
            return -1;
        }

        if (update_ft_attr(cl,
                    attr, attr_len,
                    value, value_len) != 0)
            return -1;

        p+=value_len;
    }

#ifdef DEBUG
    syslog(LOG_DEBUG, "attributes received, sess #%ld", cl->session_id);
#endif

    return 0;
}
/**
 * Command received from the client when a target has been 
 * found, 'buf' should contain a list of attributes to 
 * save along with this target file type.
 * 
 * Each attribute will look like this:
 * 
 * <name> <size> <data>
 **/
Command received from the client when a target has been
found, 'buf' should contain a list of attributes to
save along with this target file type.

Each attribute will look like this.


Command received from the client when a target has been found ' buf ' should contain a list of attributes to save along with this target file type . Each attribute will look like this .
static int
on_target_recv(nolp_t *no, char *buf,
               int size)
{
    char *p = buf,
         *e = buf+size,
         *attr,
         *value;
    struct client *cl;
    int value_len, attr_len;
    cl = (struct client *)no->private;
    while (p<e) {
        attr = p;
        if (!(p = memchr(p, ' ', e-p))) {
            syslog(LOG_ERR, "error: invalid TARGET data syntax");
            return -1;
        }
        attr_len = p-attr;
        p++;
        value_len = atoi(p);
        if (!(p = memchr(p, ' ', e-p))) {
            syslog(LOG_ERR, "error: invalid TARGET data syntax");
            return -1;
        }
        p++;
        value = p;
        if (p+value_len > e) {
            syslog(LOG_ERR, "error: invalid TARGET data syntax");
            return -1;
        }
        if (update_ft_attr(cl,
                    attr, attr_len,
                    value, value_len) != 0)
            return -1;
        p+=value_len;
    }
#ifdef DEBUG
    syslog(LOG_DEBUG, "attributes received, sess #%ld", cl->session_id);
#endif
    return 0;
}
static int on_target_recv ( nolp_t * no , char * buf , int size ) { char * p = buf , * e = buf + size , * attr , * value ; struct client * cl ; int value_len , attr_len ; cl = ( struct client * ) no -> private ; while ( p < e ) { attr = p ; if ( ! ( p = memchr ( p , ' ' , e - p ) ) ) { syslog ( LOG_ERR , " " ) ; return -1 ; } attr_len = p - attr ; p ++ ; value_len = atoi ( p ) ; if ( ! ( p = memchr ( p , ' ' , e - p ) ) ) { syslog ( LOG_ERR , " " ) ; return -1 ; } p ++ ; value = p ; if ( p + value_len > e ) { syslog ( LOG_ERR , " " ) ; return -1 ; } if ( update_ft_attr ( cl , attr , attr_len , value , value_len ) != 0 ) return -1 ; p += value_len ; } #ifdef DEBUG syslog ( LOG_DEBUG , " " , cl -> session_id ) ; #endif return 0 ; }
Command received from the client when a target has been
 found, 'buf' should contain a list of attributes to
 save along with this target file type.
Command received from the client when a target has been found ' buf ' should contain a list of attributes to save along with this target file type .