BRL-CAD
options.c
Go to the documentation of this file.
1 /* O P T I O N S . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1999-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 libdm/options.c
21  *
22  * Option processing routines.
23  *
24  */
25 
26 #include "common.h"
27 
28 #include <stdlib.h>
29 
30 #include "tcl.h"
31 
32 #include "bu/getopt.h"
33 #include "vmath.h"
34 #include "dm.h"
35 #include "dm_private.h"
36 
37 int
38 dm_processOptions(dm *dmp, struct bu_vls *init_proc_vls, int argc, char **argv)
39 {
40  int c;
41 
42  bu_optind = 0; /* re-init bu_getopt */
43  bu_opterr = 0;
44  while ((c = bu_getopt(argc, argv, "N:S:W:s:d:i:n:t:")) != -1) {
45  switch (c) {
46  case 'N':
47  dmp->dm_height = atoi(bu_optarg);
48  break;
49  case 'S':
50  case 's':
51  dmp->dm_width = dmp->dm_height = atoi(bu_optarg);
52  break;
53  case 'W':
54  dmp->dm_width = atoi(bu_optarg);
55  break;
56  case 'd':
58  break;
59  case 'i':
60  bu_vls_strcpy(init_proc_vls, bu_optarg);
61  break;
62  case 'n':
63  if (*bu_optarg != '.')
64  bu_vls_printf(&dmp->dm_pathName, ".%s", bu_optarg);
65  else
67  break;
68  case 't':
69  dmp->dm_top = atoi(bu_optarg);
70  break;
71  default:
72  bu_log("dm_processOptions: option '%c' unknown\n", bu_optopt);
73  break;
74  }
75  }
76 
77  return bu_optind;
78 }
79 
80 /*
81  * Local Variables:
82  * mode: C
83  * tab-width: 8
84  * indent-tabs-mode: t
85  * c-file-style: "stroustrup"
86  * End:
87  * ex: shiftwidth=4 tabstop=8
88  */
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
int dm_top
!0 means toplevel window
Definition: dm_private.h:90
int dm_width
Definition: dm_private.h:91
int dm_processOptions(dm *dmp, struct bu_vls *init_proc_vls, int argc, char **argv)
Definition: options.c:38
char * bu_optarg
Definition: globals.c:91
Header file for the BRL-CAD common definitions.
int bu_optind
Definition: globals.c:89
int bu_getopt(int nargc, char *const nargv[], const char *ostr)
Definition: getopt.c:43
int bu_optopt
Definition: globals.c:90
struct bu_vls dm_dName
Display name.
Definition: dm_private.h:104
int bu_opterr
Definition: globals.c:88
int dm_height
Definition: dm_private.h:92
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:694
struct bu_vls dm_pathName
full Tcl/Tk name of drawing window
Definition: dm_private.h:102
void bu_vls_strcpy(struct bu_vls *vp, const char *s)
Definition: vls.c:310
Definition: vls.h:56