New option -local_charset

This commit is contained in:
Thomas Schmitt 2008-11-06 18:38:15 +00:00
parent bcea7bba32
commit 3e109996d3
5 changed files with 106 additions and 22 deletions

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Oct 25, 2008"
.TH XORRISO 1 "Nov 07, 2008"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -1513,9 +1513,9 @@ The meanings of byte codes are defined in \fBcharacter sets\fR which have
names. Shell command iconv -l lists them.
.br
Character sets should not matter as long as only alphanumeric characters are
used for file names or as long as the computer which runs xorriso uses the
same character set as the computer which wrote the loaded image and those
computers which shall read the newly emerging ISO image.
used for file names or as long as the shell session which runs xorriso uses the
same character set as the one which wrote the loaded image and the same
character set as the computers which shall read the newly emerging ISO image.
Outside these constraints it may be necessary to let xorriso convert byte
codes.
.br
@ -1525,13 +1525,23 @@ character set to the output character set is performed when a new
image tree gets written. The sets can be defined independently by options
-in_charset and -out_charset. Normally one will have both identical, if ever.
.br
xorriso expects and uses the local character set for command arguments
and file name output. Other character sets will only be in effect on media.
If conversions are desired then it is necessary to know the name of the
local character set. xorriso can inquire the same info as shell command
"locale" with argument "charmap". This may or may not be the correct name.
So one should check.
.br
A typical wrong answer would be "ANSI_X3.4-1968" if your shell session supports
non-US-ASCII characters.
It is outside the scope of xorriso how to find out the correct name in such
a case. The author of this text uses -local_charset "ISO-8859-1".
.TP
\fB\-charset\fR character_set_name
Set the character set from which to convert file names when loading an
image and to which to convert when writing an image.
.TP
\fB\-local_charset\fR character_set_name
Override the system assumption of the local character set name.
.TP
.B Exception processing:
.PP
Since the tasks of xorriso are manifold and prone to external influence, there

View File

