2 (c) 2005: Jelmer Vernooij <jelmer@samba.org>
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.
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.
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.
22 #include "dlinklist.h"
36 static void print_tuning(struct ptb_tuning *t, void *userdata)
39 printf("%s: ", t->name);
40 for (j = 0; j < t->nr_strings; j++) {
41 printf("%s ", ptb_tuning_get_note(t->strings[j]));
46 static void del_tuning(struct ptb_tuning *t, void *userdata)
48 struct ptb_tuning_dict *d = userdata;
52 /* FIXME: Swap current and last item */
55 static void traverse_tunings(struct ptb_tuning_dict *ret, const char *name, void (*fn) (struct ptb_tuning *, void *userdata), void *userdata)
58 for (i = 0; i < ret->nr_tunings; i++) {
59 if (name && strcmp(name, ret->tunings[i].name)) continue;
61 fn (&ret->tunings[i], userdata);
65 int main(int argc, const char **argv)
67 struct ptb_tuning_dict *ret;
72 struct poptOption options[] = {
74 {"version", 'v', POPT_ARG_NONE, &version, 'v', "Show version information" },
75 {"add", 'a', POPT_ARG_NONE, &add, 'a', "Add entry" },
76 {"del", 'd', POPT_ARG_NONE, &del, 'd', "Delete entry" },
80 pc = poptGetContext(argv[0], argc, argv, options, 0);
81 poptSetOtherOptionHelp(pc, "tunings.dat [tuning-name]");
82 while((c = poptGetNextOpt(pc)) >= 0) {
85 printf("ptbdict Version "PACKAGE_VERSION"\n");
86 printf("(C) 2005 Jelmer Vernooij <jelmer@samba.org>\n");
92 if(!poptPeekArg(pc)) {
93 poptPrintUsage(pc, stderr, 0);
97 ret = ptb_read_tuning_dict(poptGetArg(pc));
100 perror("Read error: ");
104 tun = poptGetArg(pc);
109 traverse_tunings(ret, tun, del?del_tuning:print_tuning, NULL);