void getBootVolumeDescription( BVRef bvr, char * str, long strMaxLen, BOOL verbose ) { unsigned char type = (unsigned char) bvr->part_type; const char * name = getNameForValue( fdiskTypes, type ); char *p; if (name == NULL) name = bvr->type_name; p = str; if ( name && verbose ) { sprintf( str, "hd(%d,%d) ", BIOS_DEV_UNIT(bvr), bvr->part_no); for (; strMaxLen > 0 && *p != '\0'; p++, strMaxLen--); } else { *p = '\0'; } bvr->description(bvr, p, strMaxLen); if (*p == '\0') { const char * name = getNameForValue( fdiskTypes, type ); if (name == NULL) { name = bvr->type_name; } if (name == NULL) { sprintf(p, "TYPE %02x", type); } else { strncpy(p, name, strMaxLen); } } }
static void getVolumeDescription( BVRef bvr, char * str, long strMaxLen ) { unsigned char type = (unsigned char) bvr->part_type; const char * name = NULL; /* First try a few types that we can figure out the * volume description. */ switch(type) { case FDISK_FAT32: str[0] = '\0'; MSDOSGetDescription(bvr, str, strMaxLen); if (str[0] != '\0') return; break; default: // Not one of our known types break; } if (name == NULL) name = getNameForValue( fdiskTypes, type ); if (name == NULL) name = bvr->type_name; if ( name ) strncpy( str, name, strMaxLen); else sprintf( str, "TYPE %02x", type); }
static const char * bios_error(int errnum) { static char errorstr[] = "Error 0x00"; const char * errname; errname = getNameForValue( bios_errors, errnum ); if ( errname ) return errname; sprintf(errorstr, "Error 0x%02x", errnum); return errorstr; // No string, print error code only }
Field DataTypeEnum<Type>::castToName(const Field & value_or_name) const { if (value_or_name.getType() == Field::Types::String) { getValue(value_or_name.get<String>()); /// Check correctness return value_or_name.get<String>(); } else if (value_or_name.getType() == Field::Types::Int64) { Int64 value = value_or_name.get<Int64>(); checkOverflow<Type>(value); return getNameForValue(static_cast<Type>(value)).toString(); } else throw Exception(String("DataTypeEnum: Unsupported type of field ") + value_or_name.getTypeName(), ErrorCodes::BAD_TYPE_OF_FIELD); }
void DataTypeEnum<Type>::serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const { writeCSVString(getNameForValue(static_cast<const ColumnType &>(column).getData()[row_num]), ostr); }