Hi.
Sorry about the number of patches. I keep failing to post them and
then the next day more new ones appear!
In summary:
Patch 1 just tidies up some of the headers. I have moved the utf8
functions into lkarma.h so from now on, this is the only header that
applications should need. The utf8.h header is left as empty for the
time-being so that current applications don't break.
Patch 2 ensures that the fdb file is only uploaded/downloaded when
something has changed.
Patch 3 changes the device_settings calls so that they no longer
make use of the properties array. This should ease any changes to
that data structure in the future.
Patch 4 changes the sorting function which is applied before writing
the smalldb. It now ignores a "The " prefix for artist names, like
the karma itself does.
There is also a patch for generating the correct rid in lkarmafs but
I'll post that separately.
Keith.
# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1156947798 -3600
# Node ID 4f94b0d72564226069e6ebafe4c25b9318b32326
# Parent f22a6aed20b82dd0a8612bcff8d7afbb76a3255f
Header cleanups.
Moved utf8 declarations into lkarma.h
Removed unnecessary C++ definitions from internal header files.
Removed uint32 and uint8 defines.
diff -r f22a6aed20b8 -r 4f94b0d72564 src/Makefile
--- a/src/Makefile Wed Aug 23 19:31:07 2006 +0200
+++ b/src/Makefile Wed Aug 30 15:23:18 2006 +0100
@@ -4,7 +4,7 @@ SRCS= errors.c fdb.c hash.c karma.c karm
SRCS= errors.c fdb.c hash.c karma.c karmaLan.c karmaUsb.c md5.c mountSearch.c \
mp3.c playlist.c properties.c rio_rw.c ssdp.c status.c utf8.c \
util.c wav.c
-INST_HEADERS=lkarma.h utf8.h fdb.h
+INST_HEADERS=lkarma.h utf8.h
LIBDIR=../lib
diff -r f22a6aed20b8 -r 4f94b0d72564 src/fdb.h
--- a/src/fdb.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/fdb.h Wed Aug 30 15:23:18 2006 +0100
@@ -10,16 +10,8 @@
#ifndef _FDB_H
#define _FDB_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
int lk_fdb_load (void);
int lk_fdb_save (void);
void lk_fdb_set_device(int karma);
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
#endif /* _FDB_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/hash.h
--- a/src/hash.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/hash.h Wed Aug 30 15:23:18 2006 +0100
@@ -12,10 +12,6 @@
#ifndef _HASH_H
#define _HASH_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
struct hash_elem
{
const char *key;
@@ -47,8 +43,4 @@ void hash_delete_hash(HASH * table, int
void hash_delete_hash(HASH * table, int hash, const char *key, const void
*data);
void hash_destroy(HASH ** hash);
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
#endif /* _HASH_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/karma.h
--- a/src/karma.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/karma.h Wed Aug 30 15:23:18 2006 +0100
@@ -12,13 +12,8 @@
#define _KARMA_H
#include <inttypes.h>
-#include "lkarma.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-char *lk_karma_fidToPath(int rio, uint32_t file_id);
+char * lk_karma_fidToPath (int rio, uint32_t file_id);
/*Help-Functions:*/
int lk_karma_send_request (int rio, uint32_t identifier,
@@ -43,46 +38,52 @@ void lk_karma_update_database
/* private stuff */
struct lk_ops
{
- int (*lk_karma_connect)(char *ipHostOrPath);
- int32_t (*lk_karma_hangup)(int rio);
- int (*lk_karma_send_request)(int rio, uint32_t identifier, char *payload,
- int plen);
- int (*lk_karma_get_protocol_version)(int rio, uint32_t *major_version,
- uint32_t *minor_version);
- int32_t (*lk_karma_get_authentication_salt)(int rio, char **salt);
- uint32_t (*lk_karma_authenticate)(int rio, char *pass);
- int (*lk_karma_get_device_details)(int rio, char **name, char **version,
- uint32_t * storagedevices);
- int (*lk_karma_get_storage_details)(int rio, uint32_t storage_id,
- uint32_t * n_files, uint64_t * s_size,
- uint64_t * f_space, uint32_t * highest_file_id);
- int (*lk_karma_get_device_settings)(int rio, char **properties);
- int32_t (*lk_karma_update_device_settings)(int rio, char *properties);
- int32_t (*lk_karma_request_io_lock)(int rio, uint32_t type);
- int32_t (*lk_karma_release_io_lock)(int rio);
- int32_t (*lk_karma_prepare)(int rio, uint64_t size, uint32_t * file_id,
- uint32_t storage_id);
- int32_t (*lk_karma_get_all_file_details)(int rio, char **properties);
- int32_t (*lk_karma_get_file_details)(int rio, uint32_t file_id,
- char **properties);
- int32_t (*lk_karma_update_file_details)(int rio, uint32_t file_id,
- char *properties);
- int32_t (*lk_karma_read_file_chunk)(int rio, uint64_t offset,
- uint64_t size, uint32_t file_id, char **data, uint64_t * retsize);
- int32_t (*lk_karma_write_file_chunk)(int rio, uint64_t offset,
- uint64_t size, uint32_t file_id, uint32_t storage_id, const char
*data);
- int32_t (*lk_karma_delete_file)(int rio, uint32_t file_id);
- int32_t (*lk_karma_format_storage)(int rio, uint32_t storage_id);
- int32_t (*lk_karma_device_operation)(int rio, uint64_t size, char *data,
- char **newdata);
- void (*lk_karma_load_database)(int rio);
- void (*lk_karma_update_database)(int rio);
- int (*lk_karma_write_smalldb)(void);
- char *(*lk_karma_fidToPath)(int rio, uint32_t file_id);
+ int (*lk_karma_connect) (char *ipHostOrPath);
+ int32_t (*lk_karma_hangup) (int rio);
+ int (*lk_karma_send_request) (int rio, uint32_t identifier,
+ char *payload, int plen);
+ int (*lk_karma_get_protocol_version) (int rio,
+ uint32_t *major_version,
+ uint32_t *minor_version);
+ int32_t (*lk_karma_get_authentication_salt)(int rio, char **salt);
+ uint32_t (*lk_karma_authenticate) (int rio, char *pass);
+ int (*lk_karma_get_device_details) (int rio, char **name,
+ char **version,
+ uint32_t * storagedevices);
+ int (*lk_karma_get_storage_details) (int rio, uint32_t storage_id,
+ uint32_t * n_files,
+ uint64_t * s_size,
+ uint64_t * f_space,
+ uint32_t * highest_file_id);
+ int (*lk_karma_get_device_settings) (int rio, char **properties);
+ int32_t (*lk_karma_update_device_settings) (int rio, char *properties);
+ int32_t (*lk_karma_request_io_lock) (int rio, uint32_t type);
+ int32_t (*lk_karma_release_io_lock) (int rio);
+ int32_t (*lk_karma_prepare) (int rio, uint64_t size,
+ uint32_t * file_id,
+ uint32_t storage_id);
+ int32_t (*lk_karma_get_all_file_details) (int rio, char **properties);
+ int32_t (*lk_karma_get_file_details) (int rio, uint32_t file_id,
+ char **properties);
+ int32_t (*lk_karma_update_file_details) (int rio, uint32_t file_id,
+ char *properties);
+ int32_t (*lk_karma_read_file_chunk) (int rio, uint64_t offset,
+ uint64_t size,
+ uint32_t file_id, char **data,
+ uint64_t * retsize);
+ int32_t (*lk_karma_write_file_chunk) (int rio, uint64_t offset,
+ uint64_t size,
+ uint32_t file_id,
+ uint32_t storage_id,
+ const char *data);
+ int32_t (*lk_karma_delete_file) (int rio, uint32_t file_id);
+ int32_t (*lk_karma_format_storage) (int rio, uint32_t storage_id);
+ int32_t (*lk_karma_device_operation) (int rio, uint64_t size,
+ char *data, char **newdata);
+ void (*lk_karma_load_database) (int rio);
+ void (*lk_karma_update_database) (int rio);
+ int (*lk_karma_write_smalldb) (void);
+ char * (*lk_karma_fidToPath) (int rio, uint32_t file_id);
};
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
#endif /* _KARMA_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/karmaLan.c
--- a/src/karmaLan.c Wed Aug 23 19:31:07 2006 +0200
+++ b/src/karmaLan.c Wed Aug 30 15:23:18 2006 +0100
@@ -236,7 +236,7 @@ uint32_t lk_karmaLan_authenticate(int ri
memcpy(&md5input[SALTLENGTH], pass, strlen(pass));
md5_starts(&ctx);
- md5_update(&ctx, (uint8 *)md5input, SALTLENGTH+strlen(pass));
+ md5_update(&ctx, (uint8_t *)md5input, SALTLENGTH+strlen(pass));
md5_finish(&ctx, md5sum);
free(salt);
diff -r f22a6aed20b8 -r 4f94b0d72564 src/karmaLan.h
--- a/src/karmaLan.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/karmaLan.h Wed Aug 30 15:23:18 2006 +0100
@@ -12,10 +12,6 @@
#define _KARMA_LAN_H
#include <inttypes.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
#define RIOPORT 8302
#define HEADERLENGTH 8
@@ -96,8 +92,4 @@ void lk_karmaLan_load_database
void lk_karmaLan_load_database (int rio);
void lk_karmaLan_update_database (int rio);
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
#endif /* _KARMA_LAN_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/karmaUsb.h
--- a/src/karmaUsb.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/karmaUsb.h Wed Aug 30 15:23:18 2006 +0100
@@ -13,11 +13,7 @@
#include <inttypes.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-char *lk_karmaUsb_fidToPath(int rio, uint32_t file_id);
+char * lk_karmaUsb_fidToPath (int rio, uint32_t file_id);
/*Help-Functions:*/
int lk_karmaUsb_connect (char *ip);
@@ -50,8 +46,4 @@ void lk_karmaUsb_load_database
void lk_karmaUsb_load_database (int rio);
void lk_karmaUsb_load_database_smalldb (int rio);
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
#endif /* _KARMA_USB_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/lkarma.h
--- a/src/lkarma.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/lkarma.h Wed Aug 30 15:23:18 2006 +0100
@@ -190,7 +190,7 @@ int lk_synchronize_necessary(int rio);
int lk_synchronize_necessary(int rio);
uint32_t lk_rio_write(int rio, const char * filename);
void lk_karma_write_dupes(int set);
-int lk_rio_update_props_from_tags(int rio, uint32_t fid, const char *fname);
+int lk_rio_update_props_from_tags(int rio, uint32_t fid);
/*
@@ -206,6 +206,17 @@ int lk_mountSearch_discover(char **devic
*/
char *simple_itoa(unsigned int i);
+
+
+/*
+ * utf8
+ */
+
+void utf8_destroy (void);
+int utf8_set_codeset (char * codeset);
+char * utf8_get_codeset (void);
+char * utf8_from_codeset (char * data);
+char * utf8_to_codeset (char * data);
#ifdef __cplusplus
}
diff -r f22a6aed20b8 -r 4f94b0d72564 src/md5.c
--- a/src/md5.c Wed Aug 23 19:31:07 2006 +0200
+++ b/src/md5.c Wed Aug 30 15:23:18 2006 +0100
@@ -15,18 +15,18 @@
#define GET_UINT32(n,b,i) \
{ \
- (n) = ( (uint32) (b)[(i) ] ) \
- | ( (uint32) (b)[(i) + 1] << 8 ) \
- | ( (uint32) (b)[(i) + 2] << 16 ) \
- | ( (uint32) (b)[(i) + 3] << 24 ); \
+ (n) = ( (uint32_t) (b)[(i) ] ) \
+ | ( (uint32_t) (b)[(i) + 1] << 8 ) \
+ | ( (uint32_t) (b)[(i) + 2] << 16 ) \
+ | ( (uint32_t) (b)[(i) + 3] << 24 ); \
}
#define PUT_UINT32(n,b,i) \
{ \
- (b)[(i) ] = (uint8) ( (n) ); \
- (b)[(i) + 1] = (uint8) ( (n) >> 8 ); \
- (b)[(i) + 2] = (uint8) ( (n) >> 16 ); \
- (b)[(i) + 3] = (uint8) ( (n) >> 24 ); \
+ (b)[(i) ] = (uint8_t) ( (n) ); \
+ (b)[(i) + 1] = (uint8_t) ( (n) >> 8 ); \
+ (b)[(i) + 2] = (uint8_t) ( (n) >> 16 ); \
+ (b)[(i) + 3] = (uint8_t) ( (n) >> 24 ); \
}
void md5_starts( md5_context *ctx )
@@ -40,9 +40,9 @@ void md5_starts( md5_context *ctx )
ctx->state[3] = 0x10325476;
}
-static void md5_process( md5_context *ctx, uint8 data[64] )
-{
- uint32 X[16], A, B, C, D;
+static void md5_process( md5_context *ctx, uint8_t data[64] )
+{
+ uint32_t X[16], A, B, C, D;
GET_UINT32( X[0], data, 0 );
GET_UINT32( X[1], data, 4 );
@@ -163,9 +163,9 @@ static void md5_process( md5_context *ct
ctx->state[3] += D;
}
-void md5_update( md5_context *ctx, uint8 *input, uint32 length )
-{
- uint32 left, fill;
+void md5_update( md5_context *ctx, uint8_t *input, uint32_t length )
+{
+ uint32_t left, fill;
if( ! length ) return;
@@ -197,7 +197,7 @@ void md5_update( md5_context *ctx, uint8
}
}
-static uint8 md5_padding[64] =
+static uint8_t md5_padding[64] =
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -205,11 +205,11 @@ static uint8 md5_padding[64] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-void md5_finish( md5_context *ctx, uint8 digest[16] )
-{
- uint32 last, padn;
- uint32 high, low;
- uint8 msglen[8];
+void md5_finish( md5_context *ctx, uint8_t digest[16] )
+{
+ uint32_t last, padn;
+ uint32_t high, low;
+ uint8_t msglen[8];
high = ( ctx->total[0] >> 29 )
| ( ctx->total[1] << 3 );
diff -r f22a6aed20b8 -r 4f94b0d72564 src/md5.h
--- a/src/md5.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/md5.h Wed Aug 30 15:23:18 2006 +0100
@@ -14,31 +14,15 @@
#include <inttypes.h>
-#ifndef uint8
-#define uint8 unsigned char
-#endif
-
-#ifndef uint32
-#define uint32 unsigned long int
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct
{
- uint32 total[2];
- uint32 state[4];
- uint8 buffer[64];
+ uint32_t total[2];
+ uint32_t state[4];
+ uint8_t buffer[64];
} md5_context;
void md5_starts( md5_context *ctx );
-void md5_update( md5_context *ctx, uint8 *input, uint32 length );
-void md5_finish( md5_context *ctx, uint8 digest[16] );
-
-#ifdef __cplusplus
-}
-#endif /* C++ */
+void md5_update( md5_context *ctx, uint8_t *input, uint32_t length );
+void md5_finish( md5_context *ctx, uint8_t digest[16] );
#endif /* _MD5_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/mp3.h
--- a/src/mp3.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/mp3.h Wed Aug 30 15:23:18 2006 +0100
@@ -24,10 +24,6 @@
#define FRAME_HEADER_SIZE 4
#define MIN_FRAME_SIZE 21
#define NUM_SAMPLES 4
-
-#ifdef __cplusplus
-extern "C" {
-#endif
typedef struct {
unsigned long sync;
@@ -72,8 +68,4 @@ int header_frequency(mp3header *h);
int header_frequency(mp3header *h);
int write_tag(mp3info *mp3);
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
#endif /* _MP3_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/playlist.h
--- a/src/playlist.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/playlist.h Wed Aug 30 15:23:18 2006 +0100
@@ -13,10 +13,6 @@
#include <inttypes.h>
#include "lkarma.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
char * lk_playlist_escape (char * data, unsigned int length);
unsigned int lk_playlist_unescape_inplace(char * str);
@@ -34,8 +30,4 @@ int lk_playlist_insert
uint32_t fid_generation);
int lk_playlist_write (playlist * pl, int karma);
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
#endif /* _PLAYLIST_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/properties.h
--- a/src/properties.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/properties.h Wed Aug 30 15:23:18 2006 +0100
@@ -18,10 +18,6 @@
#include "hash.h"
#include "lkarma.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
#define RK_SMALLDB "/var/smalldb"
@@ -92,8 +88,4 @@ int lk_properties_write_property
uint32_t *offset, uint32_t *arrsz,
char **arr);
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
#endif /* _PROPERTIES_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/rio_rw.c
--- a/src/rio_rw.c Wed Aug 23 19:31:07 2006 +0200
+++ b/src/rio_rw.c Wed Aug 30 15:23:18 2006 +0100
@@ -29,7 +29,6 @@
#include "properties.h"
#include "util.h"
#include "rio_rw.h"
-#include "utf8.h"
/* #define BLOCKSIZE 32768 */
#define BLOCKSIZE 131072
diff -r f22a6aed20b8 -r 4f94b0d72564 src/rio_rw.h
--- a/src/rio_rw.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/rio_rw.h Wed Aug 30 15:23:18 2006 +0100
@@ -11,8 +11,6 @@
#ifndef _RIO_RW_H
#define _RIO_RW_H
-#include "lkarma.h"
-
uint32_t lk_rio_write_fdb(int rio, const char * filename);
#endif /* _RIO_RW_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/ssdp.h
--- a/src/ssdp.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/ssdp.h Wed Aug 30 15:23:18 2006 +0100
@@ -11,8 +11,6 @@
#ifndef _SSDP_H
#define _SSDP_H
-#include "lkarma.h"
-
#define RESPONSE_BUFFER_LEN 1024
#define SSDP_MULTICAST "239.255.255.250"
diff -r f22a6aed20b8 -r 4f94b0d72564 src/status.h
--- a/src/status.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/status.h Wed Aug 30 15:23:18 2006 +0100
@@ -14,10 +14,6 @@
#include <inttypes.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef void status_func(const char * in_progress,int percent);
int lk_status_init(status_func update);
@@ -25,8 +21,4 @@ int lk_status_increment(uint32_t step);
int lk_status_increment(uint32_t step);
int lk_status_destroy(void);
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
#endif /* _STATUS_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/utf8.c
--- a/src/utf8.c Wed Aug 23 19:31:07 2006 +0200
+++ b/src/utf8.c Wed Aug 30 15:23:18 2006 +0100
@@ -4,7 +4,6 @@
#include <stdio.h>
#include "lkarma.h"
-#include "utf8.h"
struct utf8{
iconv_t in;
diff -r f22a6aed20b8 -r 4f94b0d72564 src/utf8.h
--- a/src/utf8.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/utf8.h Wed Aug 30 15:23:18 2006 +0100
@@ -11,18 +11,4 @@
#ifndef _UTF8_H
#define _UTF8_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void utf8_destroy(void);
-int utf8_set_codeset(char * codeset);
-char * utf8_get_codeset(void);
-char * utf8_from_codeset(char * data);
-char * utf8_to_codeset(char * data);
-
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
#endif /* _UTF8_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/util.c
--- a/src/util.c Wed Aug 23 19:31:07 2006 +0200
+++ b/src/util.c Wed Aug 30 15:23:18 2006 +0100
@@ -181,7 +181,7 @@ unsigned char * lk_generate_rid(int file
md5_starts(&ctx);
if(length-offset < RID_BLOCKS){
- md5_update(&ctx, (uint8 *)&cache, size);
+ md5_update(&ctx, (uint8_t *)&cache, size);
md5_finish(&ctx, md5output);
}else{
md5_update(&ctx, cache, RID_BLOCKS);
diff -r f22a6aed20b8 -r 4f94b0d72564 src/util.h
--- a/src/util.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/util.h Wed Aug 30 15:23:18 2006 +0100
@@ -13,12 +13,6 @@
#ifndef _UTIL_H
#define _UTIL_H
-#include "lkarma.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
char *lk_path_string(char * file);
int mk_path(const char *pathname);
uint32_t lk_htorl(uint32_t hostlong);
@@ -28,8 +22,4 @@ unsigned char *lk_generate_rid(int file,
unsigned char *lk_generate_rid(int file, int offset, int length);
int lk_is_karma_mountpoint(const char *mountpoint);
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
#endif /* _UTIL_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 src/wav.h
--- a/src/wav.h Wed Aug 23 19:31:07 2006 +0200
+++ b/src/wav.h Wed Aug 30 15:23:18 2006 +0100
@@ -12,10 +12,6 @@
#ifndef _WAV_H
#define _WAV_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
typedef struct {
char RiffID [4] ;
@@ -34,8 +30,4 @@ int openwav(wave_header **, char *);
int openwav(wave_header **, char *);
void cleanup(wave_header **);
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
#endif /* _WAV_H */
diff -r f22a6aed20b8 -r 4f94b0d72564 tools/riocp.c
--- a/tools/riocp.c Wed Aug 23 19:31:07 2006 +0200
+++ b/tools/riocp.c Wed Aug 30 15:23:18 2006 +0100
@@ -25,7 +25,6 @@
#include <langinfo.h>
#include <lkarma.h>
-#include "utf8.h"
#include "pathedit.h"
#define CHECK(x) (x)?"failed":"ok"
# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1156947857 -3600
# Node ID cbd5cad7767669767000e265d8068b334bf5ee4c
# Parent 4f94b0d72564226069e6ebafe4c25b9318b32326
Only download the fdb file when the cache is obsolete.
Added flags to track the status of the fdb and properties files
so that they are only saved/uploaded when they have been changed.
diff -r 4f94b0d72564 -r cbd5cad77676 src/fdb.c
--- a/src/fdb.c Wed Aug 30 15:23:18 2006 +0100
+++ b/src/fdb.c Wed Aug 30 15:24:17 2006 +0100
@@ -52,12 +52,12 @@ static int fdb_read_header(gzFile fdb_fi
* fid:fid_generation path
*/
-int lk_fdb_load(void)
+int lk_fdb_load(int download)
{
gzFile fdb_file;
char * fname;
char * buf=NULL,*p,*n_tok;
- int read,size=0;
+ int read,upd,size=0;
uint32_t fid;
uint32_t *db;
char * fid_gen;
@@ -70,13 +70,15 @@ int lk_fdb_load(void)
if (fname == NULL)
return -1;
- db=lk_properties_andOrSearch(EXACT|ORS, NULL, "title", FDB_FILENAME);
- if (db) {
- db=lk_properties_andOrSearch(EXACT|ORS, db, "type", "taxi");
+ if (download) {
+ db=lk_properties_andOrSearch(EXACT|ORS, NULL, "title", FDB_FILENAME);
if (db) {
- unlink(fname);
- lk_rio_read(rio, *db, fname);
- free(db);
+ db=lk_properties_andOrSearch(EXACT|ORS, db, "type", "taxi");
+ if (db) {
+ unlink(fname);
+ lk_rio_read(rio, *db, fname);
+ free(db);
+ }
}
}
@@ -101,6 +103,7 @@ int lk_fdb_load(void)
}
buf[size]='\0';
p=strtok_r(buf, ":", &n_tok);
+ upd = properties_updated;
while(p!=NULL){
fid=strtoul(p, (char **)NULL, 10);
fid_gen=strtok_r(NULL, " ", &n_tok);
@@ -112,6 +115,8 @@ int lk_fdb_load(void)
p=strtok_r(NULL, ":", &n_tok);
}
free(buf);
+ properties_updated = upd;
+ fdb_updated = 0;
return 0;
}
@@ -237,6 +242,8 @@ int lk_fdb_save(void)
* Datenbank auf Karma als Taxifile kopieren...
*/
free(fname);
+ fdb_updated = 0;
+
return 0;
}
diff -r 4f94b0d72564 -r cbd5cad77676 src/fdb.h
--- a/src/fdb.h Wed Aug 30 15:23:18 2006 +0100
+++ b/src/fdb.h Wed Aug 30 15:24:17 2006 +0100
@@ -10,7 +10,9 @@
#ifndef _FDB_H
#define _FDB_H
-int lk_fdb_load (void);
+extern int fdb_updated;
+
+int lk_fdb_load (int download);
int lk_fdb_save (void);
void lk_fdb_set_device(int karma);
diff -r 4f94b0d72564 -r cbd5cad77676 src/karma.c
--- a/src/karma.c Wed Aug 30 15:23:18 2006 +0100
+++ b/src/karma.c Wed Aug 30 15:24:17 2006 +0100
@@ -245,7 +245,6 @@ void lk_karma_load_database(int rio)
void lk_karma_load_database(int rio)
{
lk_ops->lk_karma_load_database(rio);
- lk_fdb_load();
}
void lk_karma_update_database(int rio)
diff -r 4f94b0d72564 -r cbd5cad77676 src/karmaLan.c
--- a/src/karmaLan.c Wed Aug 30 15:23:18 2006 +0100
+++ b/src/karmaLan.c Wed Aug 30 15:24:17 2006 +0100
@@ -22,6 +22,7 @@
#include "properties.h"
#include "md5.h"
#include "util.h"
+#include "fdb.h"
#ifndef MSG_FIN
#define MSG_FIN 0
@@ -581,7 +582,11 @@ void lk_karmaLan_load_database(int rio)
free(settings);
lk_karmaLan_get_all_file_details(rio, &settings);
lk_properties_import(settings);
- }else lk_properties_load();
+ lk_fdb_load(1);
+ }else{
+ lk_properties_load();
+ lk_fdb_load(0);
+ }
free(settings);
}
diff -r 4f94b0d72564 -r cbd5cad77676 src/karmaUsb.c
--- a/src/karmaUsb.c Wed Aug 30 15:23:18 2006 +0100
+++ b/src/karmaUsb.c Wed Aug 30 15:24:17 2006 +0100
@@ -30,6 +30,7 @@
#include "playlist.h"
#include "md5.h"
#include "util.h"
+#include "fdb.h"
#ifndef MSG_FIN
#define MSG_FIN 0
@@ -955,21 +956,16 @@ void lk_karmaUsb_load_database(int rio)
char *settings = NULL, *properties = NULL;
aux = lk_karmaUsb_get_device_settings(rio, &settings);
- if(lk_properties_cache_obsolete(settings)) { /* DB was changed */
- free(settings);
- settings = NULL;
- aux = read_properties(&properties);
- if(properties)
- count = lk_properties_import(properties);
- else {
- lk_errors_set(E_FAILEDREQ);
- return;
- }
-/* fprintf(stderr, "%d Files\n", count); */
- } else
- lk_properties_load();
- if(settings)
- free(settings);
+ free(settings);
+ settings = NULL;
+ aux = read_properties(&properties);
+ if(properties)
+ count = lk_properties_import(properties);
+ else {
+ lk_errors_set(E_FAILEDREQ);
+ return;
+ }
+ lk_fdb_load(1);
if(properties)
free(properties);
}
@@ -990,6 +986,7 @@ void lk_karmaUsb_load_database_smalldb(i
lk_errors_set(E_FAILEDREQ);
return;
}
+ lk_fdb_load(1);
/* fprintf(stderr, "smalldb: %d Files\n", count); */
if(properties)
free(properties);
diff -r 4f94b0d72564 -r cbd5cad77676 src/properties.c
--- a/src/properties.c Wed Aug 30 15:23:18 2006 +0100
+++ b/src/properties.c Wed Aug 30 15:24:17 2006 +0100
@@ -38,6 +38,9 @@ struct klist{
struct klist props = {NULL, 0, 0, 17};
+int properties_updated = 0;
+int fdb_updated = 0;
+
void lk_properties_init(void)
{
uint32_t i;
@@ -47,6 +50,8 @@ void lk_properties_init(void)
props.fidTable=malloc(props.ftsize*sizeof(HASH *));
for(i=0;i<props.ftsize;i++)
props.fidTable[i]=NULL;
+ properties_updated = 0;
+ fdb_updated = 0;
}
void lk_properties_destroy(void)
@@ -64,6 +69,8 @@ void lk_properties_destroy(void)
props.fidTable=NULL;
props.count=0;
props.next_fid=17;
+ properties_updated = 0;
+ fdb_updated = 0;
}
uint32_t lk_properties_import(char * properties)
@@ -132,6 +139,7 @@ uint32_t lk_properties_import(char * pro
}
}
hash_destroy(&item);
+ properties_updated = 1;
return count;
}
@@ -234,6 +242,8 @@ int lk_properties_del_property(uint32_t
props.count--;
if(id < props.next_fid)
props.next_fid=id;
+ properties_updated = 1;
+ fdb_updated = 1;
return 0;
}
@@ -245,6 +255,8 @@ int lk_properties_set_property(uint32_t
return -1;
}
lk_properties_set_property_hash(props.fidTable[id], property, data);
+ if (memcmp(property, "path", 5) == 0)
+ fdb_updated = 1;
return 0;
}
@@ -254,6 +266,7 @@ void lk_properties_set_property_hash(HAS
if (data == NULL) return;
hash_insert(p, strdup(property), strdup(data));
+ properties_updated = 1;
}
HASH * lk_properties_idsearch(uint32_t fid)
@@ -284,6 +297,7 @@ int lk_properties_load(void)
lk_properties_import(buf);
free(buf);
free(fname);
+ properties_updated = 0;
return 0;
}
/*
@@ -313,7 +327,12 @@ int lk_properties_save(void)
char * buf;
struct utimbuf time;
- lk_fdb_save();
+ if (fdb_updated != 0)
+ lk_fdb_save();
+
+ if (properties_updated == 0)
+ return 0;
+
fname=lk_path_string("fileinfo");
if(mk_path(fname) == -1){
free(fname);
@@ -696,6 +715,9 @@ int lk_properties_write_smalldb(char *us
char *arr = NULL;
FILE *fp;
+ if (properties_updated == 0)
+ return 0;
+
arrsz = 40*nfiles;
arr = malloc(arrsz);
if (!arr)
diff -r 4f94b0d72564 -r cbd5cad77676 src/properties.h
--- a/src/properties.h Wed Aug 30 15:23:18 2006 +0100
+++ b/src/properties.h Wed Aug 30 15:24:17 2006 +0100
@@ -66,6 +66,8 @@ typedef struct table
uint32_t idx;
} table_t;
+extern int properties_updated;
+
/*
char * lk_properties_get_codeset (void);
void lk_properties_set_codeset (char * codeset);
diff -r 4f94b0d72564 -r cbd5cad77676 src/rio_rw.c
--- a/src/rio_rw.c Wed Aug 30 15:23:18 2006 +0100
+++ b/src/rio_rw.c Wed Aug 30 15:24:17 2006 +0100
@@ -29,6 +29,7 @@
#include "properties.h"
#include "util.h"
#include "rio_rw.h"
+#include "fdb.h"
/* #define BLOCKSIZE 32768 */
#define BLOCKSIZE 131072
@@ -289,8 +290,10 @@ static uint32_t lk_rio_do_write(int fdb,
len = strlen(fullpath);
fullpath[len] = ':';
path = realpath(filename, fullpath+len+1);
- if (path)
+ if (path) {
lk_properties_set_property(fid, "path", fullpath);
+ fdb_updated = 1;
+ }
}
p=lk_properties_export(fid);
diff -r 4f94b0d72564 -r cbd5cad77676 tools/riocp.c
--- a/tools/riocp.c Wed Aug 30 15:23:18 2006 +0100
+++ b/tools/riocp.c Wed Aug 30 15:24:17 2006 +0100
@@ -663,13 +663,14 @@ int main(int argc, char * argv[])
} else fprintf(stderr, "No files to remove!\n");
}
- /* IO_LOCK_W is now unconditionally needed: at least for fdb upload */
- fprintf(stderr, "lk_karma_request_io_lock (W): %s\n",
- CHECK(lk_karma_request_io_lock(karma,IO_LOCK_W)));
- if(lk_synchronize_necessary(karma)){
- lk_karma_get_all_file_details(karma, &psw);
- lk_properties_import(psw);
- free(psw);
+ if(optind < argc || fdb){
+ fprintf(stderr, "lk_karma_request_io_lock (W): %s\n",
+ CHECK(lk_karma_request_io_lock(karma,IO_LOCK_W)));
+ if(lk_synchronize_necessary(karma)){
+ lk_karma_get_all_file_details(karma, &psw);
+ lk_properties_import(psw);
+ free(psw);
+ }
}
if(optind < argc){
for(; optind<argc; optind++)
@@ -678,9 +679,6 @@ int main(int argc, char * argv[])
if (fdb) {
fdb_upload(fdb);
}
-/* } else if (fdb) {
- fdb_upload(fdb);
- } */
lk_properties_save();
if (writeSmalldb) {
# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1156947937 -3600
# Node ID c2b3ab6d9e74d59ca3db1b740e533d507dbeb4c8
# Parent cbd5cad7767669767000e265d8068b334bf5ee4c
Changed device settings so that they no longer use the
properties list, since they do not correspond to any of
the properties held in the smalldb.
diff -r cbd5cad77676 -r c2b3ab6d9e74 src/fdb.c
--- a/src/fdb.c Wed Aug 30 15:24:17 2006 +0100
+++ b/src/fdb.c Wed Aug 30 15:25:37 2006 +0100
@@ -189,10 +189,10 @@ int lk_fdb_save(void)
return -1;
gzwrite(fdb_file, "LkFdB 1 ", 8);
- id = lk_properties_get_property(0,"serial");
- if (id)
+ if (serial) {
+ id = simple_itoa(serial);
gzwrite(fdb_file, id, strlen(id));
- else
+ } else
gzwrite(fdb_file, "0", 1);
gzwrite(fdb_file, "\n", 1);
diff -r cbd5cad77676 -r c2b3ab6d9e74 src/karma.c
--- a/src/karma.c Wed Aug 30 15:24:17 2006 +0100
+++ b/src/karma.c Wed Aug 30 15:25:37 2006 +0100
@@ -13,6 +13,7 @@
#include "karma.h"
#include "karmaLan.h"
#include "karmaUsb.h"
+#include "properties.h"
#include "fdb.h"
#ifdef __USE_ISOC99
@@ -165,7 +166,9 @@ int lk_karma_get_storage_details(int rio
int lk_karma_get_device_settings(int rio, char **properties)
{
- return lk_ops->lk_karma_get_device_settings(rio, properties);
+ if (properties)
+ *properties = NULL;
+ return lk_ops->lk_karma_get_device_settings(rio);
}
int32_t lk_karma_update_device_settings(int rio, char *properties)
@@ -251,3 +254,25 @@ void lk_karma_update_database(int rio)
{
lk_ops->lk_karma_update_database(rio);
}
+
+int lk_karma_parse_settings(char *buf)
+{
+ int ret = 0;
+ char *str;
+
+ str = strstr(buf, "device_generation");
+ if (str) {
+ str += strlen("device_generation") + 1;
+ device_generation = strtol(str, NULL, 10);
+ } else
+ ret++;
+
+ str = strstr(buf, "serial");
+ if (str) {
+ str += strlen("serial") + 1;
+ serial = strtol(str, NULL, 10);
+ } else
+ ret++;
+
+ return ret;
+}
diff -r cbd5cad77676 -r c2b3ab6d9e74 src/karma.h
--- a/src/karma.h Wed Aug 30 15:24:17 2006 +0100
+++ b/src/karma.h Wed Aug 30 15:25:37 2006 +0100
@@ -35,6 +35,8 @@ int32_t lk_karma_device_operation
/*Advanced Protocol Functions:*/
void lk_karma_update_database (int rio);
+int lk_karma_parse_settings (char *buf);
+
/* private stuff */
struct lk_ops
{
@@ -55,7 +57,7 @@ struct lk_ops
uint64_t * s_size,
uint64_t * f_space,
uint32_t * highest_file_id);
- int (*lk_karma_get_device_settings) (int rio, char **properties);
+ int (*lk_karma_get_device_settings) (int rio);
int32_t (*lk_karma_update_device_settings) (int rio, char *properties);
int32_t (*lk_karma_request_io_lock) (int rio, uint32_t type);
int32_t (*lk_karma_release_io_lock) (int rio);
diff -r cbd5cad77676 -r c2b3ab6d9e74 src/karmaLan.c
--- a/src/karmaLan.c Wed Aug 30 15:24:17 2006 +0100
+++ b/src/karmaLan.c Wed Aug 30 15:25:37 2006 +0100
@@ -18,6 +18,7 @@
#include <string.h>
#include "lkarma.h"
+#include "karma.h"
#include "karmaLan.h"
#include "properties.h"
#include "md5.h"
@@ -300,9 +301,19 @@ int lk_karmaLan_get_storage_details(int
return 0;
}
-int lk_karmaLan_get_device_settings(int rio, char ** properties)
-{
- return recv_properties(rio, GET_DEVICE_SETTINGS, 0, properties);
+int lk_karmaLan_get_device_settings(int rio)
+{
+ int ret;
+ char *settings;
+
+ recv_properties(rio, GET_DEVICE_SETTINGS, 0, &settings);
+ if (settings == NULL)
+ return -1;
+
+ ret = lk_karma_parse_settings(settings);
+ free(settings);
+
+ return ret;
}
@@ -576,32 +587,30 @@ void lk_karmaLan_load_database(int rio)
void lk_karmaLan_load_database(int rio)
{
char *settings;
-
- lk_karmaLan_get_device_settings(rio, &settings);
- if(lk_properties_cache_obsolete(settings)){ /* DB was changed */
- free(settings);
+
+ lk_karmaLan_get_device_settings(rio);
+ if(lk_properties_cache_obsolete(NULL)){ /* DB was changed */
lk_karmaLan_get_all_file_details(rio, &settings);
lk_properties_import(settings);
+ free(settings);
lk_fdb_load(1);
}else{
lk_properties_load();
lk_fdb_load(0);
}
- free(settings);
}
void lk_karmaLan_update_database(int rio)
{
char *settings;
-
- lk_karmaLan_get_device_settings(rio, &settings);
- if(lk_properties_db_changed(settings)){ /* DB was changed */
+ uint32_t old = device_generation;
+
+ lk_karmaLan_get_device_settings(rio);
+ if(device_generation != old){ /* DB was changed */
lk_properties_destroy();
lk_properties_init();
+ lk_karmaLan_get_all_file_details(rio, &settings);
lk_properties_import(settings);
free(settings);
- lk_karmaLan_get_all_file_details(rio, &settings);
- lk_properties_import(settings);
- }
- free(settings);
-}
+ }
+}
diff -r cbd5cad77676 -r c2b3ab6d9e74 src/karmaLan.h
--- a/src/karmaLan.h Wed Aug 30 15:24:17 2006 +0100
+++ b/src/karmaLan.h Wed Aug 30 15:25:37 2006 +0100
@@ -62,7 +62,7 @@ int lk_karmaLan_get_storage_details
uint64_t *s_size,
uint64_t *f_space,
uint32_t *highest_file_id);
-int lk_karmaLan_get_device_settings (int rio, char **properties);
+int lk_karmaLan_get_device_settings (int rio);
int32_t lk_karmaLan_update_device_settings (int rio, char *properties);
int32_t lk_karmaLan_request_io_lock (int rio, uint32_t type);
int32_t lk_karmaLan_release_io_lock (int rio);
diff -r cbd5cad77676 -r c2b3ab6d9e74 src/karmaUsb.c
--- a/src/karmaUsb.c Wed Aug 30 15:24:17 2006 +0100
+++ b/src/karmaUsb.c Wed Aug 30 15:25:37 2006 +0100
@@ -25,6 +25,7 @@
#include <utime.h>
#include "lkarma.h"
+#include "karma.h"
#include "karmaUsb.h"
#include "properties.h"
#include "playlist.h"
@@ -65,7 +66,7 @@ int lk_karmaUsb_connect(char *path)
/* ******************** Implemented OMFS mount here ?? **********************
*/
/* The path must be absolute to be accesible in lkarmafs; e.g.: /mnt/karma2/
*/
int len = strlen(path);
- char *fname, *settings;
+ char *fname;
struct utimbuf time;
int ret = 0;
@@ -77,9 +78,7 @@ int lk_karmaUsb_connect(char *path)
if (ret)
return ret;
- lk_karmaUsb_get_device_settings(0, &settings);
- lk_properties_import(settings);
- free(settings);
+ lk_karmaUsb_get_device_settings(0);
time.modtime=0;
fname=lk_path_string("fileinfo");
@@ -145,48 +144,38 @@ int lk_karmaUsb_get_storage_details(int
}
/* --------------------------------------------------------------------------
*/
-int lk_karmaUsb_get_device_settings(int rio, char **properties)
-{
-/* "device_generation=4294967295\n" *//* max unsigned int */
+int lk_karmaUsb_get_device_settings(int rio)
+{
#define DEVICE_SETTINGS_FILE "device_settings"
#define MIN_DEV_SET_LENGTH 256 /* typical lengths are > 350 */
static char buf[512];
- static int cached = 0;
+ static uint32_t cached_device_generation = 0;
+ static int32_t cached_serial = -1;
int fd, ret = 0;
char path[1024]="";
- const char *settings =
- "capabilities="
- ";read_content;utf8;rewrite_metadata;file_replace"
- ";playlists;root_playlist;played_statistics;\n"
- "codecs=;mp3;wma;vorbis;flac;wave;\n"
- "device_generation=4294967295\n"
- "device_id=0x5210\n"
- "firmware_version=1.68\n"
- "hwrev=0x4\n"
- "manufacturer=Rio Audio\n"
- "max_playlist_entries=15000\n"
- "name=Rio Karma\n"
- "recovery=0\n"
- "rns_prefix=KRM\n"
- "rns_version=805016800\n"
- "serial=0000000\n"
- "storage_name=Hard disk\n";
-
- if (!cached) {
- strncat(path, usbMountPoint, 1024);
- strncat(path, DEVICE_SETTINGS_FILE, 1024);
+ if (cached_serial == -1) {
+ ret = strlen(usbMountPoint);
+ strncat(path+ret, usbMountPoint, 1024);
+ strncat(path, DEVICE_SETTINGS_FILE, 1024-ret);
fd = open(path, O_RDONLY);
if(fd != -1)
ret = read(fd, buf, 512);
close(fd);
if(ret < MIN_DEV_SET_LENGTH) {
lk_errors_set(E_NODEVSET);
- strcpy(buf, settings);
- }
- }
- *properties = strdup(buf);
- cached = 1;
+ cached_device_generation = 0;
+ cached_serial = 0;
+ } else {
+ lk_karma_parse_settings(buf);
+ cached_device_generation = device_generation;
+ cached_serial = serial;
+ }
+ }
+
+ device_generation = cached_device_generation;
+ serial = cached_serial;
+
return 0;
}
@@ -953,11 +942,9 @@ void lk_karmaUsb_load_database(int rio)
void lk_karmaUsb_load_database(int rio)
{
int count = 0, aux = 0;
- char *settings = NULL, *properties = NULL;
-
- aux = lk_karmaUsb_get_device_settings(rio, &settings);
- free(settings);
- settings = NULL;
+ char *properties = NULL;
+
+ aux = lk_karmaUsb_get_device_settings(rio);
aux = read_properties(&properties);
if(properties)
count = lk_properties_import(properties);
@@ -973,12 +960,9 @@ void lk_karmaUsb_load_database_smalldb(i
void lk_karmaUsb_load_database_smalldb(int rio)
{
int count = 0, aux = 0;
- char *settings = NULL, *properties = NULL;
-
- aux = lk_karmaUsb_get_device_settings(rio, &settings);
- lk_properties_import(settings);
- free(settings);
- settings = NULL;
+ char *properties = NULL;
+
+ aux = lk_karmaUsb_get_device_settings(rio);
aux = read_properties_smalldb(&properties);
if(properties)
count = lk_properties_import(properties);
diff -r cbd5cad77676 -r c2b3ab6d9e74 src/karmaUsb.h
--- a/src/karmaUsb.h Wed Aug 30 15:24:17 2006 +0100
+++ b/src/karmaUsb.h Wed Aug 30 15:25:37 2006 +0100
@@ -25,7 +25,7 @@ int lk_karmaUsb_get_storage_details
uint64_t *s_size,
uint64_t *f_space,
uint32_t *highest_file_id);
-int lk_karmaUsb_get_device_settings (int rio, char **properties);
+int lk_karmaUsb_get_device_settings (int rio);
int32_t lk_karmaUsb_request_io_lock (int rio, uint32_t type);
int32_t lk_karmaUsb_release_io_lock (int rio);
int32_t lk_karmaUsb_write_file_chunk (int rio, uint64_t offset,
diff -r cbd5cad77676 -r c2b3ab6d9e74 src/properties.c
--- a/src/properties.c Wed Aug 30 15:24:17 2006 +0100
+++ b/src/properties.c Wed Aug 30 15:25:37 2006 +0100
@@ -40,6 +40,8 @@ struct klist props = {NULL, 0, 0, 17};
int properties_updated = 0;
int fdb_updated = 0;
+uint32_t device_generation;
+uint32_t serial;
void lk_properties_init(void)
{
@@ -356,12 +358,7 @@ int lk_properties_save(void)
}
close(fd);
- /*
- time.actime=strtoul(lk_properties_get_property(0, "device_generation"),
- NULL, 10);
- */
- time.actime=(uint32_t)atol(lk_properties_get_property(0,
-
"device_generation"));
+ time.actime=device_generation;
time.modtime=time.actime;
if(utime(fname, &time)==-1){
free(fname);
@@ -375,21 +372,14 @@ int lk_properties_save(void)
void lk_properties_inc_devgeneration(void)
{
- uint32_t dg;
-
- dg=(uint32_t)atoll(lk_properties_get_property(0, "device_generation"));
- lk_properties_set_property(0, "device_generation", simple_itoa(dg+1));
+ device_generation++;
}
int lk_properties_cache_obsolete(char *device_settings)
{
- char *fname, *tmp;
+ char *fname;
struct stat modified;
-
- tmp=strdup(device_settings);
- lk_properties_import(tmp);
- free(tmp);
fname=lk_path_string("fileinfo");
if(stat(fname, &modified) == -1){
@@ -397,29 +387,11 @@ int lk_properties_cache_obsolete(char *d
return 1;
}
free(fname);
- if((uint32_t)atoll(lk_properties_get_property(0, "device_generation"))
- == (unsigned)modified.st_mtime){
+ if(device_generation == (uint32_t)modified.st_mtime){
return 0;
}else return 1;
}
-int lk_properties_db_changed(char *device_settings)
-{
- char *old, *tmp;
- int ret;
-
- tmp=lk_properties_get_property(0, "device_generation");
- if(tmp){
- old=strdup(tmp);
- tmp=strdup(device_settings);
- lk_properties_import(tmp);
- free(tmp);
- ret=strcmp(lk_properties_get_property(0,
- "device_generation"), old) != 0;
- free(old);
- return ret;
- }else return 1;
-}
uint32_t *lk_properties_andOrSearch(int mode, uint32_t *search_in, char *key,
char *data)
diff -r cbd5cad77676 -r c2b3ab6d9e74 src/properties.h
--- a/src/properties.h Wed Aug 30 15:24:17 2006 +0100
+++ b/src/properties.h Wed Aug 30 15:25:37 2006 +0100
@@ -66,6 +66,8 @@ typedef struct table
uint32_t idx;
} table_t;
+extern uint32_t device_generation;
+extern uint32_t serial;
extern int properties_updated;
/*
@@ -82,7 +84,6 @@ HASH * lk_properties_idsearch
HASH * lk_properties_idsearch (uint32_t fid);
void lk_properties_inc_devgeneration(void);
-int lk_properties_db_changed (char *device_settings);
int lk_properties_write_smalldb (char *usbMountPoint, karma_db_t *db);
int lk_properties_write_property (FILE *fp, char *attr,
diff -r cbd5cad77676 -r c2b3ab6d9e74 src/rio_rw.c
--- a/src/rio_rw.c Wed Aug 30 15:24:17 2006 +0100
+++ b/src/rio_rw.c Wed Aug 30 15:25:37 2006 +0100
@@ -52,19 +52,11 @@ static int get_file_type(mp3info *mp3);
int lk_synchronize_necessary(int rio)
{
- int ret;
- char *device_generation;
- char *p;
-
- device_generation =
- strdup(lk_properties_get_property(0, "device_generation"));
- lk_karma_get_device_settings(rio, &p);
- lk_properties_import(p);
- free(p);
- ret=strcmp(device_generation,
- lk_properties_get_property(0, "device_generation"));
- free(device_generation);
- return ret;
+ uint32_t old;
+
+ old = device_generation;
+ lk_karma_get_device_settings(rio, NULL);
+ return (old != device_generation);
}
int lk_rio_read_playlist(int rio, uint32_t fid, const char * filename)
diff -r cbd5cad77676 -r c2b3ab6d9e74 src/util.c
--- a/src/util.c Wed Aug 30 15:24:17 2006 +0100
+++ b/src/util.c Wed Aug 30 15:25:37 2006 +0100
@@ -53,18 +53,14 @@ char *simple_itoa(unsigned int i)
/* returns a string for $HOME/.openrio/pearl-$serial/$*fname */
char * lk_path_string(char * file)
{
- char * str, * serial;
- str=strdup(getenv("HOME"));
- /*26=strlen("/.openrio/pearl-0123456/")*/
- str=realloc(str, strlen(str)+26+strlen(file));
- serial = (char *)calloc(8, sizeof(char));
- snprintf(serial, 7, "%d", atoi(lk_properties_get_property(0,"serial")));
+ int len;
+ char * str, * home;
+ home=strdup(getenv("HOME"));
+ /*24=strlen("/.openrio/pearl-0123456/")*/
+ len=strlen(home)+24+strlen(file)+1;
+ str=malloc(len);
+ snprintf(str, len, "%s/.openrio/pearl-%d/%s", home, serial, file);
/*cut the leading
zeros*/
- strcat(str,"/.openrio/pearl-");
- strcat(str,serial);
- free(serial);
- strcat(str,"/");
- strcat(str,file);
return str;
}
# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1156947996 -3600
# Node ID d53799c131b5afaae7866cd52d7d2ad39ff4e776
# Parent c2b3ab6d9e74d59ca3db1b740e533d507dbeb4c8
Changed the method used for sorting tracks by artist so
that it more closely matches that used by the "Rescan music"
functionality on the device.
diff -r c2b3ab6d9e74 -r d53799c131b5 src/properties.c
--- a/src/properties.c Wed Aug 30 15:25:37 2006 +0100
+++ b/src/properties.c Wed Aug 30 15:26:36 2006 +0100
@@ -482,11 +482,23 @@ uint32_t *lk_properties_andOrSearch(int
return result;
}
-static int cmp(const void *p1, const void *p2)
-{
+static int artistcmp(const void *p1, const void *p2)
+{
+ int s1 = 0, s2 = 0;
table_t *t1 = (table_t *)p1;
table_t *t2 = (table_t *)p2;
- return strcmp(t1->str,t2->str);
+ if (memcmp(t1->str, "The ", 4) == 0 ||
+ memcmp(t1->str, "the ", 4) == 0 ) s1 = 4;
+ if (memcmp(t2->str, "The ", 4) == 0 ||
+ memcmp(t2->str, "the ", 4) == 0 ) s2 = 4;
+ return strcmp(t1->str+s1, t2->str+s2);
+}
+
+static int cmp(const void *p1, const void *p2)
+{
+ table_t *t1 = (table_t *)p1;
+ table_t *t2 = (table_t *)p2;
+ return strcmp(t1->str, t2->str);
}
int lk_properties_write_property(FILE *fp, char *attr, smalldb_type_t type,
@@ -534,7 +546,10 @@ int lk_properties_write_property(FILE *f
ptr += table[i].len;
}
if (type == SDB_STRING) {
- qsort(table,n,sizeof(table_t),cmp);
+ if (memcmp(attr, "artist", 6) == 0)
+ qsort(table,n,sizeof(table_t),artistcmp);
+ else
+ qsort(table,n,sizeof(table_t),cmp);
idx = off = 0;
ptr = table[0].str;
sz = table[0].len;
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-karma-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-karma-devel