Compare commits

...

No commits in common. 'master' and 'foxsat' have entirely different histories.

  1. 18
      Makefile
  2. 438
      cmd.c
  3. 274
      display.c
  4. 200
      file.c
  5. 174
      hmt.h
  6. 57
      lint.h
  7. 359
      main.c
  8. 20
      util.c

18
Makefile

@ -1,5 +1,5 @@
MAKE=make
MAKE=gmake
# Setting these makes sure that the subsequent include files know that
# we are going to be threaded so they should do whatever they need to
@ -15,15 +15,20 @@ DEFS=-D_REENTRANT -D_TS_ERRNO -DHMT_PROTECT
SRCS= cmd.c \
display.c \
file.c \
hmt.c \
main.c \
util.c
OBJS= $(SRCS:.c=.o)
#CC=mipsel-linux-gcc
#CC=mips-linux-gcc
#CC=gcc
#STRIP=mips-linux-strip
#STRIP=strip
CC=mips-linux-gcc
STRIP=mips-linux-strip
PLATFORM=$(shell uname -s | cut -d- -f1)
PROCESSOR=$(shell uname -p)
CFLAGS=-g -std=c99
CFLAGS=-g
INCS=
LIBS=
ifeq ($(PLATFORM),CYGWIN_NT)
@ -47,6 +52,7 @@ hmt: ${OBJS}
${CFLAGS} -o $@ \
${OBJS} \
${LIBS}
${STRIP} hmt
@echo "Done..."
clean:
@ -62,9 +68,5 @@ tags:
@echo " $<"
@$(CC) $(CFLAGS) ${WARN} ${DEFS} ${INCS} -c $< -o $@
install: hmt
strip hmt
cp hmt /mod/bin/hmt
${OBJS}: lint.h

438
cmd.c

