chiark / gitweb /
plugins/tracklength-gstreamer.c: Rewrite to use `GstDiscoverer'.
[disorder] / cgi / macros-disorder.c
index 30614c1a26d2fecca465457e52e053169d88d466..1ef1ee1f3d0ed4f8e2db80197f0b0ecd6b87e41e 100644 (file)
@@ -159,10 +159,11 @@ static int exp_part(int nargs,
       return 0;
   }
   if(dcgi_client
-     && !disorder_part(dcgi_client, (char **)&s,
+     && !disorder_part(dcgi_client,
                        track,
                        !strcmp(context, "short") ? "display" : context,
-                       part)) {
+                       part,
+                       (char **)&s)) {
     if(!strcmp(context, "short"))
       s = truncate_for_display(s, config->short_display);
     return sink_writes(output, cgi_sgmlquote(s)) < 0 ? -1 : 0;
@@ -457,7 +458,7 @@ static int exp_volume(int attribute((unused)) nargs,
                       struct sink *output,
                       void attribute((unused)) *u) {
   dcgi_lookup(DCGI_VOLUME);
-  return sink_printf(output, "%d",
+  return sink_printf(output, "%ld",
                      !strcmp(args[0], "left")
                          ? dcgi_volume_left : dcgi_volume_right) < 0 ? -1 : 0;
 }
@@ -625,7 +626,7 @@ static int exp_trackstate(int attribute((unused)) nargs,
 
   if(!dcgi_client)
     return 0;
-  if(disorder_resolve(dcgi_client, &track, args[0]))
+  if(disorder_resolve(dcgi_client, args[0], &track))
     return 0;
   dcgi_lookup(DCGI_PLAYING);
   if(dcgi_playing && !strcmp(track, dcgi_playing->track))
@@ -661,7 +662,7 @@ static int exp_resolve(int attribute((unused)) nargs,
                        void attribute((unused)) *u) {
   char *r;
 
-  if(dcgi_client && !disorder_resolve(dcgi_client, &r, args[0]))
+  if(dcgi_client && !disorder_resolve(dcgi_client, args[0], &r))
     return sink_writes(output, r) < 0 ? -1 : 0;
   return 0;
 }
@@ -859,24 +860,36 @@ static int exp__files_dirs(int nargs,
   /* Get the list */
   if(fn(dcgi_client, dir, re, &tracks, &ntracks))
     return 0;
-  /* Sort it.  NB trackname_transform() does not go to the server. */
-  tsd = tracksort_init(ntracks, tracks, type);
-  /* Expand the subsiduary templates.  We chuck in @sort and @display because
-   * it is particularly easy to do so. */
-  for(n = 0; n < ntracks; ++n)
-    if((rc = mx_expand(mx_rewritel(m,
-                                   "index", make_index(n),
-                                   "parity", n % 2 ? "odd" : "even",
-                                   "track", tsd[n].track,
-                                   "first", n == 0 ? "true" : "false",
-                                   "last", n + 1 == ntracks ? "false" : "true",
-                                   "sort", tsd[n].sort,
-                                   "display", tsd[n].display,
-                                   (char *)0),
-                       output, u)))
-      return rc;
+  if(type) {
+    /* Sort it.  NB trackname_transform() does not go to the server. */
+    tsd = tracksort_init(ntracks, tracks, type);
+    /* Expand the subsiduary templates.  We chuck in @sort and @display because
+     * it is particularly easy to do so. */
+    for(n = 0; n < ntracks; ++n)
+      if((rc = mx_expand(mx_rewritel(m,
+                                     "index", make_index(n),
+                                     "parity", n % 2 ? "odd" : "even",
+                                     "track", tsd[n].track,
+                                     "first", n == 0 ? "true" : "false",
+                                     "last", n + 1 == ntracks ? "false" : "true",
+                                     "sort", tsd[n].sort,
+                                     "display", tsd[n].display,
+                                     (char *)0),
+                         output, u)))
+        return rc;
+  } else {
+    for(n = 0; n < ntracks; ++n)
+      if((rc = mx_expand(mx_rewritel(m,
+                                     "index", make_index(n),
+                                     "parity", n % 2 ? "odd" : "even",
+                                     "track", tracks[n],
+                                     "first", n == 0 ? "true" : "false",
+                                     "last", n + 1 == ntracks ? "false" : "true",
+                                     (char *)0),
+                         output, u)))
+        return rc;
+  }
   return 0;
-
 }
 
 /*$ @tracks{DIR}{RE}{TEMPLATE}
@@ -918,7 +931,7 @@ static int exp_dirs(int nargs,
                     const struct mx_node **args,
                     struct sink *output,
                     void *u) {
-  return exp__files_dirs(nargs, args, output, u, "dir", disorder_directories);
+  return exp__files_dirs(nargs, args, output, u, "dir", disorder_dirs);
 }
 
 static int exp__search_shim(disorder_client *c, const char *terms,
@@ -936,14 +949,12 @@ static int exp__search_shim(disorder_client *c, const char *terms,
  * - @parity: "even" or "odd" alternately
  * - @first: "true" on the first directory and "false" otherwise
  * - @last: "true" on the last directory and "false" otherwise
- * - @sort: the sort key for this track
- * - @display: the UNQUOTED display string for this track
  */
 static int exp_search(int nargs,
                       const struct mx_node **args,
                       struct sink *output,
                       void *u) {
-  return exp__files_dirs(nargs, args, output, u, "track", exp__search_shim);
+  return exp__files_dirs(nargs, args, output, u, NULL, exp__search_shim);
 }
 
 /*$ @label{NAME}