strvars man page on DragonFly

Man page or keyword search:  
man Server   44335 pages
apropos Keyword Search (all sections)
Output format
DragonFly logo
[printable version]

STRVARS(3)		     C Programmer's Manual		    STRVARS(3)

NAME
       strvars - expand variables in string

SYNOPSIS
       #include <publib.h>
       int strvars(char **res, const char *str, char *(*expand)(const char *));

DESCRIPTION
       strvars	will  replaces	references to variables in the string str with
       the values of the variables.  A reference to a variable is of the  form
       $(foo) or $x (where x is a single character, but not $).	 A dollar sign
       is expressed in the string as $$, and will be converted	to  $  in  the
       output.	 Memory	 for the expanded string is allocated dynamically, and
       *res is set to point to it.

       The values of the variables are fetched using the function expand.   It
       is  given  the  name of the variable as its argument, and must return a
       pointer to the value, or NULL if that variable doesn't exist.

RETURN VALUE
       strvars will return 0 if successful, or NULL if an error occured	 (mal‐
       formed input string, result too big, or unknown variable).

EXAMPLE
       To  replace  references to environment variables, one would the follow‐
       ing.

	    #include <publib.h>
	    #include <stdlib.h>

	    char line[1024];
	    char *res;

	    if (strvars(&res, line, getenv) == NULL)
		errormsg(1, 0, "strvars failed");
	    printf("res = <%s>\n", res);

SEE ALSO
       publib(3), getenv(3)

AUTHOR
       Lars Wirzenius (lars.wirzenius@helsinki.fi)

Publib			     C Programmer's Manual		    STRVARS(3)
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net