]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 'afh_cleanup' into next.
authorAndre Noll <maan@systemlinux.org>
Sat, 4 Jul 2009 15:15:50 +0000 (17:15 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 4 Jul 2009 15:15:50 +0000 (17:15 +0200)
Quite a few conflicts, but no real problem. git rerere rulez!

Conflicts:
afs.c
afs.cmd
aft.c
attribute.c
audiod_command.c
blob.c
command.c
para.h
server.c
server.cmd
stat.c

20 files changed:
1  2 
Makefile.in
aac_afh.c
afs.c
afs.cmd
afs.h
aft.c
attribute.c
audiod.c
blob.c
command.c
configure.ac
error.h
mp3_afh.c
ogg_afh.c
para.h
send_common.c
server.c
server.cmd
string.c
string.h

diff --cc Makefile.in
Simple merge
diff --cc aac_afh.c
index 80b50a4d55b6645aba8331c562b3667dc42663f7,68f17c275119c8673a12987e449543b3d214f09d..04461178bb7912e3fb893cc5cf0215d39f965368
+++ b/aac_afh.c
  
  /** \file aac_afh.c para_server's aac audio format handler */
  
+ #include <osl.h>
++
  #include "para.h"
  #include "error.h"
--#include "string.h"
  #include "afh.h"
--#include "afs.h"
--#include "server.h"
++#include "string.h"
  #include "aac.h"
  
  static int aac_find_stsz(unsigned char *buf, size_t buflen, off_t *skip)
diff --cc afs.c
index c89e3cec68ce835d44b803ce1fc144948ab9d8e1,6cbc744d71c2c65fea67968ff8f37fd40d530c1f..b40fe8e05c943eb503b3a2344fc1287db81b3696
--- 1/afs.c
--- 2/afs.c
+++ b/afs.c
@@@ -8,8 -8,7 +8,9 @@@
  
  #include <signal.h>
  #include <fnmatch.h>
 +#include <openssl/rc4.h>
+ #include <osl.h>
 +
  #include "server.cmdline.h"
  #include "para.h"
  #include "error.h"
diff --cc afs.cmd
index 3173404623ccd5768753bfe4773eb1eb6a834221,293b5b7e2c5a7d54b9a0e1e99228728a2b7fd26d..c55dfe71ed0566d2797653e8fe05a9835b98687a
+++ b/afs.cmd
@@@ -3,8 -3,8 +3,8 @@@ SF: afs.c aft.c attribute.
  HC: Prototypes for the commands of the audio file selector.
  CC: Array of commands for the audio file selector.
  AT: server_command
- SI: openssl/rc4
 -SI: osl
 -IN: para error string afh afs server list user_list
++SI: openssl/rc4 osl
 +IN: para error crypt command string afh afs server list user_list
  SN: list of afs commands
  TM: mood lyr img pl
  ---
diff --cc afs.h
index edeb348e33b05d57981fbf34013a142ed8d3df68,d25b7043df22b75b214b9bf33f35ce3eee31cea1..bfafd949e7b26fb434e07e43434f276680c07fce
--- 1/afs.h
--- 2/afs.h
+++ b/afs.h
@@@ -118,10 -117,7 +117,7 @@@ struct ls_data 
        HASH_TYPE *hash;
  };
  
- void make_empty_status_items(char *buf);
- /** At most that many bytes will be passed from afs to para_server. */
- #define VERBOSE_LS_OUTPUT_SIZE 4096
 -int send_afs_status(int fd, int parser_friendly);
