chiark / gitweb /
Merge the Disobedience rewrite.
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 15 Jun 2008 17:25:23 +0000 (18:25 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 15 Jun 2008 17:25:23 +0000 (18:25 +0100)
1  2 
configure.ac
lib/trackdb.c

diff --combined configure.ac
index 03ba3844c58fafdfe9a44caaf05b33a9285742fc,44ca4b2683252fa622181ce6ba255f4116c38138..2522f453433301c88ceb73e4987be4963ae3dc06
@@@ -20,9 -20,9 +20,9 @@@
  # USA
  #
  
 -AC_INIT([disorder], [3.0+], [richard+disorder@sfere.greenend.org.uk])
 +AC_INIT([disorder], [4.0+], [richard+disorder@sfere.greenend.org.uk])
  AC_CONFIG_AUX_DIR([config.aux])
 -AM_INIT_AUTOMAKE(disorder, [3.0+])
 +AM_INIT_AUTOMAKE(disorder, [4.0+])
  AC_CONFIG_SRCDIR([server/disorderd.c])
  AM_CONFIG_HEADER([config.h])
  
@@@ -46,6 -46,13 +46,13 @@@ AC_PROG_C
  AC_SET_MAKE
  if test "x$GCC" = xyes; then
    gcc_werror=-Werror
+   case "$CC" in
+   *-std=* )
+     ;;
+   * )
+     CC="${CC} -std=gnu99"
+     ;;
+   esac
  else
    AC_MSG_ERROR([GNU C is required to build this program])
    gcc_werror=""
@@@ -219,18 -226,14 +226,18 @@@ if test $want_cgi = yes; the
          fi
        done
      ])
 -    if test "$rjk_cv_cgidir" = "not found"; then
 +    if test "$rjk_cv_cgiexecdir" = "not found"; then
        AC_MSG_ERROR([cannot identify httpd documentroot.  Set httpdir on configure command line])
      fi
      httpdir="$rjk_cv_httpdir"
    fi
 -  if test -z "$cgidir"; then
 -    AC_CACHE_CHECK([for CGI directory],[rjk_cv_cgidir],[
 -      rjk_cv_cgidir="not found"
 +  if test ! -z "$cgidir"; then
 +    # This is a bit harsh but should stop any disasters
 +    AC_MSG_ERROR([cgidir has been renamed to cgiexecdir])
 +  fi
 +  if test -z "$cgiexecdir"; then
 +    AC_CACHE_CHECK([for CGI directory],[rjk_cv_cgiexecdir],[
 +      rjk_cv_cgiexecdir="not found"
        for dir in /usr/lib/cgi-bin \
                   /Library/WebServer/CGI-Executables \
                   /srv/www/cgi-bin \
                   /usr/local/www/cgi-bin \
                   /usr/local/www/*/cgi-bin; do
          if test -d "$dir"; then
 -          rjk_cv_cgidir="$dir"
 +          rjk_cv_cgiexecdir="$dir"
            break
          fi
        done
      ])
 -    if test "$rjk_cv_cgidir" = "not found"; then
 -      AC_MSG_ERROR([cannot identify CGI install directory.  Set cgidir on configure command line])
 +    if test "$rjk_cv_cgiexecdir" = "not found"; then
 +      AC_MSG_ERROR([cannot identify CGI install directory.  Set cgiexecdir on configure command line])
      fi
 -    cgidir="$rjk_cv_cgidir"
 +    cgiexecdir="$rjk_cv_cgiexecdir"
    fi
  fi
 -AC_ARG_VAR([cgidir], [location of cgi-bin directory, e.g. /usr/lib/cgi-bin])
 +AC_ARG_VAR([cgiexecdir], [location of cgi-bin directory, e.g. /usr/lib/cgi-bin])
  AC_ARG_VAR([httpdir], [location of http document root, e.g. /var/www/htdocs])
  if test -z "$pkghttpdir"; then
    pkghttpdir='$(httpdir)/disorder'
diff --combined lib/trackdb.c
index 56a8e8d3d72c824f4a4ab1a0169dfa9c54fc5724,42871046a4a68aea6a5dfa1730615bacb6354a17..3647f1068639ea755a4e63c8a505f5798a6f594c
@@@ -1852,7 -1852,7 +1852,7 @@@ static int do_list(struct vector *v, co
    char *ptr;
    int err;
    size_t l, last_dir_len = 0;
 -  char *last_dir = 0, *track, *alias;
 +  char *last_dir = 0, *track;
    struct kvp *p;
  
    dl = strlen(dir);
          if((err = trackdb_getdata(trackdb_prefsdb,
                                    track, &p, tid)) == DB_LOCK_DEADLOCK)
            goto deadlocked;
 +        /* There's an awkward question here...
 +         *
 +         * If a track shares a directory with its alias then we could
 +         * do one of three things:
 +         * - report both.  Looks ridiculuous in most UIs.
 +         * - report just the alias.  Remarkably inconvenient to write
 +         *   UI code for!
 +         * - report just the real name.  Ugly if the UI doesn't prettify
 +         *   names via the name parts.
 +         */
 +#if 1
 +        /* If this file is an alias for a track in the same directory then we
 +         * skip it */
 +        struct kvp *t = kvp_urldecode(d.data, d.size);
 +        const char *alias_target = kvp_get(t, "_alias_for");
 +        if(!(alias_target
 +             && !strcmp(d_dirname(alias_target),
 +                        d_dirname(track))))
 +        if(track_matches(dl, k.data, k.size, re))
 +          vector_append(v, track);
 +#else
        /* if this file has an alias in the same directory then we skip it */
 +           char *alias;
          if((err = compute_alias(&alias, track, p, tid)))
            goto deadlocked;
          if(!(alias && !strcmp(d_dirname(alias), d_dirname(track))))
          if(track_matches(dl, k.data, k.size, re))
            vector_append(v, track);
 +#endif
        }
      }
      err = cursor->c_get(cursor, &k, &d, DB_NEXT);
@@@ -2406,6 -2383,9 +2406,9 @@@ char **trackdb_new(int *ntracksp
   * @return null-terminated array of track names, or NULL on deadlock
   *
   * The most recently added track is first in the array.
+  *
+  * TODO: exclude tracks that have been deleted again.
+  *
   */
  static char **trackdb_new_tid(int *ntracksp,
                                int maxtracks,
@@@ -2701,6 -2681,7 +2704,7 @@@ int trackdb_adduser(const char *user
             user, rights, email);
      else
        info("created user '%s' with rights '%s'", user, rights);
+     eventlog("user_add", user, (char *)0);
      return 0;
    }
  }
@@@ -2718,6 -2699,7 +2722,7 @@@ int trackdb_deluser(const char *user) 
      return -1;
    }
    info("deleted user '%s'", user);
+   eventlog("user_delete", user, (char *)0);
    return 0;
  }
  
@@@ -2797,8 -2779,10 +2802,10 @@@ int trackdb_edituserinfo(const char *us
    if(e) {
      error(0, "unknown user '%s'", user);
      return -1;
-   } else
+   } else {
+     eventlog("user_edit", user, key, (char *)0);
      return 0;
+   }
  }
  
  /** @brief List all users
@@@ -2864,6 -2848,7 +2871,7 @@@ int trackdb_confirm(const char *user, c
    switch(e) {
    case 0:
      info("registration confirmed for user '%s'", user);
+     eventlog("user_confirm", user, (char *)0);
      return 0;
    case DB_NOTFOUND:
      error(0, "confirmation for nonexistent user '%s'", user);