Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
PhkArgv(3)		 BSD Library Functions Manual		    PhkArgv(3)

NAME
     PhkArgvParse, PhkArgvFree -- parse	argument string

SYNOPSIS
     #include <phk_argv.h>

     char **
     PhkArgvParse(const	char *s, int comment);

     void
     PhkArgvFree(char **);

DESCRIPTION
     These functions can parse a string	into argv[] style arguments.

     PhkArgvParse Splits the string s into individual arguments	and returns an
     argv vector.

     The first element of the returned vector is non-NULL it contains an error
     message and the conversion	was a failure.

     Otherwise the remainder of	the vector contains the	parsed arguments, ter-
     minated by	a NULL element.

     The returned argv and the storage for the arguments are allocated with
     malloc(3) but should only be freed	with the PhkArgvFree function.

     If	the comment argument is	non-zero, any argument starting	with a '#'
     character will terminate the parsing, rendering the remainder of the in-
     put string	a comment.

     Arguments can be included in double quotes	'"' and	the usual backslash
     escapes are recognized and	converted.

EXAMPLES
	   #include "phk_argv.h"

	   [...]

	   char	**av;
	   char	*p;

	   [...]

	   av =	PhkArgvParse(p,	0);
	   if (av[0] !=	NULL)
		   err(1, "Parse error:	%s", av[0]);
	   for (i = 1; av[i] !=	NULL; i++)
		   printf("av[%d] = %s\n", i, av[i]);
	   PhkArgvFree(av);

SEE ALSO
     libphk(3)

HISTORY
     Written by	Poul-Henning Kamp, now part of libphk.

BSD			       September 9, 2006			   BSD

NAME | SYNOPSIS | DESCRIPTION | EXAMPLES | SEE ALSO | HISTORY

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=phk_argv&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports>

home | help