2 * This file is part of DisOrder.
3 * Copyright (C) 2004-2008 Richard Kettlewell
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 /** @file server/macros-disorder.c
21 * @brief DisOrder-specific expansions
24 #include "disorder-cgi.h"
26 /** @brief For error template */
27 char *dcgi_error_string;
29 /** @brief For login template */
30 char *dcgi_status_string;
32 /** @brief Return @p i as a string */
33 static const char *make_index(int i) {
36 byte_xasprintf(&s, "%d", i);
42 * Expands to the server's version string, or a (safe to use) error
43 * value if the server is unavailable or broken.
45 static int exp_server_version(int attribute((unused)) nargs,
46 char attribute((unused)) **args,
48 void attribute((unused)) *u) {
52 if(disorder_version(dcgi_client, (char **)&v))
53 v = "(cannot get version)";
55 v = "(server not running)";
56 return sink_writes(output, cgi_sgmlquote(v)) < 0 ? -1 : 0;
61 * Expands to the local version string.
63 static int exp_version(int attribute((unused)) nargs,
64 char attribute((unused)) **args,
66 void attribute((unused)) *u) {
67 return sink_writes(output,
68 cgi_sgmlquote(disorder_short_version_string)) < 0 ? -1 : 0;
73 * Expands to the base URL of the web interface.
75 static int exp_url(int attribute((unused)) nargs,
76 char attribute((unused)) **args,
78 void attribute((unused)) *u) {
79 return sink_writes(output,
80 cgi_sgmlquote(config->url)) < 0 ? -1 : 0;
85 * Expands to the UNQUOTED form of CGI argument NAME, or the empty string if
86 * there is no such argument. Use @argq for a quick way to quote the argument.
88 static int exp_arg(int attribute((unused)) nargs,
91 void attribute((unused)) *u) {
92 const char *s = cgi_get(args[0]);
95 return sink_writes(output, s) < 0 ? -1 : 0;
102 * Expands to the (quoted) form of CGI argument NAME, or the empty string if
103 * there is no such argument. Use @arg for the unquoted argument.
105 static int exp_argq(int attribute((unused)) nargs,
108 void attribute((unused)) *u) {
109 const char *s = cgi_get(args[0]);
112 return sink_writes(output, cgi_sgmlquote(s)) < 0 ? -1 : 0;
119 * Expands to the logged-in username (which might be "guest"), or to
120 * the empty string if not connected.
122 static int exp_user(int attribute((unused)) nargs,
123 char attribute((unused)) **args,
125 void attribute((unused)) *u) {
128 if(dcgi_client && (user = disorder_user(dcgi_client)))
129 return sink_writes(output, cgi_sgmlquote(user)) < 0 ? -1 : 0;
133 /* @part{TRACK|ID}{PART}{CONTEXT}
135 * Expands to a track name part.
137 * A track may be identified by name or by queue ID.
139 * CONTEXT may be omitted. If it is then 'display' is assumed.
141 * If the CONTEXT is 'short' then the 'display' part is looked up, and the
142 * result truncated according to the length defined by the short_display
143 * configuration directive.
145 static int exp_part(int nargs,
148 void attribute((unused)) *u) {
149 const char *track = args[0], *part = args[1];
150 const char *context = nargs > 2 ? args[2] : "display";
153 if(track[0] != '/') {
154 struct queue_entry *q = dcgi_findtrack(track);
162 && !disorder_part(dcgi_client, &s,
164 !strcmp(context, "short") ? "display" : context,
166 return sink_writes(output, cgi_sgmlquote(s)) < 0 ? -1 : 0;
172 * SGML-quotes STRING. Note that most expansion results are already suitable
173 * quoted, so this expansion is usually not required.
175 static int exp_quote(int attribute((unused)) nargs,
178 void attribute((unused)) *u) {
179 return sink_writes(output, cgi_sgmlquote(args[0])) < 0 ? -1 : 0;
184 * Expands to the name of the submitter of track ID, which must be a playing
185 * track, in the queue, or in the recent list.
187 static int exp_who(int attribute((unused)) nargs,
190 void attribute((unused)) *u) {
191 struct queue_entry *q = dcgi_findtrack(args[0]);
193 if(q && q->submitter)
194 return sink_writes(output, cgi_sgmlquote(q->submitter)) < 0 ? -1 : 0;
200 * Expands to the time a track started or is expected to start. The track must
201 * be a playing track, in the queue, or in the recent list.
203 static int exp_when(int attribute((unused)) nargs,
206 void attribute((unused)) *u) {
207 struct queue_entry *q = dcgi_findtrack(args[0]);
208 const struct tm *w = 0;
212 case playing_isscratch:
213 case playing_unplayed:
216 w = localtime(&q->expected);
219 case playing_no_player:
221 case playing_scratched:
222 case playing_started:
224 case playing_quitting:
226 w = localtime(&q->played);
230 return sink_printf(output, "%d:%02d", w->tm_hour, w->tm_min) < 0 ? -1 : 0;
232 return sink_writes(output, " ") < 0 ? -1 : 0;
237 * Expands to the length of a track, identified by its queue ID or its name.
238 * If it is the playing track (identified by ID) then the amount played so far
241 static int exp_length(int attribute((unused)) nargs,
244 void attribute((unused)) *u) {
245 struct queue_entry *q;
249 if(args[0][0] == '/')
250 /* Track identified by name */
253 /* Track identified by queue ID */
254 if(!(q = dcgi_findtrack(args[0])))
256 if(q->state == playing_started || q->state == playing_paused)
257 if(sink_printf(output, "%ld:%02ld/", q->sofar / 60, q->sofar % 60) < 0)
261 if(dcgi_client && disorder_length(dcgi_client, name, &length))
262 return sink_printf(output, "%ld:%02ld",
263 length / 60, length % 60) < 0 ? -1 : 0;
264 return sink_writes(output, " ") < 0 ? -1 : 0;
269 * Expands to "true" if track ID is removable (or scratchable, if it is the
270 * playing track) and "false" otherwise.
272 static int exp_removable(int attribute((unused)) nargs,
275 void attribute((unused)) *u) {
276 struct queue_entry *q = dcgi_findtrack(args[0]);
277 /* TODO would be better to reject recent */
279 if(!q || !dcgi_client)
280 return mx_bool_result(output, 0);
281 dcgi_lookup(DCGI_RIGHTS);
282 return mx_bool_result(output,
283 (q == dcgi_playing ? right_scratchable : right_removable)
284 (dcgi_rights, disorder_user(dcgi_client), q));
289 * Expands to "true" if track ID is movable and "false" otherwise.
291 * DIR (which is optional) should be a non-zero integer. If it is negative
292 * then the intended move is down (later in the queue), if it is positive then
293 * the intended move is up (earlier in the queue). The first track is not
294 * movable up and the last track not movable down.
296 static int exp_movable(int nargs,
299 void attribute((unused)) *u) {
300 struct queue_entry *q = dcgi_findtrack(args[0]);
301 /* TODO would be better to recent playing/recent */
303 if(!q || !dcgi_client)
304 return mx_bool_result(output, 0);
306 const long dir = atoi(args[1]);
308 if(dir > 0 && q == dcgi_queue)
309 return mx_bool_result(output, 0);
310 if(dir < 0 && q->next == 0)
311 return mx_bool_result(output, 0);
313 dcgi_lookup(DCGI_RIGHTS);
314 return mx_bool_result(output,
315 right_movable(dcgi_rights,
316 disorder_user(dcgi_client),
320 /* @playing{TEMPLATE}
322 * Expands to TEMPLATE, with the following expansions:
323 * - @id: the queue ID of the playing track
324 * - @track: the playing track's
327 * If no track is playing expands to nothing.
329 * TEMPLATE is optional. If it is left out then instead expands to the queue
330 * ID of the playing track.
332 static int exp_playing(int nargs,
333 const struct mx_node **args,
336 dcgi_lookup(DCGI_PLAYING);
340 return sink_writes(output, dcgi_playing->id) < 0 ? -1 : 0;
341 return mx_expand(mx_rewritel(args[0],
342 "id", dcgi_playing->id,
343 "track", dcgi_playing->track,
350 * For each track in the queue, expands TEMPLATE with the following expansions:
351 * - @id: the queue ID of the track
352 * - @track: the UNQUOTED track name
353 * - @index: the track number from 0
354 * - @parity: "even" or "odd" alternately
355 * - @first: "true" on the first track and "false" otherwise
356 * - @last: "true" on the last track and "false" otherwise
358 static int exp_queue(int attribute((unused)) nargs,
359 const struct mx_node **args,
362 struct queue_entry *q;
365 dcgi_lookup(DCGI_QUEUE);
366 for(q = dcgi_queue, i = 0; q; q = q->next, ++i)
367 if((rc = mx_expand(mx_rewritel(args[0],
370 "index", make_index(i),
371 "parity", i % 2 ? "odd" : "even",
372 "first", q == dcgi_queue ? "true" : "false",
373 "last", q->next ? "false" : "true",
382 * For each track in the recently played list, expands TEMPLATE with the
383 * following expansions:
384 * - @id: the queue ID of the track
385 * - @track: the UNQUOTED track name
386 * - @index: the track number from 0
387 * - @parity: "even" or "odd" alternately
388 * - @first: "true" on the first track and "false" otherwise
389 * - @last: "true" on the last track and "false" otherwise
391 static int exp_recent(int attribute((unused)) nargs,
392 const struct mx_node **args,
395 struct queue_entry *q;
398 dcgi_lookup(DCGI_RECENT);
399 for(q = dcgi_recent, i = 0; q; q = q->next, ++i)
400 if((rc = mx_expand(mx_rewritel(args[0],
403 "index", make_index(i),
404 "parity", i % 2 ? "odd" : "even",
405 "first", q == dcgi_recent ? "true" : "false",
406 "last", q->next ? "false" : "true",
415 * For each track in the newly added list, expands TEMPLATE wit the following
417 * - @track: the UNQUOTED track name
418 * - @index: the track number from 0
419 * - @parity: "even" or "odd" alternately
420 * - @first: "true" on the first track and "false" otherwise
421 * - @last: "true" on the last track and "false" otherwise
423 * Note that unlike @playing, @queue and @recent which are otherwise
424 * superficially similar, there is no @id sub-expansion here.
426 static int exp_new(int attribute((unused)) nargs,
427 const struct mx_node **args,
432 dcgi_lookup(DCGI_NEW);
433 /* TODO perhaps we should generate an ID value for tracks in the new list */
434 for(i = 0; i < dcgi_nnew; ++i)
435 if((rc = mx_expand(mx_rewritel(args[0],
436 "track", dcgi_new[i],
437 "index", make_index(i),
438 "parity", i % 2 ? "odd" : "even",
439 "first", i == 0 ? "true" : "false",
440 "last", i == dcgi_nnew - 1 ? "false" : "true",
449 * Expands to the volume in a given channel. CHANNEL must be "left" or
452 static int exp_volume(int attribute((unused)) nargs,
455 void attribute((unused)) *u) {
456 dcgi_lookup(DCGI_VOLUME);
457 return sink_printf(output, "%d",
458 !strcmp(args[0], "left")
459 ? dcgi_volume_left : dcgi_volume_right) < 0 ? -1 : 0;
464 * Expands to "true" if there is a playing track, otherwise "false".
466 static int exp_isplaying(int attribute((unused)) nargs,
467 char attribute((unused)) **args,
469 void attribute((unused)) *u) {
470 dcgi_lookup(DCGI_PLAYING);
471 return mx_bool_result(output, !!dcgi_playing);
476 * Expands to "true" if there the queue is nonempty, otherwise "false".
478 static int exp_isqueue(int attribute((unused)) nargs,
479 char attribute((unused)) **args,
481 void attribute((unused)) *u) {
482 dcgi_lookup(DCGI_QUEUE);
483 return mx_bool_result(output, !!dcgi_queue);
488 * Expands to "true" if there the recently played list is nonempty, otherwise
491 static int exp_isrecent(int attribute((unused)) nargs,
492 char attribute((unused)) **args,
494 void attribute((unused)) *u) {
495 dcgi_lookup(DCGI_RECENT);
496 return mx_bool_result(output, !!dcgi_recent);
501 * Expands to "true" if there the newly added track list is nonempty, otherwise
504 static int exp_isnew(int attribute((unused)) nargs,
505 char attribute((unused)) **args,
507 void attribute((unused)) *u) {
508 dcgi_lookup(DCGI_NEW);
509 return mx_bool_result(output, !!dcgi_nnew);
514 * Expands to a track preference.
516 static int exp_pref(int attribute((unused)) nargs,
519 void attribute((unused)) *u) {
522 if(dcgi_client && !disorder_get(dcgi_client, args[0], args[1], &value))
523 return sink_writes(output, cgi_sgmlquote(value)) < 0 ? -1 : 0;
527 /* @prefs{TRACK}{TEMPLATE}
529 * For each track preference of track TRACK, expands TEMPLATE with the
530 * following expansions:
531 * - @name: the UNQUOTED preference name
532 * - @index: the preference number from 0
533 * - @value: the UNQUOTED preference value
534 * - @parity: "even" or "odd" alternately
535 * - @first: "true" on the first preference and "false" otherwise
536 * - @last: "true" on the last preference and "false" otherwise
538 * Use @quote to quote preference names and values where necessary; see below.
540 static int exp_prefs(int attribute((unused)) nargs,
541 const struct mx_node **args,
545 struct kvp *k, *head;
548 if((rc = mx_expandstr(args[0], &track, u, "argument #0 (TRACK)")))
550 if(!dcgi_client || disorder_prefs(dcgi_client, track, &head))
552 for(k = head, i = 0; k; k = k->next, ++i)
553 if((rc = mx_expand(mx_rewritel(args[1],
554 "index", make_index(i),
555 "parity", i % 2 ? "odd" : "even",
558 "first", k == head ? "true" : "false",
559 "last", k->next ? "false" : "true",
566 /* @transform{TRACK}{TYPE}{CONTEXT}
568 * Transforms a track name (if TYPE is "track") or directory name (if type is
569 * "dir"). CONTEXT should be the context, if it is left out then "display" is
572 static int exp_transform(int nargs,
575 void attribute((unused)) *u) {
576 const char *t = trackname_transform(args[1], args[0],
577 (nargs > 2 ? args[2] : "display"));
578 return sink_writes(output, cgi_sgmlquote(t)) < 0 ? -1 : 0;
583 * Expands to "true" if playing is enabled, otherwise "false".
585 static int exp_enabled(int attribute((unused)) nargs,
586 char attribute((unused)) **args,
588 void attribute((unused)) *u) {
592 disorder_enabled(dcgi_client, &e);
593 return mx_bool_result(output, e);
598 * Expands to "true" if random play is enabled, otherwise "false".
600 static int exp_random_enabled(int attribute((unused)) nargs,
601 char attribute((unused)) **args,
603 void attribute((unused)) *u) {
607 disorder_random_enabled(dcgi_client, &e);
608 return mx_bool_result(output, e);
611 /* @trackstate{TRACK}
613 * Expands to "playing" if TRACK is currently playing, or "queue" if it is in
614 * the queue, otherwise to nothing.
616 static int exp_trackstate(int attribute((unused)) nargs,
619 void attribute((unused)) *u) {
621 struct queue_entry *q;
625 if(disorder_resolve(dcgi_client, &track, args[0]))
627 dcgi_lookup(DCGI_PLAYING);
628 if(dcgi_playing && !strcmp(track, dcgi_playing->track))
629 return sink_writes(output, "playing") < 0 ? -1 : 0;
630 dcgi_lookup(DCGI_QUEUE);
631 for(q = dcgi_queue; q; q = q->next)
632 if(!strcmp(track, q->track))
633 return sink_writes(output, "queued") < 0 ? -1 : 0;
639 * Expands to an UNQUOTED URL which points back to the current page. (NB it
640 * might not be byte for byte identical - for instance, CGI arguments might be
643 static int exp_thisurl(int attribute((unused)) nargs,
644 char attribute((unused)) **args,
646 void attribute((unused)) *u) {
647 return sink_writes(output, cgi_thisurl(config->url)) < 0 ? -1 : 0;
652 * Expands to an UNQUOTED name for the TRACK that is not an alias, or to
653 * nothing if it is not a valid track.
655 static int exp_resolve(int attribute((unused)) nargs,
658 void attribute((unused)) *u) {
661 if(dcgi_client && !disorder_resolve(dcgi_client, &r, args[0]))
662 return sink_writes(output, r) < 0 ? -1 : 0;
668 * Expands to "true" if the playing track is paused, to "false" if it is
669 * playing (or if there is no playing track at all).
671 static int exp_paused(int attribute((unused)) nargs,
672 char attribute((unused)) **args,
674 void attribute((unused)) *u) {
675 dcgi_lookup(DCGI_PLAYING);
676 return mx_bool_result(output, (dcgi_playing
677 && dcgi_playing->state == playing_paused));
682 * Expands to the current state of track ID.
684 static int exp_state(int attribute((unused)) nargs,
687 void attribute((unused)) *u) {
688 struct queue_entry *q = dcgi_findtrack(args[0]);
691 return sink_writes(output, playing_states[q->state]) < 0 ? -1 : 0;
695 /* @right{RIGHT}{WITH-RIGHT}{WITHOUT-RIGHT}@
697 * Expands to WITH-RIGHT if the current user has right RIGHT, otherwise to
698 * WITHOUT-RIGHT. The WITHOUT-RIGHT argument may be left out.
700 * If both WITH-RIGHT and WITHOUT-RIGHT are left out then expands to "true" if
701 * the user has the right and "false" otherwise.
703 * If there is no connection to the server then expands to nothing (in all
706 static int exp_right(int nargs,
707 const struct mx_node **args,
716 dcgi_lookup(DCGI_RIGHTS);
717 if((rc = mx_expandstr(args[0], &right, u, "argument #0 (RIGHT)")))
719 if(parse_rights(right, &r, 1/*report*/))
721 /* Single-argument form */
723 return mx_bool_result(output, !!(r & dcgi_rights));
724 /* Multiple argument form */
726 return mx_expand(args[1], output, u);
728 return mx_expand(args[2], output, u);
732 /* @userinfo{PROPERTY}
734 * Expands to the named property of the current user.
736 static int exp_userinfo(int attribute((unused)) nargs,
739 void attribute((unused)) *u) {
743 && !disorder_userinfo(dcgi_client, disorder_user(dcgi_client),
745 return sink_writes(output, v) < 0 ? -1 : 0;
751 * Expands to the latest error string.
753 static int exp_error(int attribute((unused)) nargs,
754 char attribute((unused)) **args,
756 void attribute((unused)) *u) {
757 return sink_writes(output, dcgi_error_string ? dcgi_error_string : "")
763 * Expands to the latest status string.
765 static int exp_status(int attribute((unused)) nargs,
766 char attribute((unused)) **args,
768 void attribute((unused)) *u) {
769 return sink_writes(output, dcgi_status_string ? dcgi_status_string : "")
775 * Expands to the URL of the image called NAME.
777 * Firstly if there is a label called images.NAME then the image stem will be
778 * the value of that label. Otherwise the stem will be NAME.png.
780 * If the label url.static exists then it will give the base URL for images.
781 * Otherwise the base url will be /disorder/.
783 static int exp_image(int attribute((unused)) nargs,
786 void attribute((unused)) *u) {
787 const char *url, *stem;
790 /* Compute the stem */
791 byte_xasprintf(&labelname, "images.%s", args[0]);
792 if(option_label_exists(labelname))
793 stem = option_label(labelname);
795 byte_xasprintf((char **)&stem, "%s.png", args[0]);
796 /* If the stem looks like it's reasonalby complete, use that */
798 || !strncmp(stem, "http:", 5)
799 || !strncmp(stem, "https:", 6))
802 /* Compute the URL */
803 if(option_label_exists("url.static"))
804 byte_xasprintf((char **)&url, "%s/%s",
805 option_label("url.static"), stem);
807 /* Default base is /disorder */
808 byte_xasprintf((char **)&url, "/disorder/%s", stem);
810 return sink_writes(output, cgi_sgmlquote(url)) < 0 ? -1 : 0;
813 /** @brief Entry in a list of tracks or directories */
815 /** @brief Track name */
817 /** @brief Sort key */
819 /** @brief Display key */
823 /** @brief Compare two @ref entry objects */
824 static int compare_entry(const void *a, const void *b) {
825 const struct entry *ea = a, *eb = b;
827 return compare_tracks(ea->sort, eb->sort,
828 ea->display, eb->display,
829 ea->track, eb->track);
832 /** @brief Implementation of exp_tracks() and exp_dirs() */
833 static int exp__files_dirs(int nargs,
834 const struct mx_node **args,
838 int (*fn)(disorder_client *client,
843 char **tracks, *dir, *re;
845 const struct mx_node *m;
848 if((rc = mx_expandstr(args[0], &dir, u, "argument #0 (DIR)")))
851 if((rc = mx_expandstr(args[1], &re, u, "argument #1 (RE)")))
861 if(fn(dcgi_client, dir, re, &tracks, &ntracks))
863 /* Sort it. NB trackname_transform() does not go to the server. */
864 e = xcalloc(ntracks, sizeof *e);
865 for(n = 0; n < ntracks; ++n) {
866 e->track = tracks[n];
867 e[n].track = tracks[n];
868 e[n].sort = trackname_transform(type, tracks[n], "sort");
869 e[n].display = trackname_transform(type, tracks[n], "display");
871 qsort(e, ntracks, sizeof (struct entry), compare_entry);
872 /* Expand the subsiduary templates. We chuck in @sort and @display because
873 * it is particularly easy to do so. */
874 for(n = 0; n < ntracks; ++n)
875 if((rc = mx_expand(mx_rewritel(m,
876 "index", make_index(n),
877 "parity", n % 2 ? "odd" : "even",
879 "first", n == 0 ? "true" : "false",
880 "last", n + 1 == ntracks ? "false" : "true",
882 "display", e[n].display,
890 /** @tracks{DIR}{RE}{TEMPLATE}
892 * For each track below DIR, expands TEMPLATE with the
893 * following expansions:
894 * - @track: the UNQUOTED track name
895 * - @index: the track number from 0
896 * - @parity: "even" or "odd" alternately
897 * - @first: "true" on the first track and "false" otherwise
898 * - @last: "true" on the last track and "false" otherwise
899 * - @sort: the sort key for this track
900 * - @display: the UNQUOTED display string for this track
902 * RE is optional and if present is the regexp to match against.
904 static int exp_tracks(int nargs,
905 const struct mx_node **args,
908 return exp__files_dirs(nargs, args, output, u, "track", disorder_files);
911 /** @dirs{DIR}{RE}{TEMPLATE}
913 * For each directory below DIR, expands TEMPLATE with the
914 * following expansions:
915 * - @track: the UNQUOTED directory name
916 * - @index: the directory number from 0
917 * - @parity: "even" or "odd" alternately
918 * - @first: "true" on the first directory and "false" otherwise
919 * - @last: "true" on the last directory and "false" otherwise
920 * - @sort: the sort key for this directory
921 * - @display: the UNQUOTED display string for this directory
923 * RE is optional and if present is the regexp to match against.
925 static int exp_dirs(int nargs,
926 const struct mx_node **args,
929 return exp__files_dirs(nargs, args, output, u, "dir", disorder_directories);
932 static int exp__search_shim(disorder_client *c, const char *terms,
933 const char attribute((unused)) *re,
934 char ***vecp, int *nvecp) {
935 return disorder_search(c, terms, vecp, nvecp);
938 /** @search{KEYWORDS}{TEMPLATE}
940 * For each track matching KEYWORDS, expands TEMPLATE with the
941 * following expansions:
942 * - @track: the UNQUOTED directory name
943 * - @index: the directory number from 0
944 * - @parity: "even" or "odd" alternately
945 * - @first: "true" on the first directory and "false" otherwise
946 * - @last: "true" on the last directory and "false" otherwise
947 * - @sort: the sort key for this track
948 * - @display: the UNQUOTED display string for this track
950 static int exp_search(int nargs,
951 const struct mx_node **args,
954 return exp__files_dirs(nargs, args, output, u, "track", exp__search_shim);
957 static int exp_label(int attribute((unused)) nargs,
960 void attribute((unused)) *u) {
961 return sink_writes(output, option_label(args[0])) < 0 ? -1 : 0;
964 /** @brief Register DisOrder-specific expansions */
965 void dcgi_expansions(void) {
966 mx_register("arg", 1, 1, exp_arg);
967 mx_register("argq", 1, 1, exp_argq);
968 mx_register("enabled", 0, 0, exp_enabled);
969 mx_register("error", 0, 0, exp_error);
970 mx_register("image", 1, 1, exp_image);
971 mx_register("isnew", 0, 0, exp_isnew);
972 mx_register("isplaying", 0, 0, exp_isplaying);
973 mx_register("isqueue", 0, 0, exp_isqueue);
974 mx_register("isrecent", 0, 0, exp_isrecent);
975 mx_register("label", 1, 1, exp_label);
976 mx_register("length", 1, 1, exp_length);
977 mx_register("movable", 1, 2, exp_movable);
978 mx_register("part", 2, 3, exp_part);
979 mx_register("paused", 0, 0, exp_paused);
980 mx_register("pref", 2, 2, exp_pref);
981 mx_register("quote", 1, 1, exp_quote);
982 mx_register("random-enabled", 0, 0, exp_random_enabled);
983 mx_register("removable", 1, 1, exp_removable);
984 mx_register("resolve", 1, 1, exp_resolve);
985 mx_register("server-version", 0, 0, exp_server_version);
986 mx_register("state", 1, 1, exp_state);
987 mx_register("status", 0, 0, exp_status);
988 mx_register("thisurl", 0, 0, exp_thisurl);
989 mx_register("trackstate", 1, 1, exp_trackstate);
990 mx_register("transform", 2, 3, exp_transform);
991 mx_register("url", 0, 0, exp_url);
992 mx_register("user", 0, 0, exp_user);
993 mx_register("userinfo", 1, 1, exp_userinfo);
994 mx_register("version", 0, 0, exp_version);
995 mx_register("volume", 1, 1, exp_volume);
996 mx_register("when", 1, 1, exp_when);
997 mx_register("who", 1, 1, exp_who);
998 mx_register_magic("dirs", 2, 3, exp_dirs);
999 mx_register_magic("new", 1, 1, exp_new);
1000 mx_register_magic("playing", 0, 1, exp_playing);
1001 mx_register_magic("prefs", 2, 2, exp_prefs);
1002 mx_register_magic("queue", 1, 1, exp_queue);
1003 mx_register_magic("recent", 1, 1, exp_recent);
1004 mx_register_magic("right", 1, 3, exp_right);
1005 mx_register_magic("search", 2, 2, exp_search);
1006 mx_register_magic("tracks", 2, 3, exp_tracks);
1014 indent-tabs-mode:nil