New command -toc_info_type

This commit is contained in:
2024-06-28 16:42:28 +02:00
parent 2306175432
commit 7f1abc4174
14 changed files with 304 additions and 89 deletions

View File

@ -1,7 +1,7 @@
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
Copyright 2007-2020 Thomas Schmitt, <scdbackup@gmx.net>
Copyright 2007-2024 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2 or later.
@ -510,7 +510,7 @@ int Decode_ecma119_format(struct tm *erg, char *text, int flag)
int Decode_xorriso_timestamp(struct tm *erg, char *code, int flag)
/* 2007.11.07.225624 or 2007_11_07_225624 */
/* 2007.11.07.225624 or 2007_11_07_225624 */
{
char buf[20];
int year,month,day,hour= 0,minute= 0,second= 0, i, l, mem;
@ -585,7 +585,7 @@ done:;
}
time_t Decode_timestring(char *code, time_t *date, int flag)
int Decode_timestring(char *code, time_t *date, int flag)
{
char scale_chr;
double value,seconds;
@ -643,8 +643,8 @@ time_t Decode_timestring(char *code, time_t *date, int flag)
seconds_valid= 1;
goto completed;
} else if((ret= Decode_ecma119_format(&result_tm, code, 0)) > 0) {
/* YYYYMMDDhhmmsscc[UTC] */
/* 2010040711405800UTC */
/* YYYYMMDDhhmmsscc[LOC] */
/* 2010040711405800LOC */
seconds= mktime(&result_tm);
if(ret == 1) {
@ -672,6 +672,88 @@ completed:;
}
int Decode_ecma119_17byte(time_t *seconds, char *code, int flag)
/* YYYYMMDDhhmmssccN (N = 15 minutes Offset from GMT: -48 West to +52 east) */
{
int ret;
char digits[17];
struct tm erg;
*seconds= 0;
strncpy(digits, code, 16);
digits[16]= 0;
ret= Decode_ecma119_format(&erg, digits, 0);
if(ret <= 0)
return(ret);
*seconds= mktime(&erg);
*seconds-= (int) code[16] * 60 * 15;
/* Convert from local time to GMT */
#ifdef HAVE_TM_GMTOFF
*seconds+= erg.tm_gmtoff;
#else
if(erg.tm_isdst < 0)
erg.tm_isdst = 0;
#ifndef Libburnia_timezonE
#define Libburnia_timezonE timezone
#endif
*seconds-= Libburnia_timezonE - erg.tm_isdst * 3600;
#endif
return(1);
}
int Encode_ecma119_17byte(time_t seconds, char *centi_seconds,
char *code, int flag)
{
struct tm *gmt;
gmt= gmtime(&seconds);
if(gmt == NULL)
return(0);
sprintf(code, "%4.4d", 1900 + gmt->tm_year);
sprintf(code + 4, "%2.2d", gmt->tm_mon + 1);
sprintf(code + 6, "%2.2d", gmt->tm_mday);
sprintf(code + 8, "%2.2d", gmt->tm_hour);
sprintf(code + 10, "%2.2d", gmt->tm_min);
sprintf(code + 12, "%2.2d", gmt->tm_sec);
strncpy(code + 14, centi_seconds, 2);
code[16]= code[17]= 0;
return(1);
}
/* flag: bit0= format to xorriso timestamp in local time
bit1= truncate centiseconds (with !bit0)
*/
int Untimezone_ecma119_17byte(char *code, int flag)
{
int ret;
time_t seconds;
char new_code[18];
if(code[16] == 0 && !(flag & 1))
return(1);
ret= Decode_ecma119_17byte(&seconds, code, 0);
if(ret <= 0)
return(ret);
if(flag & 1) {
/* xorriso timestamp format in local time */
if(Ftimetxt(seconds, new_code, 1 | 2) == NULL)
return(0);
} else {
/* ECMA-119 17 byte format in GMT */
ret= Encode_ecma119_17byte(seconds, flag & 2 ? "00" : code + 14, new_code,
0);
if(ret <= 0)
return(ret);
}
strcpy(code, new_code);
return(1);
}
/* @param flag bit0=with year and seconds
bit1-3= form
0= ls -l format