EAV-XS
view release on metacpan or search on metacpan
libeav/include/eav.h view on Meta::CPAN
#ifndef EAV_H
#define EAV_H
#include <stdbool.h>
#include <stddef.h>
#ifdef HAVE_IDNKIT
#include <idn/api.h>
#endif
/* high-level API modes */
typedef enum {
EAV_RFC_822,
EAV_RFC_5321,
EAV_RFC_5322,
EAV_RFC_6531
} EAV_RFC;
/* TLD types */
typedef enum {
EAV_TLD_INVALID = 1 << 1, /* internal usage only */
EAV_TLD_NOT_ASSIGNED = 1 << 2,
EAV_TLD_COUNTRY_CODE = 1 << 3,
EAV_TLD_GENERIC = 1 << 4,
EAV_TLD_GENERIC_RESTRICTED = 1 << 5,
EAV_TLD_INFRASTRUCTURE = 1 << 6,
EAV_TLD_SPONSORED = 1 << 7,
EAV_TLD_TEST = 1 << 8,
EAV_TLD_SPECIAL = 1 << 9,
EAV_TLD_RETIRED = 1 << 10
} EAV_TLD;
/* result information from callbacks */
typedef struct eav_result_s {
bool is_ipv4;
bool is_ipv6;
bool is_domain;
int rc;
#ifdef HAVE_IDNKIT
idn_result_t idn_rc;
#else
int idn_rc;
#endif
#ifdef EAV_EXTRA
char *lpart;
char *domain;
#endif
} eav_result_t;
/* eav.c utf-8 callback */
#ifdef HAVE_IDNKIT
typedef eav_result_t *
(*eav_utf8_f) (idn_resconf_t,
idn_action_t,
const char *,
size_t,
bool tld_check);
#else
typedef eav_result_t *
(*eav_utf8_f) (const char *, size_t, bool);
#endif
/* eav.c ascii callback */
typedef eav_result_t * (*eav_ascii_f) (const char *,
size_t,
bool);
typedef struct eav_s {
EAV_RFC rfc; /* mode */
int allow_tld; /* flags: allow only these TLDs */
bool tld_check; /* do fqdn & tld checks */
/* XXX private */
bool utf8;
int errcode;
const char *idnmsg; /* idn error message */
bool initialized; /* true when idn is initialized */
#ifdef HAVE_IDNKIT
idn_resconf_t idn;
idn_action_t actions;
#endif
eav_utf8_f utf8_cb;
eav_ascii_f ascii_cb;
eav_result_t *result;
} eav_t;
/* low-level API: error codes */
enum {
EEAV_NO_ERROR,
EEAV_INVALID_RFC,
( run in 0.758 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )