*/
disorder_client *client;
+/** @brief For error template */
+char *error_string;
+
/** @brief Cached data */
static unsigned flags;
return s;
}
-/* @server-version@
+/* @server-version
*
* Expands to the server's version string, or a (safe to use) error
* value if the server is unavailable or broken.
return sink_write(output, cgi_sgmlquote(v)) < 0 ? -1 : 0;
}
-/* @version@
+/* @version
*
* Expands to the local version string.
*/
cgi_sgmlquote(disorder_short_version_string)) < 0 ? -1 : 0;
}
-/* @url@
+/* @url
*
* Expands to the base URL of the web interface.
*/
cgi_sgmlquote(config->url)) < 0 ? -1 : 0;
}
-/* @arg{NAME}@
+/* @arg{NAME}
*
* Expands to the CGI argument NAME, or the empty string if there is
* no such argument.
return 0;
}
-/* @user@
+/* @user
*
* Expands to the logged-in username (which might be "guest"), or to
* the empty string if not connected.
return sink_write(output, " ") < 0 ? -1 : 0;
}
-/* @removable{ID}@
+/* @removable{ID}
*
* Expands to "true" if track ID is removable (or scratchable, if it is the
* playing track) and "false" otherwise.
(rights, disorder_user(client), q));
}
-/* @movable{ID}@
+/* @movable{ID}
*
* Expands to "true" if track ID is movable and "false" otherwise.
*/
return 0;
}
-/* @volume{CHANNEL}@
+/* @volume{CHANNEL}
*
* Expands to the volume in a given channel. CHANNEL must be "left" or
* "right".
? volume_left : volume_right) < 0 ? -1 : 0;
}
-/* @isplaying@
+/* @isplaying
*
* Expands to "true" if there is a playing track, otherwise "false".
*/
return mx_bool_result(output, !!playing);
}
-/* @isqueue@
+/* @isqueue
*
* Expands to "true" if there the queue is nonempty, otherwise "false".
*/
return mx_bool_result(output, !!recent);
}
-/* @isnew@
+/* @isnew
*
* Expands to "true" if there the newly added track list is nonempty, otherwise
* "false".
return mx_bool_result(output, !!nnew);
}
-/* @pref{TRACK}{KEY}@
+/* @pref{TRACK}{KEY}
*
* Expands to a track preference.
*/
return sink_write(output, cgi_sgmlquote(value)) < 0 ? -1 : 0;
}
-/* @prefs{TRACK}{TEMPLATE}@
+/* @prefs{TRACK}{TEMPLATE}
*
* For each track preference of track TRACK, expands TEMPLATE with the
* following expansions:
return 0;
}
-/* @transform{TRACK}{TYPE}{CONTEXT}@
+/* @transform{TRACK}{TYPE}{CONTEXT}
*
* Transforms a track name (if TYPE is "track") or directory name (if type is
* "dir"). CONTEXT should be the context, if it is left out then "display" is
return mx_bool_result(output, enabled);
}
-/* @random-enabled@
+/* @random-enabled
*
* Expands to "true" if random play is enabled, otherwise "false".
*/
return mx_bool_result(output, enabled);
}
-/* @trackstate{TRACK}@
+/* @trackstate{TRACK
*
* Expands to "playing" if TRACK is currently playing, or "queue" if it is in
* the queue, otherwise to nothing.
return 0;
}
-/* @thisurl@
+/* @thisurl
*
* Expands to an UNQUOTED URL which points back to the current page. (NB it
* might not be byte for byte identical - for instance, CGI arguments might be
return cgi_thisurl(config->url);
}
-/* @resolve{TRACK}@
+/* @resolve{TRACK}
*
* Expands to an UNQUOTED name for the TRACK that is not an alias, or to
* nothing if it is not a valid track.
return 0;
}
-/* @paused@
+/* @paused
*
* Expands to "true" if the playing track is paused, to "false" if it is
* playing (or if there is no playing track at all).
return 0;
}
-/* @userinfo{PROPERTY}@
+/* @userinfo{PROPERTY}
*
* Expands to the named property of the current user.
*/
return 0;
}
+/* @error
+ *
+ * Expands to the latest error string.
+ */
+static int exp_error(int attribute((unused)) nargs,
+ char attribute((unused)) **args,
+ struct sink *output,
+ void attribute((unused)) *u) {
+ return sink_write(output, cgi_sgmlquote(error_string)) < 0 ? -1 : 0;
+}
+
+/* @userinfo{PROPERTY}@
+ *
/** @brief Register DisOrder-specific expansions */
void register_disorder_expansions(void) {
mx_register(exp_arg, 1, 1, "arg");
mx_register(exp_enabled, 0, 0, "enabled");
+ mx_register(exp_error, 0, 0, "error");
mx_register(exp_isnew, 0, 0, "isnew");
mx_register(exp_isplaying, 0, 0, "isplaying");
mx_register(exp_isqueue, 0, 0, "isplaying");
mx_register_magic(exp_recent, 1, 1, "recent");
}
+void disorder_macros_reset(void) {
+ /* Junk the old connection if there is one */
+ if(client)
+ disorder_close(client);
+ /* Create a new connection */
+ client = disorder_new(0);
+ /* Forget everything we knew */
+ flags = 0;
+}
+
/*
Local Variables:
c-basic-offset:2