aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--etc/mpio/mpioshrc2
-rw-r--r--libmpio/defs.h4
-rw-r--r--libmpio/directory.c44
-rw-r--r--libmpio/mpio.c6
-rw-r--r--libmpio/mpio.h8
-rw-r--r--mpiosh/callback.c49
-rw-r--r--mpiosh/config.c10
-rw-r--r--mpiosh/config.h3
-rw-r--r--mpiosh/mpiosh.c6
10 files changed, 126 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index d47f1a2..412bfc6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2002-11-13 Markus Germeier <mager@tzi.de>
+
+ * mpiosh/callback.c (mpiosh_cmd_format): backup and restore
+ config files (probably not complete yet!)
+ * libmpio/defs.h (MPIO_CHARSET):
+ * libmpio/directory.c (mpio_dentry_put, mpio_dentry_get_real):
+ use ISO-8859-15 instead of ASCII as default charset encoding
+ (much nicer now!)
+ * libmpio/directory.c (mpio_charset_get, mpio_charset_set):
+ added functions to allow changing of charset
+ * mpiosh/config.c: read charset from config file
+
2002-11-04 Andreas Buesching <crunchy@tzi.de>
* mpiosh/callback.c (mpiosh_cmd_quit): writing configuration
@@ -31,7 +43,6 @@
mpiosh/config.h: added these new files to support global and user
configuration files.
-
2002-10-27 Markus Germeier <mager@tzi.de>
* libmpio/mpio.{c,h}: split mpio_file_{get,put} into several
diff --git a/etc/mpio/mpioshrc b/etc/mpio/mpioshrc
index 516b7d0..9160d59 100644
--- a/etc/mpio/mpioshrc
+++ b/etc/mpio/mpioshrc
@@ -2,4 +2,4 @@
default_mem=internal
prompt_int=mpio <i>
prompt_ext=mpio <e>
-
+charset=ISO-8859-15
diff --git a/libmpio/defs.h b/libmpio/defs.h
index 49d8311..03099fb 100644
--- a/libmpio/defs.h
+++ b/libmpio/defs.h
@@ -1,7 +1,7 @@
/* -*- linux-c -*- */
/*
- * $Id: defs.h,v 1.13 2002/10/27 02:45:28 germeier Exp $
+ * $Id: defs.h,v 1.14 2002/11/13 23:05:28 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -100,6 +100,7 @@ typedef BYTE mpio_filename_t[MPIO_FILENAME_LEN];
#endif
#define MPIO_DEVICE "/dev/usb/mpio"
+#define MPIO_CHARSET "ISO-8859-15"
#define SECTOR_SIZE 0x200
#define SECTOR_ECC 0x040
@@ -214,6 +215,7 @@ typedef struct {
BYTE version[CMD_SIZE];
int fd;
+ BYTE *charset; /* charset used for filename conversion */
mpio_firmware_t firmware;
diff --git a/libmpio/directory.c b/libmpio/directory.c
index c5bdc8e..4ef08f4 100644
--- a/libmpio/directory.c
+++ b/libmpio/directory.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: directory.c,v 1.10 2002/10/27 17:37:25 germeier Exp $
+ * $Id: directory.c,v 1.11 2002/11/13 23:05:28 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -65,6 +65,44 @@ int date_dos2unix(unsigned short time,unsigned short date)
return secs;
}
+/*
+ * charset for filename encoding/converting
+ */
+BYTE *
+mpio_charset_get(mpio_t *m)
+{
+ return strdup(m->charset);
+}
+
+BYTE
+mpio_charset_set(mpio_t *m, BYTE *charset)
+{
+ iconv_t ic;
+ int r = 1;
+
+ ic = iconv_open("UNICODE", charset);
+ if (ic < 0)
+ r=0;
+ iconv_close(ic);
+
+ ic = iconv_open(charset, "UNICODE");
+ if (ic < 0)
+ r=0;
+ iconv_close(ic);
+
+ if (r)
+ {
+ debugn(2, "setting new charset to: \"%s\"\n", charset);
+ free(m->charset);
+ m->charset=strdup(charset);
+ } else {
+ debugn(2, "could not set charset to: \"%s\"\n", charset);
+ }
+
+ return r;
+}
+
+
/* directory operations */
BYTE *
@@ -256,7 +294,7 @@ mpio_dentry_get_real(mpio_t *m, mpio_mem_t mem, BYTE *buffer,
if (vfat)
{
- ic = iconv_open("ASCII", "UNICODE");
+ ic = iconv_open(m->charset, "UNICODE");
memset(fname, 0, filename_size);
hexdumpn(4, unicode, in+2);
debugn(4, "before iconv: in: %2d - out: %2d\n", in, out);
@@ -471,7 +509,7 @@ mpio_dentry_put(mpio_t *m, mpio_mem_t mem,
}
/* generate vfat filename in UNICODE */
- ic = iconv_open("UNICODE", "ASCII");
+ ic = iconv_open("UNICODE", m->charset);
fin = in = filename_size + 1;
fout = out = filename_size * 2 + 2 + 26;
fname = malloc(in);
diff --git a/libmpio/mpio.c b/libmpio/mpio.c
index 2bcdd5c..fbf6def 100644
--- a/libmpio/mpio.c
+++ b/libmpio/mpio.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: mpio.c,v 1.36 2002/10/27 17:37:27 germeier Exp $
+ * $Id: mpio.c,v 1.37 2002/11/13 23:05:28 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -106,7 +106,6 @@ mpio_check_filename(mpio_filename_t filename)
return 0;
}
-
void
mpio_init_internal(mpio_t *m)
{
@@ -303,6 +302,9 @@ mpio_init(mpio_callback_init_t progress_callback)
mpio_rootdir_read(new_mpio, MPIO_EXTERNAL_MEM);
}
}
+
+ /* set default charset for filename conversion */
+ new_mpio->charset=strdup(MPIO_CHARSET);
return new_mpio;
}
diff --git a/libmpio/mpio.h b/libmpio/mpio.h
index 3f0205c..230ee9a 100644
--- a/libmpio/mpio.h
+++ b/libmpio/mpio.h
@@ -1,7 +1,7 @@
#/* -*- linux-c -*- */
/*
- * $Id: mpio.h,v 1.12 2002/10/27 17:37:27 germeier Exp $
+ * $Id: mpio.h,v 1.13 2002/11/13 23:05:28 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -63,6 +63,12 @@ mpio_model_t mpio_get_model(mpio_t *);
/* retrieves free memory in bytes */
int mpio_memory_free(mpio_t *, mpio_mem_t, int *free);
+/*
+ * charset for filename encoding/converting
+ */
+BYTE *mpio_charset_get(mpio_t *);
+BYTE mpio_charset_set(mpio_t *, BYTE *);
+
/*
* directory operations
*/
diff --git a/mpiosh/callback.c b/mpiosh/callback.c
index b43d0c4..a88bbc9 100644
--- a/mpiosh/callback.c
+++ b/mpiosh/callback.c
@@ -2,7 +2,7 @@
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
- * $Id: callback.c,v 1.31 2002/11/04 16:25:17 crunchy Exp $
+ * $Id: callback.c,v 1.32 2002/11/13 23:05:28 germeier Exp $
*
* Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>
*
@@ -212,6 +212,10 @@ mpiosh_cmd_open(char *args[])
printf("error: could not open connection MPIO player\n");
else
printf("connection to MPIO player is opened\n");
+
+ if ((mpiosh.dev) && (mpiosh.config->charset))
+ mpio_charset_set(mpiosh.dev, mpiosh.config->charset);
+
}
void
@@ -592,27 +596,58 @@ void
mpiosh_cmd_format(char *args[])
{
char answer[512];
+ BYTE *config, *fmconfig;
+ int csize, fmsize;
MPIOSH_CHECK_CONNECTION_CLOSED;
UNUSED(args);
- printf("WARNING\n");
- printf("Support for formatting memory is not complete and has"
- " some known issues!!\n");
- printf("WARNING\n");
-
printf("This will destroy all tracks saved on the memory card. "
"Are you sure (y/n)? ");
fgets(answer, 511, stdin);
if (answer[0] == 'y' || answer[0] == 'Y') {
+ if (mpiosh.card == MPIO_INTERNAL_MEM) {
+ /* save config files and write them back after formatting */
+ config = NULL;
+ fmconfig = NULL;
+
+ csize = mpio_file_get_to_memory(mpiosh.dev, MPIO_INTERNAL_MEM,
+ MPIO_CONFIG_FILE, NULL, &config);
+ fmsize = mpio_file_get_to_memory(mpiosh.dev, MPIO_INTERNAL_MEM,
+ MPIO_CHANNEL_FILE, NULL, &fmconfig);
+ }
+
if (mpio_memory_format(mpiosh.dev, mpiosh.card,
mpiosh_callback_format) == -1)
printf("\nfailed\n");
- else
+ else {
printf("\n");
+
+ if (mpiosh.card == MPIO_INTERNAL_MEM) {
+ /* restore everything we saved */
+ if (config)
+ if (mpio_file_put_from_memory(mpiosh.dev, MPIO_INTERNAL_MEM,
+ MPIO_CONFIG_FILE, FTYPE_CONF,
+ NULL, config, csize)==-1)
+ mpio_perror("error");
+ if (fmconfig)
+ if (mpio_file_put_from_memory(mpiosh.dev, MPIO_INTERNAL_MEM,
+ MPIO_CHANNEL_FILE, FTYPE_CHAN,
+ NULL, fmconfig, fmsize)==-1)
+ mpio_perror("error");
+
+ if (config || fmconfig)
+ mpio_sync(mpiosh.dev, MPIO_INTERNAL_MEM);
+ if (config)
+ free(config);
+ if (fmconfig)
+ free(fmconfig);
+ }
+
+ }
}
}
diff --git a/mpiosh/config.c b/mpiosh/config.c
index dfe0e29..b77c99f 100644
--- a/mpiosh/config.c
+++ b/mpiosh/config.c
@@ -2,7 +2,7 @@
*
* Author: Andreas Buesching <crunchy@tzi.de>
*
- * $Id: config.c,v 1.2 2002/11/04 16:25:17 crunchy Exp $
+ * $Id: config.c,v 1.3 2002/11/13 23:05:28 germeier Exp $
*
* Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>
*
@@ -137,6 +137,14 @@ mpiosh_config_read(struct mpiosh_config_t *config)
config->default_mem = MPIO_EXTERNAL_MEM;
}
}
+
+ value = mpiosh_config_read_key(config, "mpiosh", "charset");
+ if (value) {
+ config->charset = strdup(value);
+ } else {
+ config->charset = NULL;
+ }
+
}
return 1;
diff --git a/mpiosh/config.h b/mpiosh/config.h
index 24ca437..6c37752 100644
--- a/mpiosh/config.h
+++ b/mpiosh/config.h
@@ -2,7 +2,7 @@
*
* Author: Andreas Buesching <crunchy@tzi.de>
*
- * $Id: config.h,v 1.1 2002/10/29 20:03:35 crunchy Exp $
+ * $Id: config.h,v 1.2 2002/11/13 23:05:28 germeier Exp $
*
* Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>
*
@@ -32,6 +32,7 @@ struct mpiosh_config_t {
char *prompt_int;
char *prompt_ext;
+ char *charset;
unsigned default_mem;
};
diff --git a/mpiosh/mpiosh.c b/mpiosh/mpiosh.c
index 5d76f42..2f39c04 100644
--- a/mpiosh/mpiosh.c
+++ b/mpiosh/mpiosh.c
@@ -2,7 +2,7 @@
/*
*
- * $Id: mpiosh.c,v 1.22 2002/11/04 16:25:17 crunchy Exp $
+ * $Id: mpiosh.c,v 1.23 2002/11/13 23:05:28 germeier Exp $
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
@@ -63,6 +63,10 @@ mpiosh_init(void)
mpiosh.dev = mpio_init(mpiosh_callback_init);
printf("\n");
+
+ if ((mpiosh.dev) && (mpiosh.config->charset))
+ mpio_charset_set(mpiosh.dev, mpiosh.config->charset);
+
}
void