1 #include "validate.h"
2 
3 #ifdef NU_WITH_VALIDATION
4 
nu_validate(const char * encoded,size_t max_len,nu_validread_iterator_t it)5 const char* nu_validate(const char *encoded, size_t max_len, nu_validread_iterator_t it) {
6 	const char *p = encoded;
7 
8 	while (p < encoded + max_len) {
9 		/* max_len should be tested inside of it() call */
10 		int byte_len = it(p, max_len - (p - encoded));
11 
12 		if (byte_len <= 0) {
13 			return p;
14 		}
15 
16 		p += byte_len;
17 	}
18 
19 	return 0;
20 }
21 
22 #endif /* NU_WITH_VALIDATION */
23