int player_hit(struct player *p, struct game *g) { if (player_remove(p, g)) { ERR_TRACE(); return -1; } if (!p->lives) { player_respawn(p); if (player_add(p, g)) { ERR_TRACE(); return -1; } } else { if (!--p->lives) { SDLNet_TCP_Send(p->client->s, "\11", 1); player_free(p); } else { player_respawn(p); if (player_add(p, g)) { ERR_TRACE(); return -1; } } } return 0; }
int ipmi_cmd_get_oem_netfn_iana_support (ipmi_ctx_t ctx, uint8_t channel_number, uint8_t net_fn, uint8_t list_index, fiid_obj_t obj_cmd_rs) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } /* remaining parameter checks in fill function */ if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_get_oem_netfn_iana_support_rs) < 0) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_get_oem_netfn_iana_support_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_get_oem_netfn_iana_support (channel_number, net_fn, list_index, obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_APP_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
/** * Pop the bubble splitting it into two bubbles. * No children are created if the bubble was too small. */ int bubble_pop(struct bubble *b, struct game *g) { if (b->l <= 1) { bubble_destroy(b); return 0; } double radius = cpCircleShapeGetRadius(&b->shape); cpVect pos = cpBodyGetPos(&b->body); cpVect vel = cpBodyGetVel(&b->body); bubble_remove(b, g); bubble_destroy(b); b = bubble_init(b, pos.x, pos.y, vel.x + 5, vel.y + 5, radius / 2, b->l - 1); if (!b) { ERR_TRACE(); return -1; } //b->events = b->events; if (bubble_add(b, g)) { ERR_TRACE(); return -1; } struct bubble *c = bubble_create(pos.x, pos.y, vel.x - 5, vel.y + 5, radius / 2, b->l - 1); if (!c) { ERR_TRACE(); return -1; } //c->events = b->events; if (bubble_add(c, g)) { ERR_TRACE(); return -1; } return 0; }
void udp_accept_connection(void) { struct sockaddr_in cli_addr; socklen_t cli_len; char *buffer; size_t length; int ret; journal("Listening for connection...\n"); ret = recvfrom(sockfd, NULL, 0, 0, (struct sockaddr *)(&cli_addr), &cli_len); if (unlikely(ret)) { int errsave = errno; ERR_TRACE(); journal("Unable to read from socket: %s.\n", strerror(errsave)); CHECK_SOCKET_ERROR(errsave); } cli_len = sizeof(cli_addr); ret = get_quote_of_the_day(&buffer, &length); if (unlikely(ret)) { return; } ret = sendto(sockfd, buffer, length, 0, (struct sockaddr *)(&cli_addr), cli_len); if (unlikely(ret < 0)) { ERR_TRACE(); journal("Unable to write to UDP socket: %s.\n", strerror(errno)); return; } }
int ipmi_cmd_set_system_boot_options_service_partition_scan (ipmi_ctx_t ctx, uint8_t parameter_valid, uint8_t service_partition_discovered, uint8_t service_partition_scan, fiid_obj_t obj_cmd_rs) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } /* remaining parameter checks in fill function */ if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_set_system_boot_options_rs) < 0) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_set_system_boot_options_service_partition_scan_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_set_system_boot_options_service_partition_scan (parameter_valid, service_partition_discovered, service_partition_scan, obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_CHASSIS_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
int ipmi_cmd_set_auxiliary_log_status (ipmi_ctx_t ctx, uint8_t log_type, const void *log_data, unsigned int log_data_len, fiid_obj_t obj_cmd_rs) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } /* remaining parameter checks in fill function */ if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_set_auxiliary_log_status_rs) < 0) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_set_auxiliary_log_status_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_set_auxiliary_log_status (log_type, log_data, log_data_len, obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_STORAGE_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
int ipmi_cmd_set_sol_configuration_parameters_sol_retry (ipmi_ctx_t ctx, uint8_t channel_number, uint8_t retry_count, uint8_t retry_interval, fiid_obj_t obj_cmd_rs) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } /* remaining parameter checks in fill function */ if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_set_sol_configuration_parameters_rs) < 0) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_set_sol_configuration_parameters_sol_retry_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_set_sol_configuration_parameters_sol_retry (channel_number, retry_count, retry_interval, obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_TRANSPORT_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
int ipmi_cmd_read_fru_data (ipmi_ctx_t ctx, uint8_t fru_device_id, uint16_t fru_inventory_offset_to_read, uint8_t count_to_read, fiid_obj_t obj_cmd_rs) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_read_fru_data_rs) < 0) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_read_fru_data_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_read_fru_data (fru_device_id, fru_inventory_offset_to_read, count_to_read, obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_STORAGE_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
int ipmi_cmd_chassis_identify (ipmi_ctx_t ctx, const uint8_t *identify_interval, const uint8_t *force_identify, fiid_obj_t obj_cmd_rs) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } /* remaining parameter checks in fill function */ if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_chassis_identify_rs) < 0) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_chassis_identify_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_chassis_identify (identify_interval, force_identify, obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_CHASSIS_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
int ipmi_cmd_dcmi_get_management_controller_identifier_string (ipmi_ctx_t ctx, uint8_t offset_to_read, uint8_t number_of_bytes_to_read, fiid_obj_t obj_cmd_rs) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } /* remaining parameter checks in fill function */ if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_dcmi_get_management_controller_identifier_string_rs) < 0) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_dcmi_get_management_controller_identifier_string_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_dcmi_get_management_controller_identifier_string (offset_to_read, number_of_bytes_to_read, obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_GROUP_EXTENSION_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
int ipmi_cmd_clear_sel (ipmi_ctx_t ctx, uint16_t reservation_id, uint8_t operation, fiid_obj_t obj_cmd_rs) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } /* remaining parameter checks in fill function */ if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_clear_sel_rs) < 0) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_clear_sel_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_clear_sel (reservation_id, operation, obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_STORAGE_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
int ipmi_cmd_dcmi_set_dcmi_configuration_parameters_dhcp_timing_3 (ipmi_ctx_t ctx, uint8_t set_selector, uint16_t server_contact_retry_interval, fiid_obj_t obj_cmd_rs) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } /* technically, user can input anything for activate, but only 0x01 will do anything */ if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_dcmi_set_dcmi_configuration_parameters_rs) < 0) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_dcmi_set_dcmi_configuration_parameters_dhcp_timing_3_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_dcmi_set_dcmi_configuration_parameters_dhcp_timing_3 (set_selector, server_contact_retry_interval, obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_GROUP_EXTENSION_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
int ipmi_cmd_dcmi_get_thermal_limit (ipmi_ctx_t ctx, uint8_t entity_id, uint8_t entity_instance, fiid_obj_t obj_cmd_rs) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } /* remaining parameter checks in fill function */ if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_dcmi_get_thermal_limit_rs) < 0) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_dcmi_get_thermal_limit_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_dcmi_get_thermal_limit (entity_id, entity_instance, obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_GROUP_EXTENSION_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
int ipmi_cmd_dcmi_get_dcmi_configuration_parameters_dhcp_timing_3 (ipmi_ctx_t ctx, uint8_t set_selector, fiid_obj_t obj_cmd_rs) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_dcmi_get_dcmi_configuration_parameters_dhcp_timing_3_rs) < 0) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_dcmi_get_dcmi_configuration_parameters_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_dcmi_get_dcmi_configuration_parameters (IPMI_DCMI_CONFIGURATION_PARAMETER_DHCP_TIMING_3, set_selector, obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_GROUP_EXTENSION_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
static int _ipmi_cmd_dcmi_get_dcmi_capability_info_common (ipmi_ctx_t ctx, fiid_obj_t obj_cmd_rs, fiid_field_t *tmpl_cmd_rs_expected, uint8_t parameter_selector) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } /* remaining parameter checks in fill function */ if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_rs_expected) < 0) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_dcmi_get_dcmi_capability_info_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_dcmi_get_dcmi_capability_info (parameter_selector, obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_GROUP_EXTENSION_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
int ipmi_cmd_get_device_guid (ipmi_ctx_t ctx, fiid_obj_t obj_cmd_rs) { fiid_obj_t obj_cmd_rq = NULL; int rv = -1; if (!ctx || ctx->magic != IPMI_CTX_MAGIC) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); return (-1); } if (!fiid_obj_valid (obj_cmd_rs)) { API_SET_ERRNUM (ctx, IPMI_ERR_PARAMETERS); return (-1); } if ((FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_get_device_guid_rs) < 0) && (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rs, tmpl_cmd_get_device_guid_format_rs) < 0)) { API_FIID_OBJECT_ERROR_TO_API_ERRNUM (ctx, obj_cmd_rs); return (-1); } if (!(obj_cmd_rq = fiid_obj_create (tmpl_cmd_get_device_guid_rq))) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (fill_cmd_get_device_guid (obj_cmd_rq) < 0) { API_ERRNO_TO_API_ERRNUM (ctx, errno); goto cleanup; } if (api_ipmi_cmd (ctx, IPMI_BMC_IPMB_LUN_BMC, IPMI_NET_FN_APP_RQ, obj_cmd_rq, obj_cmd_rs) < 0) { ERR_TRACE (ipmi_ctx_errormsg (ctx), ipmi_ctx_errnum (ctx)); goto cleanup; } rv = 0; cleanup: fiid_obj_destroy (obj_cmd_rq); return (rv); }
int ipmi_sdr_cache_record_count (ipmi_sdr_ctx_t ctx, uint16_t *record_count) { if (!ctx || ctx->magic != IPMI_SDR_CTX_MAGIC) { ERR_TRACE (ipmi_sdr_ctx_errormsg (ctx), ipmi_sdr_ctx_errnum (ctx)); return (-1); } if (!record_count) { SDR_SET_ERRNUM (ctx, IPMI_SDR_ERR_PARAMETERS); return (-1); } if (ctx->operation != IPMI_SDR_OPERATION_READ_CACHE) { SDR_SET_ERRNUM (ctx, IPMI_SDR_ERR_CACHE_READ_INITIALIZATION); return (-1); } *record_count = ctx->record_count; ctx->errnum = IPMI_SDR_ERR_SUCCESS; return (0); }
int ipmi_sdr_stats_compile (ipmi_sdr_ctx_t ctx) { int rv = -1; if (!ctx || ctx->magic != IPMI_SDR_CTX_MAGIC) { ERR_TRACE (ipmi_sdr_ctx_errormsg (ctx), ipmi_sdr_ctx_errnum (ctx)); return (-1); } if (ctx->operation != IPMI_SDR_OPERATION_READ_CACHE) { SDR_SET_ERRNUM (ctx, IPMI_SDR_ERR_CACHE_READ_INITIALIZATION); return (-1); } if (ctx->stats_compiled) goto out; if (ipmi_sdr_cache_iterate (ctx, _sdr_stat_callback, NULL) < 0) goto cleanup; ctx->stats_compiled = 1; out: rv = 0; ctx->errnum = IPMI_SDR_ERR_SUCCESS; cleanup: return (rv); }
int ipmi_openipmi_ctx_io_init (ipmi_openipmi_ctx_t ctx) { unsigned int addr = IPMI_SLAVE_ADDRESS_BMC; char *driver_device; int flags; if (!ctx || ctx->magic != IPMI_OPENIPMI_CTX_MAGIC) { ERR_TRACE (ipmi_openipmi_ctx_errormsg (ctx), ipmi_openipmi_ctx_errnum (ctx)); return (-1); } if (ctx->io_init) goto out; if (ctx->driver_device) driver_device = ctx->driver_device; else driver_device = IPMI_OPENIPMI_DRIVER_DEVICE_DEFAULT; if ((ctx->device_fd = open (driver_device, O_RDWR)) < 0) { OPENIPMI_ERRNO_TO_OPENIPMI_ERRNUM (ctx, errno); goto cleanup; } flags = fcntl(ctx->device_fd, F_GETFD); if (flags < 0) { OPENIPMI_ERRNO_TO_OPENIPMI_ERRNUM (ctx, errno); goto cleanup; } flags |= FD_CLOEXEC; if (fcntl(ctx->device_fd, F_SETFD, flags) < 0) { OPENIPMI_ERRNO_TO_OPENIPMI_ERRNUM (ctx, errno); goto cleanup; } if (ioctl (ctx->device_fd, IPMICTL_SET_MY_ADDRESS_CMD, &addr) < 0) { OPENIPMI_ERRNO_TO_OPENIPMI_ERRNUM (ctx, errno); goto cleanup; } ctx->io_init = 1; out: ctx->errnum = IPMI_OPENIPMI_ERR_SUCCESS; return (0); cleanup: /* ignore potential error, error path */ close (ctx->device_fd); ctx->device_fd = -1; return (-1); }
int ipmi_sdr_cache_sdr_version (ipmi_sdr_ctx_t ctx, uint8_t *sdr_version) { if (!ctx || ctx->magic != IPMI_SDR_CTX_MAGIC) { ERR_TRACE (ipmi_sdr_ctx_errormsg (ctx), ipmi_sdr_ctx_errnum (ctx)); return (-1); } if (!sdr_version) { SDR_SET_ERRNUM (ctx, IPMI_SDR_ERR_PARAMETERS); return (-1); } if (ctx->operation != IPMI_SDR_OPERATION_READ_CACHE) { SDR_SET_ERRNUM (ctx, IPMI_SDR_ERR_CACHE_READ_INITIALIZATION); return (-1); } *sdr_version = ctx->sdr_version; ctx->errnum = IPMI_SDR_ERR_SUCCESS; return (0); }
int ipmi_sdr_cache_next (ipmi_sdr_ctx_t ctx) { unsigned int record_length; if (!ctx || ctx->magic != IPMI_SDR_CTX_MAGIC) { ERR_TRACE (ipmi_sdr_ctx_errormsg (ctx), ipmi_sdr_ctx_errnum (ctx)); return (-1); } if (ctx->operation != IPMI_SDR_OPERATION_READ_CACHE) { SDR_SET_ERRNUM (ctx, IPMI_SDR_ERR_CACHE_READ_INITIALIZATION); return (-1); } record_length = (uint8_t)((ctx->sdr_cache + ctx->current_offset.offset)[IPMI_SDR_RECORD_LENGTH_INDEX]); if ((ctx->current_offset.offset + record_length + IPMI_SDR_RECORD_HEADER_LENGTH) >= ctx->records_end_offset) return (0); _sdr_set_current_offset (ctx, ctx->current_offset.offset + IPMI_SDR_RECORD_HEADER_LENGTH + record_length); ctx->errnum = IPMI_SDR_ERR_SUCCESS; return (1); }
int ipmi_sdr_cache_most_recent_erase_timestamp (ipmi_sdr_ctx_t ctx, uint32_t *most_recent_erase_timestamp) { if (!ctx || ctx->magic != IPMI_SDR_CTX_MAGIC) { ERR_TRACE (ipmi_sdr_ctx_errormsg (ctx), ipmi_sdr_ctx_errnum (ctx)); return (-1); } if (!most_recent_erase_timestamp) { SDR_SET_ERRNUM (ctx, IPMI_SDR_ERR_PARAMETERS); return (-1); } if (ctx->operation != IPMI_SDR_OPERATION_READ_CACHE) { SDR_SET_ERRNUM (ctx, IPMI_SDR_ERR_CACHE_READ_INITIALIZATION); return (-1); } *most_recent_erase_timestamp = ctx->most_recent_erase_timestamp; ctx->errnum = IPMI_SDR_ERR_SUCCESS; return (0); }
/** * Initializes a new player. * The player is placed in the queue of available players. */ struct player *player_init(struct player *p, struct game *g, double x, double y, double w, double h, uint32_t score, uint8_t data) { cpVect all[4] = {cpv(0,0), cpv(0,h), cpv(w,h), cpv(w,0)}; cpBody *body = cpBodyInit(&p->body, 10, cpMomentForBox(10, w, h)); if (!body) { ERR_ERRNO(); return 0; } cpBodySetPos(body, cpv(x,y)); //cpShape *shape = cpPolyShapeNew(body,4,all,cpv((p->l+p->r)/2.0,(p->b+p->t)/2.0)); cpShape *shape = cpPolyShapeInit(&p->shape, body, 4, all, cpv(0, 0)); if (!shape) { ERR_ERRNO(); cpBodyDestroy(body); return 0; } shape->data = p; shape->collision_type = PLAYER; if (linkedlist_add_last(g->p_q, p)) { ERR_TRACE(); cpBodyDestroy(body); cpShapeDestroy(shape); return 0; } p->x = x; p->y = y; p->node = g->p_q->last; return p; }
int ipmi_sunbmc_ctx_set_driver_device (ipmi_sunbmc_ctx_t ctx, const char *driver_device) { if (!ctx || ctx->magic != IPMI_SUNBMC_CTX_MAGIC) { ERR_TRACE (ipmi_sunbmc_ctx_errormsg (ctx), ipmi_sunbmc_ctx_errnum (ctx)); return (-1); } if (!driver_device) { SUNBMC_SET_ERRNUM (ctx, IPMI_SUNBMC_ERR_PARAMETERS); return (-1); } free (ctx->driver_device); ctx->driver_device = NULL; if (!(ctx->driver_device = strdup (driver_device))) { SUNBMC_SET_ERRNUM (ctx, IPMI_SUNBMC_ERR_OUT_OF_MEMORY); return (-1); } ctx->errnum = IPMI_SUNBMC_ERR_SUCCESS; return (0); }
int ipmi_sdr_stats_entity_instance_unique (ipmi_sdr_ctx_t ctx, uint8_t entity_id) { int rv = -1; if (!ctx || ctx->magic != IPMI_SDR_CTX_MAGIC) { ERR_TRACE (ipmi_sdr_ctx_errormsg (ctx), ipmi_sdr_ctx_errnum (ctx)); return (-1); } if (ctx->operation != IPMI_SDR_OPERATION_READ_CACHE) { SDR_SET_ERRNUM (ctx, IPMI_SDR_ERR_CACHE_READ_INITIALIZATION); return (-1); } if (!ctx->stats_compiled) { SDR_SET_ERRNUM (ctx, IPMI_SDR_ERR_STATS_NOT_COMPILED); return (-1); } rv = ctx->entity_counts[entity_id].entity_instances_count; ctx->errnum = IPMI_SDR_ERR_SUCCESS; return (rv); }
/** * Add the bubble into the game. */ int bubble_add(struct bubble *b, struct game *g) { if (linkedlist_add_last(g->b, b)) { ERR_TRACE(); return -1; } b->node = g->b->last; cpSpaceAddBody(g->cp, &b->body); cpSpaceAddShape(g->cp, &b->shape); return 0; }
int ipmi_sdr_cache_search_record_id (ipmi_sdr_ctx_t ctx, uint16_t record_id) { off_t offset; int found = 0; if (!ctx || ctx->magic != IPMI_SDR_CTX_MAGIC) { ERR_TRACE (ipmi_sdr_ctx_errormsg (ctx), ipmi_sdr_ctx_errnum (ctx)); return (-1); } if (ctx->operation != IPMI_SDR_OPERATION_READ_CACHE) { SDR_SET_ERRNUM (ctx, IPMI_SDR_ERR_CACHE_READ_INITIALIZATION); return (-1); } offset = ctx->records_start_offset; while (offset < ctx->records_end_offset) { uint8_t *ptr = ctx->sdr_cache + offset; uint16_t record_id_current; unsigned int record_length; /* Record ID stored little-endian */ record_id_current = (uint16_t)ptr[IPMI_SDR_RECORD_ID_INDEX_LS] & 0xFF; record_id_current |= ((uint16_t)ptr[IPMI_SDR_RECORD_ID_INDEX_MS] & 0xFF) << 8; if (record_id == record_id_current) { found++; _sdr_set_current_offset (ctx, offset); break; } record_length = (uint8_t)((ctx->sdr_cache + offset)[IPMI_SDR_RECORD_LENGTH_INDEX]); if ((offset + record_length + IPMI_SDR_RECORD_HEADER_LENGTH) >= ctx->records_end_offset) break; offset += IPMI_SDR_RECORD_HEADER_LENGTH; offset += record_length; } if (!found) { SDR_SET_ERRNUM (ctx, IPMI_SDR_ERR_NOT_FOUND); return (-1); } ctx->errnum = IPMI_SDR_ERR_SUCCESS; return (0); }
int ipmi_kcs_ctx_set_driver_address (ipmi_kcs_ctx_t ctx, uint16_t driver_address) { if (!ctx || ctx->magic != IPMI_KCS_CTX_MAGIC) { ERR_TRACE (ipmi_kcs_ctx_errormsg (ctx), ipmi_kcs_ctx_errnum (ctx)); return (-1); } ctx->driver_address = driver_address; ctx->errnum = IPMI_KCS_ERR_SUCCESS; return (0); }
int ipmi_kcs_ctx_set_register_spacing (ipmi_kcs_ctx_t ctx, uint8_t register_spacing) { if (!ctx || ctx->magic != IPMI_KCS_CTX_MAGIC) { ERR_TRACE (ipmi_kcs_ctx_errormsg (ctx), ipmi_kcs_ctx_errnum (ctx)); return (-1); } ctx->register_spacing = register_spacing; ctx->errnum = IPMI_KCS_ERR_SUCCESS; return (0); }
int ipmi_kcs_ctx_set_poll_interval (ipmi_kcs_ctx_t ctx, uint8_t poll_interval) { if (!ctx || ctx->magic != IPMI_KCS_CTX_MAGIC) { ERR_TRACE (ipmi_kcs_ctx_errormsg (ctx), ipmi_kcs_ctx_errnum (ctx)); return (-1); } ctx->poll_interval = poll_interval; ctx->errnum = IPMI_KCS_ERR_SUCCESS; return (0); }