dpkg 1.21.11
Data Structures | Functions
String handling
Collaboration diagram for String handling:

Data Structures

struct  str_crop_info
 

Functions

bool str_match_end (const char *str, const char *end)
 Match the end of a string. More...
 
unsigned int str_fnv_hash (const char *str)
 Fowler/Noll/Vo – FNV-1a simple string hash. More...
 
char * str_concat (char *dst,...) DPKG_ATTR_SENTINEL
 
char * str_fmt (const char *fmt,...) DPKG_ATTR_PRINTF(1)
 Print formatted output to an allocated string. More...
 
char * str_escape_fmt (char *dest, const char *src, size_t n)
 Escape format characters from a string. More...
 
char * str_quote_meta (const char *src)
 Quote shell metacharacters in a string. More...
 
char * str_strip_quotes (char *str)
 Check and strip possible surrounding quotes in string. More...
 
char * str_rtrim_spaces (const char *str, char *str_end)
 Trim possible ending spaces in string. More...
 
int str_width (const char *str)
 Compute the screen width of a string. More...
 
void str_gen_crop (const char *str, int max_width, struct str_crop_info *crop)
 Generate the crop values for a string given a maximum screen width. More...
 

Detailed Description

Function Documentation

◆ str_concat()

char * str_concat ( char *  dst,
  ... 
)

References args.

Referenced by pkgbin_name_archqual().

Here is the caller graph for this function:

◆ str_escape_fmt()

char * str_escape_fmt ( char *  dst,
const char *  src,
size_t  n 
)

Escape format characters from a string.

Parameters
dstThe destination string.
srcThe source string.
nThe size of the destination buffer.
Returns
The end of the destination string.

◆ str_fmt()

char * str_fmt ( const char *  fmt,
  ... 
)

Print formatted output to an allocated string.

Parameters
fmtThe format string.
...The format arguments.
Returns
The new allocated formatted output string (never NULL).

References args, and m_vasprintf().

Referenced by atomic_file_new(), do_raw_extract(), dpkg_db_get_path(), dpkg_fsys_get_path(), execbackend(), and path_make_temp_template().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_fnv_hash()

unsigned int str_fnv_hash ( const char *  str)

Fowler/Noll/Vo – FNV-1a simple string hash.

For more info,

See also
http://www.isthe.com/chongo/tech/comp/fnv/index.html.
Parameters
strThe string to hash.
Returns
The hashed value.

References FNV_MIXING_PRIME, and FNV_OFFSET_BASIS.

◆ str_gen_crop()

void str_gen_crop ( const char *  str,
int  max_width,
struct str_crop_info crop 
)

Generate the crop values for a string given a maximum screen width.

This function analyzes the string passed and computes the correct point where to crop the string, returning the amount of string and maximum bytes to use for padding for example.

On NLS enabled builds, in addition the string will be cropped on any newline.

Parameters
strThe string to crop.
max_widthThe max screen width to use.
[out]cropThe generated crop values for the string.

References _, str_crop_info::max_bytes, ohshit(), and str_crop_info::str_bytes.

Here is the call graph for this function:

◆ str_match_end()

bool str_match_end ( const char *  str,
const char *  end 
)

Match the end of a string.

Parameters
strThe string.
endThe end to match in str.
Returns
Whether the string was matched at the end.

Referenced by do_split().

Here is the caller graph for this function:

◆ str_quote_meta()

char * str_quote_meta ( const char *  src)

Quote shell metacharacters in a string.

This function allows passing strings to commands without splitting the arguments, like in system(3)

Parameters
srcThe source string to escape.
Returns
The new allocated string (never NULL).

References m_malloc().

Here is the call graph for this function:

◆ str_rtrim_spaces()

char * str_rtrim_spaces ( const char *  str,
char *  str_end 
)

Trim possible ending spaces in string.

Parameters
strThe string to act on.
str_endThe end of the string to act on.
Returns
A pointer to the end of the trimmed string.

◆ str_strip_quotes()

char * str_strip_quotes ( char *  str)

Check and strip possible surrounding quotes in string.

Parameters
strThe string to act on.
Returns
A pointer to str or NULL if the quotes were unbalanced.

◆ str_width()

int str_width ( const char *  str)

Compute the screen width of a string.

Parameters
strThe multibyte string.
Returns
The width of the string.

References _, m_malloc(), and ohshit().

Here is the call graph for this function: