CP_HIDDEN void cpi_check_invocation(cp_context_t *ctx, int funcmask, const char *func) { assert(ctx != NULL); assert(funcmask != 0); assert(func != NULL); assert(cpi_is_context_locked(ctx)); if ((funcmask & CPI_CF_LOGGER) &&ctx->env->in_logger_invocation) { cpi_fatalf(_("Function %s was called from within a logger invocation."), func); } if ((funcmask & CPI_CF_LISTENER) && ctx->env->in_event_listener_invocation) { cpi_fatalf(_("Function %s was called from within an event listener invocation."), func); } if ((funcmask & CPI_CF_START) && ctx->env->in_start_func_invocation) { cpi_fatalf(_("Function %s was called from within a plug-in start function invocation."), func); } if ((funcmask & CPI_CF_STOP) && ctx->env->in_stop_func_invocation) { cpi_fatalf(_("Function %s was called from within a plug-in stop function invocation."), func); } if (ctx->env->in_create_func_invocation) { cpi_fatalf(_("Function %s was called from within a plug-in create function invocation."), func); } if (ctx->env->in_destroy_func_invocation) { cpi_fatalf(_("Function %s was called from within a plug-in destroy function invocation."), func); } }
/* * Initializes the implicit local plug-in loader of the specified context. * Does nothing if the loader has already been initialized. */ static cp_status_t init_local_ploader(cp_context_t *context) { cp_status_t status = CP_OK; assert(cpi_is_context_locked(context)); // Create new local plug-in loader, if one does not exist if (context->env->local_loader == NULL) { context->env->local_loader = cp_create_local_ploader(&status); status = cp_register_ploader(context, context->env->local_loader); } return status; }
static void do_log(cp_context_t *context, cp_log_severity_t severity, const char *msg) { lnode_t *node; const char *apid = NULL; assert(cpi_is_context_locked(context)); if (context->env->in_logger_invocation) { cpi_fatalf(_("Encountered a recursive logging request within a logger invocation.")); } if (context->plugin != NULL) { apid = context->plugin->plugin->identifier; } context->env->in_logger_invocation++; node = list_first(context->env->loggers); while (node != NULL) { logger_t *lh = lnode_get(node); if (severity >= lh->min_severity) { lh->logger(severity, msg, apid, lh->user_data); } node = list_next(context->env->loggers, node); } context->env->in_logger_invocation--; }