-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib/string/strtok/: xastrsep2ls(): Add function
Signed-off-by: Alejandro Colomar <[email protected]>
- Loading branch information
1 parent
c3f46d4
commit fcc1d8e
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <[email protected]> | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
|
||
#include <config.h> | ||
|
||
#include "string/strtok/xastrsep2ls.h" | ||
|
||
#include <stddef.h> | ||
|
||
|
||
extern inline char **xastrsep2ls(char *restrict s, const char *restrict delim, | ||
size_t *restrict np); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <[email protected]> | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
|
||
#ifndef SHADOW_INCLUDE_LIB_STRING_STRTOK_XASTRSEP2LS_H_ | ||
#define SHADOW_INCLUDE_LIB_STRING_STRTOK_XASTRSEP2LS_H_ | ||
|
||
|
||
#include <config.h> | ||
|
||
#include <errno.h> | ||
#include <stddef.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include "attr.h" | ||
#include "shadowlog.h" | ||
#include "string/strtok/astrsep2ls.h" | ||
|
||
|
||
ATTR_ACCESS(read_write, 1) ATTR_ACCESS(write_only, 3) | ||
ATTR_STRING(1) ATTR_STRING(2) | ||
inline char **xastrsep2ls(char *restrict s, const char *restrict delim, | ||
size_t *restrict np); | ||
|
||
|
||
inline char **xastrsep2ls(char *s, const char *restrict delim, | ||
size_t *restrict np) | ||
{ | ||
char **ls; | ||
|
||
ls = astrsep2ls(s, delim, np); | ||
if (ls == NULL) | ||
goto x; | ||
|
||
return ls; | ||
x: | ||
fprintf(log_get_logfd(), "%s: %s\n", | ||
log_get_progname(), strerror(errno)); | ||
exit(13); | ||
} | ||
|
||
|
||
#endif // include guard |