GRU - Generic Reusable Utilities
gru_util.h
Go to the documentation of this file.
1 /*
2  Copyright 2016 Otavio Rodolfo Piske
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15  */
16 
17 #ifndef GRU_UTIL_H
18 #define GRU_UTIL_H
19 
20 #include <assert.h>
21 #include <ctype.h>
22 #include <stdbool.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 
27 #include "collection/gru_list.h"
28 #include "common/gru_portable.h"
29 #include "string/gru_alt.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
41 gru_export char *gru_rtrim(char *input, size_t size);
42 
49 gru_export char *gru_ltrim(char *input, size_t size);
50 
57 gru_export char *gru_trim(char *input, size_t size);
58 
64 gru_export const char *gru_get_name_from_url(const char *url, size_t size);
65 
74 gru_export gru_list_t *gru_split(const char *str, char sep, gru_status_t *status);
75 
82 
90 gru_export char *gru_str_serialize(gru_list_t *list, char sep, gru_status_t *status);
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif // GRU_UTIL_H
#define gru_export
Definition: gru_portable.h:19
gru_export char * gru_str_serialize(gru_list_t *list, char sep, gru_status_t *status)
Serializes a string list.
Definition: gru_util.c:103
gru_export gru_list_t * gru_split(const char *str, char sep, gru_status_t *status)
Split a string.
Definition: gru_util.c:78
gru_export 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.
Definition: gru_util.c:66
gru_export char * gru_ltrim(char *input, size_t size)
Removes spaces from the left side of a string.
Definition: gru_util.c:41
gru_export char * gru_trim(char *input, size_t size)
Removes spaces from all sides of a string.
Definition: gru_util.c:57
gru_export char * gru_rtrim(char *input, size_t size)
Removes spaces from the right side of a string.
Definition: gru_util.c:22
gru_export 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...
Definition: gru_util.c:99
Definition: gru_list.h:41
Status type.
Definition: gru_status.h:47