FreeCalypso > hg > freecalypso-tools
view ringtools/fc-ringlist-comp.c @ 995:74024eb17e04
fc-loadtool help: improve language regarding 16 MiB flash chips
In FC project history, 16 MiB flash originally meant Pirelli DP-L10.
Then we got FCDEV3B with the same flash (our own design), but now we are
discovering more Calypso devices that used such large flash, both late
Calypso era (Sony Ericsson K2x0) as well as much earlier ones (FIC FLUID
devices.txt file with 2004 dates, Leonardo+ rev 5). Hence we need to
migrate to more generic or neutral language in associated documentation,
without giving elevated status to specific examples that drove our
early project history.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 03 Dec 2023 21:11:12 +0000 |
parents | f442156d31ad |
children |
line wrap: on
line source
/* * This program compiles a list of ringing tone or message alert tone * melodies from ASCII source into the binary format (.mls) that will * be uploaded into FreeCalypso device FFS and read by the UI layer * of FC phone firmwares. */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <strings.h> #define MAX_FFS_PATHNAME 19 #define MAX_FFS_PREFIX 5 #define MAX_NAME_FIELD 59 struct bin_record { char ffs_pathname[MAX_FFS_PATHNAME+1]; char ui_name[MAX_NAME_FIELD+1]; }; char *infname, *outfname; FILE *inf, *outf; char ffs_prefix[MAX_FFS_PREFIX+2]; unsigned ffs_prefix_len; char linebuf[256]; int lineno; set_ffs_prefix(prefix_arg) char *prefix_arg; { char *cp; if (prefix_arg[0] != '/') { fprintf(stderr, "error: given FFS prefix does not begin with \'/\'\n"); exit(1); } ffs_prefix_len = strlen(prefix_arg); if (ffs_prefix_len > MAX_FFS_PREFIX) { fprintf(stderr, "error: given FFS prefix is too long\n"); exit(1); } strcpy(ffs_prefix, prefix_arg); cp = ffs_prefix + ffs_prefix_len; if (cp[-1] != '/') { cp[0] = '/'; cp[1] = '\0'; ffs_prefix_len++; } } enforce_and_strip_newline() { char *cp; cp = index(linebuf, '\n'); if (!cp) { fprintf(stderr, "%s line %d: too long or missing newline\n", infname, lineno); exit(1); } *cp = '\0'; } emit_record(fname, uname) char *fname, *uname; { struct bin_record rec; strcpy(rec.ffs_pathname, ffs_prefix); strncpy(rec.ffs_pathname + ffs_prefix_len, fname, MAX_FFS_PATHNAME + 1 - ffs_prefix_len); strncpy(rec.ui_name, uname, MAX_NAME_FIELD + 1); fwrite(&rec, sizeof rec, 1, outf); } process_line() { char *cp, *fname, *uname; cp = linebuf; while (isspace(*cp)) cp++; if (*cp == '\0' || *cp == '#') return; fname = cp; while (*cp && !isspace(*cp)) cp++; if (!*cp) { inv: fprintf(stderr, "%s line %d: invalid syntax\n", infname, lineno); exit(1); } *cp++ = '\0'; while (isspace(*cp)) cp++; if (*cp == '\0' || *cp == '#') goto inv; uname = cp; if (strlen(fname) + ffs_prefix_len > MAX_FFS_PATHNAME) { fprintf(stderr, "%s line %d: melody filename exceeds limit\n", infname, lineno); exit(1); } if (strlen(uname) > MAX_NAME_FIELD) { fprintf(stderr, "%s line %d: melody UI name exceeds limit\n", infname, lineno); exit(1); } emit_record(fname, uname); } main(argc, argv) char **argv; { if (argc != 4) { fprintf(stderr, "usage: %s src-file bin-file ffs-prefix\n", argv[0]); exit(1); } if (strcmp(argv[1], "-")) { infname = argv[1]; inf = fopen(infname, "r"); if (!inf) { perror(infname); exit(1); } } else { infname = "stdin"; inf = stdin; } set_ffs_prefix(argv[3]); outfname = argv[2]; outf = fopen(outfname, "w"); if (!outf) { perror(outfname); exit(1); } for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) { enforce_and_strip_newline(); process_line(); } exit(0); }