/******************************************************************** * FUNCTION set_error * * Generate an error stack entry or if log_error is enabled, * then log the error report right now. * * Used to flag internal code errors * * DO NOT USE THIS FUNCTION DIRECTLY! * USE THE SET_ERROR MACRO INSTEAD! * * INPUTS: * filename == C filename that caused the error * linenum -- line number in the C file that caused the error * status == internal error code * sqlError = mySQL error code (deprecated) * * RETURNS * the 'status' parameter will be returned *********************************************************************/ status_t set_error (const char *filename, int linenum, status_t status, int sqlError) { if (log_get_debug_level() > LOG_DEBUG_NONE) { log_error("\nE0:\n %s:%d\n Error %d: %s\n", filename, linenum, status, get_error_string(status)); } else if (error_level < MAX_ERR_LEVEL) { error_stack[error_level].linenum = linenum; error_stack[error_level].sqlError = sqlError; error_stack[error_level].status = status; strncpy(error_stack[error_level].filename, filename, MAX_ERR_FILENAME-1); error_stack[error_level].filename[MAX_ERR_FILENAME-1] = 0; error_stack[error_level].msg = get_error_string(status); error_level++; } error_count++; return status; } /* set_error */
/******************************************************************** * FUNCTION yangcli_notification_handler * * matches callback template mgr_not_cbfn_t * * INPUTS: * scb == session receiving RPC reply * msg == notification msg that was parsed * consumed == address of return consumed message flag * * OUTPUTS: * *consumed == TRUE if msg has been consumed so * it will not be freed by mgr_not_dispatch * == FALSE if msg has been not consumed so * it will be freed by mgr_not_dispatch *********************************************************************/ void yangcli_notification_handler (ses_cb_t *scb, mgr_not_msg_t *msg, boolean *consumed) { assert(scb && "scb is NULL!"); assert(msg && "msg is NULL!"); assert(consumed && "consumed is NULL!"); *consumed = FALSE; mgr_scb_t *mgrcb = scb->mgrcb; server_cb_t *server_cb = get_cur_server_cb(); session_cb_t *save_session_cb = server_cb->cur_session_cb; session_cb_t *session_cb = NULL; if (mgrcb) { session_cb = mgrcb->session_cb; } if (session_cb == NULL) { log_error("\nError: session no longer valid; dropping notification"); return; } const xmlChar *sesname = get_session_name(session_cb); if (session_cb != save_session_cb) { set_cur_session_cb(server_cb, session_cb); } /* check the contents of the notification */ if (msg && msg->notification) { /* dispatch this event to any handler registered for * this event; !!! not session-specific !!! */ uint32 retcnt = dispatch_notif_event(session_cb, msg); /* display only unhandled notifications, and only if * the session is configured to show them */ log_debug_t loglevel = log_get_debug_level(); log_debug_t base_loglevel = loglevel + 1; if (loglevel == LOG_DEBUG_INFO) { base_loglevel++; } if (retcnt == 0 && session_cb->echo_notifs && base_loglevel >= session_cb->echo_notif_loglevel) { gl_normal_io(server_cb->cli_gl); if (loglevel >= session_cb->echo_notif_loglevel) { log_write("\n\nIncoming notification for session %u [%s]:", scb->sid, sesname); val_dump_value_max(msg->notification, 0, session_cb->defindent, DUMP_VAL_LOG, session_cb->display_mode, FALSE, FALSE); log_write_append("\n\n"); } else if (msg->eventType) { log_write("\n\nIncoming <%s> notification for session " "%u [%s]\n\n", msg->eventType->name, scb->sid, sesname); } } /* store msg in the session notification log */ dlq_enque(msg, &session_cb->notificationQ); *consumed = TRUE; } if (session_cb != save_session_cb) { set_cur_session_cb(server_cb, save_session_cb); } } /* yangcli_notification_handler */
/******************************************************************** * FUNCTION init_server_profile * * Hardwire the initial server profile variables * * OUTPUTS: * *agt_profile is filled in with params of defaults * *********************************************************************/ static void init_server_profile (void) { memset(&agt_profile, 0x0, sizeof(agt_profile_t)); /* init server state variables stored here */ dlq_createSQue(&agt_profile.agt_savedevQ); dlq_createSQue(&agt_profile.agt_commit_testQ); agt_profile.agt_config_state = AGT_CFG_STATE_INIT; /* Set the default values for the user parameters * these may be overridden from the command line; */ agt_profile.agt_targ = NCX_AGT_TARG_CANDIDATE; agt_profile.agt_start = NCX_AGT_START_MIRROR; agt_profile.agt_loglevel = log_get_debug_level(); agt_profile.agt_log_acm_reads = FALSE; agt_profile.agt_log_acm_writes = TRUE; /* T: <validate> op on candidate will call all SILs * F: only SILs for nodes changed in the candidate will * be called; only affects <validate> command */ agt_profile.agt_validate_all = TRUE; agt_profile.agt_has_startup = FALSE; agt_profile.agt_usestartup = TRUE; agt_profile.agt_factorystartup = FALSE; agt_profile.agt_startup_error = FALSE; agt_profile.agt_running_error = FALSE; agt_profile.agt_logappend = FALSE; agt_profile.agt_xmlorder = FALSE; agt_profile.agt_deleteall_ok = FALSE; agt_profile.agt_stream_output = TRUE; /* this flag is no longer supported -- it must be * set to false for XPath to work correctly */ agt_profile.agt_delete_empty_npcontainers = FALSE; /* this flag adds the <sequence-id> leaf to notifications * It was default true for yuma through 2.2-3 release * Starting 2.2-4 it is removed by default since the XSD * in RFC 5277 does not allow extensions */ agt_profile.agt_notif_sequence_id = FALSE; agt_profile.agt_accesscontrol = NULL; agt_profile.agt_conffile = NULL; agt_profile.agt_logfile = NULL; agt_profile.agt_startup = NULL; agt_profile.agt_defaultStyle = NCX_EL_EXPLICIT; agt_profile.agt_superuser = NULL; agt_profile.agt_eventlog_size = 1000; agt_profile.agt_maxburst = 10; agt_profile.agt_hello_timeout = 300; agt_profile.agt_idle_timeout = 3600; agt_profile.agt_linesize = 72; agt_profile.agt_indent = 1; agt_profile.agt_usevalidate = TRUE; agt_profile.agt_useurl = TRUE; agt_profile.agt_defaultStyleEnum = NCX_WITHDEF_EXPLICIT; agt_profile.agt_accesscontrol_enum = AGT_ACMOD_ENFORCING; agt_profile.agt_system_sorted = AGT_DEF_SYSTEM_SORTED; agt_profile.agt_max_sessions = 1024; } /* init_server_profile */