++int send_afs_status(struct rc4_context *rc4c, int parser_friendly);
  
  /** Data about the current audio file, passed from afs to server. */
  struct audio_file_data {
diff --cc aft.c
index e5409244c5a626204cb1e645ae52b903f2a49448,5ad5d8f06583bea878c6d29b9f1158d19062f741..daa9a500a7712d01731fcadb577f509060768ea4
--- 1/aft.c
--- 2/aft.c
+++ b/aft.c
@@@ -7,11 -7,9 +7,12 @@@
  /** \file aft.c Audio file table functions. */
  
  #include <dirent.h> /* readdir() */
 +#include <openssl/rc4.h>
 +
+ #include <osl.h>
  #include "para.h"
  #include "error.h"
 +#include "crypt.h"
  #include "string.h"
  #include <sys/mman.h>
  #include <fnmatch.h>
@@@ -805,26 -853,20 +858,25 @@@ static int print_list_item(struct ls_da
                goto out;
        }
        get_attribute_bitmap(&afsi->attributes, att_buf);
 -      ret = get_local_time(&afsi->last_played, last_played_time,
 -              sizeof(last_played_time), current_time, opts->mode);
 -      if (ret < 0)
 -              goto out;
 +      if (opts->flags & LS_FLAG_UNIXDATE)
 +              sprintf(last_played_time, "%llu",
 +                      (long long unsigned)afsi->last_played);
 +      else {
 +              ret = get_local_time(&afsi->last_played, last_played_time,
 +                      sizeof(last_played_time), current_time, opts->mode);
 +              if (ret < 0)
 +                      goto out;
 +      }
        get_duration_buf(afhi->seconds_total, duration_buf, opts);
-       if (have_score) {
-               if (opts->mode == LS_MODE_LONG)
-                       sprintf(score_buf, "%*li ", w->score_width, d->score);
-               else
-                       sprintf(score_buf, "%li ", d->score);
-       }
        if (opts->mode == LS_MODE_LONG) {
+               struct ls_widths *w = &opts->widths;
+               if (opts->flags & LS_FLAG_ADMISSIBLE_ONLY) {
+                       ret = para_printf(b, "%*li ",
+                               opts->widths.score_width, d->score);
+                       if (ret < 0)
+                               goto out;
+               }
                ret = para_printf(b,
-                       "%s"    /* score */
                        "%s "   /* attributes */
                        "%*u "  /* amp */
                        "%*d "  /* image_id  */
@@@ -2469,6 -2420,25 +2435,25 @@@ int com_cpsi(struct rc4_context *rc4c, 
        return ret;
  }
  
 -int send_afs_status(int fd, int parser_friendly)
+ void afs_stat_callback(int fd, const struct osl_object *query)
+ {
+       int *parser_friendly = query->data;
+       char *buf = *parser_friendly?
+               parser_friendly_status_items : status_items;
+       if (!buf)
+               return;
+       pass_buffer_as_shm(buf, strlen(buf), &fd);
+ }
 -      return send_callback_request(afs_stat_callback, &query, send_result, &fd);
++int send_afs_status(struct rc4_context *rc4c, int parser_friendly)
+ {
+       struct osl_object query = {.data = &parser_friendly,
+               .size = sizeof(parser_friendly)};
++      return send_callback_request(afs_stat_callback, &query, rc4_send_result, rc4c);
+ }
  /* TODO: optionally fix problems by removing offending rows */
  static int check_audio_file(struct osl_row *row, void *data)
  {
diff --cc attribute.c
index ff284c3ad7e7822b136e7b788c8f13d17c40888b,dc375c1d8dc57aea4e5ed06c7bfdf6092fa16880..41a10058d9358463713006aaf6c4b9257375e587
@@@ -5,12 -5,9 +5,13 @@@
   */
  
  /** \file attribute.c Attribute handling functions. */
 +
 +#include <openssl/rc4.h>
+ #include <osl.h>
 +
  #include "para.h"
  #include "error.h"
 +#include "crypt.h"
  #include "string.h"
  #include "afh.h"
  #include "afs.h"
diff --cc audiod.c
Simple merge
diff --cc blob.c
index 5905c9ad660cd93360fe77ef50ff81c4fe2a39df,b4ac2fa4a0954f8b687e1d27f7f07b1341767c79..38e5cb54df04ad3a0600ac893e108a71446eb6da
--- 1/blob.c
--- 2/blob.c
+++ b/blob.c
@@@ -7,11 -7,9 +7,12 @@@
  /** \file blob.c Macros and functions for blob handling. */
  
  #include <fnmatch.h>
 +#include <openssl/rc4.h>
+ #include <osl.h>
 +
  #include "para.h"
  #include "error.h"
 +#include "crypt.h"
  #include "string.h"
  #include "afh.h"
  #include "afs.h"
diff --cc command.c
index fc5b5cace3c8e51e4ef1560c4c813131f7966020,17132e872fb265096fec0d57b9428e1bd78e387a..fa844b5ed2213bb8dc00777c18d25e9659b36e19
+++ b/command.c
@@@ -294,27 -290,109 +280,109 @@@ int com_version(struct rc4_context *rc4
        );
  }
  
+ #define EMPTY_STATUS_ITEMS \
+       ITEM(PATH) \
+       ITEM(DIRECTORY) \
+       ITEM(BASENAME) \
+       ITEM(SCORE) \
+       ITEM(ATTRIBUTES_BITMAP) \
+       ITEM(ATTRIBUTES_TXT) \
+       ITEM(HASH) \
+       ITEM(IMAGE_ID) \
+       ITEM(IMAGE_NAME) \
+       ITEM(LYRICS_ID) \
+       ITEM(LYRICS_NAME) \
+       ITEM(BITRATE) \
+       ITEM(FORMAT) \
+       ITEM(FREQUENCY) \
+       ITEM(CHANNELS) \
+       ITEM(DURATION) \
+       ITEM(SECONDS_TOTAL) \
+       ITEM(NUM_PLAYED) \
+       ITEM(LAST_PLAYED) \
+       ITEM(TECHINFO) \
+       ITEM(ARTIST) \
+       ITEM(TITLE) \
+       ITEM(YEAR) \
+       ITEM(ALBUM) \
+       ITEM(COMMENT) \
+       ITEM(AMPLIFICATION)
+ /**
+  * Write a list of audio-file related status items with empty values.
+  *
+  * This is used by vss when currently no audio file is open.
+  */
+ static char *empty_status_items(int parser_friendly)
+ {
+       if (parser_friendly)
+               return make_message(
+                       #define ITEM(x) "0004 %02x:\n"
+                       EMPTY_STATUS_ITEMS
+                       #undef ITEM
+                       #define ITEM(x) , SI_ ## x
+                       EMPTY_STATUS_ITEMS
+                       #undef ITEM
+               );
+       return make_message(
+               #define ITEM(x) "%s:\n"
+               EMPTY_STATUS_ITEMS
+               #undef ITEM
+               #define ITEM(x) ,status_item_list[SI_ ## x]
+               EMPTY_STATUS_ITEMS
+               #undef ITEM
+       );
+ }
+ #undef EMPTY_STATUS_ITEMS
  /* stat */
 -int com_stat(int fd, int argc, char * const * argv)
 +int com_stat(struct rc4_context *rc4c, int argc, char * const * argv)
  {
-       int ret, num = 0;/* status will be printed that many
-                         * times. num <= 0 means: print forever
-                         */
+       int i, ret;
        struct misc_meta_data tmp, *nmmd = &tmp;
        char *s;
+       int32_t num = 0;
+       int parser_friendly = 0;
  
        para_sigaction(SIGUSR1, dummy);
  
-       if (argc > 1)
-               num = atoi(argv[1]);
+       for (i = 1; i < argc; i++) {
+               const char *arg = argv[i];
+               if (arg[0] != '-')
+                       break;
+               if (!strcmp(arg, "--")) {
+                       i++;
+                       break;
+               }
+               if (!strncmp(arg, "-n=", 3)) {
+                       ret = para_atoi32(arg + 3, &num);
+                       if (ret < 0)
+                               return ret;
+                       continue;
+               }
+               if (!strcmp(arg, "-p")) {
+                       parser_friendly = 1;
+                       continue;
+               }
+       }
+       if (i != argc)
+               return -E_COMMAND_SYNTAX;
        for (;;) {
                mmd_dup(nmmd);
-               s = get_status(nmmd);
+               s = get_status(nmmd, parser_friendly);
 -              ret = send_buffer(fd, s);
 +              ret = rc4_send_buffer(rc4c, s);
                free(s);
                if (ret < 0)
                        goto out;
 -                      ret = send_buffer(fd, esi);
+               if (nmmd->vss_status_flags & VSS_NEXT) {
+                       static char *esi;
+                       if (!esi)
+                               esi = empty_status_items(parser_friendly);
 -                      send_afs_status(fd, parser_friendly);
++                      ret = rc4_send_buffer(rc4c, esi);
+                       if (ret < 0)
+                               goto out;
+               } else
++                      send_afs_status(rc4c, parser_friendly);
                ret = 1;
                if (num > 0 && !--num)
                        goto out;
diff --cc configure.ac
index b0aba93721c62f0409797fc56c954a210d9989c7,3e4239094b128c0913ce48ba93e207fff0bc59a0..fde72f2aa795676691f741392bfba87569458944
@@@ -138,13 -138,9 +138,10 @@@ writers=" file
  default_writer="FILE_WRITE"
  
  client_cmdline_objs="client.cmdline"
 -client_errlist_objs="client net string crypt fd sched stdin stdout client_common"
 +client_errlist_objs="client net string crypt fd sched stdin stdout
 +      client_common sha1"
  client_ldflags=""
  
- fsck_cmdline_objs="fsck.cmdline"
- fsck_errlist_objs="osl rbtree fsck string sha1 fd"
  gui_cmdline_objs="gui.cmdline"
  gui_errlist_objs="exec signal string stat ringbuffer fd"
  gui_other_objs="gui gui_theme"
diff --cc error.h
Simple merge
diff --cc mp3_afh.c
index 2d18d5e5de7df641f6cbe7b7ad937cb3f2d69e3e,f0db140d2213a36283e497a73531c4edfb7d79ef..ff133ca563441ceb6daa02979c7a223b1c74e323
+++ b/mp3_afh.c
@@@ -20,8 -21,8 +21,6 @@@
  #include "error.h"
  #include "afh.h"
  #include "string.h"
--#include "afs.h"
--#include "server.h"
  
  /** \cond some defines and structs which are only used in this file */
  
diff --cc ogg_afh.c
index 55cf4ced1b50b1d9661eb9590abcd90105351f81,e91c6c2b343b464fd2d9ff0472eff52bdd21cae9..f0c1e43586aecebb45f3fac3732fa274eac54690
+++ b/ogg_afh.c
@@@ -9,13 -9,14 +9,12 @@@
  #include <ogg/ogg.h>
  #include <vorbis/codec.h>
  #include <vorbis/vorbisfile.h>
+ #include <osl.h>
  
  #include "para.h"
--#include "afh.h"
  #include "error.h"
++#include "afh.h"
  #include "string.h"
--#include "afs.h"
--#include "server.h"
  
  /** must be big enough to hold header */
  #define CHUNK_SIZE 32768
diff --cc para.h
Simple merge
diff --cc send_common.c
Simple merge
diff --cc server.c
index 8c61732592269301e22bd4ecfffc0c5cf5571ceb,e08b0661d14ddc4a8ef1cf2386cb75efe0655d19..245562631d18122084d97ca2af9f9afdec2cf59f
+++ b/server.c
@@@ -65,7 -63,7 +63,8 @@@
  #include <signal.h>
  #include <dirent.h>
  #include <sys/time.h>
 +#include <openssl/rc4.h>
+ #include <osl.h>
  
  #include "para.h"
  #include "error.h"
@@@ -374,15 -369,16 +371,15 @@@ static void command_post_select(struct 
        PARA_INFO_LOG("got connection from %s, forking\n", peer_name);
        mmd->num_connects++;
        mmd->active_connections++;
-       /* The chunk table and the info_string are pointers located in the
-        * mmd struct that point to dynamically allocated memory that must be
-        * freed by the parent and the child. However, as the mmd struct is in
-        * a shared memory area, there's no guarantee that after the fork these
-        * pointers are still valid in child context. As these two pointers are
-        * not used in the child anyway, we save them to local variables and
-        * free the memory via that copy in the child.
 -      random();
+       /*
 -       * The chunk table is a pointer located in the mmd struct that point to
 -       * dynamically allocated memory that must be freed by the parent and
 -       * the child. However, as the mmd struct is in a shared memory area,
 -       * there's no guarantee that after the fork these pointers are still
 -       * valid in child context. As this pointer is not used in the child
 -       * anyway, we save it to a local variable and free the memory via that
 -       * copy in the child.
++       * The chunk table is a pointer located in the mmd struct that points
++       * to dynamically allocated memory, i.e. it must be freed by the parent
++       * and the child. However, as the mmd struct is in a shared memory
++       * area, there's no guarantee that after the fork this pointer is still
++       * valid in child context. As it is not used in the child anyway, we
++       * save it to a local variable before the fork and free the memory via
++       * that copy in the child directly after the fork.
         */
-       info_string = mmd->afd.afhi.info_string;
        chunk_table = mmd->afd.afhi.chunk_table;
        child_pid = fork();
        if (child_pid < 0) {
diff --cc server.cmd
index d574d2c89c0be38b42902bd8108c40472a79424c,a089060af3e9e60962bf1044f3339521eb89055a..0c1321017fb163f5e7d114dffe540b851336d1ae
@@@ -3,8 -3,8 +3,8 @@@ SF: command.
  HC: prototypes for the server command handlers
  CC: array of server commands
  AT: server_command
- SI: openssl/rc4
 -IN: para error string afh afs server list user_list
 -SI: osl
++SI: openssl/rc4 osl
 +IN: para error crypt command string afh afs server list user_list
  SN: list of server commands
  ---
  N: ff
diff --cc string.c
Simple merge
diff --cc string.h
index a9dfae90019ed9cd37490c9d4555bc06f53219be,38e5edc90507688e9113d496fccdd40f114ae249..d28b0ac4633e5457f97da5b00465973f3c6bba6c
+++ b/string.h
@@@ -33,8 -63,9 +63,8 @@@ __must_check __malloc char *para_strdup
  __must_check __malloc __printf_1_2 char *make_message(const char *fmt, ...);
  __must_check __malloc char *para_strcat(char *a, const char *b);
  __must_check __malloc char *para_dirname(const char *name);
- __must_check const char *para_basename(const char *name);
+ __must_check char *para_basename(const char *name);
  void chop(char *buf);
 -__must_check __malloc char *para_tmpname(void);
  __must_check __malloc char *para_logname(void);
  __must_check __malloc char *para_homedir(void);
  unsigned split_args(char *args, char *** const argv_ptr, const char *delim);