GRASS Programmer's Manual
6.5.svn(2014)-r66266
|
GIS Library - GRASS implementation of asprintf(). More...
#include <grass/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <assert.h>
#include <grass/gis.h>
Go to the source code of this file.
Macros | |
#define | _GNU_SOURCE /* enable asprintf */ |
Functions | |
int | G_vasprintf (char **out, const char *fmt, va_list ap) |
Safe replacement for asprintf(). More... | |
int | G_asprintf (char **out, const char *fmt,...) |
GIS Library - GRASS implementation of asprintf().
Eric G. Miller - Thu, 2 May 2002 17:51:54 -0700
I've got a sort of cheat for asprintf. We can't use vsnprintf for the same reason we can't use snprintf ;-) Comments welcome.
We cheat by printing to a tempfile via vfprintf() and then reading it back in. Probably not the most efficient way.
WARNING: Temporarily, the G_asprintf macro cannot be used. See explanation in gisdefs.h.
(C) 2001-2008 by the GRASS Development Team
This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.
Definition in file asprintf.c.
#define _GNU_SOURCE /* enable asprintf */ |
Definition at line 28 of file asprintf.c.
int G_asprintf | ( | char ** | out, |
const char * | fmt, | ||
... | |||
) |
Definition at line 116 of file asprintf.c.
References count, and G_vasprintf().
Referenced by db_read_dbmscap(), db_select_CatValArray(), db_select_int(), db_select_value(), GPJ__get_datum_params(), GPJ__get_ellipsoid_params(), GPJ_ask_datum_params(), GPJ_get_datum_transform_by_name(), GPJ_grass_to_osr(), GPJ_osr_to_grass(), GPJ_set_csv_loc(), and make_mapset().
int G_vasprintf | ( | char ** | out, |
const char * | fmt, | ||
va_list | ap | ||
) |
Safe replacement for asprintf().
Allocate a string large enough to hold the new output, including the terminating NULL, and returns a pointer to the first parameter. The pointer should be passed to G_free() to release the allocated storage when it is no longer needed.
[out] | out | |
[in] | fmt |
Definition at line 66 of file asprintf.c.
References count, fclose(), file_name, G_free(), and NULL.
Referenced by G_asprintf().