char * __helix_i64toa(INT64 val, char *str, int radix) { char IsNegative = 0; INT64 theNum = val; int StrIndex = 0; if (theNum < (INT64)0) { theNum = -theNum; IsNegative = 1; } do { int CurDigit = INT64_TO_INT32(theNum % radix); if (CurDigit > 9) str[StrIndex++] = (char)(CurDigit + 'A' - 10); else str[StrIndex++] = (char)(CurDigit + '0'); theNum /= radix; } while (theNum!=0); if (IsNegative) { str[StrIndex++] = '-'; } str[StrIndex++] = 0; // Now reverse the string. strrev(str); return str; }
/** * Retrieve an integer attribute from the given collection. * * @param coll The collection to retrieve the attribute from. * @param key The name of the attribute. * @param value The value of the attribute if found (owned by the collection). * @return 1 if the attribute was found, 0 otherwise */ int xmmsv_coll_attribute_get_int32 (xmmsv_t *coll, const char *key, int32_t *val) { int64_t raw_val; x_return_val_if_fail (xmmsv_is_type (coll, XMMSV_TYPE_COLL), 0); if (xmmsv_dict_entry_get_int (coll->value.coll->attributes, key, &raw_val)) { *val = INT64_TO_INT32 (raw_val); return true; } return false; }
/** * Retrieves the value at the given position in the idlist. * @param coll The collection to update. * @param index The position of the value to retrieve. * @param val The pointer at which to store the found value. * @return TRUE on success, false otherwise. */ int xmmsv_coll_idlist_get_index_int32 (xmmsv_t *coll, int index, int32_t *val) { int64_t raw_val; x_return_val_if_fail (coll, 0); if (xmmsv_list_get_int (coll->value.coll->idlist, index, &raw_val)) { *val = INT64_TO_INT32 (raw_val); return true; } return false; }