library/src/javascript/JSON/BP-JSON.cc
// Basic json string compare featured in the simple json example, but updated to work
// with additional checks.
Basic json string compare featured in the simple json example, but updated to work
with additional checks.
Basic json string compare featured in the simple json example but updated to work with additional checks .
BP_ERROR_T BP_JSONStringEq(const char *json, jsmntok_t *tok, const char *s)
{
	if(!json)
		return ERR_FAILURE;
	if(!tok)
		return ERR_FAILURE;
	if(!s)
		return ERR_FAILURE;
	if(tok->type       == JSMN_STRING)
	if((int) bpstrlen(s) == tok->end)
	if(tok->start)
	if(strncmp(json + tok->start, s, tok->end - tok->start) == 0)
	{
		if(!BP_StringIsReasonablePrintableString(( char *) json + tok->start, tok->end - tok->start, BP_FALSE, BP_FALSE))
			return ERR_FAILURE;
		return ERR_SUCCESS;
	}
	return ERR_FAILURE;
}
BP_ERROR_T BP_JSONStringEq ( const char * json , jsmntok_t * tok , const char * s ) { if ( ! json ) return ERR_FAILURE ; if ( ! tok ) return ERR_FAILURE ; if ( ! s ) return ERR_FAILURE ; if ( tok -> type == JSMN_STRING ) if ( ( int ) bpstrlen ( s ) == tok -> end ) if ( tok -> start ) if ( strncmp ( json + tok -> start , s , tok -> end - tok -> start ) == 0 ) { if ( ! BP_StringIsReasonablePrintableString ( ( char * ) json + tok -> start , tok -> end - tok -> start , BP_FALSE , BP_FALSE ) ) return ERR_FAILURE ; return ERR_SUCCESS ; } return ERR_FAILURE ; }
Basic json string compare featured in the simple json example, but updated to work
with additional checks.
Basic json string compare featured in the simple json example but updated to work with additional checks .
// run basic checks // run checks // string must be reasonable printable string or we exit with failure // return indicating success // return indicating failure