#include "stringop.h"
#include <string.h>
#include <ctype.h>
Functions | |
char * | vl_string_parse_protocol (char const *str, int *prot) |
Parse string prefix for file protocol. | |
char const * | vl_string_protocol_name (int prot) |
Get protocol name. | |
int | vl_string_basename (char *dst, int n, char const *src, int n_ext) |
Extract base of file name. | |
int | vl_string_replace_wildcard (char *dst, int n, char const *src, char wild, char esc, char const *repl) |
Replace wildcard by string. | |
int | vl_string_copy (char *dst, int n, char const *src) |
Copy string. | |
int | vl_string_copy_sub (char *dst, int n, char const *beg, char const *end) |
Copy substring. | |
char * | vl_string_find_char_rev (char const *beg, char const *end, char c) |
Search character in reversed order. | |
int | vl_string_length (char const *str) |
Calculate string length. | |
int | vl_string_casei_cmp (const char *s1, const char *s2) |
Compare strings case-insensitive. |
int vl_string_basename | ( | char * | dst, | |
int | n, | |||
char const * | src, | |||
int | n_ext | |||
) |
dst | destination buffer. | |
n | size of destination buffer. | |
src | string to process. | |
n_ext | maximum number of extensions to strip. |
n_ext
trailing extensions from the string src and writes the result to the buffer dst of length n.
The leading path is the suffix that ends with the last occurence of the `\'
or `/'
characters. A trailing extension is the shortest suffix starting with the `.'
character.
int vl_string_casei_cmp | ( | const char * | s1, | |
const char * | s2 | |||
) |
s1 | fisrt string. | |
s2 | second string. |
int vl_string_copy | ( | char * | dst, | |
int | n, | |||
char const * | src | |||
) |
dst | output buffer. | |
n | size of output buffer. | |
src | string to copy. |
int vl_string_copy_sub | ( | char * | dst, | |
int | n, | |||
char const * | beg, | |||
char const * | end | |||
) |
dst | output buffer. | |
n | size of output buffer. | |
beg | start of the source string. | |
end | end of the source string. |
NUL
is found or end is reached (the character pointed by end is not included).
char* vl_string_find_char_rev | ( | char const * | beg, | |
char const * | end, | |||
char | c | |||
) |
beg | substring beginning. | |
end | substring ending. | |
c | character to search for. |
int vl_string_length | ( | char const * | str | ) |
str | string. |
char* vl_string_parse_protocol | ( | char const * | str, | |
int * | prot | |||
) |
str | string. | |
prot | protocol code (output). |
`:'
character (if any). It then matches the suffix to the supported protocols. The corresponding protocol code is wrote to prot.
char const* vl_string_protocol_name | ( | int | prot | ) |
prot | protocol id. |
int vl_string_replace_wildcard | ( | char * | dst, | |
int | n, | |||
char const * | src, | |||
char | wild, | |||
char | esc, | |||
char const * | repl | |||
) |
dst | output buffer. | |
n | size of output buffer. | |
src | input string. | |
wild | widcard character. | |
esc | escape character. | |
repl | replacement string. |
Wildcard characters may be escaped by preceeding them by the esc character. More in general, anything following an occurence of esc character is copied verbatim. To disable the escape characters simply set esc to 0.