[GRASS-SVN] r43612 -
grass/branches/releasebranch_6_4/vector/v.db.select
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Sep 22 09:49:52 EDT 2010
Author: neteler
Date: 2010-09-22 13:49:52 +0000 (Wed, 22 Sep 2010)
New Revision: 43612
Modified:
grass/branches/releasebranch_6_4/vector/v.db.select/main.c
Log:
backport: file output
Modified: grass/branches/releasebranch_6_4/vector/v.db.select/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.db.select/main.c 2010-09-22 13:49:17 UTC (rev 43611)
+++ grass/branches/releasebranch_6_4/vector/v.db.select/main.c 2010-09-22 13:49:52 UTC (rev 43612)
@@ -7,7 +7,7 @@
*
* PURPOSE: Print vector attributes
*
- * COPYRIGHT: (C) 2005-2007 by the GRASS Development Team
+ * COPYRIGHT: (C) 2005-2009 by the GRASS Development Team
*
* This program is free software under the
* GNU General Public License (>=v2).
@@ -15,22 +15,23 @@
* for details.
*
**************************************************************/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
+
#include <grass/glocale.h>
#include <grass/gis.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
-
int main(int argc, char **argv)
{
struct GModule *module;
struct Option *map_opt, *field_opt, *fs_opt, *vs_opt, *nv_opt, *col_opt,
- *where_opt;
+ *where_opt, *file_opt;
struct Flag *c_flag, *v_flag, *r_flag;
dbDriver *driver;
dbString sql, value_string;
@@ -76,6 +77,12 @@
nv_opt->description = _("Null value indicator");
nv_opt->guisection = _("Format");
+ file_opt = G_define_standard_option(G_OPT_F_OUTPUT);
+ file_opt->key = "file";
+ file_opt->required = NO;
+ file_opt->description =
+ _("Name for output file (if omitted or \"-\" output to stdout)");
+
r_flag = G_define_flag();
r_flag->key = 'r';
r_flag->description =
@@ -99,6 +106,12 @@
/* set input vector map name and mapset */
field = atoi(field_opt->answer);
+ if (file_opt->answer && strcmp(file_opt->answer, "-") != 0) {
+ if (NULL == freopen(file_opt->answer, "w", stdout)) {
+ G_fatal_error(_("Unable to open file <%s> for writing"), file_opt->answer);
+ }
+ }
+
if (r_flag->answer) {
min_box = (BOUND_BOX *) G_malloc(sizeof(BOUND_BOX));
G_zero((void *)min_box, sizeof(BOUND_BOX));
More information about the grass-commit
mailing list