src/cmd/utils/cmd_read_num.c
/*
** cmd_read_vec() moves source to end of vector
** returns 0 on success
*/
cmd_read_vec() moves source to end of vector
returns 0 on success
cmd_read_vec () moves source to end of vector returns 0 on success
int			cmd_read_vec(char **source, t_vec3 *vec)
{
	int			err;
	char		*str;
	if (source == NULL || vec == NULL)
		return (rt_err("Arguments are NULL"));
	if ((str = *source) == NULL)
		return (rt_err("Dereference to NULL pointer"));
	if (!*str || *(str++) != '<')
		return (rt_err("Expected \'<\'"));
	err = 0;
	err += cmd_read_space(&str) < 0 ? -1 : 0;
	err += cmd_read_num(&str, &(vec->x));
	err += cmd_read_space(&str) < 0 ? -1 : 0;
	err += cmd_read_comma(&str);
	err += cmd_read_space(&str) < 0 ? -1 : 0;
	err += cmd_read_num(&str, &(vec->y));
	err += cmd_read_space(&str) < 0 ? -1 : 0;
	err += cmd_read_comma(&str);
	err += cmd_read_space(&str) < 0 ? -1 : 0;
	err += cmd_read_num(&str, &(vec->z));
	err += cmd_read_space(&str) < 0 ? -1 : 0;
	if (err < 0)
		return (rt_err("Syntax error: bad vector string"));
	if (!*str || *(str++) != '>')
		return (rt_err("Syntax error: expected \'>\'"));
	*source = str;
	return (0);
}
int cmd_read_vec ( char * * source , t_vec3 * vec ) { int err ; char * str ; if ( source == NULL || vec == NULL ) return ( rt_err ( " " ) ) ; if ( ( str = * source ) == NULL ) return ( rt_err ( " " ) ) ; if ( ! * str || * ( str ++ ) != ' ' ) return ( rt_err ( " \' \' " ) ) ; err = 0 ; err += cmd_read_space ( & str ) < 0 ? -1 : 0 ; err += cmd_read_num ( & str , & ( vec -> x ) ) ; err += cmd_read_space ( & str ) < 0 ? -1 : 0 ; err += cmd_read_comma ( & str ) ; err += cmd_read_space ( & str ) < 0 ? -1 : 0 ; err += cmd_read_num ( & str , & ( vec -> y ) ) ; err += cmd_read_space ( & str ) < 0 ? -1 : 0 ; err += cmd_read_comma ( & str ) ; err += cmd_read_space ( & str ) < 0 ? -1 : 0 ; err += cmd_read_num ( & str , & ( vec -> z ) ) ; err += cmd_read_space ( & str ) < 0 ? -1 : 0 ; if ( err < 0 ) return ( rt_err ( " " ) ) ; if ( ! * str || * ( str ++ ) != ' ' ) return ( rt_err ( " \' \' " ) ) ; * source = str ; return ( 0 ) ; }
cmd_read_vec() moves source to end of vector
returns 0 on success
cmd_read_vec () moves source to end of vector returns 0 on success