On Mon, Aug 21, 2006, Keith Bennett wrote:
> > Regarding the computer info, hostnames could be concatenated with
> > the pathnames with ':' rather than " ". This way each string
> > could be directly interpreted as a Net address.
>
> Okay. I will also add an identifier and version number to the
> top of both the properties and DB files. Any ideas about what
> the identifiers should be? How about LkPrP and LkFdB?
This patch adds an identifier to the fdb file.
It also separates the hostname from the path with a ":" character.
I'll add LkPrP at some later date.
Keith.
# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1156240281 -3600
# Node ID ef6c13edd3f2ca7cb659aff26c19b1dd95e69bb7
# Parent 8a3256630392f562b0c0981a824cc46599a79980
Write identifying header to fdb files.
Separate hostname and path by a ':' character in the fdb file.
Ignore playlist entries when testing for a missing fdb path.
diff -r 8a3256630392 -r ef6c13edd3f2 src/errors.c
--- a/src/errors.c Tue Aug 22 00:30:57 2006 +0200
+++ b/src/errors.c Tue Aug 22 10:51:21 2006 +0100
@@ -52,7 +52,9 @@ const char *lkerrorList[MAXLKERRORS + 1]
/* E_WRCHUNK 33 */ "** Libkarma error: write_file_chunk() failed",
/* E_SMALLMP3 34 */ "** Libkarma error: tune file is too small",
/* E_UNSUPTAG 35 */ "* Libkarma warning: unsupported tag type",
- /* E_NOTAGFILE 36 */ "* Libkarma warning: can't access tags file"
+ /* E_NOTAGFILE 36 */ "* Libkarma warning: can't access tags file",
+ /* E_BADFDB 37 */ "* Libkarma warning: unrecognised fdb file",
+ /* E_UNSUPFDB 38 */ "* Libkarma warning: unsupported fdb file"
};
#define libkarmaErrorString lkerrorList[libkarmaError]
diff -r 8a3256630392 -r ef6c13edd3f2 src/fdb.c
--- a/src/fdb.c Tue Aug 22 00:30:57 2006 +0200
+++ b/src/fdb.c Tue Aug 22 10:51:21 2006 +0100
@@ -18,6 +18,35 @@
#include "fdb.h"
static int rio = 0;
+
+static int fdb_read_header(gzFile fdb_file)
+{
+ char *p, buf[64];
+ int ver;
+
+ gzread(fdb_file, buf, 64);
+ buf[63] = '\0';
+ if (memcmp(buf, "LkFdB ", 6) != 0) {
+ lk_errors_set(E_BADFDB);
+ return -1;
+ }
+ for (p=buf; *p != '\0'; p++)
+ if (*p == ' ')
+ break;
+ *p = '\0';
+ ver = atoi(buf);
+ if (ver > 1) {
+ lk_errors_set(E_BADFDB);
+ return -1;
+ }
+ p++;
+ for (; *p != '\0'; p++)
+ if (*p == '\n')
+ break;
+ p++;
+ gzseek(fdb_file, p-buf, SEEK_SET);
+ return 0;
+}
/*
* fid:fid_generation path
@@ -54,6 +83,9 @@ int lk_fdb_load(void)
fdb_file=gzopen(fname, "r");
free(fname);
if (fdb_file == NULL)
+ return -1;
+
+ if (fdb_read_header(fdb_file) != 0)
return -1;
do{
@@ -97,6 +129,9 @@ char **lk_fdb_getlist(char *fdb)
fdb_file=gzopen(fdb, "r");
if (fdb_file == NULL)
+ return NULL;
+
+ if (fdb_read_header(fdb_file) != 0)
return NULL;
do{
@@ -148,6 +183,14 @@ int lk_fdb_save(void)
if (fdb_file == NULL)
return -1;
+ gzwrite(fdb_file, "LkFdB 1 ", 8);
+ id = lk_properties_get_property(0,"serial");
+ if (id)
+ gzwrite(fdb_file, id, strlen(id));
+ else
+ gzwrite(fdb_file, "0", 1);
+ gzwrite(fdb_file, "\n", 1);
+
fdb=lk_properties_andOrSearch(EXACT|ORS, NULL, "path", "");
if(fdb){
for(i=0; fdb[i]; i++){
@@ -159,13 +202,19 @@ int lk_fdb_save(void)
if (!path || !tm) {
if (first) {
- tm=lk_properties_get_property_hash(tmp, "title");
- if (tm && strncmp(tm, FDB_FILENAME,
- strlen(FDB_FILENAME)+1) == 0) {
- tm =lk_properties_get_property_hash(tmp, "type");
- if (tm && strncmp(tm, "taxi", 5) == 0)
+ tm=lk_properties_get_property_hash(tmp, "type");
+
+ /* playlist files always have a missing path */
+ if (tm && memcmp(tm, "playlist", 8) == 0)
+ continue;
+ else if (tm && strncmp(tm, "taxi", 5) == 0) {
+ /* fdb file always has a missing path */
+ tm=lk_properties_get_property_hash(tmp, "title");
+ if (tm && strncmp(tm, FDB_FILENAME,
+ strlen(FDB_FILENAME)+1) == 0)
continue;
}
+
lk_errors_set(E_NOPROP);
first = 0;
}
diff -r 8a3256630392 -r ef6c13edd3f2 src/lkarma.h
--- a/src/lkarma.h Tue Aug 22 00:30:57 2006 +0200
+++ b/src/lkarma.h Tue Aug 22 10:51:21 2006 +0100
@@ -150,8 +150,10 @@ char * lk_errors_numberstr(int lkerrnum)
#define E_SMALLMP3 34 /* error: tune file is too small */ /* RIO_RW */
#define E_UNSUPTAG 35 /* warning: unsupported tag type */ /* RIO_RW */
#define E_NOTAGFILE 36 /* warning: can't access tags file */ /* RIO_RW */
-
-#define MAXLKERRORS 36
+#define E_BADFDB 37 /* warning: unrecognised fdb file */ /* FDB */
+#define E_UNSUPFDB 38 /* warning: unsupported fdb file */ /* FDB */
+
+#define MAXLKERRORS 38
/*
diff -r 8a3256630392 -r ef6c13edd3f2 src/rio_rw.c
--- a/src/rio_rw.c Tue Aug 22 00:30:57 2006 +0200
+++ b/src/rio_rw.c Tue Aug 22 10:51:21 2006 +0100
@@ -288,7 +288,7 @@ static uint32_t lk_rio_do_write(int fdb,
if (!fdb) {
if (gethostname(fullpath, 255) != 0) fullpath[0] = '\0';
len = strlen(fullpath);
- fullpath[len] = ' ';
+ fullpath[len] = ':';
path = realpath(filename, fullpath+len+1);
if (path)
lk_properties_set_property(fid, "path", fullpath);
diff -r 8a3256630392 -r ef6c13edd3f2 tools/riocp.c
--- a/tools/riocp.c Tue Aug 22 00:30:57 2006 +0200
+++ b/tools/riocp.c Tue Aug 22 10:51:21 2006 +0100
@@ -137,7 +137,7 @@ static void fdb_download(int checkhost)
continue;
memcpy(hostname, filename, 255);
for (p=hostname; *p != '\0'; p++)
- if (*p == ' ')
+ if (*p == ':')
break;
*p = '\0';
if (checkhost && memcmp(hostname, ourhostname, len) != 0)
-------------------------------------------------------------------------
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