Add thumbnail command

This commit is contained in:
HummyPkg 2019-03-07 21:33:53 +00:00
parent 49a7c616ba
commit 297f581bde
5 changed files with 32 additions and 5 deletions

18
cmd.c
View File

@ -68,12 +68,24 @@ cmd_protect(struct hmt *hmt, int flag)
void
cmd_encrypted(struct hmt *hmt, int flag)
{
CHECK_OFFSET(HMT_ENCRYPTED);
CHECK_OFFSET(HMT_FLAGS3);
if (flag)
hmt->bin[HMT_ENCRYPTED] |= HMT_IS_ENCRYPTED;
hmt->bin[HMT_FLAGS3] |= HMT_IS_ENCRYPTED;
else
hmt->bin[HMT_ENCRYPTED] &= ~HMT_IS_ENCRYPTED;
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++;
}

4
hmt.c
View File

@ -84,6 +84,8 @@ hmt_is(struct hmt *hmt, enum hmt_attribute attr)
{
case HMTA_ENCRYPTED:
return hmt->flags2 & 0x1;
case HMTA_THUMBNAIL:
return hmt->flags2 & 0x2;
case HMTA_GHOST:
return hmt->flags2 & 0x8;
case HMTA_LOCKED:
@ -134,6 +136,8 @@ hmt_flags(struct hmt *hmt)
strcat(buf, "Guidance,");
if (hmt_is(hmt, HMTA_ENCRYPTED))
strcat(buf, "ODEncrypted,");
if (hmt_is(hmt, HMTA_THUMBNAIL))
strcat(buf, "Thumbnail,");
if (hmt_is(hmt, HMTA_SHRUNK))
strcat(buf, "Shrunk,");
if (hmt_is(hmt, HMTA_DEDUPED))

4
hmt.h
View File

@ -12,6 +12,7 @@ enum hmt_attribute {
HMTA_UNLIMITEDCOPY,
HMTA_RADIO,
HMTA_GHOST,
HMTA_THUMBNAIL,
};
struct hmt {
@ -104,8 +105,9 @@ int hmt_is(struct hmt *, enum hmt_attribute);
#define HMT_FLAGS1_LOCKED 0x4
#define HMT_FLAGS1_NEW 0x8
#define HMT_ENCRYPTED 0x28e
#define HMT_FLAGS3 0x28e
#define HMT_IS_ENCRYPTED 0x1
#define HMT_HAS_THUMBNAIL 0x2
#define HMT_BOOKMARKS_CNT 0x298
#define HMT_BOOKMARKS 0x31c

1
lint.h
View File

@ -25,6 +25,7 @@ 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);

10
main.c
View File

@ -38,6 +38,7 @@ syntax()
" +/-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"
);
fprintf(stderr,
" -p Display parseable file information (see *).\n"
@ -100,6 +101,7 @@ main(int argc, char **argv)
CMD_PROTECT,
CMD_GUIDANCE,
CMD_ENCRYPTED,
CMD_THUMBNAIL,
CMD_SHRUNK,
CMD_DEDUP,
CMD_DETECTADS,
@ -116,7 +118,7 @@ main(int argc, char **argv)
CMD_SETBOOKMARKS,
CMD_CLEARBOOKMARKS,
CMD_PATCH,
CMD_UNPATCH
CMD_UNPATCH,
} cmd = CMD_LIST;
char *newstr = "";
int i, toggle;
@ -168,6 +170,8 @@ main(int argc, char **argv)
cmd = CMD_DEDUP;
else if (!strcmp(argv[1] + 1, "detectads"))
cmd = CMD_DETECTADS;
else if (!strcmp(argv[1] + 1, "thumbnail"))
cmd = CMD_THUMBNAIL;
else if (!strcmp(argv[1] + 1, "bookmarks"))
cmd = CMD_BOOKMARKS;
else if (!strncmp(argv[1], "+patch", 6))
@ -304,6 +308,10 @@ main(int argc, char **argv)
cmd_detectads(hmt, toggle);
break;
case CMD_THUMBNAIL:
cmd_thumbnail(hmt, toggle);
break;
case CMD_SETTITLE:
cmd_settitle(hmt, newstr);
break;