annotate loadtools/bpunify.c @ 919:1f27fc13eab7

tiffs: add support for extended filenames found in SE K2x0 FFS
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 31 Dec 2022 09:27:01 +0000
parents 850b4f066d75
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
895
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * fc-buzplay: this module implements the unified 'play' command.
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <ctype.h>
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <string.h>
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <strings.h>
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 set_bu_volume(vol)
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 unsigned vol;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 {
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 char *targv[3], argbuf[16];
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 sprintf(argbuf, "%u", vol - 1);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 targv[0] = "buzlev";
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 targv[1] = argbuf;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 targv[2] = 0;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 tpinterf_make_cmd(targv);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (tpinterf_send_cmd() < 0)
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 return(-1);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 return tpinterf_pass_output(1);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 cmd_play(argc, argv)
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 char **argv;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 {
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 char *filename, *tail;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 int pwt_mode, rc;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 unsigned global_vol;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 filename = argv[1];
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 tail = rindex(filename, '.');
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (!tail) {
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 unknown: fprintf(stderr,
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 "unable to intuit format of %s, use play-bu or play-pwt\n",
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 filename);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 return(-1);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 }
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (!strcmp(tail, ".buz"))
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 pwt_mode = 0;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 else if (!strcmp(tail, ".pwt"))
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 pwt_mode = 1;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 else
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 goto unknown;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 if (argv[2]) {
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 global_vol = strtoul(argv[2], 0, 0);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 if (global_vol < 1 || global_vol > 64) {
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 fprintf(stderr,
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 "error: invalid global volume argument\n");
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 return(-1);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 }
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 } else
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 global_vol = 64;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 if (pwt_mode)
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 return buzplay_pwt_file(filename, global_vol);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 else {
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 rc = set_bu_volume(global_vol);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 if (rc)
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 return(rc);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 return buzplay_bu_file(filename);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 }
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 }