/******************************************************************************* * * FUNCTION: acpi_ut_bound_string_length * * PARAMETERS: string - String with boundary * count - Boundary of the string * * RETURN: Length of the string. Less than or equal to Count. * * DESCRIPTION: Calculate the length of a string with boundary. *
******************************************************************************/
while (*string && count) {
length++;
string++;
count--;
}
return (length);
}
/******************************************************************************* * * FUNCTION: acpi_ut_bound_string_output * * PARAMETERS: string - String with boundary * end - Boundary of the string * c - Character to be output to the string * * RETURN: Updated position for next valid character * * DESCRIPTION: Output a character into a string with boundary check. *
******************************************************************************/
staticchar *acpi_ut_bound_string_output(char *string, constchar *end, char c)
{
if (string < end) {
*string = c;
}
++string; return (string);
}
/******************************************************************************* * * FUNCTION: acpi_ut_put_number * * PARAMETERS: string - Buffer to hold reverse-ordered string * number - Integer to be converted * base - Base of the integer * upper - Whether or not using upper cased digits * * RETURN: Updated position for next valid character * * DESCRIPTION: Convert an integer into a string, note that, the string holds a * reversed ordered number without the trailing zero. *
******************************************************************************/
/******************************************************************************* * * FUNCTION: acpi_ut_scan_number * * PARAMETERS: string - String buffer * number_ptr - Where the number is returned * * RETURN: Updated position for next valid character * * DESCRIPTION: Scan a string for a decimal integer. *
******************************************************************************/
constchar *acpi_ut_scan_number(constchar *string, u64 *number_ptr)
{
u64 number = 0;
while (isdigit((int)*string)) {
acpi_ut_short_multiply(number, 10, &number);
number += *(string++) - '0';
}
*number_ptr = number; return (string);
}
/******************************************************************************* * * FUNCTION: acpi_ut_print_number * * PARAMETERS: string - String buffer * number - The number to be converted * * RETURN: Updated position for next valid character * * DESCRIPTION: Print a decimal integer into a string. *
******************************************************************************/
while (pos1 != ascii_string) {
*(pos2++) = *(--pos1);
}
*pos2 = 0; return (string);
}
/******************************************************************************* * * FUNCTION: acpi_ut_format_number * * PARAMETERS: string - String buffer with boundary * end - Boundary of the string * number - The number to be converted * base - Base of the integer * width - Field width * precision - Precision of the integer * type - Special printing flags * * RETURN: Updated position for next valid character * * DESCRIPTION: Print an integer into a string with any base and any precision. *
******************************************************************************/
pos = acpi_ut_put_number(reversed_string, number, base, upper);
i = (s32)ACPI_PTR_DIFF(pos, reversed_string);
/* Printing 100 using %2d gives "100", not "00" */
if (i > precision) {
precision = i;
}
width -= precision;
/* Output the string */
if (!(type & (ACPI_FORMAT_ZERO | ACPI_FORMAT_LEFT))) { while (--width >= 0) {
string = acpi_ut_bound_string_output(string, end, ' ');
}
} if (sign) {
string = acpi_ut_bound_string_output(string, end, sign);
} if (need_prefix) {
string = acpi_ut_bound_string_output(string, end, '0'); if (base == 16) {
string =
acpi_ut_bound_string_output(string, end,
upper ? 'X' : 'x');
}
} if (!(type & ACPI_FORMAT_LEFT)) { while (--width >= 0) {
string = acpi_ut_bound_string_output(string, end, zero);
}
}
while (i <= --precision) {
string = acpi_ut_bound_string_output(string, end, '0');
} while (--i >= 0) {
string = acpi_ut_bound_string_output(string, end,
reversed_string[i]);
} while (--width >= 0) {
string = acpi_ut_bound_string_output(string, end, ' ');
}
return (string);
}
/******************************************************************************* * * FUNCTION: vsnprintf * * PARAMETERS: string - String with boundary * size - Boundary of the string * format - Standard printf format * args - Argument list * * RETURN: Number of bytes actually written. * * DESCRIPTION: Formatted output to a string using argument list pointer. *
******************************************************************************/
/******************************************************************************* * * FUNCTION: snprintf * * PARAMETERS: string - String with boundary * size - Boundary of the string * Format, ... - Standard printf format * * RETURN: Number of bytes actually written. * * DESCRIPTION: Formatted output to a string. *
******************************************************************************/
int snprintf(char *string, acpi_size size, constchar *format, ...)
{
va_list args; int length;
va_start(args, format);
length = vsnprintf(string, size, format, args);
va_end(args);
return (length);
}
/******************************************************************************* * * FUNCTION: sprintf * * PARAMETERS: string - String with boundary * Format, ... - Standard printf format * * RETURN: Number of bytes actually written. * * DESCRIPTION: Formatted output to a string. *
******************************************************************************/
int sprintf(char *string, constchar *format, ...)
{
va_list args; int length;
va_start(args, format);
length = vsnprintf(string, ACPI_UINT32_MAX, format, args);
va_end(args);
return (length);
}
#ifdef ACPI_APPLICATION /******************************************************************************* * * FUNCTION: vprintf * * PARAMETERS: format - Standard printf format * args - Argument list * * RETURN: Number of bytes actually written. * * DESCRIPTION: Formatted output to stdout using argument list pointer. *
******************************************************************************/
int vprintf(constchar *format, va_list args)
{
acpi_cpu_flags flags; int length;
flags = acpi_os_acquire_lock(acpi_gbl_print_lock);
length = vsnprintf(acpi_gbl_print_buffer, sizeof(acpi_gbl_print_buffer), format, args);
/******************************************************************************* * * FUNCTION: vfprintf * * PARAMETERS: file - File descriptor * format - Standard printf format * args - Argument list * * RETURN: Number of bytes actually written. * * DESCRIPTION: Formatted output to a file using argument list pointer. *
******************************************************************************/
int vfprintf(FILE * file, constchar *format, va_list args)
{
acpi_cpu_flags flags; int length;
flags = acpi_os_acquire_lock(acpi_gbl_print_lock);
length = vsnprintf(acpi_gbl_print_buffer, sizeof(acpi_gbl_print_buffer), format, args);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.