GRU - Generic Reusable Utilities
Loading...
Searching...
No Matches
gru_alt.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#ifndef GRU_ALT_H
17#define GRU_ALT_H
18
19#include <string.h>
20
21#include "common/gru_base.h"
22#include "common/gru_portable.h"
23
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#ifndef HAVE_STRLCPY
34
43 const char *gru_restrict src,
44 size_t size);
45
53gru_export size_t strlcat(char *gru_restrict dst,
54 const char *gru_restrict src,
55 size_t size);
56
57#endif // HAVE_STRLCPY
58
59#ifndef HAVE_STRNDUP
60
66gru_export char *strndup(const char *source, size_t limit);
67#endif // HAVE_STRNDUP
68
69#ifdef __cplusplus
70}
71#endif
72
73#endif /* GRU_ALT_H */
gru_export size_t strlcat(char *gru_restrict dst, const char *gru_restrict src, size_t size)
Poor man's implementation of strlcat.
Definition: gru_alt.c:37
gru_export char * strndup(const char *source, size_t limit)
Poor man's implementation of strndup (duplicate a string)
Definition: gru_alt.c:54
gru_export size_t strlcpy(char *gru_restrict dst, const char *gru_restrict src, size_t size)
Very simple alternatives to some safer string variables.
#define gru_restrict
Definition: gru_portable.h:20
#define gru_export
Definition: gru_portable.h:19