Skip to content

Latest commit

 

History

History
62 lines (39 loc) · 1.86 KB

README.md

File metadata and controls

62 lines (39 loc) · 1.86 KB

strtonargv(3)

NAME

strtonargv - convert a string to a list of arguments

SYNOPSIS

#include "strtonargv.h"

char strtonargv(char *dest[], char** *src, int *n);

char *CFS = " \t\n";

DESCRIPTION

strtonargv(3) function converts the string in src to an argument list.

If dest is not NULL, strtonargv(3) stores the argument list in dest[] up to *n elements and sets *n to the number of elements converted.

If dest is NULL, strtonargv(3) sets *n to the number of elements that would have been converted if dest were not NULL.

CFS is the Common-Field Separator character used to splits a string into elements.

RETURN VALUE

The strtonargv(3) function sets the argument n to the number of elements converted and returns the result of the conversion, unless the dest argument is NULL. If the argument dest is NULL, strtonargv(3) returns NULL. If the argument n is either NULL or negative, strtonargv(3) returns NULL and errno is set to EINVAL.

ERRORS

EINVAL The given n is either NULL or negative.

EXAMPLES

strtonargv.c is a good example of how to use the strtonargv(3) function in two calls; a first call to get the number of argument to convert; a second call to convert elements using a stack allocated array of strings.

AUTHOR

Written by Gaël PORTAY gael.portay@savoirfairelinux.com

COPYRIGHT

Copyright (C) 2018 Savoir-Faire Linux Inc. and Gaël PORTAY

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version.