c_bool v_serviceChangeState( v_service service, v_serviceStateKind newState) { c_bool result; assert(service != NULL); assert(C_TYPECHECK(service, v_service)); assert(service->state != NULL); assert(C_TYPECHECK(service->state, v_serviceState)); result = v_serviceStateChangeState(service->state, newState); if(result) { switch(newState) { case STATE_OPERATIONAL: OS_REPORT(OS_INFO, "v_serviceChangeState", 0, "++++++++++++++++++++++++++++++++++++++++++++++++" OS_REPORT_NL "++ The service '%s' is now operational. " OS_REPORT_NL "++++++++++++++++++++++++++++++++++++++++++++++++", v_serviceGetName(service)); break; case STATE_TERMINATED: OS_REPORT(OS_INFO, "v_serviceChangeState", 0, "================================================" OS_REPORT_NL "== The service '%s' has now terminated. "OS_REPORT_NL "================================================", v_serviceGetName(service)); break; case STATE_DIED: OS_REPORT(OS_INFO, "v_serviceChangeState", 0, "================================================" OS_REPORT_NL "== The service '%s' has died. "OS_REPORT_NL "================================================", v_serviceGetName(service)); break; case STATE_NONE: case STATE_INITIALISING: case STATE_TERMINATING: case STATE_INCOMPATIBLE_CONFIGURATION: default: /* ignore */ break; } } return result; }
c_char * u_serviceGetName( u_service service) { c_char *name; u_result result; v_service s; name = NULL; if (service != NULL) { result = u_entityReadClaim(u_entity(service), (v_entity*)(&s)); if (result == U_RESULT_OK) { assert(s); name = os_strdup(v_serviceGetName(s)); u_entityRelease(u_entity(service)); } else { OS_REPORT(OS_WARNING, "u_serviceGetName", 0, "Could not claim service."); } } return name; }