GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
PhkArgv(3) FreeBSD Library Functions Manual PhkArgv(3)

PhkArgvParse, PhkArgvFree
parse argument string

#include <phk_argv.h>

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

void
PhkArgvFree(char **);

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, terminated 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 input string a comment.

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

#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);

libphk(3)

Written by Poul-Henning Kamp, now part of libphk.
September 9, 2006 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.