BRL-CAD
set_uplotOutputMode.c
Go to the documentation of this file.
1 /* S E T _ U P L O T O U T P U T M O D E . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2008-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @file libged/set_uplotOutputMode.c
21  *
22  * The set_uplotOutputMode command.
23  *
24  */
25 
26 #include "common.h"
27 #include <string.h>
28 #include "ged.h"
29 #include "plot3.h"
30 
31 /*
32  * Set/get the unix plot output mode
33  *
34  * Usage:
35  * set_uplotOutputMode [binary|text]
36  *
37  */
38 int
39 ged_set_uplotOutputMode(struct ged *gedp, int argc, const char *argv[])
40 {
41  static const char *usage = "[binary|text]";
42 
45  GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
46 
47  /* initialize result */
48  bu_vls_trunc(gedp->ged_result_str, 0);
49 
50  if (argc > 2) {
51  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
52  return GED_ERROR;
53  }
54 
55  /* Get the plot output mode */
56  if (argc == 1) {
57  if (gedp->ged_gdp->gd_uplotOutputMode == PL_OUTPUT_MODE_BINARY)
58  bu_vls_printf(gedp->ged_result_str, "binary");
59  else
60  bu_vls_printf(gedp->ged_result_str, "text");
61 
62  return GED_OK;
63  }
64 
65  if (argv[1][0] == 'b' &&
66  BU_STR_EQUAL("binary", argv[1]))
67  gedp->ged_gdp->gd_uplotOutputMode = PL_OUTPUT_MODE_BINARY;
68  else if (argv[1][0] == 't' &&
69  BU_STR_EQUAL("text", argv[1]))
70  gedp->ged_gdp->gd_uplotOutputMode = PL_OUTPUT_MODE_TEXT;
71  else {
72  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
73  return GED_ERROR;
74  }
75 
76 
77  return GED_OK;
78 }
79 
80 
81 /*
82  * Local Variables:
83  * tab-width: 8
84  * mode: C
85  * indent-tabs-mode: t
86  * c-file-style: "stroustrup"
87  * End:
88  * ex: shiftwidth=4 tabstop=8
89  */
void usage(struct ged *gedp)
Definition: coil.c:315
#define GED_OK
Definition: ged.h:55
int ged_set_uplotOutputMode(struct ged *gedp, int argc, const char *argv[])
Definition: ged.h:338
void bu_vls_trunc(struct bu_vls *vp, int len)
Definition: vls.c:198
#define GED_CHECK_ARGC_GT_0(_gedp, _argc, _flags)
Definition: ged.h:202
Header file for the BRL-CAD common definitions.
#define GED_ERROR
Definition: ged.h:61
#define GED_CHECK_DATABASE_OPEN(_gedp, _flags)
Definition: ged.h:114
#define GED_CHECK_DRAWABLE(_gedp, _flags)
Definition: ged.h:129
struct bu_vls * ged_result_str
Definition: ged.h:357
struct ged_drawable * ged_gdp
Definition: ged.h:360
int gd_uplotOutputMode
output mode for unix plots
Definition: ged.h:318
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:694
#define BU_STR_EQUAL(s1, s2)
Definition: str.h:126