bool ParseBoundingBox(Core::Buffer& buffer, Math::BoundingBox& value) { Parser* parser = GetDefaultParser(); CHECK_START(buffer); Math::vec3 p[8]; for (int i = 0; i < 8; ++i) parser->Parse(WORD_VEC3F, buffer, &p[i]); CHECK_END(buffer); return true; }
void display_vars( struct snmp_pdu *response) { #ifdef DEBUG int c = 0; struct variable_list *vars; fprintf(stderr, "********************************************************\n"); for(vars = response->variables; vars; vars = vars->next_variable) { c++; fprintf(stderr, "**** oid count %d ******\n", c); if (CHECK_END(vars->type)) { fprint_variable(stderr, vars->name, vars->name_length, vars); /* print_variable(vars->name, vars->name_length, vars); */ } else dbg("display_vars(): No idea."); } fprintf(stderr, "********************************************************\n"); #endif }
static int getc (comp_t* com, int noesc) { qse_char_t c; if (com->ptr >= com->end) { com->c.value = QSE_CHAR_EOF; com->c.escaped = 0; return 0; } com->c.value = *com->ptr++; com->c.escaped = 0; if (noesc || com->c.value != QSE_T('\\')) return 0; CHECK_END (com); c = *com->ptr++; if (c == QSE_T('n')) c = QSE_T('\n'); else if (c == QSE_T('r')) c = QSE_T('\r'); else if (c == QSE_T('t')) c = QSE_T('\t'); else if (c == QSE_T('f')) c = QSE_T('\f'); else if (c == QSE_T('b')) c = QSE_T('\b'); else if (c == QSE_T('v')) c = QSE_T('\v'); else if (c == QSE_T('a')) c = QSE_T('\a'); #if 0 /* backrefernce conflicts with octal notation */ else if (c >= QSE_T('0') && c <= QSE_T('7')) { qse_char_t cx; c = c - QSE_T('0'); CHECK_END (com); cx = *com->ptr++; if (cx >= QSE_T('0') && cx <= QSE_T('7')) { c = c * 8 + cx - QSE_T('0'); CHECK_END (com); cx = *com->ptr++; if (cx >= QSE_T('0') && cx <= QSE_T('7')) { c = c * 8 + cx - QSE_T('0'); } } } #endif else if (c == QSE_T('x')) { qse_char_t cx; CHECK_END (com); cx = *com->ptr++; if (IS_HEX(cx)) { c = HEX_TO_NUM(cx); CHECK_END (com); cx = *com->ptr++; if (IS_HEX(cx)) { c = c * 16 + HEX_TO_NUM(cx); } } } #if defined(QSE_CHAR_IS_WCHAR) else if (c == QSE_T('u') && QSE_SIZEOF(qse_char_t) >= 2) { qse_char_t cx; CHECK_END (com); cx = *com->ptr++; if (IS_HEX(cx)) { qse_size_t i; c = HEX_TO_NUM(cx); for (i = 0; i < 3; i++) { CHECK_END (com); cx = *com->ptr++; if (!IS_HEX(cx)) break; c = c * 16 + HEX_TO_NUM(cx); } } } else if (c == QSE_T('U') && QSE_SIZEOF(qse_char_t) >= 4) { qse_char_t cx; CHECK_END (com); cx = *com->ptr++; if (IS_HEX(cx)) { qse_size_t i; c = HEX_TO_NUM(cx); for (i = 0; i < 7; i++) { CHECK_END (com); cx = *com->ptr++; if (!IS_HEX(cx)) break; c = c * 16 + HEX_TO_NUM(cx); } } } #endif com->c.value = c; com->c.escaped = QSE_TRUE; #if 0 com->c = (com->ptr < com->end)? *com->ptr++: QSE_CHAR_EOF; if (com->c == QSE_CHAR_EOF) qse_printf (QSE_T("getc => <EOF>\n")); else qse_printf (QSE_T("getc => %c\n"), com->c); #endif return 0; }
/** * snmp_get * @ss: a handle to the snmp session needed to make an * snmp transaction. * @objid: string containing the OID entry. * @value: the value received from snmp will be put in this union. * * Gets a single value indicated by the objectid using snmp. * In the case of multiple values being returned, the type in @value will be * ASN_NULL (0x05). Nothing else in @value will be filled in. * * Returns: 0 if successful, <0 if there was an error. **/ SaErrorT snmp_get(struct snmp_session *ss, const char *objid, struct snmp_value *value) { struct snmp_pdu *pdu; struct snmp_pdu *response; oid anOID[MAX_OID_LEN]; size_t anOID_len = MAX_OID_LEN; struct variable_list *vars; SaErrorT returncode = SA_OK; int status; /* * Create the PDU for the data for our request. */ pdu = snmp_pdu_create(SNMP_MSG_GET); read_objid(objid, anOID, &anOID_len); snmp_add_null_var(pdu, anOID, anOID_len); /* * Send the Request out. */ status = snmp_synch_response(ss, pdu, &response); /* * Process the response. */ if (status == STAT_SUCCESS) { if(response->errstat == SNMP_ERR_NOERROR) { vars = response->variables; value->type = vars->type; if (vars->next_variable != NULL) { /* There are more values, set return type to null. */ value->type = ASN_NULL; } else if ( !(CHECK_END(vars->type)) ) { /* This is one of the exception condition */ returncode = SA_ERR_HPI_NOT_PRESENT; dbg("snmp exception %d \n",vars->type); } else if ( (vars->type == ASN_INTEGER) || (vars->type == ASN_COUNTER) || (vars->type == ASN_UNSIGNED) ) { value->integer = *(vars->val.integer); } else { value->str_len = vars->val_len; if (value->str_len >= MAX_ASN_STR_LEN) value->str_len = MAX_ASN_STR_LEN; else value->string[value->str_len] = '\0'; memcpy(value->string, vars->val.string, value->str_len); } } else { dbg("Error in packet %s\nReason: %s\n", objid, snmp_errstring(response->errstat)); returncode = errstat2hpi(response->errstat); } } else { value->type = (u_char)0x00; snmp_sess_perror("snmpget", ss); returncode = snmpstat2hpi(status); } /* Clean up: free the response */ if (response) snmp_free_pdu(response); return (returncode); }
/** * snmp_set2: Gets a single value indicated by the objectid * using snmp. * @handle: a handle to the snmp session needed to make an * snmp transaction. * @objid: string containing the OID entry. * @value: the value received from snmp will be put in this union. * * In the case of multiple values being returned, the type in 'value' will be * ASN_NULL (0x05). Nothing else in 'value' will be filled in. * Use snmp_get_all for doing gets that return multiple values. * * Return value: Returns 0 if successful, -1 if there was an error. **/ SaErrorT snmp_set2(struct snmp_session *ss, oid *objid, size_t objid_len, struct snmp_value *value) { struct snmp_pdu *pdu; struct snmp_pdu *response; struct variable_list *vars; void *dataptr = NULL; int status = 0; SaErrorT rtncode = SA_OK; /* Default - All is OK */ /* * Create the PDU for the data for our request. */ pdu = snmp_pdu_create(SNMP_MSG_SET); switch (value->type) { case ASN_INTEGER: case ASN_UNSIGNED: case ASN_COUNTER: dataptr = &value->integer; break; case ASN_OCTET_STR: dataptr = value->string; break; default: rtncode = SA_ERR_HPI_INVALID_PARAMS; dbg("datatype %c not yet supported by snmp_set2()", value->type); break; } if (rtncode == SA_OK) { /* * Set the data to send out */ /* Old code - snmp_add_var(pdu, objid, objid_len, datatype, dataptr); */ //int retcode = snmp_add_var(pdu, objid, objid_len, datatype, dataptr); snmp_pdu_add_variable(pdu, objid, objid_len, value->type, dataptr, value->str_len); /* * Send the Request out. */ status = snmp_synch_response(ss, pdu, &response); /* * Process the response. */ if (status == STAT_SUCCESS) { vars = response->variables; if (response->errstat == SNMP_ERR_NOERROR) { /* display data */ #ifdef DEBUG fprintf(stderr, "*** snmp_set2 ******************************************\n"); if (CHECK_END(response->variables->type)) { fprint_variable(stderr, response->variables->name, response->variables->name_length, response->variables); } else fprintf(stderr, "snmp_set2(): No idea.\n"); fprintf(stderr, "********************************************************\n"); #endif if (!(CHECK_END(response->variables->type)) ) { /* This is one of the exception condition */ rtncode = SA_ERR_HPI_NOT_PRESENT; dbg("snmp exception %d \n",vars->type); } } else { dbg("snmp_set2: Error in packet, Reason: %s", snmp_errstring(response->errstat)); rtncode = errstat2hpi(response->errstat); } } else { snmp_sess_perror("snmpset", ss); rtncode = snmpstat2hpi(status); } /* Clean up: free the response */ if (response) snmp_free_pdu(response); } return rtncode; }
/** * snmp_get2: Gets a single value indicated by the objectid * using snmp. * @handle: a handle to the snmp session needed to make an * snmp transaction. * @objid: string containing the OID entry. * @value: the value received from snmp will be put in this union. * * In the case of multiple values being returned, the type in 'value' will be * ASN_NULL (0x05). Nothing else in 'value' will be filled in. * Use snmp_get_all for doing gets that return multiple values. * * Return value: Returns 0 if successful, <0 if there was an error. **/ SaErrorT snmp_get2(struct snmp_session *ss, oid *objid, size_t objid_len, struct snmp_value *value) { struct snmp_pdu *pdu; struct snmp_pdu *response; struct variable_list *vars; SaErrorT returncode = SA_OK; int i; int status; /* * Create the PDU for the data for our request. */ pdu = snmp_pdu_create(SNMP_MSG_GET); snmp_add_null_var(pdu, objid, objid_len); /* * Send the Request out. */ status = snmp_synch_response(ss, pdu, &response); /* * Process the response. */ if (status == STAT_SUCCESS) { if (response->errstat == SNMP_ERR_NOERROR) { vars = response->variables; value->type = vars->type; if (vars->next_variable != NULL) { /* If there are more values, set return type to null. */ value->type = ASN_NULL; } else if ( !(CHECK_END(vars->type)) ) { /* This is one of the exception condition */ returncode = SA_ERR_HPI_NOT_PRESENT; dbg("snmp exception %d \n",vars->type); } else if ( (vars->type == ASN_INTEGER) || (vars->type == ASN_COUNTER) || (vars->type == ASN_UNSIGNED) ) { value->integer = *(vars->val.integer); } else { value->str_len = vars->val_len; if (value->str_len >= MAX_ASN_STR_LEN) value->str_len = MAX_ASN_STR_LEN; else value->string[value->str_len] = '\0'; memcpy(value->string, vars->val.string, value->str_len); } /* display data */ #ifdef DEBUG if (CHECK_END(vars->type)) { fprintf(stderr, "*** snmp_get2 ******************************************\n"); fprint_variable(stderr, vars->name, vars->name_length, vars); fprintf(stderr, "********************************************************\n"); } else { dbg("snmp_get2(): No idea.Unknown Type: %X", vars->type); fprint_variable(stderr, vars->name, vars->name_length, vars); } #endif } else { dbg("Error, Reason: %s", snmp_errstring(response->errstat)); fprintf(stderr, "objid: "); for(i = 0; i<objid_len; i++ ) fprintf(stderr, "%d.", (int)objid[i]); fprintf(stderr, "\n"); returncode = errstat2hpi(response->errstat); } } else { snmp_sess_perror("snmpget", ss); returncode = snmpstat2hpi(status); } /* Clean up: free the response */ sc_free_pdu(&response); return (returncode); }