/** \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)
#include <signal.h>
#include <fnmatch.h>
+#include <openssl/rc4.h>
+ #include <osl.h>
+
#include "server.cmdline.h"
#include "para.h"
#include "error.h"
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
---
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 {
/** \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>
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 */
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)
{
*/
/** \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"
/** \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"
);
}
+ #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;
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"
#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 */
#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
#include <signal.h>
#include <dirent.h>
#include <sys/time.h>
+#include <openssl/rc4.h>
+ #include <osl.h>
#include "para.h"
#include "error.h"
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) {
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
__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);