GRU - Generic Reusable Utilities
Loading...
Searching...
No Matches
Functions
gru_util.c File Reference
#include <stdint.h>
#include "collection/gru_list.h"
#include "common/gru_alloc.h"
#include "gru_util.h"

Functions

char * gru_rtrim (char *input, size_t size)
 Removes spaces from the right side of a string. More...
 
char * gru_ltrim (char *input, size_t size)
 Removes spaces from the left side of a string. More...
 
char * gru_trim (char *input, size_t size)
 Removes spaces from all sides of a string. More...
 
const char * gru_get_name_from_url (const char *url, size_t size)
 Given an URL, this function will return the file name for the download. More...
 
gru_list_tgru_split (const char *str, char sep, gru_status_t *status)
 Split a string. More...
 
void gru_split_clean (gru_list_t *list)
 Cleans a string list returned by gru_split and free's the memory used by the strings created for each sub-part. More...
 
char * gru_str_serialize (gru_list_t *list, char sep, gru_status_t *status)
 Serializes a string list. More...
 

Function Documentation

◆ gru_get_name_from_url()

const char * gru_get_name_from_url ( const char *  url,
size_t  size 
)

Given an URL, this function will return the file name for the download.

Parameters
urlThe url
Returns
the file name

◆ gru_ltrim()

char * gru_ltrim ( char *  input,
size_t  size 
)

Removes spaces from the left side of a string.

Parameters
inputInput string
sizeSize of the string
Returns
A pointer to the new string (which is the same address as input)

◆ gru_rtrim()

char * gru_rtrim ( char *  input,
size_t  size 
)

Removes spaces from the right side of a string.

Parameters
inputInput string
sizeSize of the string
Returns
A pointer to the new string (which is the same address as input)

◆ gru_split()

gru_list_t * gru_split ( const char *  str,
char  sep,
gru_status_t status 
)

Split a string.

Parameters
strthe string to split
setseparator
statusstatus object
Returns
a gru_list_t object where each element is a subpart of the original string separated by d
Examples
string/gru_split_test.c, and string/gru_split_test_2.c.

◆ gru_split_clean()

void gru_split_clean ( gru_list_t list)

Cleans a string list returned by gru_split and free's the memory used by the strings created for each sub-part.

Parameters
listthe list to clean
Examples
string/gru_split_test.c, and string/gru_split_test_2.c.

◆ gru_str_serialize()

char * gru_str_serialize ( gru_list_t list,
char  sep,
gru_status_t status 
)

Serializes a string list.

Parameters
list
sep
status
Returns
Examples
string/gru_serialize_test.c.

◆ gru_trim()

char * gru_trim ( char *  input,
size_t  size 
)

Removes spaces from all sides of a string.

Parameters
inputInput string
sizeSize of the string
Returns
A pointer to the new string (which is the same address as input)