@ -2,407 +2,149 @@
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <sys/mman.h>
#include "lint.h"
#define CHECK_OFFSET(xxx) \
if (hmt->binsize < (xxx)) \
{ \
printf("File too small to patch.\n"); \
return; \
}
void
cmd_new(struct hmt *hmt, int flag)
{
CHECK_OFFSET(HMT_FLAGS1)
if (hmt->binsize < HMT_FLAGS1)
{
printf("File too small to patch.\n");
return;
}
if (flag)
hmt->bin[HMT_FLAGS1] &= ~HMT_FLAGS1_NEW;
else
hmt->bin[HMT_FLAGS1] |= HMT_FLAGS1_NEW;
hmt->modified++;
}
void
cmd_lock(struct hmt *hmt, int flag)
{
CHECK_OFFSET(HMT_FLAGS1)
if (hmt->binsize < HMT_FLAGS1)
{
printf("File too small to patch.\n");
return;
}
if (flag)
hmt->bin[HMT_FLAGS1] |= HMT_FLAGS1_LOCKED;
else
hmt->bin[HMT_FLAGS1] &= ~HMT_FLAGS1_LOCKED;
hmt->modified++;
}
void
cmd_guidance(struct hmt *hmt, int flag)
{
/* 0x03E0 2 byte 'Guide' flag for Media List.
0xFF00 = Guide off. 0x0101 = Guide on. */
if (flag)
{
patch_byte(hmt, HMT_GUIDEFLAG, 0x01);
patch_byte(hmt, HMT_GUIDEFLAG + 1, 0x01);
}
else
{
patch_byte(hmt, HMT_GUIDEFLAG, 0xff);
patch_byte(hmt, HMT_GUIDEFLAG + 1, 0x00);
}
hmt->modified++;
}
void
cmd_protect(struct hmt *hmt, int flag)
{
CHECK_OFFSET(HMT_FLAGS2)
if (flag)
hmt->bin[HMT_FLAGS2] = 0;
else
hmt->bin[HMT_FLAGS2] = 4;
hmt->modified++;
}
void
cmd_encrypted(struct hmt *hmt, int flag)
{
CHECK_OFFSET(HMT_FLAGS3);
if (flag)
hmt->bin[HMT_FLAGS3] |= HMT_IS_ENCRYPTED;
else
hmt->bin[HMT_FLAGS3] &= ~HMT_IS_ENCRYPTED;
hmt->modified++;
}
void
cmd_thumbnail(struct hmt *hmt, int flag)
{
CHECK_OFFSET(HMT_FLAGS3);
if (flag)
hmt->bin[HMT_FLAGS3] |= HMT_HAS_THUMBNAIL;
else
hmt->bin[HMT_FLAGS3] &= ~HMT_HAS_THUMBNAIL;
hmt->modified++;
}
void
cmd_shrunk(struct hmt *hmt, int flag)
{
CHECK_OFFSET(HMT_SHRUNK);
if (flag)
hmt->bin[HMT_SHRUNK] = 'E';
else
hmt->bin[HMT_SHRUNK] = 'e';
hmt->modified++;
}
void
cmd_dedup(struct hmt *hmt, int flag)
{
CHECK_OFFSET(HMT_DEDUPED);
if (flag)
hmt->bin[HMT_DEDUPED] = 'N';
else
hmt->bin[HMT_DEDUPED] = 'n';
hmt->modified++;
}
void
cmd_detectads(struct hmt *hmt, int flag)
{
CHECK_OFFSET(HMT_DETECTADS);
if (flag)
hmt->bin[HMT_DETECTADS] = 'G';
else
hmt->bin[HMT_DETECTADS] = 'g';
hmt->modified++;
}
void
cmd_setgenre(struct hmt *hmt, char *g)
{
CHECK_OFFSET(HMT_GENRE)
printf("Current genre: %s\n", genredescr(hmt->bin[HMT_GENRE]));
if (*g == '-')
hmt->bin[HMT_GENRE] = (uint8_t)atoi(g + 1);
else
hmt->bin[HMT_GENRE] = genrecode(g);
printf("Set genre to: %s\n", genredescr(hmt->bin[HMT_GENRE]));
hmt->modified++;
}
void
cmd_setresume(struct hmt *hmt, char *resume)
{
int32_t r = strtol(resume, (char **)NULL, 10);
CHECK_OFFSET(HMT_PLAYED_TIME)
if (r < 0)
{
uint32_t d;
d = hmt->end - hmt->start;
printf("Recording Duration:%u\n", d);
r += d;
}
printf("Setting resume point to: %u second(s) in.\n", r);
write_uint32(hmt->bin + HMT_PLAYED_TIME, r);
hmt->modified++;
}
static void
patch_epg_offset(struct hmt *hmt, uint32_t offset, uint32_t len, char *str)
{
if (hmt->binsize > 0x1001)
{
uint32_t j, k;
uint32_t n;
/* Read the number of EPG blocks. */
j = read_uint16(hmt->bin + 0x1000, 1);
/* Loop through them. */
for (n = 1; n <= j; n++)
{
/* Offset of block header. */
uint32_t off = 0x1004 + n * 32;
if (hmt->binsize < off)
break;
/* Read offset of EPG data. */
k = read_uint32(hmt->bin + off + 8, 1);
if (k < off)
continue;
if (hmt->binsize >= k + 704)
{
if (debug)
printf("Patching EPG block %d.\n", n);
patch_string(hmt, k + offset, len, str);
}
}
}
}
void
cmd_settitle(struct hmt *hmt, char *str)
{
patch_string(hmt, HMT_TITLE, HMT_TITLE_LEN, str);
patch_string(hmt, HMT_ITITLE, HMT_ITITLE_LEN, str);
patch_epg_offset(hmt, 0x3e, HMT_TITLE_LEN, str);
}
void
cmd_setsynopsis(struct hmt *hmt, char *str)
{
CHECK_OFFSET(HMT_EPG)
if (strlen(str) >= HMT_EPG_LEN)
if (hmt->binsize < HMT_FLAGS1)
{
fprintf(stderr, "New synopsis too long.\n");
printf("File too small to patch.\n");
return;
}
patch_string(hmt, HMT_EPG, HMT_EPG_LEN, str);
patch_epg_offset(hmt, 0x141, HMT_EPG_LEN, str);
}
void
cmd_setseries(struct hmt *hmt, char *g)
{
unsigned int series, episode, episodes;
if (sscanf(g, "%u,%u,%u", &series, &episode, &episodes) >= 2)
{
hmt->bin[HMT_SERIES] = (uint8_t)series;
hmt->bin[HMT_EPISODE] = (uint8_t)episode;
hmt->bin[HMT_EPISODETOT] = (uint8_t)episodes;
hmt->modified++;
}
if (flag)
hmt->bin[HMT_FLAGS1] |= HMT_FLAGS1_PROTECTED;
else
printf("Invalid episode '%s'\n", g);
}
static int
intcomp(const void *a, const void *b)
{
return (*(uint32_t *)a - *(uint32_t *)b);
hmt->bin[HMT_FLAGS1] &= ~HMT_FLAGS1_PROTECTED;
}
void
cmd_bookmarks(struct hmt *hmt, char *str, int add)
patch_string(struct hmt *hmt, uint32_t offset, char *str, int ReportErrs)
{
uint32_t *b = (uint32_t *)(hmt->bin + HMT_BOOKMARKS);
uint16_t n = read_uint16(hmt->bin + HMT_BOOKMARKS_CNT, 1);
char *p;
int i;
if (!add)
n = 0;
if (!str || !(p = strtok(str, ":")))
if (hmt->binsize < offset + strlen(str))
{
/* No bookmarks provided. */
if (add)
return;
*(uint16_t *)(hmt->bin + HMT_BOOKMARKS_CNT) = 0;
hmt->modified++;
if (ReportErrs==1) {
printf("File too small to patch.\n");
}
return;
}
do
{
if (n >= 32)
{
fprintf(stderr, "Too many bookmarks, maximum 32.\n");
return;
}
b[n++] = (uint32_t)strtoul(p, (char **)NULL, 10);
hmt->modified++;
} while ((p = strtok((char *)NULL, ":")));
*(uint16_t *)(hmt->bin + HMT_BOOKMARKS_CNT) = n;
qsort(b, n, sizeof(uint32_t), intcomp);
}
void
patch_byte(struct hmt *hmt, uint32_t offset, uint8_t val)
{
CHECK_OFFSET(offset)
if (hmt->bin[offset] != val)
{
hmt->bin[offset] = val;
hmt->modified++;
if (offset != HMT_FILENAME) {
for (i=0; i<255; i++) {hmt->bin[offset+i] = 0x00;}
hmt->bin[offset] = 0x15;
strcpy((char *)(hmt->bin + offset+1), (const char *)str);
} else {
for (i=0; i<512; i++) {hmt->bin[offset+i] = 0x00;}
strcpy((char *)(hmt->bin + offset), (const char *)str);
}
}
void
patch_string(struct hmt *hmt, uint32_t offset, uint32_t len, char *str)
cmd_getstring(struct hmt *hmt, uint32_t offset)
{
CHECK_OFFSET(offset + strlen(str))
if (debug > 3)
fprintf(stderr, "patch_string(%#x, %d, %s)\n",
offset, len, str);
memset(hmt->bin + offset, '\0', len - 1);
strcpy((char *)(hmt->bin + offset), (const char *)str);
hmt->modified++;
printf("%s\n", strip_string(hmt->bin + offset));
}
void
patch_uint16(struct hmt *hmt, uint32_t offset, uint16_t val)
expand_hmt(struct hmt *hmt, uint32_t new_size)
{
CHECK_OFFSET(offset)
/*void *new_bin = malloc(new_size);*/
write_uint16(hmt->bin + offset, val);
hmt->modified++;
}
void
patch_uint32(struct hmt *hmt, uint32_t offset, uint32_t val)
{
CHECK_OFFSET(offset)
write_uint32(hmt->bin + offset, val);
hmt->modified++;
}
void
cmd_patch(struct hmt *hmt, char *str)
{
int width;
uint32_t offset;
uint32_t val;
char offsets[0x20], vals[0x20];
if (sscanf(str, "%d=%[^:]:%s", &width, offsets, vals) != 3)
{
printf("Syntax error.\n");
return;
}
offset = strtoul(offsets, (char **)NULL, 0);
val = strtoul(vals, (char **)NULL, 0);
printf("Patching width %d - %#x(%u) = %#x(%u)\n", width,
offset, offset, val, val);
switch(width)
{
case 8:
patch_byte(hmt, offset, (uint8_t)val);
break;
case 16:
patch_uint16(hmt, offset, (uint16_t)val);
break;
case 32:
patch_uint32(hmt, offset, val);
break;
default:
printf("Unknown patch width.\n");
break;
}
if (debug)
printf("expand_hmt(0x%08X, %d) {\n", (void *)hmt, (int)new_size);
/*memset(new_bin, 0, new_size);*/
/*memcpy(new_bin, hmt->bin, hmt->binsize);*/
munmap((void *)hmt->bin, hmt->binsize);
hmt->binsize = new_size;
/* Will this work when size is larger than file? */
hmt->bin = (uint8_t *)mmap(NULL, hmt->binsize, PROT_READ|PROT_WRITE,
MAP_SHARED, hmt->fd, 0);
/*free(hmt->bin);*/
/*hmt->bin = new_bin;*/
hmt->epgstart = hmt->bin + 0x1004;
if (debug)
printf("expand_hmt(0x%08X, %d) }\n", (void *)hmt, (int)new_size);
}
void
cmd_unpatch(struct hmt *hmt, char *str)
init_hmt_epg_block(struct hmt *hmt)
{
int width;
uint32_t offset;
char offsets[0x20];
if (sscanf(str, "%d=%[^:]", &width, offsets) != 2)
{
printf("Syntax error.\n");
return;
}
offset = strtoul(offsets, (char **)NULL, 0);
if (hmt->binsize < offset)
{
printf("Offset too large for file.\n");
return;
}
uint32_t duration = 0;
if (debug)
printf("Reading width %d - %#x(%u)\n", width,
offset, offset);
switch(width)
{
case 8:
{
uint8_t val = hmt->bin[offset] & 0xff;
printf("%d %#x\n", val, val);
break;
}
case 16:
{
uint16_t val = read_uint16(hmt->bin + offset, 1);
printf("%d %#x\n", val, val);
break;
}
case 32:
{
uint32_t val = read_uint32(hmt->bin + offset, 1);
printf("%d %#x\n", val, val);
break;
}
default:
printf("Unknown patch width.\n");
break;
}
printf("init_hmt_epg_block(0x%08X) {\n", (void *)hmt);
hmt->bin[HMT_BLOCK_LENGTH] = 0x1;
if (debug)
printf(
"Zeroing 0x%04X bytes from 0x%04X\n",
HMT_EPG_BLOCK_LENGTH + HMT_GUIDE_BLOCK_MIN_SIZE,
hmt->epgstart - hmt->bin
);
memset(hmt->epgstart, 0, HMT_EPG_BLOCK_LENGTH + HMT_GUIDE_BLOCK_MIN_SIZE);
if (debug)
printf(
"Copying 0x%04X bytes from 0x%04X to 0x%04X\n",
4, HMT_RECORDING_START, hmt->epgstart + HMT_SCHEDULED_START - hmt->bin
);
memcpy(hmt->epgstart + HMT_SCHEDULED_START, hmt->bin + HMT_RECORDING_START, 4);
if (debug)
printf("1\n");
duration =
*(uint32_t*)(hmt->bin + HMT_RECORDING_END) -
*(uint32_t*)(hmt->bin + HMT_RECORDING_START);
if (debug)
printf(
"Setting duration %d in 0x%04X\n",
duration, hmt->epgstart + HMT_SCHEDULED_DURATION - hmt->bin
);
memcpy(hmt->epgstart + HMT_SCHEDULED_DURATION, &duration, 4);
*(hmt->epgstart + 0x0c) = 0x04;
*(hmt->epgstart + 0x0e) = 0x01;
/**(hmt->epgstart + 0x14) = 0x15;*/
if (debug)
printf(
"Copying 0x%04X bytes from 0x%04X to 0x%04X\n",
0xff, HMT_TITLE, hmt->epgstart + 0x14 - hmt->bin
);
memcpy(hmt->epgstart + 0x14, hmt->bin + HMT_TITLE, 0xff /*53*/);
/* *(hmt->epgstart + 0x114) = 0x15; */
/* Synopsis, up to 255 bytes. */
/* No guide block. */
if (debug)
printf("init_hmt_epg_block(0x%08X) }\n", (void *)hmt);
}

274
display.c

@ -1,161 +1,203 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include "lint.h"
const char *
genre(unsigned char b)
{
switch (b)
{
case 0:
return "Unclassified";
case 0x10:
return "Film";
case 0x20:
return "News & Factual";
case 0x30:
return "Entertainment";
case 0x40:
return "Sport";
case 0x50:
return "Children";
case 0x60:
return "Education";
case 0xa0:
return "Lifestyle";
case 0xf0:
return "Drama";
default:
return "Unknown";
}
}
char *
ctimenl(time_t tm)
ctimenl(time_t *tm)
{
static char buf[32];
static char buf[25];
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';
}
strcpy(buf, ctime(tm));
if ((p = strpbrk(buf, "\r\n")))
*p = '\0';
return buf;
}
void
display_bookmarks(struct hmt *hmt)
uint8_t *
strip_string(uint8_t *str)
{
int i;
for (i = 0; i < hmt->num_bookmarks && i < 32; i++)
printf("%d ", hmt->bookmarks[i]);
printf("\n");
if (str[0] == 0x10 && str[1] == 0x69 && str[2] == 0x37)
return str + 3;
if (*str == 0x15)
return str + 1;
/* non freesat recordings seems to have a 0x05 as the header string */
if (*str == 0x05)
return str + 1;
return str;
}
void
display_hmt(struct hmt *hmt)
{
int g;
g = guidance(hmt);
uint16_t i;
uint16_t j;
time_t tm;
char time_buf[256];
char fullpath[512]={0};
char filename[512]={0};
int posslash = -1;
/* title, epg, def, channel num, channel name, start, end, flags,
* guidance
*/
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);
printf("%s\t", strip_string(hmt->bin + (HMT_TITLE)));
if (hmt->epgstart != NULL)
printf("%s\t", strip_string(hmt->epgstart + HMT_EPG));
else
printf("\t");
printf("%s\t", hmt->bin[HMT_FLAGS2] & HMT_FLAGS2_HD ? "HD" : "SD");
i = read_uint16(hmt->bin + HMT_CHANNEL_NUM, 0);
printf("%i\t%s\t", i,
strip_string(hmt->bin + HMT_CHANNEL_NAME));
tm = read_uint32(hmt->bin + HMT_RECORDING_START, 0);
(void) strftime(time_buf, sizeof(time_buf), "%a %b %d %H:%M:%S %Y", gmtime(&tm));
printf("%s\t", time_buf);
printf("%lu\t", tm);
tm = read_uint32(hmt->bin + HMT_RECORDING_END, 0);
(void) strftime(time_buf, sizeof(time_buf), "%a %b %d %H:%M:%S %Y", gmtime(&tm));
printf("%s\t", time_buf);
printf("%lu\t", tm);
printf("%s%s%s%s%s",
hmt->bin[HMT_FLAGS1] & HMT_FLAGS1_LOCKED ? "Locked," : "",
hmt->bin[HMT_FLAGS1] & HMT_FLAGS1_NEW ? "" : "New,",
hmt->bin[HMT_FLAGS1] & HMT_FLAGS1_PROTECTED? "Protected," : "",
hmt->bin[HMT_FLAGS2] & HMT_FLAGS2_ENCRYPTED ? "Encrypted," : "",
hmt->epgguidance != NULL ? "Guidance," : ""
);
if (hmt->bin[HMT_CONVERT_FLAG] == 'P')
printf("Converting,\t");
else
if (hmt->bin[HMT_CONVERT_FLAG] == 'F')
printf("Converted,\t");
else
printf("Unconverted,\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);
if (hmt->epgguidance != NULL)
printf("%s\t", strip_string(hmt->epgguidance));
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);
i = read_uint16(hmt->bin + HMT_CHANNEL_NUM, 0);
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);
memcpy(fullpath, hmt->bin + HMT_FOLDER, sizeof(fullpath));
posslash = (strrchr(fullpath, '/') - fullpath);
memcpy(filename, hmt->bin + HMT_FOLDER + posslash + 1, (sizeof(fullpath) - posslash));
fullpath[posslash+1]=0;
printf("Genre:%s (%d)\n", genredescr(hmt->genre), hmt->genre);
printf("EPG:%s\n", hmt->synopsis);
if (g)
printf("Guidance:%s\n", hmt->guidance);
printf("Format: %s\n", hmt->bin[HMT_FLAGS2] & HMT_FLAGS2_HD ? "HD" : "SD");
printf("Title: %s\n", strip_string(hmt->bin + (HMT_TITLE)));
if (hmt_is(hmt, HMTA_ENCRYPTED))
printf("Raw file is encrypted on disk.\n");
printf("Channel: %i (%s)\n", i, hmt->bin + HMT_CHANNEL_NAME);
printf("\n");
printf("Folder: %s\n", fullpath);
printf("Filename: %s.ts\n", filename);
if (hmt->epgstart != NULL) {
printf("EPG: %s\n", strip_string(hmt->epgstart + HMT_EPG));
} else {
printf("EPG:\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);
if (hmt->epgguidance != NULL)
printf("Guidance: %s\n", strip_string(hmt->epgguidance));
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("Flags: %s%s%s%s%s%s",
hmt->bin[HMT_FLAGS2] & HMT_FLAGS2_HD ? "HD," : "SD,",
hmt->bin[HMT_FLAGS1] & HMT_FLAGS1_LOCKED ? "Locked," : "",
hmt->bin[HMT_FLAGS1] & HMT_FLAGS1_NEW ? "" : "New,",
hmt->bin[HMT_FLAGS1] & HMT_FLAGS1_PROTECTED? "Protected," : "",
hmt->bin[HMT_FLAGS2] & HMT_FLAGS2_ENCRYPTED ? "Encrypted," : "",
hmt->epgguidance != NULL ? "Guidance," : ""
);
if (hmt->bin[HMT_CONVERT_FLAG] == 'P')
printf("Converting,\n");
else
if (hmt->bin[HMT_CONVERT_FLAG] == 'F')
printf("Converted,\n");
else
printf("Unconverted,\n");
printf("Play resumes at:%u second%s in.\n", hmt->resume,
hmt->resume == 1 ? "" : "s");
printf("Timezone offset:%d\n", hmt->tzoffset);
printf("Copy count: %d\n", hmt->bin[HMT_COPYCOUNT]);
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;
tm = read_uint32(hmt->epgstart + HMT_SCHEDULED_START, 0);
(void) strftime(time_buf, sizeof(time_buf), "%a %b %d %H:%M:%S %Y", gmtime(&tm));
printf("Scheduled start: %s\n", time_buf);
/* printf("Scheduled start:%lu (%s)\n", tm, ctimenl(&tm)); */
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 + 0x3e));
}
/* Synopsis is off + 0x141 */
}
}
}
tm = read_uint32(hmt->epgstart + HMT_SCHEDULED_DURATION, 0);
printf("Scheduled duration: %lu\n", tm);
tm = read_uint32(hmt->bin + HMT_RECORDING_START, 0);
(void) strftime(time_buf, sizeof(time_buf), "%a %b %d %H:%M:%S %Y", gmtime(&tm));
printf("Recording start: %s\n", time_buf);
/* printf("Recording start:%lu (%s)\n", tm, ctimenl(&tm)); */
tm = read_uint32(hmt->bin + HMT_RECORDING_END, 0);
(void) strftime(time_buf, sizeof(time_buf), "%a %b %d %H:%M:%S %Y", gmtime(&tm));
printf("Recording end: %s\n", time_buf);
/* printf("Recording end:%lu (%s)\n", tm, ctimenl(&tm)); */
/* printf("Play resumes at: %i seconds in.\n", read_uint16(hmt->bin + HMT_PLAYED_TIME, 0)); */
printf("\n");
j = read_uint16(hmt->bin + HMT_SID, 0);
printf("Service ID (SID): %u\n", j);
j = read_uint16(hmt->bin + HMT_TSID, 0);
printf("Transport Stream ID (TSID): %u\n", j);
j = read_uint16(hmt->bin + HMT_ONID, 0);
printf("Originating Network ID (ONID): %u\n", j);
j = read_uint16(hmt->bin + HMT_PMTPID, 0);
printf("Programme Map Table PID (PMTPID): %u\n", j);
j = read_uint16(hmt->bin + HMT_VIDEOPID, 0);
printf("Video PID: %u\n", j);
j = read_uint16(hmt->bin + HMT_AUDIOPID, 0);
printf("Audio PID: %u\n", j);
}

