chiark / gitweb /
A bit more doxygenization.
[disorder] / lib / client.c
index dc1d44ea4215c832d1f1a9e7e4264e89c86612dd..c06bdf1617a04587ff0bad706a8689843a98ce69 100644 (file)
 #include "rights.h"
 #include "trackdb.h"
 
+/** @brief Client handle contents */
 struct disorder_client {
-  FILE *fpin, *fpout;
+  /** @brief Stream to read from */
+  FILE *fpin;
+  /** @brief Stream to write to */
+  FILE *fpout;
+  /** @brief Peer description */
   char *ident;
+  /** @brief Username */
   char *user;
+  /** @brief Report errors to @c stderr */
   int verbose;
-  char *last;                          /* last error string */
+  /** @brief Last error string */
+  char *last;
 };
 
 /** @brief Create a new client
@@ -165,6 +173,10 @@ static int disorder_simple_v(disorder_client *c,
   const char *arg;
   struct dynstr d;
 
+  if(!c->fpout) {
+    error(0, "not connected to server");
+    return -1;
+  }
   if(cmd) {
     dynstr_init(&d);
     dynstr_append_string(&d, cmd);
@@ -543,6 +555,7 @@ int disorder_playing(disorder_client *c, struct queue_entry **qp) {
   return 0;
 }
 
+/** @brief Fetch the queue, recent list, etc */
 static int disorder_somequeue(disorder_client *c,
                              const char *cmd, struct queue_entry **qp) {
   struct queue_entry *qh, **qt = &qh, *q;
@@ -1135,7 +1148,13 @@ int disorder_register(disorder_client *c, const char *user,
  * @return 0 on success, non-0 on error
  */
 int disorder_confirm(disorder_client *c, const char *confirm) {
-  return disorder_simple(c, 0, "confirm", confirm, (char *)0);
+  char *u;
+  int rc;
+  
+  if(!(rc = dequote(disorder_simple(c, &u, "confirm", confirm, (char *)0),
+                   &u)))
+    c->user = u;
+  return rc;
 }
 
 /** @brief Make a cookie for this login
@@ -1156,6 +1175,15 @@ int disorder_revoke(disorder_client *c) {
   return disorder_simple(c, 0, "revoke", (char *)0);
 }
 
+/** @brief Request a password reminder email
+ * @param c Client
+ * @param user Username
+ * @return 0 on success, non-0 on error
+ */
+int disorder_reminder(disorder_client *c, const char *user) {
+  return disorder_simple(c, 0, "reminder", user, (char *)0);
+}
+
 /*
 Local Variables:
 c-basic-offset:2