FreeCalypso > hg > freecalypso-tools
comparison loadtools/bpunify.c @ 895:850b4f066d75
fc-buzplay: unified play command
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 03 Apr 2022 08:30:35 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
894:7ade15d4e0cb | 895:850b4f066d75 |
---|---|
1 /* | |
2 * fc-buzplay: this module implements the unified 'play' command. | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <ctype.h> | |
7 #include <stdio.h> | |
8 #include <string.h> | |
9 #include <strings.h> | |
10 #include <stdlib.h> | |
11 | |
12 set_bu_volume(vol) | |
13 unsigned vol; | |
14 { | |
15 char *targv[3], argbuf[16]; | |
16 | |
17 sprintf(argbuf, "%u", vol - 1); | |
18 targv[0] = "buzlev"; | |
19 targv[1] = argbuf; | |
20 targv[2] = 0; | |
21 tpinterf_make_cmd(targv); | |
22 if (tpinterf_send_cmd() < 0) | |
23 return(-1); | |
24 return tpinterf_pass_output(1); | |
25 } | |
26 | |
27 cmd_play(argc, argv) | |
28 char **argv; | |
29 { | |
30 char *filename, *tail; | |
31 int pwt_mode, rc; | |
32 unsigned global_vol; | |
33 | |
34 filename = argv[1]; | |
35 tail = rindex(filename, '.'); | |
36 if (!tail) { | |
37 unknown: fprintf(stderr, | |
38 "unable to intuit format of %s, use play-bu or play-pwt\n", | |
39 filename); | |
40 return(-1); | |
41 } | |
42 if (!strcmp(tail, ".buz")) | |
43 pwt_mode = 0; | |
44 else if (!strcmp(tail, ".pwt")) | |
45 pwt_mode = 1; | |
46 else | |
47 goto unknown; | |
48 if (argv[2]) { | |
49 global_vol = strtoul(argv[2], 0, 0); | |
50 if (global_vol < 1 || global_vol > 64) { | |
51 fprintf(stderr, | |
52 "error: invalid global volume argument\n"); | |
53 return(-1); | |
54 } | |
55 } else | |
56 global_vol = 64; | |
57 if (pwt_mode) | |
58 return buzplay_pwt_file(filename, global_vol); | |
59 else { | |
60 rc = set_bu_volume(global_vol); | |
61 if (rc) | |
62 return(rc); | |
63 return buzplay_bu_file(filename); | |
64 } | |
65 } |