200
file.c

@ -5,18 +5,30 @@
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <time.h>
#include <strings.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "lint.h"
struct hmt *
open_file(char *filename, int readonly)
open_file(char *filename, int iOpenMode)
{
struct hmt *hmt;
struct stat st;
char *ext;
uint16_t magic;
uint16_t numepgblocks = 0;
uint16_t thisepgblock = 0;
uint8_t numtransportblocks = 0;
uint8_t numguidanceblocks = 0;
int i;
uint16_t thisblocklength;
uint16_t eventid;
int foundit;
if (!(hmt = malloc(sizeof(struct hmt))))
{
@ -24,8 +36,11 @@ open_file(char *filename, int readonly)
return NULL;
}
hmt->epgguidance = NULL;
hmt->epgstart = NULL;
if (debug)
printf("Opening file '%s' (readonly=%d)\n", filename, readonly);
printf("Opening file '%s'\n", filename);
strcpy(hmt->fname, filename);
@ -60,54 +75,141 @@ open_file(char *filename, int readonly)
printf("Opening %s, %lu bytes.\n", hmt->fname,
(unsigned long)hmt->binsize);
hmt->readonly = readonly;
if ((hmt->fd = open(hmt->fname, readonly ? O_RDONLY : O_RDWR, 0)) == -1)
if ((hmt->fd = open(hmt->fname, iOpenMode, 0)) == -1)
{
perror(hmt->fname);
free(hmt);
return NULL;
}
hmt->bin = (uint8_t *)mmap(NULL, hmt->binsize,
readonly ? PROT_READ : PROT_READ|PROT_WRITE,
MAP_SHARED, hmt->fd, 0);
if (hmt->bin == MAP_FAILED)
if (iOpenMode == O_RDONLY)
{
if (debug)
printf("mmap() failed, falling back to read.\n");
/* This occurs if the underlying filesystem does not support
* mmap, e.g. NTFS. Fallback to holding the file in memory.
*/
if (!(hmt->bin = (uint8_t *)malloc(hmt->binsize)))
{
perror("malloc");
free(hmt);
close(hmt->fd);
return NULL;
}
read(hmt->fd, hmt->bin, hmt->binsize);
hmt->mmapped = 0;
hmt->bin = (uint8_t *)mmap(NULL, hmt->binsize, PROT_READ,
MAP_SHARED, hmt->fd, 0);
}
else
{
if (debug)
printf("File mapped into memory.\n");
hmt->mmapped = 1;
hmt->bin = (uint8_t *)mmap(NULL, hmt->binsize, PROT_READ|PROT_WRITE,
MAP_SHARED, hmt->fd, 0);
}
if (hmt->bin == MAP_FAILED)
{
perror("mmap");
close(hmt->fd);
free(hmt);
return NULL;
}
magic = read_uint16(hmt->bin, 0);
if (magic != 0x1701)
/* if (magic != 0x1701) */
if (magic != 0x0000)
{
printf("Invalid HMT file, %s\n", hmt->fname);
printf("Invalid HMT file, %s", hmt->fname);
close_file(hmt);
return NULL;
}
hmt->modified = 0;
parse_hmt(hmt);
/* Check for non-standard/non-freesat HMTs
Don't try to find the EPG data if this is one of them!
*/
if (hmt->binsize < 0x1004)
{
hmt->epgstart=NULL;
} else {
/*
Need to find the correct EPG entry after the main HMT Block at the start of the file
If the recording spans multiple EPG entries there will be the same number of EPG blocks
each of which may have one or more Guidance Blocks and/or one or more Transport Stream
blocks.
Two possible ways of doing this:
1. If the recording was an EPG based recording then the target event ID will be located in the header block
at offset 0x36b (2 bytes) and also in the EPG block at offset 0x00. This can be used for a definite match.
2. For manual record on demand and manual timed recordings the event ID is not present in the header so have to
find the correct EPG block using a text based comparison of the programme titles.
*/
/* First EPG Block starts at the end of the HMT Block */
hmt->epgstart = (hmt->bin + 0x1004);
numepgblocks = read_uint16(hmt->bin + (HMT_BLOCK_LENGTH - 1), 0);
thisepgblock=1;
foundit = 0;
eventid = read_uint16(hmt->bin + HMT_HEADER_PROG_EV_ID, 0);
if (eventid == 0) {
/* This is a manual recording where the eventid is not present so use string matching to find the EPG block */
while ((strcmp((char *)hmt->epgstart+HMT_EPG_TITLE, (char *)hmt->bin+HMT_TITLE)!=0) && (thisepgblock <= numepgblocks)) {
/* This is not the correct epg entry so skip to next one */
numtransportblocks = hmt->epgstart[(HMT_EPG_BLOCK_LENGTH - 11)];
numguidanceblocks = hmt->epgstart[(HMT_EPG_BLOCK_LENGTH - 10)];
hmt->epgstart = hmt->epgstart + HMT_EPG_BLOCK_LENGTH;
for (i=0; i< (numtransportblocks+numguidanceblocks); i++) {
/* Skip this guidance or transport block as it's not the correct EPG entry */
thisblocklength = read_uint16(hmt->epgstart+2, 0);
hmt->epgstart = hmt->epgstart + thisblocklength + 4;
}
thisepgblock++;
}
if (strcmp((char *)hmt->epgstart+HMT_EPG_TITLE, (char *)hmt->bin+HMT_TITLE) == 0) {
foundit = 1;
}
} else {
/* This is an Event Based (EPG Based) recording so find the EPG Block using the Event ID */
while ((read_uint16(hmt->epgstart, 0) != eventid) && (thisepgblock <= numepgblocks)) {
/* This is not the correct epg entry so skip to next one */
numtransportblocks = hmt->epgstart[(HMT_EPG_BLOCK_LENGTH - 11)];
numguidanceblocks = hmt->epgstart[(HMT_EPG_BLOCK_LENGTH - 10)];
hmt->epgstart = hmt->epgstart + HMT_EPG_BLOCK_LENGTH;
for (i=0; i< (numtransportblocks+numguidanceblocks); i++) {
/* Skip this guidance or transport block as it's not the correct EPG entry */
thisblocklength = read_uint16(hmt->epgstart+2, 0);
hmt->epgstart = hmt->epgstart + thisblocklength + 4;
}
thisepgblock++;
}
if (read_uint16(hmt->epgstart, 0) == eventid) {
foundit = 1;
}
}
/* Check that we've found the EPG block ..... if not, revert to the first EPG block in the file.
This can happen if, for example, the recording was a manual recording which has been renamed so
there's no event ID and the title strings between the header and the EPG block don't match.
*/
if (foundit == 0) {
hmt->epgstart = (hmt->bin + 0x1004);
}
/* So now we have the start of the correct EPG record.
See if there's any guidance blocks and if so, set the relevant pointer
for the start of the Guidance test.
Note - Foxsat HDR HMT files can contain multiple Guidance Blocks - return the first one */
numguidanceblocks = hmt->epgstart[(HMT_EPG_BLOCK_LENGTH - 10)];
if (numguidanceblocks != 0) {
hmt->epgguidance = hmt->epgstart + HMT_EPG_BLOCK_LENGTH;
/* Skip any transport blocks first */
numtransportblocks = hmt->epgstart[(HMT_EPG_BLOCK_LENGTH - 11)];
if (numtransportblocks != 0) {
for(i=0; i<numtransportblocks; i++) {
thisblocklength = read_uint16(hmt->epgguidance+2, 0);
hmt->epgguidance = hmt->epgguidance + thisblocklength + 4;
}
}
/* Pointer now at the start of the guidance block
so now set it to the Guidance Text itself */
hmt->epgguidance = hmt->epgguidance + 21;
}
}
return hmt;
}
@ -117,19 +219,35 @@ close_file(struct hmt *hmt)
if (debug)
printf("Closing file.\n");
if (hmt->mmapped)
munmap((void *)hmt->bin, hmt->binsize);
else
{
if (hmt->modified && !hmt->readonly)
{
lseek(hmt->fd, SEEK_SET, 0);
write(hmt->fd, hmt->bin, hmt->binsize);
}
free(hmt->bin);
}
munmap((void *)hmt->bin, hmt->binsize);
if (hmt->fd > 0)
close(hmt->fd);
hmt->fd = -1;
}
struct hmt *
extend_file(struct hmt *hmt, uint32_t extra_size)
{
FILE *file = NULL;
void *nul = NULL;
/*
* No portable way of extending a memory mapped file, just close it, append
* extra bytes and reopen.
*/
close_file(hmt);
if (debug)
printf("Extending file by %d byte(s)\n", extra_size);
if (file = fopen(hmt->fname, "ab")) {
nul = malloc(extra_size);
memset(nul, 0, extra_size);
fwrite(nul, 1, extra_size, file);
fclose(file);
free(nul);
nul = NULL;
}
return open_file(hmt->fname, O_RDWR);
}

