Blame src/asn1c/constraints.h

Packit 728676
/*-
Packit 728676
 * Copyright (c) 2004, 2006 Lev Walkin <vlm@lionet.info>. All rights reserved.
Packit 728676
 * Redistribution and modifications are permitted subject to BSD license.
Packit 728676
 */
Packit 728676
#ifndef	_ASN1_CONSTRAINTS_VALIDATOR_H_
Packit 728676
#define	_ASN1_CONSTRAINTS_VALIDATOR_H_
Packit 728676
Packit 728676
#include <asn_system.h>		/* Platform-dependent types */
Packit 728676
Packit 728676
#ifdef __cplusplus
Packit 728676
extern "C" {
Packit 728676
#endif
Packit 728676
Packit 728676
struct asn_TYPE_descriptor_s;		/* Forward declaration */
Packit 728676
Packit 728676
/*
Packit 728676
 * Validate the structure according to the ASN.1 constraints.
Packit 728676
 * If errbuf and errlen are given, they shall be pointing to the appropriate
Packit 728676
 * buffer space and its length before calling this function. Alternatively,
Packit 728676
 * they could be passed as NULL's. If constraints validation fails,
Packit 728676
 * errlen will contain the actual number of bytes taken from the errbuf
Packit 728676
 * to encode an error message (properly 0-terminated).
Packit 728676
 * 
Packit 728676
 * RETURN VALUES:
Packit 728676
 * This function returns 0 in case all ASN.1 constraints are met
Packit 728676
 * and -1 if one or more constraints were failed.
Packit 728676
 */
Packit 728676
int
Packit 728676
asn_check_constraints(struct asn_TYPE_descriptor_s *type_descriptor,
Packit 728676
	const void *struct_ptr,	/* Target language's structure */
Packit 728676
	char *errbuf,		/* Returned error description */
Packit 728676
	size_t *errlen		/* Length of the error description */
Packit 728676
	);
Packit 728676
Packit 728676
Packit 728676
/*
Packit 728676
 * Generic type for constraint checking callback,
Packit 728676
 * associated with every type descriptor.
Packit 728676
 */
Packit 728676
typedef int (asn_constr_check_f)(
Packit 728676
	struct asn_TYPE_descriptor_s *type_descriptor,
Packit 728676
	const void *struct_ptr,
Packit 728676
	asn_app_constraint_failed_f *optional_callback,	/* Log the error */
Packit 728676
	void *optional_app_key		/* Opaque key passed to a callback */
Packit 728676
	);
Packit 728676
Packit 728676
/*******************************
Packit 728676
 * INTERNALLY USEFUL FUNCTIONS *
Packit 728676
 *******************************/
Packit 728676
Packit 728676
asn_constr_check_f asn_generic_no_constraint;	/* No constraint whatsoever */
Packit 728676
asn_constr_check_f asn_generic_unknown_constraint; /* Not fully supported */
Packit 728676
Packit 728676
/*
Packit 728676
 * Invoke the callback with a complete error message.
Packit 728676
 */
Packit 728676
#define	_ASN_CTFAIL	if(ctfailcb) ctfailcb
Packit 728676
Packit 728676
#ifdef __cplusplus
Packit 728676
}
Packit 728676
#endif
Packit 728676
Packit 728676
#endif	/* _ASN1_CONSTRAINTS_VALIDATOR_H_ */