smart.c
/*
 * Parse the comma separated list of attributes to match
 *
 * Caller frees memory allocated for the smart_matches_t pointer.
 *
 * Returns 0 on success
 */
Parse the comma separated list of attributes to match
Caller frees memory allocated for the smart_matches_t pointer.

Returns 0 on success
Parse the comma separated list of attributes to match Caller frees memory allocated for the smart_matches_t pointer . Returns 0 on success
static int
parse_matches(smart_matches_t **matches, char *attr)
{
	int res;
	if (attr[0] == '\0')
		return -1;
	while (*attr != '\0') {
		char *next;
		size_t len;
		if ((next = strchr(attr, ',')) == NULL) {
			len = strlen(attr);
			next = attr + len;
		} else {
			len = next - attr;
			next++;
		}
		if (len == 0) {
			printf("Malformed attribute %s\n", attr);
			return -1;
		}
		res = add_match(matches, attr);
		if (res)
			return res;
		attr = next;
	}
	return 0;
}
static int parse_matches ( smart_matches_t * * matches , char * attr ) { int res ; if ( attr [ 0 ] == ' \0 ' ) return -1 ; while ( * attr != ' \0 ' ) { char * next ; size_t len ; if ( ( next = strchr ( attr , ' ' ) ) == NULL ) { len = strlen ( attr ) ; next = attr + len ; } else { len = next - attr ; next ++ ; } if ( len == 0 ) { printf ( " \n " , attr ) ; return -1 ; } res = add_match ( matches , attr ) ; if ( res ) return res ; attr = next ; } return 0 ; }
Parse the comma separated list of attributes to match
 Caller frees memory allocated for the smart_matches_t pointer.
Parse the comma separated list of attributes to match Caller frees memory allocated for the smart_matches_t pointer .