2 (c) 2004: 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.
35 int main(int argc, const char **argv)
45 struct poptOption options[] = {
47 {"version", 'v', POPT_ARG_NONE, &version, 'v', "Show version information" },
51 pc = poptGetContext(argv[0], argc, argv, options, 0);
52 poptSetOtherOptionHelp(pc, "file.ptb");
53 while((c = poptGetNextOpt(pc)) >= 0) {
56 printf("ptb2ptb Version "PACKAGE_VERSION"\n");
57 printf("(C) 2004-2005 Jelmer Vernooij <jelmer@samba.org>\n");
63 ptb_set_debug(debugging);
65 if(!poptPeekArg(pc)) {
66 poptPrintUsage(pc, stderr, 0);
69 input = poptGetArg(pc);
71 if (!quiet) fprintf(stderr, "Parsing %s... \n", input);
73 ret = ptb_read_file(input);
76 perror("Read error: ");
81 int baselength = strlen(input);
82 if (!strcmp(input + strlen(input) - 4, ".ptb")) {
85 output = malloc(baselength + 9);
86 strncpy(output, input, baselength);
87 strcpy(output + baselength, ".ptb.2");
90 if (!quiet) fprintf(stderr, "Generating new powertab file in %s...\n", output);
92 if (ptb_write_file(output, ret) == -1) {
93 fprintf(stderr, "Error while generating PowerTab file\n");