/* $Id: adma.c,v 1.2 2021/11/06 17:35:07 khorben Exp $ */ /* Copyright (c) 2008 khorben of Uberwall */ /* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "plugin.h" /* adma */ /* types */ #pragma pack(1) struct header { char magic[8]; char unk1[8]; char model[32]; }; struct dirent { uint32_t d_zero; /* ? */ uint32_t d_unk1; /* ? */ char unk2[8]; char magic[4]; /* actually not */ uint32_t d_dev; /* ? */ uint32_t d_fileno; uint32_t d_fileno2; /* ? */ char unk4[4]; uint8_t d_namlen; uint8_t d_type; /* ? */ uint16_t d_reclen; /* ? */ uint8_t d_unk5; /* ? */ char unk6[7]; char filename[16]; char unk7[48]; }; #pragma pack() /* variables */ /* magic */ static unsigned char sig[] = "adma1.01"; static PluginMagic adma_magic[] = { { 0, 0, sig, sizeof(sig)-1 }, { 0, 0, NULL, 0 } }; /* functions */ static int adma_callback(PluginHelper * ph, int signature, FILE * fp); /* plugin */ Plugin plugin = { PT_ARCHIVE, "ADMA", adma_magic, adma_callback }; /* private */ static int _callback_header(PluginHelper * ph, struct header * hdr); static int _callback_files(PluginHelper * ph, FILE * fp); static int adma_callback(PluginHelper * ph, int signature, FILE * fp) { int score = 0; struct header buf; (void) signature; if(fread(&buf, sizeof(buf), 1, fp) != 1) return -1; score += _callback_header(ph, &buf); score += _callback_files(ph, fp); return score / 2; } static int _callback_header(PluginHelper * ph, struct header * hdr) { char buf[sizeof(hdr->model) + 1]; memcpy(buf, hdr->model, sizeof(hdr->model)); buf[sizeof(buf) - 1] = '\0'; ph->printf(ph, "model: %s", buf); return 100; } static int _callback_files(PluginHelper * ph, FILE * fp) { struct dirent de; size_t cnt; #define DIRENT_MAGIC "\xe6\x6e\x26\x7d" char buf[256]; ph->printf(ph, "\n"); for(cnt = 0; fread(&de, sizeof(de), 1, fp) == 1; cnt++) { #if 0 if(memcmp(de.magic, DIRENT_MAGIC, 4) != 0) break; #else if(cnt == 11) break; #endif memcpy(buf, de.filename, sizeof(de.filename)); buf[sizeof(buf) - 1] = '\0'; buf[de.d_namlen] = '\0'; ph->printf(ph, "FILE #%2zu: %6s, zero=%u, unk1=0x%08x" ", dev=%u, fileno=%u, fileno2=%u, namlen=%u" ", type=%u, reclen=%u, unk5=%u\n", cnt, buf, de.d_zero, de.d_unk1, de.d_dev, de.d_fileno, de.d_fileno2, de.d_namlen, de.d_type, de.d_reclen, de.d_unk5); } return 100; }