eccLib 1.1.0
Python library for bioinformatics written in C
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1
6#ifndef COMMON_H
7#define COMMON_H
8
9#include <stdbool.h>
10#include <stdint.h>
11#include <stdlib.h>
12
13#include <Python.h>
14
30typedef struct {
35 const char *token;
40 size_t len;
42
59int strtok_ri(const char *restrict str, char delim, Py_ssize_t *restrict strLen,
60 occurrence_t *restrict lastoccurrence);
61
70void percent_encode_char(char *restrict out, char c);
71
80uint32_t strncount(const char *restrict str, char c, size_t len);
81
89#define UNUSED(x) (void)(x)
90
91#define STR_HELPER(x) #x
97#define STR(x) STR_HELPER(x)
98
109void *memchr2(const void *buf, int c1, int c2, size_t len);
110
111#endif
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.
Definition common.c:17
uint32_t strncount(const char *restrict str, char c, size_t len)
Counts the number of occurrences of c in str.
Definition common.c:48
void percent_encode_char(char *restrict out, char c)
Writes a percent encoded character to a buffer.
Definition common.c:42
void * memchr2(const void *buf, int c1, int c2, size_t len)
Finds the first occurrence of either c1 or c2 in buf.
Definition common.c:59
An occurrence of a token in a string.
Definition common.h:30
size_t len
The length of the token.
Definition common.h:40
const char * token
The token that was found.
Definition common.h:35