本文整理汇总了C++中RERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ RERROR函数的具体用法?C++ RERROR怎么用?C++ RERROR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: p_mod
static Term
p_mod(Term t1, Term t2 USES_REGS) {
switch (ETypeOfTerm(t1)) {
case (CELL)long_int_e:
switch (ETypeOfTerm(t2)) {
case (CELL)long_int_e:
/* two integers */
{
Int i1 = IntegerOfTerm(t1);
Int i2 = IntegerOfTerm(t2);
Int mod;
if (i2 == 0)
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " mod 0", i1);
if (i1 == Int_MIN && i2 == -1) {
return MkIntTerm(0);
}
mod = i1%i2;
if (mod && (mod ^ i2) < 0)
mod += i2;
RINT(mod);
}
case (CELL)double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
case (CELL)big_int_e:
#ifdef USE_GMP
return Yap_gmp_mod_int_big(IntegerOfTerm(t1), t2);
#endif
default:
RERROR();
break;
}
case (CELL)double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
case (CELL)big_int_e:
#ifdef USE_GMP
switch (ETypeOfTerm(t2)) {
case long_int_e:
/* modulo between bignum and integer */
{
Int i2 = IntegerOfTerm(t2);
if (i2 == 0)
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is ... mod 0");
return Yap_gmp_mod_big_int(t1, i2);
}
case (CELL)big_int_e:
/* two bignums */
return Yap_gmp_mod_big_big(t1, t2);
case double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
default:
RERROR();
}
#endif
default:
RERROR();
}
}
示例2: p_rem
static Term
p_rem(Term t1, Term t2) {
switch (ETypeOfTerm(t1)) {
case (CELL)long_int_e:
switch (ETypeOfTerm(t2)) {
case (CELL)long_int_e:
/* two integers */
{
Int i1 = IntegerOfTerm(t1);
Int i2 = IntegerOfTerm(t2);
Int mod;
if (i2 == 0) goto zero_divisor;
if (i1 == Int_MIN && i2 == -1) {
#ifdef USE_GMP
return Yap_gmp_add_ints(Int_MAX, 1);
#else
return Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, t1,
"rem/2 with %d and %d", i1, i2);
#endif
}
mod = i1%i2;
RINT(i1%i2);
}
case (CELL)double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
case (CELL)big_int_e:
#ifdef USE_GMP
return Yap_gmp_rem_int_big(IntegerOfTerm(t1), t2);
#endif
default:
RERROR();
}
break;
case (CELL)double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "mod/2");
case (CELL)big_int_e:
#ifdef USE_GMP
switch (ETypeOfTerm(t2)) {
case long_int_e:
return Yap_gmp_rem_big_int(t1, IntegerOfTerm(t2));
case (CELL)big_int_e:
/* two bignums */
return Yap_gmp_rem_big_big(t1, t2);
case double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
default:
RERROR();
}
#endif
default:
RERROR();
}
zero_divisor:
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is mod 0");
}
示例3: pam_conv
/** Dialogue between RADIUS and PAM modules
*
* Uses PAM's appdata_ptr so it's thread safe, and doesn't
* have any nasty static variables hanging around.
*/
static int pam_conv(int num_msg, struct pam_message const **msg, struct pam_response **resp, void *appdata_ptr)
{
int count;
struct pam_response *reply;
REQUEST *request;
rlm_pam_data_t *pam_config = (rlm_pam_data_t *) appdata_ptr;
request = pam_config->request;
/* strdup(NULL) doesn't work on some platforms */
#define COPY_STRING(s) ((s) ? strdup(s) : NULL)
reply = rad_malloc(num_msg * sizeof(struct pam_response));
memset(reply, 0, num_msg * sizeof(struct pam_response));
for (count = 0; count < num_msg; count++) {
switch (msg[count]->msg_style) {
case PAM_PROMPT_ECHO_ON:
reply[count].resp_retcode = PAM_SUCCESS;
reply[count].resp = COPY_STRING(pam_config->username);
break;
case PAM_PROMPT_ECHO_OFF:
reply[count].resp_retcode = PAM_SUCCESS;
reply[count].resp = COPY_STRING(pam_config->password);
break;
case PAM_TEXT_INFO:
RDEBUG2("%s", msg[count]->msg);
break;
case PAM_ERROR_MSG:
default:
RERROR("PAM conversation failed");
/* Must be an error of some sort... */
for (count = 0; count < num_msg; count++) {
if (msg[count]->msg_style == PAM_ERROR_MSG) RERROR("%s", msg[count]->msg);
if (reply[count].resp) {
/* could be a password, let's be sanitary */
memset(reply[count].resp, 0, strlen(reply[count].resp));
free(reply[count].resp);
}
}
free(reply);
pam_config->error = true;
return PAM_CONV_ERR;
}
}
*resp = reply;
/* PAM frees reply (including reply[].resp) */
return PAM_SUCCESS;
}
示例4: p_rem
static Term
p_rem(Term t1, Term t2 USES_REGS) {
switch (ETypeOfTerm(t1)) {
case (CELL)long_int_e:
switch (ETypeOfTerm(t2)) {
case (CELL)long_int_e:
/* two integers */
{
Int i1 = IntegerOfTerm(t1);
Int i2 = IntegerOfTerm(t2);
if (i2 == 0)
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " rem 0", i1);
if (i1 == Int_MIN && i2 == -1) {
return MkIntTerm(0);
}
RINT(i1%i2);
}
case (CELL)double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
case (CELL)big_int_e:
#ifdef USE_GMP
return Yap_gmp_rem_int_big(IntegerOfTerm(t1), t2);
#endif
default:
RERROR();
}
break;
case (CELL)double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "mod/2");
case (CELL)big_int_e:
#ifdef USE_GMP
switch (ETypeOfTerm(t2)) {
case long_int_e:
if (IntegerOfTerm(t2) == 0)
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is ... rem 0");
return Yap_gmp_rem_big_int(t1, IntegerOfTerm(t2));
case (CELL)big_int_e:
/* two bignums */
return Yap_gmp_rem_big_big(t1, t2);
case double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
default:
RERROR();
}
#endif
default:
RERROR();
}
}
示例5: do_pam
/** Check the users password against the standard UNIX password table + PAM.
*
* @note For most flexibility, passing a pamauth type to this function
* allows you to have multiple authentication types (i.e. multiple
* files associated with radius in /etc/pam.d).
*
* @param request The current request.
* @param username User to authenticate.
* @param passwd Password to authenticate with,
* @param pamauth Type of PAM authentication.
* @return 0 on success -1 on failure.
*/
static int do_pam(REQUEST *request, char const *username, char const *passwd, char const *pamauth)
{
pam_handle_t *handle = NULL;
int ret;
rlm_pam_data_t pam_config;
struct pam_conv conv;
/*
* Initialize the structures
*/
conv.conv = pam_conv;
conv.appdata_ptr = &pam_config;
pam_config.request = request;
pam_config.username = username;
pam_config.password = passwd;
pam_config.error = false;
RDEBUG2("Using pamauth string \"%s\" for pam.conf lookup", pamauth);
ret = pam_start(pamauth, username, &conv, &handle);
if (ret != PAM_SUCCESS) {
RERROR("pam_start failed: %s", pam_strerror(handle, ret));
return -1;
}
ret = pam_authenticate(handle, 0);
if (ret != PAM_SUCCESS) {
RERROR("pam_authenticate failed: %s", pam_strerror(handle, ret));
pam_end(handle, ret);
return -1;
}
/*
* FreeBSD 3.x doesn't have account and session management
* functions in PAM, while 4.0 does.
*/
#if !defined(__FreeBSD_version) || (__FreeBSD_version >= 400000)
ret = pam_acct_mgmt(handle, 0);
if (ret != PAM_SUCCESS) {
RERROR("pam_acct_mgmt failed: %s", pam_strerror(handle, ret));
pam_end(handle, ret);
return -1;
}
#endif
RDEBUG2("Authentication succeeded");
pam_end(handle, ret);
return 0;
}
示例6: rlm_redis_query
/*
* Query the redis database
*/
int rlm_redis_query(REDISSOCK **dissocket_p, REDIS_INST *inst,
char const *query, REQUEST *request)
{
REDISSOCK *dissocket;
int argc;
char const *argv[MAX_REDIS_ARGS];
char argv_buf[MAX_QUERY_LEN];
if (!query || !*query || !inst || !dissocket_p) {
return -1;
}
argc = rad_expand_xlat(request, query, MAX_REDIS_ARGS, argv, false,
sizeof(argv_buf), argv_buf);
if (argc <= 0)
return -1;
dissocket = *dissocket_p;
DEBUG2("executing %s ...", argv[0]);
dissocket->reply = redisCommandArgv(dissocket->conn, argc, argv, NULL);
if (!dissocket->reply) {
RERROR("%s", dissocket->conn->errstr);
dissocket = fr_connection_reconnect(inst->pool, dissocket);
if (!dissocket) {
error:
*dissocket_p = NULL;
return -1;
}
dissocket->reply = redisCommand(dissocket->conn, query);
if (!dissocket->reply) {
RERROR("Failed after re-connect");
fr_connection_del(inst->pool, dissocket);
goto error;
}
*dissocket_p = dissocket;
}
if (dissocket->reply->type == REDIS_REPLY_ERROR) {
RERROR("Query failed, %s", query);
return -1;
}
return 0;
}
示例7: cache_entry_insert
/** Insert a new entry into the data store
*
* @param inst main rlm_cache instance.
* @param request The current request.
* @param handle Pointer to memcached handle.
* @param c entry to insert.
* @return CACHE_OK on success else CACHE_ERROR on error.
*/
static cache_status_t cache_entry_insert(UNUSED rlm_cache_t *inst, REQUEST *request, rlm_cache_handle_t **handle,
rlm_cache_entry_t *c)
{
rlm_cache_memcached_handle_t *mandle = *handle;
memcached_return_t ret;
TALLOC_CTX *pool;
char *to_store;
pool = talloc_pool(NULL, 1024);
if (!pool) return CACHE_ERROR;
if (cache_serialize(pool, &to_store, c) < 0) {
talloc_free(pool);
return CACHE_ERROR;
}
ret = memcached_set(mandle->handle, c->key, talloc_array_length(c->key) - 1,
to_store ? to_store : "",
to_store ? talloc_array_length(to_store) - 1 : 0, c->expires, 0);
talloc_free(pool);
if (ret != MEMCACHED_SUCCESS) {
RERROR("Failed storing entry with key \"%s\": %s: %s", c->key,
memcached_strerror(mandle->handle, ret),
memcached_last_error_message(mandle->handle));
return CACHE_ERROR;
}
return CACHE_OK;
}
示例8: p_rdiv
static Term
p_rdiv(Term t1, Term t2 USES_REGS) {
#ifdef USE_GMP
switch (ETypeOfTerm(t1)) {
case (CELL)double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "rdiv/2");
case (CELL)long_int_e:
switch (ETypeOfTerm(t2)) {
case (CELL)long_int_e:
/* two integers */
{
Int i1 = IntegerOfTerm(t1);
Int i2 = IntegerOfTerm(t2);
if (i2 == 0)
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is " Int_FORMAT " rdiv 0", i1);
return Yap_gmq_rdiv_int_int(i1, i2);
}
case (CELL)big_int_e:
/* I know the term is much larger, so: */
return Yap_gmq_rdiv_int_big(IntegerOfTerm(t1), t2);
default:
RERROR();
}
break;
case (CELL)big_int_e:
switch (ETypeOfTerm(t2)) {
case long_int_e:
if (IntegerOfTerm(t2) == 0)
return Yap_ArithError(EVALUATION_ERROR_ZERO_DIVISOR, t2, "X is ... rdiv 0");
/* I know the term is much larger, so: */
return Yap_gmq_rdiv_big_int(t1, IntegerOfTerm(t2));
case (CELL)big_int_e:
return Yap_gmq_rdiv_big_big(t1, t2);
case double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "mod/2");
default:
RERROR();
}
default:
RERROR();
}
#else
RERROR();
#endif
}
示例9: p_gcd
/*
module gcd
*/
static Term
p_gcd(Term t1, Term t2 USES_REGS)
{
switch (ETypeOfTerm(t1)) {
case long_int_e:
switch (ETypeOfTerm(t2)) {
case long_int_e:
/* two integers */
{
Int i1 = IntegerOfTerm(t1), i2 = IntegerOfTerm(t2);
i1 = (i1 >= 0 ? i1 : -i1);
i2 = (i2 >= 0 ? i2 : -i2);
RINT(gcd(i1,i2 PASS_REGS));
}
case double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "gcd/2");
case big_int_e:
#ifdef USE_GMP
return Yap_gmp_gcd_int_big(IntegerOfTerm(t1), t2);
#endif
default:
RERROR();
}
break;
case double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "gcd/2");
case big_int_e:
#ifdef USE_GMP
switch (ETypeOfTerm(t2)) {
case long_int_e:
return Yap_gmp_gcd_int_big(IntegerOfTerm(t2), t1);
case big_int_e:
return Yap_gmp_gcd_big_big(t1, t2);
case double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "gcd/2");
default:
RERROR();
}
#endif
default:
RERROR();
}
RERROR();
}
示例10: p_xor
/*
xor #
*/
static Term
p_xor(Term t1, Term t2 USES_REGS)
{
switch (ETypeOfTerm(t1)) {
case long_int_e:
switch (ETypeOfTerm(t2)) {
case long_int_e:
/* two integers */
RINT(IntegerOfTerm(t1) ^ IntegerOfTerm(t2));
case double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "#/2");
case big_int_e:
#ifdef USE_GMP
return Yap_gmp_xor_int_big(IntegerOfTerm(t1), t2);
#endif
default:
RERROR();
}
break;
case double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t1, "#/2");
case big_int_e:
#ifdef USE_GMP
switch (ETypeOfTerm(t2)) {
case long_int_e:
return Yap_gmp_xor_int_big(IntegerOfTerm(t2), t1);
case big_int_e:
return Yap_gmp_xor_big_big(t1, t2);
case double_e:
return Yap_ArithError(TYPE_ERROR_INTEGER, t2, "#/2");
default:
RERROR();
}
#endif
default:
RERROR();
}
RERROR();
}
示例11: cache_entry_find
/** Locate a cache entry in memcached
*
* @param out Where to write the pointer to the cach entry.
* @param inst main rlm_cache instance.
* @param request The current request.
* @param handle Pointer to memcached handle.
* @param key to search for.
* @return CACHE_OK on success CACHE_MISS if no entry found, CACHE_ERROR on error.
*/
static cache_status_t cache_entry_find(rlm_cache_entry_t **out, UNUSED rlm_cache_t *inst, REQUEST *request,
rlm_cache_handle_t **handle, char const *key)
{
rlm_cache_memcached_handle_t *mandle = *handle;
memcached_return_t mret;
size_t len;
int ret;
uint32_t flags;
char *from_store;
rlm_cache_entry_t *c;
from_store = memcached_get(mandle->handle, key, strlen(key), &len, &flags, &mret);
if (!from_store) {
if (mret == MEMCACHED_NOTFOUND) return CACHE_MISS;
RERROR("Failed retrieving entry for key \"%s\": %s: %s", key, memcached_strerror(mandle->handle, mret),
memcached_last_error_message(mandle->handle));
return CACHE_ERROR;
}
RDEBUG2("Retrieved %zu bytes from memcached", len);
RDEBUG2("%s", from_store);
c = talloc_zero(NULL, rlm_cache_entry_t);
ret = cache_deserialize(c, from_store, len);
free(from_store);
if (ret < 0) {
RERROR("%s", fr_strerror());
talloc_free(c);
return CACHE_ERROR;
}
c->key = talloc_strdup(c, key);
*out = c;
return CACHE_OK;
}
示例12: mod_post_auth
static rlm_rcode_t mod_post_auth(void *instance, REQUEST *request)
{
rlm_eap_t *inst = instance;
VALUE_PAIR *vp;
eap_handler_t *handler;
eap_packet_raw_t *eap_packet;
/*
* Only build a failure message if something previously rejected the request
*/
vp = pairfind(request->config_items, PW_POSTAUTHTYPE, 0, TAG_ANY);
if (!vp || (vp->vp_integer != PW_POSTAUTHTYPE_REJECT)) return RLM_MODULE_NOOP;
if (!pairfind(request->packet->vps, PW_EAP_MESSAGE, 0, TAG_ANY)) {
RDEBUG2("Request didn't contain an EAP-Message, not inserting EAP-Failure");
return RLM_MODULE_NOOP;
}
if (pairfind(request->reply->vps, PW_EAP_MESSAGE, 0, TAG_ANY)) {
RDEBUG2("Reply already contained an EAP-Message, not inserting EAP-Failure");
return RLM_MODULE_NOOP;
}
eap_packet = eap_vp2packet(request, request->packet->vps);
if (!eap_packet) {
RERROR("Malformed EAP Message");
return RLM_MODULE_FAIL;
}
handler = eap_handler(inst, &eap_packet, request);
if (!handler) {
RDEBUG2("Failed to get handler, probably already removed, not inserting EAP-Failure");
return RLM_MODULE_NOOP;
}
RDEBUG2("Request was previously rejected, inserting EAP-Failure");
eap_fail(handler);
eap_handler_free(inst, handler);
/*
* Make sure there's a message authenticator attribute in the response
* RADIUS protocol code will calculate the correct value later...
*/
vp = pairfind(request->reply->vps, PW_MESSAGE_AUTHENTICATOR, 0, TAG_ANY);
if (!vp) {
pairmake_reply("Message-Authenticator", "0x00", T_OP_EQ);
}
return RLM_MODULE_UPDATED;
}
示例13: xlat_client
/*
* Xlat for %{client:[<ipaddr>.]foo}
*/
static ssize_t xlat_client(TALLOC_CTX *ctx, char **out, UNUSED size_t outlen,
UNUSED void const *mod_inst, UNUSED void const *xlat_inst,
REQUEST *request, char const *fmt)
{
char const *value = NULL;
char buffer[INET6_ADDRSTRLEN], *q;
char const *p = fmt;
fr_ipaddr_t ip;
CONF_PAIR *cp;
RADCLIENT *client = NULL;
*out = NULL;
q = strrchr(p, '.');
if (q) {
strlcpy(buffer, p, (q + 1) - p);
if (fr_inet_pton(&ip, buffer, -1, AF_UNSPEC, false, true) < 0) goto request_client;
p = q + 1;
client = client_find(NULL, &ip, IPPROTO_IP);
if (!client) {
RDEBUG("No client found with IP \"%s\"", buffer);
return 0;
}
} else {
request_client:
client = request->client;
if (!client) {
RERROR("No client associated with this request");
return -1;
}
}
cp = cf_pair_find(client->cs, p);
if (!cp || !(value = cf_pair_value(cp))) {
if (strcmp(fmt, "shortname") == 0 && request->client->shortname) {
value = request->client->shortname;
}
else if (strcmp(fmt, "nas_type") == 0 && request->client->nas_type) {
value = request->client->nas_type;
}
if (!value) return 0;
}
*out = talloc_typed_strdup(ctx, value);
return talloc_array_length(*out) - 1;
}
示例14: eval2
static Term
eval2(Int fi, Term t1, Term t2 USES_REGS) {
arith2_op f = fi;
switch (f) {
case op_plus:
return p_plus(t1, t2 PASS_REGS);
case op_minus:
return p_minus(t1, t2 PASS_REGS);
case op_times:
return p_times(t1, t2 PASS_REGS);
case op_div:
return p_div(t1, t2 PASS_REGS);
case op_idiv:
return p_div2(t1, t2 PASS_REGS);
case op_and:
return p_and(t1, t2 PASS_REGS);
case op_or:
return p_or(t1, t2 PASS_REGS);
case op_sll:
return p_sll(t1, t2 PASS_REGS);
case op_slr:
return p_slr(t1, t2 PASS_REGS);
case op_mod:
return p_mod(t1, t2 PASS_REGS);
case op_rem:
return p_rem(t1, t2 PASS_REGS);
case op_fdiv:
return p_fdiv(t1, t2 PASS_REGS);
case op_xor:
return p_xor(t1, t2 PASS_REGS);
case op_atan2:
return p_atan2(t1, t2 PASS_REGS);
case op_power:
return p_exp(t1, t2 PASS_REGS);
case op_power2:
return p_power(t1, t2 PASS_REGS);
case op_gcd:
return p_gcd(t1, t2 PASS_REGS);
case op_min:
return p_min(t1, t2);
case op_max:
return p_max(t1, t2);
case op_rdiv:
return p_rdiv(t1, t2 PASS_REGS);
}
RERROR();
}
示例15: cache_entry_expire
/** Call delete the cache entry from memcached
*
* @param inst main rlm_cache instance.
* @param request The current request.
* @param handle Pointer to memcached handle.
* @param c entry to expire.
* @return CACHE_OK on success else CACHE_ERROR.
*/
static cache_status_t cache_entry_expire(UNUSED rlm_cache_t *inst, REQUEST *request, rlm_cache_handle_t **handle,
rlm_cache_entry_t *c)
{
rlm_cache_memcached_handle_t *mandle = *handle;
memcached_return_t ret;
ret = memcached_delete(mandle->handle, c->key, talloc_array_length(c->key) - 1, 0);
if (ret != MEMCACHED_SUCCESS) {
RERROR("Failed deleting entry with key \"%s\": %s", c->key,
memcached_last_error_message(mandle->handle));
return CACHE_ERROR;
}
return CACHE_OK;
}