hmt/display.c
prpr b341756468 Tag string fields to allow UTF-8 or ISO-6937.
Modify iPlate guidance also.
Add/correct/use manifest constants.
Update filename location to offset 0x180.
2022-04-07 02:54:35 +01:00

162 lines
3.8 KiB
C

#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include "lint.h"
char *
ctimenl(time_t tm)
{
static char buf[32];
char *p;
p = ctime(&tm);
memset(buf, '\0', sizeof(buf));
if (p)
{
strncpy(buf, p, sizeof(buf) - 1);
if ((p = strpbrk(buf, "\r\n")))
*p = '\0';
}
return buf;
}
void
display_bookmarks(struct hmt *hmt)
{
int i;
for (i = 0; i < hmt->num_bookmarks && i < 32; i++)
printf("%d ", hmt->bookmarks[i]);
printf("\n");
}
void
display_hmt(struct hmt *hmt)
{
int g;
g = guidance(hmt);
if (sysopts & SYSOPT_PARSABLE)
{
printf("%s\t", hmt->mediatitle);
printf("%s\t", hmt->synopsis);
printf("%s\t", hmt->definition == DEF_HD ? "HD" : "SD");
printf("%u\t%s\t", hmt->lcn, hmt->channel);
printf("%u\t", hmt->start);
printf("%u\t", hmt->end);
printf("%s\t", hmt_flags(hmt));
if (g)
printf("%s\t", hmt->guidance);
else
printf("\t");
printf("%d\t", hmt->num_bookmarks);
printf("%u\t", hmt->schedstart);
printf("%u\t", hmt->scheddur);
printf("%d\t", hmt->genre);
printf("%u\t", hmt->resume);
printf("%s/%s\t", recordingstatus(hmt), failurereason(hmt));
printf("%u\t%u\t%u\t", hmt->series, hmt->episode,
hmt->episodetot);
printf("\n");
return;
}
printf("Format:%s\n", hmt->definition == DEF_HD ? "HD" : "SD");
printf("Title:%s\n", hmt->mediatitle);
printf("ITitle:%s\n", hmt->title);
printf("Channel:%u (%s)\n", hmt->lcn, hmt->channel);
printf("Episode:%u,%u/%u\n",
hmt->series, hmt->episode, hmt->episodetot);
printf("Folder:%s\n", hmt->directory);
if (*hmt->filename == '\0' && hmt->filename[1] != '\0')
printf("Filename:%s\n", hmt->filename + 1);
else
printf("Filename:%s\n", hmt->filename);
printf("Genre:%s (%d)\n", genredescr(hmt->genre), hmt->genre);
printf("EPG:%s\n", hmt->synopsis);
if (g)
printf("Guidance:%s\n", hmt->guidance);
if (hmt_is(hmt, HMTA_ENCRYPTED))
printf("Raw file is encrypted on disk.\n");
printf("\n");
printf("Recording Status: %s (%s)\n",
recordingstatus(hmt), failurereason(hmt));
printf("Flags: %s\n", hmt_flags(hmt));
printf("Copy count:%d\n", hmt->copycount);
printf("\n");
printf("Scheduled start:%u (%s)\n", hmt->schedstart,
ctimenl(hmt->schedstart));
printf("Scheduled duration:%u\n", hmt->scheddur);
printf("Recording start:%u (%s)\n", hmt->start,
ctimenl(hmt->start));
printf("Recording end:%u (%s)\n", hmt->end, ctimenl(hmt->end));
printf("Duration:%u\n", hmt->end - hmt->start);
printf("Stored duration:%u\n", hmt->duration);
printf("Play resumes at:%u second%s in.\n", hmt->resume,
hmt->resume == 1 ? "" : "s");
printf("Timezone offset:%d\n", hmt->tzoffset);
printf("\n");
printf("Service ID (SID):%u\n", hmt->service_id);
printf("Event ID:%u\n", hmt->event_id);
printf("Transport Stream ID (TSID):%u\n", hmt->tsid);
printf("Originating Network ID (ONID):%u\n", hmt->onid);
printf("Programme Map Table PID (PMTPID):%u\n", hmt->pmt_pid);
printf("Video PID:%u\n", hmt->video_pid);
printf("Audio PID:%u\n", hmt->audio_pid);
printf("Bookmarks:%d = ", hmt->num_bookmarks);
display_bookmarks(hmt);
/* Display basic information EPG blocks... TBC */
if (hmt->binsize > 0x1001)
{
uint16_t j;
uint32_t k;
int n;
printf("\n");
j = read_uint16(hmt->bin + 0x1000, 1);
printf("EPG Blocks:%u\n", j);
for (n = 1; n <= j; n++)
{
uint32_t off = 0x1004 + n * 32;
if (hmt->binsize < off)
break;
printf(" Block:%d", n);
k = read_uint32(hmt->bin + off + 4, 1);
printf(" Time:%u", k);
k = read_uint32(hmt->bin + off + 8, 1);
printf(" Offset:%#x\n", k);
if (k < off)
continue;
if (hmt->binsize >= k + 704)
{
/* Offset to EPG block. */
off = k;
printf(" Block%d_Title:%s\n", n,
strip_string(hmt->bin + off + HMT_EPG_TITLE));
}
/* Synopsis is off + 0x13e */
}
}
}