aboutsummaryrefslogtreecommitdiff
path: root/libmpio
diff options
context:
space:
mode:
Diffstat (limited to 'libmpio')
-rw-r--r--libmpio/defs.h4
-rw-r--r--libmpio/directory.c44
-rw-r--r--libmpio/mpio.c6
-rw-r--r--libmpio/mpio.h8
4 files changed, 55 insertions, 7 deletions
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
*/