Updates for set_type_hint() and the sfdb_ui.
[ardour.git] / gtk2_ardour / opts.cc
1 /*
2     Copyright (C) 2001 Paul Davis
3     
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18     $Id$
19 */
20
21 #include <getopt.h>
22 #include <iostream>
23 #include <cstdlib>
24
25 #include "opts.h"
26
27 #include "i18n.h"
28
29 using namespace std;
30
31 string GTK_ARDOUR::session_name = "";
32 string GTK_ARDOUR::jack_client_name = "ardour";
33 bool  GTK_ARDOUR::show_key_actions = false;
34 bool GTK_ARDOUR::no_splash = true;
35 bool GTK_ARDOUR::just_version = false;
36 bool GTK_ARDOUR::use_vst = true;
37 bool GTK_ARDOUR::new_session = false;
38 char* GTK_ARDOUR::curvetest_file = 0;
39 bool GTK_ARDOUR::try_hw_optimization = false;
40
41 using namespace GTK_ARDOUR;
42
43 int
44 print_help (const char *execname)
45 {
46         cout << _("Usage: ") << execname << "\n"
47              << _("  -v, --version                    Show version information\n")
48              << _("  -h, --help                       Print this message\n")
49              << _("  -b, --bindings                   Print all possible keyboard binding names\n")
50              << _("  -n, --show-splash                Show splash screen\n")
51              << _("  -c, --name  name                 Use a specific jack client name, default is ardour\n")
52              << _("  -N, --new session-name           Create a new session from the command line\n")                       
53              << _("  -o, --use-hw-optimizations        Try to use h/w specific optimizations\n")
54 #ifdef VST_SUPPORT
55              << _("  -V, --novst                      Do not use VST support\n")
56 #endif
57              << _("  [session-name]                   Name of session to load\n")
58              << _("  -C, --curvetest filename         Curve algorithm debugger\n")
59                 ;
60         return 1;
61
62 }
63
64 int
65 GTK_ARDOUR::parse_opts (int argc, char *argv[])
66
67 {
68         const char *optstring = "U:hbvVnoc:C:N:";
69         const char *execname = strrchr (argv[0], '/');
70
71         if (execname == 0) {
72                 execname = argv[0];
73         } else {
74                 execname++;
75         }
76
77         const struct option longopts[] = {
78                 { "version", 0, 0, 'v' },
79                 { "help", 0, 0, 'h' },
80                 { "bindings", 0, 0, 'b' },
81                 { "show-splash", 0, 0, 'n' },
82                 { "name", 1, 0, 'c' },
83                 { "novst", 0, 0, 'V' },
84                 { "new", 1, 0, 'N' },
85                 { "use-hw-optimizations", 0, 0, 'o' },
86                 { "curvetest", 1, 0, 'C' },
87                 { 0, 0, 0, 0 }
88         };
89
90         int option_index = 0;
91         int c = 0;
92
93         while (1) {
94                 c = getopt_long (argc, argv, optstring, longopts, &option_index);
95
96                 if (c == -1) {
97                         break;
98                 }
99
100                 switch (c) {
101                 case 0:
102                         break;
103                 
104                 case 'v':
105                         just_version = true;
106                         break;
107
108                 case 'h':
109                         print_help (execname);
110                         exit (0);
111                         break;
112                 case 'b':
113                         show_key_actions = true;
114                         break;
115
116                 case 'n':
117                         no_splash = false;
118                         break;
119
120                 case 'N':
121                         new_session = true;
122                         session_name = optarg;
123                         break;
124
125                 case 'o':
126                         try_hw_optimization = true;
127                         break;
128
129                 case 'V':
130 #ifdef VST_SUPPORT
131                         use_vst = false;
132 #endif /* VST_SUPPORT */
133                         break;
134
135                 case 'c':
136                         jack_client_name = optarg;
137                         break;
138
139                 case 'C':
140                         curvetest_file = optarg;
141                         break;
142
143                 default:
144                         break;
145                 }
146         }
147
148         if (optind < argc) {
149                 session_name = argv[optind++];
150         }
151
152         return 0;
153 }
154