BRL-CAD
group.c
Go to the documentation of this file.
1 /* G R O U P . 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/group.c
21  *
22  * The group command.
23  *
24  */
25 
26 #include "common.h"
27 
28 #include <string.h>
29 
30 #include "bu/cmd.h"
31 #include "wdb.h"
32 
33 #include "./ged_private.h"
34 
35 
36 int
37 ged_group(struct ged *gedp, int argc, const char *argv[])
38 {
39  static const char *usage = "gname object(s)";
40 
43  GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
44 
45  /* initialize result */
46  bu_vls_trunc(gedp->ged_result_str, 0);
47 
48  /* must be wanting help */
49  if (argc == 1) {
50  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
51  return GED_HELP;
52  }
53 
54  if (argc < 3) {
55  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
56  return GED_ERROR;
57  }
58 
59  return _ged_combadd2(gedp, (char *)argv[1], argc-2, argv+2, 0, WMOP_UNION, 0, 0);
60 }
61 
62 
63 /*
64  * Local Variables:
65  * tab-width: 8
66  * mode: C
67  * indent-tabs-mode: t
68  * c-file-style: "stroustrup"
69  * End:
70  * ex: shiftwidth=4 tabstop=8
71  */
void usage(struct ged *gedp)
Definition: coil.c:315
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.
int _ged_combadd2(struct ged *gedp, char *combname, int argc, const char *argv[], int region_flag, db_op_t relation, int ident, int air)
Definition: comb.c:709
#define WMOP_UNION
Definition: wdb.h:887
int ged_group(struct ged *gedp, int argc, const char *argv[])
Definition: group.c:37
#define GED_ERROR
Definition: ged.h:61
#define GED_CHECK_DATABASE_OPEN(_gedp, _flags)
Definition: ged.h:114
struct bu_vls * ged_result_str
Definition: ged.h:357
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:694
#define GED_HELP
Definition: ged.h:62
#define GED_CHECK_READ_ONLY(_gedp, _flags)
Definition: ged.h:181