Merge branch 'refs/heads/t/command_handler_cleanups'
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 25 Oct 2015 15:06:43 +0000 (16:06 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 25 Oct 2015 15:11:14 +0000 (16:11 +0100)
Cooking for about two months.

* refs/heads/t/command_handler_cleanups: (39 commits)
  com_addatt(): Return negative on errors
  com_rm(): In force mode, don't complain if no paths matched.
  aft: Unify handling of hash and path duplicates.
  afs: Provide pbout para_buffer for each callback.
  afs: Make afs callbacks more flexible.
  afs: Rename callback_function to afs_callback.
  com_check(): Add attribute checking.
  Let afs_event() return int.
  playlist_check_callback(): Return negative on errors
  mood_check_callback(): Return negative on errors
  com_mvblob(): Return negative on errors
  com_addblob(): Return negative on errors
  com_rmblob(): Return negative on errors, cleanup
  com_catblob(): Return negative on errors
  com_lsblob(): Return negative on errors
  rmatt: Cleanup callback.
  com_rmatt(): Return negative on errors
  com_mvatt(): Return negative on errors
  com_lsatt(): Return negative on errors
  com_init(): Return negative on errors
  ...

1  2 
NEWS
afs.cmd
aft.c
attribute.c
audiod_command.c
blob.c
command.c
error.h
mood.c

diff --cc NEWS
index f1940d3d0780e428816f7c3f241273a795cce04e,834b61fcb3b1906d88bccaae1eeea18c41fa1149..7faa0dddfd6c08954a03b3ef79d768dc14014d6e
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -1,19 -1,9 +1,24 @@@
  NEWS
  ====
  
 ------------------------------------------
 -current master branch "magnetic momentum"
 ------------------------------------------
 +------------------------------------------
 +current master branch "cascading gradient"
 +------------------------------------------
 +
 +      - para_afh learned to modify meta tags of mp3 wma ogg spx
 +        opus flac aac files.
++      - afs commands propagate error codes to the client.
++      - The check command now also checks the attribute table for
++        inconsistencies.
++      - New -v flag for the version command (print verbose version string)
++
 +
 +--------------------------------------
 +0.5.5 (2015-09-20) "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.
diff --cc afs.cmd
Simple merge
diff --cc aft.c
index f2c1edab75c49125b6939c031e24ad28cf0e74cf,a5da1a929e8c5c34920aab8d798d1a7f64cb3e68..8a8e5282576dec0f3319bb98685bd0e1df9767c5
--- 1/aft.c
--- 2/aft.c
+++ b/aft.c
@@@ -1800,17 -1723,16 +1722,16 @@@ static int com_add_callback(struct afs_
                        &objs[AFTCOL_CHUNKS]));
                if (ret < 0)
                        goto out;
-               afs_event(AFHI_CHANGE, &msg, row);
-               goto out;
-       }
-       /* new entry, use default afsi */
-       if (flags & ADD_FLAG_VERBOSE) {
-               ret = para_printf(&msg, "new file\n");
+               ret = afs_event(AFHI_CHANGE, &aca->pbout, row);
                if (ret < 0)
                        goto out;
+               goto out;
        }
+       /* new entry, use default afsi */
+       if (flags & ADD_FLAG_VERBOSE)
+               para_printf(&aca->pbout, "new file\n");
        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;
