ftwin 0.8.10
|
Implementation of human-readable size parsing and formatting. More...
#include "human_size.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <apr_strings.h>
Go to the source code of this file.
Functions | |
const char * | format_human_size (apr_off_t size, apr_pool_t *pool) |
Formats a size in bytes into a human-readable string. | |
apr_off_t | parse_human_size (const char *size_str) |
Parses a human-readable size string (e.g., "10M", "2.5G") into bytes. | |
Implementation of human-readable size parsing and formatting.
Definition in file human_size.c.
const char * format_human_size | ( | apr_off_t | size, |
apr_pool_t * | pool | ||
) |
Formats a size in bytes into a human-readable string.
The function selects the most appropriate unit (B, KB, MB, GB, TB) to produce a concise representation.
[in] | size | The size in bytes. |
[in] | pool | The APR pool to allocate the resulting string from. |
Definition at line 13 of file human_size.c.
apr_off_t parse_human_size | ( | const char * | size_str | ) |
Parses a human-readable size string (e.g., "10M", "2.5G") into bytes.
Supports suffixes: B (bytes), K (kilobytes), M (megabytes), G (gigabytes), T (terabytes). If no suffix is provided, the value is treated as bytes.
[in] | size_str | The string to parse. |
Definition at line 32 of file human_size.c.