annotate ringtools/imy/main.c @ 1011:6d9b10633f10 default tip

etmsync Pirelli IMEI retrieval: fix poor use of printf() Bug reported by Vadim Yanitskiy <fixeria@osmocom.org>: the construct where a static-allocated string was passed to printf() without any format arguments causes newer compilers to report a security problem. Given that formatted output is not needed here, just fixed string output, change printf() to fputs(), and direct the error message to stderr while at it.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 23 May 2024 17:29:57 +0000
parents a96cb97b66a2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
882
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This file contains the top-level code for fc-imy2pwt.
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdlib.h>
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "sizelimits.h"
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 char *imy_filename;
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 char melody_str_buf[MELODY_BUF_SIZE];
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 unsigned beats_per_min = 120;
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 FILE *outF;
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 main(argc, argv)
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 char **argv;
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 if (argc < 2 || argc > 3) {
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 fprintf(stderr, "usage: %s imy-file [outfile]\n", argv[0]);
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 exit(1);
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 }
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 imy_filename = argv[1];
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 read_imy_firstpass();
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 compute_note_durations();
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 if (argc > 2) {
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 outF = fopen(argv[2], "w");
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 if (!outF) {
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 perror(argv[2]);
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 exit(1);
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 } else
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 outF = stdout;
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 melody_convert_pass();
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 exit(0);
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 }