eccLib 1.1.0
Python library for bioinformatics written in C
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
Common

Commonly used functions. More...

Data Structures

struct  occurrence_t
 An occurrence of a token in a string. More...
 

Macros

#define UNUSED(x)   (void)(x)
 Supresses unused variable warnings.
 
#define STR(x)   STR_HELPER(x)
 Converts a macro to a string.
 

Functions

int strtok_ri (const char *restrict str, char delim, Py_ssize_t *restrict strLen, occurrence_t *restrict lastoccurrence)
 Version of strtok_r that doesn't modify the original string.
 
void percent_encode_char (char *restrict out, char c)
 Writes a percent encoded character to a buffer.
 
uint32_t strncount (const char *restrict str, char c, size_t len)
 Counts the number of occurrences of c in str.
 
void * memchr2 (const void *buf, int c1, int c2, size_t len)
 Finds the first occurrence of either c1 or c2 in buf.
 

Detailed Description

Commonly used functions.

Mainly contains functions for string manipulation (very much a core of the library). Also here is where percent encoding handling lives

Macro Definition Documentation

◆ STR

#define STR (   x)    STR_HELPER(x)

Converts a macro to a string.

Parameters
xthe macro to convert

◆ UNUSED

#define UNUSED (   x)    (void)(x)

Supresses unused variable warnings.

Parameters
xthe variable to suppress the warning for

In C++11 you can just not provide a name for the parameter to suppress the warning, but in C you have to use this macro

Function Documentation

◆ memchr2()

void * memchr2 ( const void *  buf,
int  c1,
int  c2,
size_t  len 
)

Finds the first occurrence of either c1 or c2 in buf.

Parameters
bufthe buffer to search in
c1the first character to search for
c2the second character to search for
lenthe length of the buffer to search in
Returns
a pointer to the first occurrence of either c1 or c2 in buf, or NULL if not found
Here is the caller graph for this function:

◆ percent_encode_char()

void percent_encode_char ( char *restrict  out,
char  c 
)

Writes a percent encoded character to a buffer.

Creates a percent encoded character in the form xx and writes it to out

Parameters
outthe buffer to write to
cthe character to encode
Here is the caller graph for this function:

◆ strncount()

uint32_t strncount ( const char *restrict  str,
char  c,
size_t  len 
)

Counts the number of occurrences of c in str.

Parameters
strthe string to search in
cthe character to search for
lenthe length of the string to search in
Returns
the number of occurrences of c in str
Here is the caller graph for this function:

◆ strtok_ri()

int strtok_ri ( const char *restrict  str,
char  delim,
Py_ssize_t *restrict  strLen,
occurrence_t *restrict  lastoccurrence 
)

Version of strtok_r that doesn't modify the original string.

A reentrant inplace string tokenizer. A custom type is used to store the last occurrence of the token. Both strLen and lastoccurrence are modified by this function

Parameters
strthe string to tokenize, may be NULL in which case the last occurrence is used
delimthe delimiter to use
strLenthe length of the string to tokenize, will be decremented by the length of the token found. So it will reflect the remaining length of the string after the token
lastoccurrencea struct that holds the last occurrence of the token. Cannot be NULL
Returns
-1 on error, 0 on break, 1 on success
Here is the caller graph for this function: