Merge branch 'refs/heads/t/com_ls_compat'
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 17 Sep 2015 18:07:02 +0000 (20:07 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 17 Sep 2015 18:11:36 +0000 (20:11 +0200)
A single commit which adds support for the new syntax for the -l and -s options
of the ls command. These options should now be specified as -l=v rather than
-lv, for example. The old syntax still works, but support will be dropped in
v0.6.0.

* fdb039 Introduce new syntax for com_ls().

NEWS
afh_common.c
afs.cmd
aft.c
blob.c
configure.ac
server.h

diff --git a/NEWS b/NEWS
index 834b61fcb3b1906d88bccaae1eeea18c41fa1149..758cc3fdfdfe8dfa2817ba6f449c3f545f0bab62 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ NEWS
 -----------------------------------------
 current master branch "magnetic momentum"
 -----------------------------------------
+
+Many new features and a lot of other improvements.
+
        - On Linux systems, local sockets are now created in the
          abstract name space by default. This allows to get rid of
          the socket specials in /var/paraslash.
@@ -16,7 +19,10 @@ current master branch "magnetic momentum"
          the background if no log file is given. Instead, all log
          messages go to /dev/null in this case.
        - Web page cleanup.
-
+       - New syntax for the -l and -s options of the ls command.
+         These options should now be specified as -l=v rather than
+         -lv, for example. The old syntax still works, but support
+         will be dropped in v0.6.0.
 
 Download: ./releases/paraslash-git.tar.bz2 (tarball)
 
index 08bcde90697ec251c50ebd58abaf5f7ddf3ecff0..eb0813df1cb10d16512fd6a863d7c50cb24cba43 100644 (file)
@@ -64,7 +64,7 @@ static struct audio_format_handler afl[] = {
        },
        {
                .name = "flac",
-#ifdef HAVE_FLAC
+#if defined(HAVE_OGG) && defined(HAVE_FLAC)
                .init = flac_afh_init,
 #endif
        },
diff --git a/afs.cmd b/afs.cmd
index fb496aa5a33a383cce141359e49f0a965b117da1..07db3ccb6fadd270a8e2513f0084795e18230acd 100644 (file)
--- a/afs.cmd
+++ b/afs.cmd
@@ -287,6 +287,7 @@ N: mv@member@
 O: int com_mv@member@(struct command_context *cc);
 P: AFS_READ | AFS_WRITE
 D: Rename a blob of type @member@.
-U: mv@member@ old_@member@_name new_@member@_name
-H: Rename the blob identified by old_@member@_name to new_@member@_name.
-H: This command fails if new_@member@_name already exists.
+U: mv@member@ source_@member@_name dest_@member@_name
+H: Rename the blob identified by the source blob name to the destination blob
+H: name. The command fails if the source does not exist, or if the destination
+H: already exists.
diff --git a/aft.c b/aft.c
index cfb1f69773a73a2f6401bf2b93bfc1be21217412..102856bafd6ecf319f50d696149dc800dd1fab5a 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -1573,16 +1573,16 @@ static struct osl_row *find_hash_sister(unsigned char *hash)
 
 /** The format of the data stored by save_audio_file_data(). */
 enum com_add_buffer_offsets {
-       /** afhi (if present) starts here. */
+       /* afhi (if present) starts at this offset. */
        CAB_AFHI_OFFSET_POS = 0,
        /** Start of the chunk table (if present). */
-       CAB_CHUNKS_OFFSET_POS = 2,
-       /** Audio format id. */
-       CAB_AUDIO_FORMAT_OFFSET = 4,
+       CAB_CHUNKS_OFFSET_POS = 4,
        /** Flags given to the add command. */
-       CAB_FLAGS_OFFSET = 5,
+       CAB_FLAGS_OFFSET = 8,
+       /** Audio format id. */
+       CAB_AUDIO_FORMAT_ID_OFFSET = 12,
        /** The hash of the audio file being added. */
-       CAB_HASH_OFFSET = 9,
+       CAB_HASH_OFFSET = 13,
        /** Start of the path of the audio file. */
        CAB_PATH_OFFSET = (CAB_HASH_OFFSET + HASH_SIZE),
 };
@@ -1603,27 +1603,23 @@ static void save_add_callback_buffer(unsigned char *hash, const char *path,
        size_t size = CAB_PATH_OFFSET + path_len + afhi_size
                + sizeof_chunk_table(afhi);
        char *buf = para_malloc(size);
-       uint16_t pos;
-
-       write_u8(buf + CAB_AUDIO_FORMAT_OFFSET, audio_format_num);
-       write_u32(buf + CAB_FLAGS_OFFSET, flags);
-
-       memcpy(buf + CAB_HASH_OFFSET, hash, HASH_SIZE);
-       strcpy(buf + CAB_PATH_OFFSET, path);
+       uint32_t pos;
 
        pos = CAB_PATH_OFFSET + path_len;
-       PARA_DEBUG_LOG("size: %zu, afhi starts at %d\n", size, pos);
-       PARA_DEBUG_LOG("last afhi byte: %p, pos %zu\n", buf + pos + afhi_size - 1,
-               pos + afhi_size - 1);
-       write_u16(buf + CAB_AFHI_OFFSET_POS, pos);
+       write_u32(buf + CAB_AFHI_OFFSET_POS, pos);
        save_afhi(afhi, buf + pos);
-
        pos += afhi_size;
-       PARA_DEBUG_LOG("size: %zu, chunks start at %d\n", size, pos);
-       write_u16(buf + CAB_CHUNKS_OFFSET_POS, pos);
+
+       write_u32(buf + CAB_CHUNKS_OFFSET_POS, pos);
        if (afhi)
                save_chunk_table(afhi, buf + pos);
-       PARA_DEBUG_LOG("last byte in buf: %p\n", buf + size - 1);
+
+       write_u32(buf + CAB_FLAGS_OFFSET, flags);
+       write_u8(buf + CAB_AUDIO_FORMAT_ID_OFFSET, audio_format_num);
+
+       memcpy(buf + CAB_HASH_OFFSET, hash, HASH_SIZE);
+       strcpy(buf + CAB_PATH_OFFSET, path);
+
        obj->data = buf;
        obj->size = size;
 }
@@ -1767,8 +1763,8 @@ static void com_add_callback(int fd, const struct osl_object *query)
                        goto out;
        }
        /* no hs or force mode, child must have sent afhi */
