Debian Codegraph @

utils/ipatch_convert.c

raw
1 /* in progress, i.e. not yet working */
2
3
4 /*
5 * instpatch.c - A command line interface to libInstPatch
6 *
7 * libInstPatch
8 * Copyright (C) 1999-2014 Element Green <[email protected]>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; version 2
13 * of the License only.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 * 02111-1307, USA or point your web browser to http://www.gnu.org.
24 */
25 #include <stdio.h>
26 #include <libinstpatch/libinstpatch.h>
27
28 #define _GNU_SOURCE
29 #include <getopt.h>
30
31 static void usage(void);
32
33 extern char *optarg;
34 extern int optind, opterr, optopt;
35
36 int
37 main(int argc, char *argv[])
38 {
39 int option_index = 0;
40 int c;
41
42 static struct option long_options[] =
43 {
44 {"convert", 1, 0, 'c'},
45 {"output", 1, 0, 'o'},
46 {NULL, 0, NULL, 0}
47 };
48
49 while(TRUE)
50 {
51 c = getopt_long(argc, argv, "c:o:", long_options, &option_index);
52
53 if(c == -1)
54 {
55 break;
56 }
57
58 switch(c)
59 {
60 case 'c': /* conversion type */
61 break;
62
63 case 'o': /* conversion output file name/dir */
64 break;
65
66 case ':': /* missing option */
67 fprintf(stderr, "Missing parameter for option '-%c, %s'\n",
68 (char)(long_options[option_index].val),
69 long_options[option_index].name);
70 usage();
71 exit(1);
72 break;
73
74 case '?': /* unknown switch */
75 usage();
76 exit(1);
77 break;
78
79 default:
80 fprintf(stderr, "Unknown getopt return val '%d'\n", c);
81 exit(1);
82 break;
83 }
84 }
85 }
86
87 #define U(text) fprintf (stderr, text);
88
89 static void
90 usage(void)
91 {
92 U("libInstPatch utility for MIDI instrument patch file processing\n");
93 U("Copyright (C) 1999-2005 Josh Green <[email protected]>\n");
94 U("Distributed under the LGPL license\n\n");
95
96 U("Usage: instpatch [OPTION]... [FILE]...\n\n");
97
98 U("Examples:\n");
99 U(" instpatch -n sf2 -o newfile.sf2 # Create a new SoundFont file.\n");
100 U(" instpatch -c dls2 *.sf2 # Convert all SoundFont files to DLS2.\n");
101 U(" instpatch -ql myfile.gig # List items in a GigaSampler file.\n");
102 U(" instpatch -qp -i 32 example.dls # Get properties of item 32 in DLS file.\n");
103 U("\n");
104
105 U("Query options (with -q or --query):\n");
106 U(" -i, --item=ID Select item by numeric ID\n");
107 U(" -l, --list List items\n");
108 U(" -p, --prop Query properties\n");
109 U("\n");
110
111 U("Conversion options (with -c or --convert):\n");
112 U(" -t, --type=TYPE File TYPE to convert to\n");
113
114 U(" -n, --new=TYPE Create a new patch object of TYPE\n");
115 U(" -c, --convert=TYPE Convert type of file(s)\n");
116 U(" -o, --output=file/dir Specify output file name and/or directory for --new and --convert\n");
117 }