New option -local_charset

This commit is contained in:
2008-11-06 18:38:15 +00:00
parent de05652cf1
commit 22dc07ce9a
5 changed files with 106 additions and 22 deletions

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);
}