@@@ -2560,9 -2415,8 +2414,9 @@@ static int com_setatt_callback(struct a
        if (!cad.add_mask && !cad.del_mask)
                goto out;
        pmd.patterns.data = p;
-       if (p >= (char *)query->data + query->size)
 -      assert(p < (char *)aca->query.data + aca->query.size);
++      if (p >= (char *)aca->query.data + aca->query.size)
 +              goto out;
-       pmd.patterns.size = (char *)query->data + query->size - p;
+       pmd.patterns.size = (char *)aca->query.data + aca->query.size - p;
        ret = for_each_matching_row(&pmd);
        if (ret < 0)
                goto out;
diff --cc attribute.c
index d74ec92839c2c3753ebadf1caf2a06d2f109645e,e3bd40b5425261c97bdf3ed31700ac52ae83884e..f3f8ea7a45d0fb1136827cc19c8a715fdd3773a6
@@@ -135,49 -129,45 +129,45 @@@ static int print_attribute(struct osl_t
        struct osl_object bitnum_obj;
        int ret;
  
-       if (!(laad->flags & LSATT_FLAG_LONG))
-               return para_printf(&laad->pb, "%s\n", name);
+       if (!(flags & LSATT_FLAG_LONG)) {
+               para_printf(&aca->pbout, "%s\n", name);
+               return 1;
+       }
        ret = osl(osl_get_object(table, row, ATTCOL_BITNUM, &bitnum_obj));
        if (ret < 0) {
-               para_printf(&laad->pb, "%s: %s\n", name, para_strerror(-ret));
+               para_printf(&aca->pbout, "%s: %s\n", name, para_strerror(-ret));
                return ret;
        }
-       return para_printf(&laad->pb, "%u\t%s\n", *(unsigned char*)bitnum_obj.data,
+       para_printf(&aca->pbout, "%u\t%s\n", *(unsigned char*)bitnum_obj.data,
                name);
+       return 1;
  }
  
- static void com_lsatt_callback(int fd, const struct osl_object *query)
+ static int com_lsatt_callback(struct afs_callback_arg *aca)
  {
-       struct lsatt_action_data laad = {
-               .flags = *(unsigned *) query->data,
-               .pb = {
-                       .max_size = shm_get_shmmax(),
-                       .private_data = &(struct afs_max_size_handler_data) {
-                               .fd = fd,
-                               .band = SBD_OUTPUT
-                       },
-                       .max_size_handler = afs_max_size_handler
-               }
-       };
+       unsigned flags = *(unsigned *)aca->query.data;
+       int ret;
        struct pattern_match_data pmd = {
                .table = attribute_table,
 -              .loop_col_num = ATTCOL_BITNUM,
 +              .loop_col_num = ATTCOL_NAME,
                .match_col_num = ATTCOL_NAME,
-               .patterns = {.data = (char *)query->data + sizeof(laad.flags),
-                       .size = query->size - sizeof(laad.flags)},
+               .patterns = {.data = (char *)aca->query.data + sizeof(flags),
+                       .size = aca->query.size - sizeof(flags)},
                .pm_flags = PM_NO_PATTERN_MATCHES_EVERYTHING,
-               .data = &laad,
+               .data = aca,
                .action = print_attribute
        };
-       if (laad.flags & LSATT_FLAG_SORT_BY_ID)
+       if (flags & LSATT_FLAG_SORT_BY_ID)
 -              pmd.loop_col_num = ATTCOL_NAME;
 +              pmd.loop_col_num = ATTCOL_BITNUM;
-       if (laad.flags & LSATT_FLAG_REVERSE)
+       if (flags & LSATT_FLAG_REVERSE)
                pmd.pm_flags |= PM_REVERSE_LOOP;
-       for_each_matching_row(&pmd);
-       if (laad.pb.offset)
-               pass_buffer_as_shm(fd, SBD_OUTPUT, laad.pb.buf, laad.pb.offset);
-       free(laad.pb.buf);
+       ret = for_each_matching_row(&pmd);
+       if (ret < 0)
+               goto out;
+       if (pmd.num_matches == 0)
+               ret = -E_NO_MATCH;
+ out:
+       return ret;
  }
  
  int com_lsatt(struct command_context *cc)
Simple merge
diff --cc blob.c
index adfdb1a999fa53a873959d5af6b96a15ac5f6f58,1a411823ea25aa9ad46fc644da27175e90e8d4be..2e0a4762bfd1e34d0f12c7a9b2d4de582c8316d4
--- 1/blob.c
--- 2/blob.c
+++ b/blob.c
@@@ -286,24 -257,20 +257,20 @@@ static int com_rmblob_callback(struct o
                .action = remove_blob
        };
        ret = for_each_matching_row(&pmd);
-       if (ret < 0) {
-               ret2 = para_printf(&rmbd.pb, "%s\n", para_strerror(-ret));
-               if (ret2 < 0)
-                       goto out;
-       }
+       if (ret < 0)
+               goto out;
        if (pmd.num_matches == 0)
-               ret2 = para_printf(&rmbd.pb, "no matches, nothing removed\n");
+               ret = -E_NO_MATCH;
        else {
-               ret2 = para_printf(&rmbd.pb, "removed %d blobs\n", pmd.num_matches);
-               afs_event(BLOB_REMOVE, NULL, table);
+               para_printf(&aca->pbout, "removed %d blob(s)\n",
+                       pmd.num_matches);
 -              ret = afs_event(BLOB_RENAME, NULL, table);
++              ret = afs_event(BLOB_REMOVE, NULL, table);
        }
  out:
-       if (ret2 >= 0 && rmbd.pb.offset)
-               pass_buffer_as_shm(fd, SBD_OUTPUT, rmbd.pb.buf, rmbd.pb.offset);
-       free(rmbd.pb.buf);
+       return ret;
  }
  
- static int com_rmblob(callback_function *f, struct command_context *cc)
+ static int com_rmblob(afs_callback *f, struct command_context *cc)
  {
        if (cc->argc < 2)
                return -E_MOOD_SYNTAX;
diff --cc command.c
Simple merge
diff --cc error.h
Simple merge
diff --cc mood.c
Simple merge