174
hmt.h

@ -1,160 +1,66 @@
#ifdef _WIN32
#include <windows.h>
#define MAXPATHLEN MAX_PATH
#else
#include <strings.h>
#include <sys/param.h>
#endif
enum hmt_attribute {
HMTA_ENCRYPTED = 0,
HMTA_LOCKED,
HMTA_NEW,
HMTA_ENCFLAGGED,
HMTA_SHRUNK,
HMTA_DEDUPED,
HMTA_DETECTADS,
HMTA_UNLIMITEDCOPY,
HMTA_RADIO,
HMTA_GHOST,
HMTA_THUMBNAIL,
};
struct hmt {
char fname[MAXPATHLEN + 1];
int fd;
uint8_t *bin;
uint8_t *epgstart; /* Start of the correct EPG entry in the HMT file */
uint8_t *epgguidance; /* Start of the guidance text for the relevant EPG entry */
uint32_t binsize;
int mmapped;
int modified;
int readonly;
/* Recording information */
char *directory;
char *filename;
uint8_t type;
uint32_t start;
uint32_t end;
uint16_t duration;
uint8_t recstatus;
uint8_t flags1;
uint8_t flags2;
uint8_t failreason;
uint32_t resume;
uint16_t num_bookmarks;
char *mediatitle;
uint32_t *bookmarks;
uint8_t flags3;
uint8_t guidance_type;
uint8_t guidance_mode;
char *guidance;
uint8_t copycount;
uint16_t tzoffset;
uint32_t lcn;
char *channel;
uint16_t service_id;
uint16_t tsid;
uint16_t onid;
uint16_t pmt_pid;
uint16_t video_pid;
enum { DEF_SD = 1, DEF_HD } definition;
uint16_t audio_pid;
uint32_t schedstart;
uint32_t scheddur;
uint8_t genre;
char *title;
char *synopsis;
uint16_t event_id;
uint8_t xflags1;
uint8_t xflags2;
uint8_t xflags3;
int series;
int episode;
int episodetot;
};
#define HMT_EPG_BLOCK_LENGTH 0x220
#define HMT_EPG_TITLE 0x14
#define HMT_BLOCK_LENGTH 0x1003
void parse_hmt(struct hmt *);
uint8_t *strip_string(uint8_t *);
int guidance(struct hmt *);
const char *genredescr(unsigned char b);
unsigned char genrecode(char *);
const char *genre(unsigned char);
const char *recordingstatus(struct hmt *);
const char *failurereason(struct hmt *);
char *hmt_flags(struct hmt *);
int hmt_is(struct hmt *, enum hmt_attribute);
#define HMT_FOLDER 0x80
#define HMT_FOLDER_LEN 254
#define HMT_FILENAME 0x17f
#define HMT_FILENAME_LEN 256
#define HMT_HEADER_PROG_EV_ID 0x036b
#define HMT_TITLE 0x29a
#define HMT_TITLE_LEN 48
#define HMT_ITITLE 0x516
#define HMT_ITITLE_LEN 48
#define HMT_FOLDER 0x21
#define HMT_FOLDER_LEN 512
#define HMT_CHANNEL_NUM 0x458 /* 4 bytes */
#define HMT_CHANNEL_NAME 0x45c
#define HMT_EPG 0x616
#define HMT_EPG_LEN 252
#define HMT_FILENAME 0x21
#define HMT_FILENAME_LEN 512
#define HMT_RECSTATUS 0x28c
#define HMT_FAILREASON 0x290
#define HMT_TITLE 0x221
#define HMT_TITLE_LEN 255
#define HMT_SYNOPSIS_LEN 255
#define HMT_RECTYPE 0x4b8
#define HMT_CHANNEL_NUM 0x11 /* 2 bytes */
#define HMT_CHANNEL_NAME 0x321
#define HMT_EPG 0x114
#define HMT_FLAGS1 0x28d
#define HMT_FLAGS1_LOCKED 0x4
#define HMT_FLAGS1_NEW 0x8
#define HMT_FLAGS1 0x367
#define HMT_FLAGS1_LOCKED 0x80
#define HMT_FLAGS1_PROTECTED 0x40
#define HMT_FLAGS1_NEW 0x20
#define HMT_CONVERT_FLAG 0x500
#define HMT_FLAGS3 0x28e
#define HMT_IS_ENCRYPTED 0x1
#define HMT_HAS_THUMBNAIL 0x2
#define HMT_FLAGS2 0x368
#define HMT_FLAGS2_ENCRYPTED 0x10 /* As in "keep encrypted" */
#define HMT_FLAGS2_HD 0x80
#define HMT_BOOKMARKS_CNT 0x298
#define HMT_BOOKMARKS 0x31c
#define HMT_FLAGS3 0x369
#define HMT_FLAGS3_LIMITCOPY 0x20
#define HMT_FLAGS2 0x3dc
#define HMT_FLAGS2_ENCRYPTED 0x2 /* As in "keep encrypted" */
#define HMT_FLAGS2_UNLIMITCOPY 0x4
#define HMT_RECORDING_START 0x280 /* 4 bytes */
#define HMT_RECORDING_END 0x284 /* 4 bytes */
#define HMT_STORED_DURATION 0x288 /* 2 bytes */
#define HMT_SCHEDULED_START 0x4f8 /* 4 bytes */
#define HMT_SCHEDULED_DURATION 0x4fc /* 4 bytes */
#define HMT_PLAYED_TIME 0x294 /* 4 bytes */
#define HMT_GENRE 0x514
#define HMT_EVENTID 0x716
#define HMT_RECORDING_START 0x19 /* 4 bytes */
#define HMT_RECORDING_END 0x1D /* 4 bytes */
#define HMT_SCHEDULED_START 0x04 /* 4 bytes */
#define HMT_SCHEDULED_DURATION 0x08 /* 4 bytes */
#define HMT_PLAYED_TIME 0x05 /* 4 bytes */
#define HMT_GUIDEFLAG 0x3e0
#define HMT_GUIDEFLAG_ON 0x01
#define HMT_GUIDANCE 0x3e2
#define HMT_GUIDANCE_LEN 74
#define HMT_SID 0x488 /* 2 bytes */
#define HMT_TSID 0x48a /* 2 bytes */
#define HMT_ONID 0x48c /* 2 bytes */
#define HMT_PMTPID 0x48e /* 2 bytes */
#define HMT_VIDEOPID 0x490 /* 2 bytes */
#define HMT_AUDIOPID 0x49c /* 2 bytes */
#define HMT_HDFLAG 0x498 /* 1 == SD, 2 == HD */
#define HMT_HDFLAG2 0x4bc /* 1 == SD, 0 == HD */
#define HMT_SID 0x417 /* 2 bytes */
#define HMT_TSID 0x425 /* 2 bytes */
#define HMT_ONID 0x427 /* 2 bytes */
#define HMT_PMTPID 0x419 /* 2 bytes */
#define HMT_VIDEOPID 0x41b /* 2 bytes */
#define HMT_AUDIOPID 0x41d /* 2 bytes */
#define HMT_COPYCOUNT 0x431
/* Section of HMT used for 'eng' string from guidance text. */
#define HMT_SHRUNK 0x73d /* Set to E for shrunk.. */
#define HMT_DEDUPED 0x73e /* Set to N for deduped.. */
#define HMT_DETECTADS 0x73f /* Set to G for detectads.. */
#define HMT_SERIES 0x10
#define HMT_EPISODE 0x11
#define HMT_EPISODETOT 0x12
#define HMT_EPG_SYNOPSIS 0x114 /* 0x115 */
#define HMT_GUIDE_BLOCK_MIN_SIZE 0x15
#define HMT_WITH_EPG_BLOCK_MIN_SIZE (HMT_BLOCK_LENGTH + HMT_EPG_BLOCK_LENGTH + HMT_GUIDE_BLOCK_MIN_SIZE)