-       afhi_offset = read_u16(buf + CAB_AFHI_OFFSET_POS);
-       chunks_offset = read_u16(buf + CAB_CHUNKS_OFFSET_POS);
+       afhi_offset = read_u32(buf + CAB_AFHI_OFFSET_POS);
+       chunks_offset = read_u32(buf + CAB_CHUNKS_OFFSET_POS);
 
        objs[AFTCOL_AFHI].data = buf + afhi_offset;
        objs[AFTCOL_AFHI].size = chunks_offset - afhi_offset;
@@ -1821,7 +1817,7 @@ static void com_add_callback(int fd, const struct osl_object *query)
                        goto out;
        }
        default_afsi.last_played = time(NULL) - 365 * 24 * 60 * 60;
-       default_afsi.audio_format_id = read_u8(buf + CAB_AUDIO_FORMAT_OFFSET);
+       default_afsi.audio_format_id = read_u8(buf + CAB_AUDIO_FORMAT_ID_OFFSET);
 
        objs[AFTCOL_AFSI].data = &afsi_buf;
        objs[AFTCOL_AFSI].size = AFSI_SIZE;
diff --git a/blob.c b/blob.c
index 0092bea3fbf47c2c5afb7ca1e1e8b3b138119d60..adfdb1a999fa53a873959d5af6b96a15ac5f6f58 100644 (file)
--- a/blob.c
+++ b/blob.c
@@ -295,7 +295,7 @@ static void com_rmblob_callback(struct osl_table *table, int fd,
                ret2 = para_printf(&rmbd.pb, "no matches, nothing removed\n");
        else {
                ret2 = para_printf(&rmbd.pb, "removed %d blobs\n", pmd.num_matches);
-               afs_event(BLOB_RENAME, NULL, table);
+               afs_event(BLOB_REMOVE, NULL, table);
        }
 out:
        if (ret2 >= 0 && rmbd.pb.offset)
index 2edabc86d6e1deb28a3df7edbb668d0a12c73c8b..a30b0c209bf138429d8ef823c07712533952a9f5 100644 (file)
@@ -53,7 +53,7 @@ AC_DEFUN([UNSTASH_FLAGS], [
        LIBS="$OLD_LIBS"
 ])
 AC_DEFUN([LIB_SUBST_FLAGS], [
-       if test "$HAVE_[]m4_toupper([$1])" == 'yes'; then
+       if test "$HAVE_[]m4_toupper([$1])" = 'yes'; then
                AC_DEFINE(HAVE_[]m4_toupper([$1]), 1,
                        define to 1 to turn on $1 support)
        else
index 93fd558cd7636db5ee0fe6c3ded7a053ab9d3a2e..8de691ca321bd49db2d7c25398537f31b7d03a0c 100644 (file)
--- a/server.h
+++ b/server.h
@@ -34,20 +34,18 @@ struct sender_command_data {
 };
 
 /**
- * Used for parent-child communication.
+ * Miscellaneous data for communication between server and command handlers.
  *
- * There's only one struct of this type which lives in shared memory
- * for communication between the server instances. Access to this
- * area is serialized via mmd_lock() and mmd_unlock(). There are two
- * reasons for a variable to be included here:
+ * There's only one instance of this structure which lives in a shared memory
+ * area. Command handlers communicate with the server process through this
+ * area. Changes made by the command handlers stay after the command handler
+ * exits. Conversely, changes made by the server process propagate to the
+ * command handlers. Access to this area is serialized via mmd_lock() and
+ * mmd_unlock().
  *
- *     - At least one command (i.e. child of the server) must be able to
- *     change its value.
- *
- * or
- *
- *     - The contents are listed in the stat command and have to be up to
- *     date.
+ * There are two reasons for a variable to be included here: (a) at least one
+ * command handler changes its value, or (b) updates by the server must
+ * propagate to the stat command handlers.
  */
 struct misc_meta_data {
        /** The size of the current audio file in bytes. */
@@ -56,11 +54,11 @@ struct misc_meta_data {
        unsigned int vss_status_flags;
        /** The new status flags -- commands may set them. */
        unsigned int new_vss_status_flags;
-       /** The number of data chunks sent for the current audio file. */
+       /** The number of data chunks sent so far. */
        long unsigned chunks_sent;
        /** Set by the jmp/ff commands to the new position in chunks. */
        long unsigned repos_request;
-       /** The number of the chunk currently sent out. */
+       /** The number of the chunk currently being sent. */
        long unsigned current_chunk;
        /** The milliseconds that have been skipped of the current audio file. */
        long offset;
@@ -69,8 +67,8 @@ struct misc_meta_data {
        /**
         * The event counter.
         *
-        * Commands may increase this to force a status update to be sent to all
-        * connected clients.
+        * Commands may increase this to force a status update to be sent to
+        * all connected stat clients.
         */
        unsigned int events;
        /** The number of audio files already sent. */