@ -5353,7 +5353,7 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
{
int is_default, no_defaults, i, ret, adr_mode, bin_path_in_use= 0, do_single;
char *line, sfe[5 * SfileadrL + 80], mode[80], *form, *treatment;
char *in_pt, *out_pt;
char *in_pt, *out_pt, *nl_charset, *local_charset;
static char channel_prefixes[4][4]= {".","R","I","M"};
static char load_names[][20]= {"auto", "session", "track", "lba", "volid"};
static int max_load_mode= 4;
@ -5844,6 +5844,13 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
Xorriso_get_local_charset(xorriso, &local_charset, 0);
nl_charset= nl_langinfo(CODESET);
is_default= (strcmp(local_charset, nl_charset) == 0);
sprintf(line, "-local_charset %s\n", Text_shellsafe(local_charset, sfe, 0));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso, filter, fp, flag & 2);
is_default= (xorriso->out_charset == NULL && xorriso->in_charset == NULL);
in_pt= "";
if(xorriso->in_charset != NULL)
@ -10844,21 +10851,29 @@ int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag)
/* Option -charset */
/* @param flag bit0= set in_charset
bit1= set out_charset
bit2= set local_charset
*/
int Xorriso_option_charset(struct XorrisO *xorriso, char *name, int flag)
{
char *name_pt= NULL, sfe[5 * SfileadrL];
int ret;
char *name_pt= NULL, sfe[5 * SfileadrL], *local_charset;
iconv_t iconv_ret= (iconv_t) -1;
if(name != NULL)
if(name[0] != 0)
name_pt= name;
if(flag & 4) {
ret= Xorriso_set_local_charset(xorriso, name_pt, 0);
if(ret <= 0)
return(ret);
}
if(flag & 1) {
if(name_pt != NULL) {
iconv_ret= iconv_open(nl_langinfo(CODESET), name_pt);
Xorriso_get_local_charset(xorriso, &local_charset, 0);
iconv_ret= iconv_open(local_charset, name_pt);
if(iconv_ret == (iconv_t) -1) {
sprintf(xorriso->info_text,
"-%scharset: Cannot convert from charset %s",
"-%scharset: Cannot convert from character set %s",
flag & 2 ? "" : "in_", Text_shellsafe(name_pt, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",
0);
@ -10873,7 +10888,8 @@ int Xorriso_option_charset(struct XorrisO *xorriso, char *name, int flag)
}
if(flag & 2) {
if(name_pt != NULL) {
iconv_ret= iconv_open(nl_langinfo(CODESET), name_pt);
Xorriso_get_local_charset(xorriso, &local_charset, 0);
iconv_ret= iconv_open(local_charset, name_pt);
if(iconv_ret == (iconv_t) -1) {
sprintf(xorriso->info_text, "-%scharset: Cannot convert to charset %s",
flag & 1 ? "" : "out_", Text_shellsafe(name_pt, sfe, 0));
@ -10888,13 +10904,14 @@ int Xorriso_option_charset(struct XorrisO *xorriso, char *name, int flag)
return(-1);
}
}
if(name_pt == NULL)
name_pt= nl_langinfo(CODESET);
sprintf(xorriso->info_text, "Character set for %sconversion is now: %s",
(flag & 3) == 1 ? "input " : (flag & 3) == 2 ? "output " : "",
Text_shellsafe(name_pt, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "NOTE", 0);
if(flag & 3) {
if(name_pt == NULL)
Xorriso_get_local_charset(xorriso, &name_pt, 0);
sprintf(xorriso->info_text, "Character set for %sconversion is now: %s",
(flag & 3) == 1 ? "input " : (flag & 3) == 2 ? "output " : "",
Text_shellsafe(name_pt, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}
return(1);
}
@ -12411,12 +12428,14 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" -rom_toc_scan \"on\"|\"off\"[:\"emul_on\"|\"emul_off\"]",
" Enable scanning for ISO sessions on read-only drives/media",
" resp. on overwriteable media with emulated TOC.",
" -charset name Set the character set name to be use for file name",
" -charset name Set the character set name to be used for file name",
" conversion from and to media.",
" -in_charset name",
" Like -charset but only for conversion from media.",
" -out_charset name",
" Like -charset but only for conversion to media.",
" -local_charset name",
" Override system assumption of the local character set name.",
" -ban_stdio_write",
" Allow for writing only the usage of optical drives.",
" -blank \"fast\"|\"all\"|\"deformat\"|\"deformat_quickest\"",
@ -14815,7 +14834,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"cd","cdi","cdx","charset","close","commit_eject",
"dev", "dummy","dialog","disk_pattern","eject","iso_rr_pattern","follow",
"format","fs","gid","grow_blindly",
"history","indev","in_charset","joliet","list_delimiter",
"history","indev","in_charset","joliet","list_delimiter","local_charset",
"mark","not_leaf","not_list","not_mgt",
"options_from_file","osirrox","outdev","out_charset","overwrite",
"pacifier","padding","path_list","pathspecs","pkt_output","print","prompt",
@ -15223,6 +15242,10 @@ next_command:;
(*idx)+= 2;
ret= Xorriso_option_load(xorriso, arg1, arg2, 0);
} else if(strcmp(cmd,"local_charset")==0) {
(*idx)++;
ret= Xorriso_option_charset(xorriso, arg1, 4);
} else if(strcmp(cmd,"logfile")==0) {
(*idx)+= 2;
ret= Xorriso_option_logfile(xorriso, arg1, arg2, 0);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.11.04.162214"
#define Xorriso_timestamP "2008.11.06.183736"

View File

@ -21,6 +21,9 @@
#include <fcntl.h>
#include <utime.h>
/* for -charset */
#include <iconv.h>
#include <langinfo.h>
/* ------------------------------------------------------------------------ */
@ -3855,6 +3858,7 @@ int Xorriso_toc_line(struct XorrisO *xorriso, int flag)
/* @param flag bit0= no output if no boot record was found
bit1= short form
bit3= report to info channel (else to result channel)
*/
int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag)
@ -3932,6 +3936,8 @@ no_boot:;
}
strcat(respt, "\n");
Xorriso_toc_line(xorriso, flag & 8);
if(flag & 2)
return(1);
if(bin_path_valid)
sprintf(respt, "Boot bin_path: %s\n", Text_shellsafe(path, sfe, 0));
else if(xorriso->loaded_boot_bin_lba <= 0)
@ -4043,7 +4049,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
return(1);
if(!(flag & 2))
Xorriso_show_boot_info(xorriso, 1 | (flag & 8));
Xorriso_show_boot_info(xorriso, 1 | (flag & 8) | ((flag & 1) << 1));
disc= isoburn_toc_drive_get_disc(drive);
if(flag & 4)
@ -8126,3 +8132,43 @@ int Xorriso_extract_cut(struct XorrisO *xorriso,
return(1);
}
int Xorriso_get_local_charset(struct XorrisO *xorriso, char **name, int flag)
{
(*name)= iso_get_local_charset(0);
return(1);
}
int Xorriso_set_local_charset(struct XorrisO *xorriso, char *name, int flag)
{
int ret;
char *nl_charset, sfe[5 * SfileadrL];
iconv_t iconv_ret= (iconv_t) -1;
nl_charset= nl_langinfo(CODESET);
if(name == NULL)
name= nl_charset;
if(name != NULL) {
iconv_ret= iconv_open(nl_charset, name);
if(iconv_ret == (iconv_t) -1)
goto cannot;
else
iconv_close(iconv_ret);
}
ret= iso_set_local_charset(name, 0);
if(ret <= 0) {
cannot:;
sprintf(xorriso->info_text,
"-local_charset: Cannot assume as local character set: %s",
Text_shellsafe(name, sfe, 0));
return(0);
}
sprintf(xorriso->info_text, "Local character set is now assumed as: %s",
Text_shellsafe(name, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "NOTE", 0);
return(1);
}

View File

@ -300,6 +300,11 @@ int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize,
char *head_buffer, struct CheckmediajoB *job,
int flag);
int Xorriso_get_local_charset(struct XorrisO *xorriso, char **name, int flag);
int Xorriso_set_local_charset(struct XorrisO *xorriso, char *name, int flag);
struct CheckmediajoB {
int use_dev; /* 0= use indev , 1= use outdev , 2= use sector map*/