57
lint.h

@ -7,62 +7,21 @@ extern int debug;
extern const char *version;
extern unsigned long sysopts;
uint16_t read_uint16(uint8_t *, int);
uint32_t read_uint32(uint8_t *, int);
void write_uint32(uint8_t *, uint32_t);
void write_uint16(uint8_t *, uint16_t);
inline uint16_t read_uint16(uint8_t *, int);
inline uint32_t read_uint32(uint8_t *, int);
void hexdump(uint8_t *, uint32_t, uint32_t);
struct hmt *open_file(char *, int);
void close_file(struct hmt *);
struct hmt *extend_file(struct hmt *hmt, uint32_t extra_size);
void display_bookmarks(struct hmt *hmt);
uint8_t * strip_string(uint8_t *);
void display_hmt(struct hmt *hmt);
void cmd_protect(struct hmt *, int);
void cmd_encrypted(struct hmt *, int);
void cmd_shrunk(struct hmt *, int);
void cmd_dedup(struct hmt *, int);
void cmd_detectads(struct hmt *, int);
void cmd_thumbnail(struct hmt *, int);
void cmd_new(struct hmt *, int);
void cmd_lock(struct hmt *, int);
void cmd_guidance(struct hmt *, int);
void cmd_setresume(struct hmt *, char *);
void cmd_setsynopsis(struct hmt *, char *);
void cmd_settitle(struct hmt *, char *);
void cmd_setgenre(struct hmt *, char *);
void cmd_bookmarks(struct hmt *, char *, int);
void patch_byte(struct hmt *, uint32_t, uint8_t);
void patch_string(struct hmt *, uint32_t, uint32_t, char *);
void cmd_patch(struct hmt *, char *);
void cmd_unpatch(struct hmt *, char *);
void cmd_setseries(struct hmt *, char *);
#ifdef _WIN32
#include <io.h>
#include <windows.h>
#define MAXPATHLEN MAX_PATH
#define open(a,b,c) _open(a,b,c)
#define close(a) _close(a)
#define read(a,b,c) _read(a,b,c)
#define write(a,b,c) _write(a,b,c)
#define lseek(a,b,c) _lseek(a,b,c)
#define MAP_FAILED 0
#define mmap(a,b,c,d,e,f) MAP_FAILED
#define munmap(a,b)
#define strncasecmp _strnicmp
typedef long off_t;
#else /* _WIN32 */
#include <sys/mman.h>
#include <sys/param.h>
#include <unistd.h>
#endif /* _WIN32 */
void patch_string(struct hmt *, uint32_t, char *, int);
void cmd_getstring(struct hmt *, uint32_t);
void expand_hmt(struct hmt *hmt, uint32_t new_size);
void init_hmt_epg_block(struct hmt *hmt);

