diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-07-17 11:47:31 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-07-17 11:47:31 +0300 |
commit | cc2d3badf3dedb99e817529599a90d8b77566f05 (patch) | |
tree | a892ade6a492f83f93755faf5eb096921b50b0c6 | |
parent | fb20738f3033358e79b0f98b46de93190cb0acfb (diff) | |
download | idest-cc2d3badf3dedb99e817529599a90d8b77566f05.tar.gz idest-cc2d3badf3dedb99e817529599a90d8b77566f05.tar.bz2 |
Accept optional "display names" in query mode.
* NEWS: Update.
* src/editem.c: Extend frame spec syntax.
-rw-r--r-- | NEWS | 52 | ||||
-rw-r--r-- | src/editem.c | 33 |
2 files changed, 57 insertions, 28 deletions
@@ -48,48 +48,66 @@ Prints verbose frame descriptions instead of their short names. The argument, if supplied, is a comma-separated list of the frame names to delete. -* Comment content descriptors are displayed at the output. +* Frame qualifiers are displayed at the output. -In query mode, non-empty comment content descriptors are printed in square -brackets before their corresponding values. All comment fields are -concatenated and shown as a single one, e.g.: +Certain frames hold a set of additional fields, apart from their +actual value and can appear mutliple times provided that those +additional field differ. We call these fields "frame qualifiers". +For example, comment frames (COMM) have two qualifiers: language +and content descriptor. -comment: Test [RESULT] value [CDDB_TrackNumber] 8. - -In all-frames mode, each comment field is shown individually, with the -corresponding language code and descriptor: +In query mode, qualifiers are displayed after the corresponding frame +name and are separated by colons, e.g.: comment:eng:RESULT: value comment:eng:CDDB_TrackNumber: 8 -* When setting or deleting comment fields, qualifiers are accepted. +* All idest operations accept qualified frame names. -Optional qualifiers specify language and content descriptor of the -field. The extended syntax for setting comment fields is: +The full syntax is: - --set comment:LANG:DESCR=VALUE + NAME:QUAL -Where LANG is a valid 3-character language code and DESCR is the -content descriptor. If LANG is omitted, "eng" is assumed. Examples: +Where NAME is a frame name or ID and QUAL stands for a list of +qualifiers separated by colons. Empty +qualifiers and '*' act as wildcards, matching any actual field value. +For example: + --query title,comment::my-comment + --delete=comment:eng:my-comment --set comment:esp:mi-comentario="Valor de prueba" --set comment::my-comment="Test value" +* Frame display names in query mode + +Frame specifications in query mode can contain optional "frame display +name". When present, it will be displayed instead of the frame ID. +The full syntax is: + + NAME%ID[:QUAL] + +(See above for a description of the optional QUAL part). For example: + + idest --query Title%TIT2,Artist%TPE1,Author%TOLY,Composer%TCOM *.mp3 + * Changes in Scheme representation of frame lists. Each frame in the list is represented as a cons. Car of this cons is the frame name (a string). Its cdr is an association list keeping this frame properties. Keys in this list are property -IDs (Scheme symbols). Following properties are defined: +IDs (Scheme symbols). The following properties are defined for +all frames: descr frame description text value of this frame + +More properties are defined at a per-frame basis to represent +frame qualifiers. For example, for "comment" (COMM) frames: + lang a three-letter code of the language in which the text is written condesc content descriptor -The two latter properties are defined only for comment frames. - * Guile startup files. When run with the --script option, idest searches for files .idest.scm, diff --git a/src/editem.c b/src/editem.c index ba03c91..1054d4f 100644 --- a/src/editem.c +++ b/src/editem.c @@ -158,18 +158,32 @@ ed_item_from_frame_spec(const char *arg, size_t len) struct ed_item itm; struct id3_frametype const *frametype; struct idest_frametab const *ft; + size_t n; const char *id; + char *idstr; ed_item_zero(&itm); if (split_item_name(&itm, arg, len)) error(1, 0, "ivalid frame spec: %s", arg); - id = name_to_frame_id(itm.name); + n = strcspn(itm.name, "%"); + if (itm.name[n]) { + char *s = xmalloc(n + 1); + memcpy(s, itm.name, n); + s[n] = 0; + + idstr = xstrdup(itm.name + n + 1); + free(itm.name); + itm.name = s; + } else + idstr = itm.name; + + id = name_to_frame_id(idstr); if (!id) { - frametype = id3_frametype_lookup(itm.name, strlen(itm.name)); + frametype = id3_frametype_lookup(idstr, strlen(idstr)); if (!frametype) - error(1, 0, "%s: unknown frame name", itm.name); - id = itm.name; + error(1, 0, "%s: unknown frame name", idstr); + id = idstr; } else { frametype = id3_frametype_lookup(id, 4); assert(frametype != NULL); @@ -180,6 +194,10 @@ ed_item_from_frame_spec(const char *arg, size_t len) error(1, 0, "don't know how to handle frame %s", id); memcpy(itm.id, id, sizeof(itm.id)); + + if (idstr != itm.name) + free(idstr); + if (itm.qc > ft->qc) error(1, 0, "too many field qualifiers for this frame: %s", arg); @@ -192,13 +210,6 @@ ed_item_from_frame_spec(const char *arg, size_t len) return ed_item_dup(&itm); } -struct ed_item * -ed_item_from_frame(struct id3_frame *frame) -{ - //FIXME; - abort(); -} - void ed_item_print(struct ed_item const *itm) { |