359
main.c

@ -1,91 +1,52 @@
/*
* Humax HMT Tool
* (c) af123, 2011-2016
* af123, 2011
*/
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <time.h>
#include "lint.h"
int debug = 0;
const char *version = "2.0.11";
const char *version = "2.5";
unsigned long sysopts = 0;
int
syntax()
{
fprintf(stderr, "Humax HMT Tool v%s, by af123, 2011-2019.\n\n",
version);
fprintf(stderr, "Humax HMT Tool v%s, by af123, 2012.\n", version);
fprintf(stderr, "Modified for Foxsat HDR by adrianf36 2012 and MofTot 2018-20.\n\n");
fprintf(stderr,
"Syntax: hmt [command] <filename> [filename] ...\n");
"Syntax: hmt [command] <filename> [filename] ...\n");
fprintf(stderr,
" Commands:\n"
" +/-new Mark/unmark recording as new.\n"
" +/-lock Mark/unmark recording as locked.\n"
" +/-guidance Mark/unmark recording as having guidance.\n"
" Commands:\n"
" -p Read HMT and produce parseable output for use by the WebIf\n"
" -f Read HMT and return path and filename (without extension) to TS file\n"
" +/-new Mark/unmark recording as new.\n"
" +/-lock Mark/unmark recording as locked.\n"
);
#ifdef HMT_PROTECT
fprintf(stderr,
" +/-protect Enable/disable protection"
" (prevents decryption on copy).\n"
" +/-encrypted Mark/unmark recording as encrypted.\n"
" +/-shrunk Mark/unmark recording as shrunk.\n"
" +/-dedup Mark/unmark recording as deduped.\n"
" +/-detectads Mark/unmark recording as ad-detection-done.\n"
" +/-thumbnail Mark/unmark recording as thumbnail present.\n"
" +/-protect Mark/unmark recording as protected.\n"
);
#endif
fprintf(stderr,
" -p Display parseable file information (see *).\n"
" -list Display file information (default).\n"
" -bookmarks Display bookmarks.\n"
" +addbookmark=<seconds>[:<seconds>]...\n"
" +setbookmarks=<seconds>[:<seconds>]...\n"
" +clearbookmarks\n"
" +settitle=<new title>\n"
" +setsynopsis=<new synopsis>\n"
" +setguidance=<new guidance>\n"
);
fprintf(stderr,
" +setseries=<series,episode,episodes>\n"
" +setfolder=<new folder> (patch hmt only)\n"
" +setfilename=<new filename> (patch hmt only)\n"
" +setgenre=<genre> (can just specifiy initial part)\n"
" +setresume=<resume point (seconds)> "
"(-seconds to set from end)\n"
);
fprintf(stderr,
"\n"
"Generic patch commands:\n"
" +patch8=offset:value patch 8-bit value\n"
" +patch16=offset:value patch 16-bit value\n"
" +patch32=offset:value patch 32-bit value\n"
" Offset and value can be preceded with 0x to indicate hex.\n"
);
fprintf(stderr,
"\n"
"Generic read commands:\n"
" +read8=offset read 8-bit value\n"
" +read16=offset read 16-bit value\n"
" +read32=offset read 32-bit value\n"
" Offset can be preceded with 0x to indicate hex.\n"
);
fprintf(stderr,
"\n"
"* Parseable output is tab delimited and contains the following"
" fields:\n"
" Title, Synopsis, HD/SD, LCN, Channel Name,\n"
" Start time, End time, Flags, Guidance, Bookmark count,\n"
" Scheduled start, Scheduled duration, Genre code,\n"
" Resume point, Status/Reason.\n"
" +settitle=<new title>\n"
" +setsynopsis=<new synopsis>\n"
" +setfilename=<new filename>\n"
" where <new filename> = Full Path and filename of related TS file\n"
" WITHOUT the .TS extension. e.g. /mnt/hd3/Video/File123\n"
" Note. File paths MUST be /mnt/hd3/... and NOT /media/...\n"
);
fprintf(stderr, "\n");
return 0;
@ -94,33 +55,20 @@ syntax()
int
main(int argc, char **argv)