void deconv2(void *g, int row_g, int col_g, void *f, int row_f, int col_f, void *out) { double *g2 = unpack2(g, row_g, col_g, col_g); double *f2 = unpack2(f, row_f, col_f, col_g); double ff[(row_g - row_f + 1) * col_g]; deconv(g2, row_g * col_g, f2, row_f * col_g, ff, col_g); pack2(ff, row_g - row_f + 1, col_g, col_g - col_f + 1, out); free(g2); free(f2); }
int __cdecl wmain (int argc, wchar_t *argv[], wchar_t *envp[]) { int ok = 0, i; int list = 0, xtract = 0, extract = 0; int out = 0, all = 0, crclist = 0; TCHAR path[MAX_DPATH] = { 0 }, pathx[MAX_DPATH] = { 0 }; #if 0 TCHAR tmppath[MAX_DPATH]; #endif int used[32] = { 0 }; TCHAR *parm2 = NULL; TCHAR *parm3 = NULL; TCHAR *match = NULL; resetlist (); for (i = 0; i < argc && i < 32; i++) { if (!_tcsicmp (argv[i], _T("-crclist"))) { crclist = 1; used[i] = 1; } if (!_tcsicmp (argv[i], _T("o"))) { out = 1; used[i] = 1; } if (!_tcsicmp (argv[i], _T("-o"))) { out = 1; used[i] = 1; } if (!_tcsicmp (argv[i], _T("l"))) { list = 1; used[i] = 1; } if (!_tcsicmp (argv[i], _T("-l"))) { list = 1; used[i] = 1; } if (!_tcsicmp (argv[i], _T("x"))) { xtract = 1; used[i] = 1; } if (!_tcsicmp (argv[i], _T("-x"))) { xtract = 1; used[i] = 1; } if (!_tcsicmp (argv[i], _T("e"))) { extract = 1; used[i] = 1; } if (!_tcsicmp (argv[i], _T("-e"))) { extract = 1; used[i] = 1; } if (!_tcsicmp (argv[i], _T("*"))) { all = 1; used[i] = 1; } if (!_tcsicmp (argv[i], _T("**"))) { all = -1; used[i] = 1; } if (!used[i] && (_tcschr (argv[i], '*') || _tcschr (argv[i], '?'))) { extract = 1; match = argv[i]; used[i] = 1; } } for (i = 1; i < argc && i < 32; i++) { if (!used[i]) { _tcscpy (pathx, argv[i]); GetFullPathName (argv[i], MAX_DPATH, path, NULL); used[i] = 1; break; } } for (i = 1; i < argc && i < 32; i++) { if (!used[i]) { parm2 = argv[i]; used[i] = 1; break; } } for (i = 1; i < argc && i < 32; i++) { if (!used[i]) { parm3 = argv[i]; used[i] = 1; break; } } // _tcscpy (tmppath, path); // scanpath (tmppath, path); if (crclist) { docrclist (_T(".")); ok = 1; } else if (!list && match) { unpack2 (path, match, 0); ok = 1; } else if (!list && !parm2 && all > 0) { unpack2 (path, _T("*"), 0); ok = 1; } else if (!list && extract && parm2) { unpack2 (path, parm2, 0); ok = 1; } else if (argc == 2 || (argc > 2 && list)) { unlist (path, all); ok = 1; } else if (((xtract && parm2) || all || (argc >= 3 && parm2)) && !out) { unpack (path, parm2, parm3, 0, all, 0); ok = 1; } else if (parm2 && (argc >= 4 && out)) { unpack (path, parm2, parm3, 1, all, 0); ok = 1; } if (!ok) { _tprintf (_T("UAE unpacker uaeunp 0.8f by Toni Wilen (c)2012\n")); _tprintf (_T("\n")); _tprintf (_T("List: \"uaeunp (-l) <path>\"\n")); _tprintf (_T("List all recursively: \"uaeunp -l <path> **\"\n")); _tprintf (_T("Extract to file: \"uaeunp (-x) <path> <filename> [<dst name>]\"\n")); _tprintf (_T("Extract all (single directory): \"uaeunp (-x) <path> *\"\n")); _tprintf (_T("Extract all (recursively): \"uaeunp (-x) <path> **\"\n")); _tprintf (_T("Extract all (recursively, current dir): \"uaeunp -e <path> <match string>\"\n")); _tprintf (_T("Output to console: \"uaeunp (-x) -o <path> <filename>\"\n")); _tprintf (_T("\n")); _tprintf (_T("Supported disk image formats:\n")); _tprintf (_T(" ADF, HDF (VHD), DMS, encrypted DMS, IPF, FDI, DSQ, WRP\n")); _tprintf (_T("Supported filesystems:\n")); _tprintf (_T(" OFS, FFS, SFS, SFS2 and FAT12\n")); _tprintf (_T("Supported archive formats:\n")); _tprintf (_T(" 7ZIP, LHA, LZX, RAR (unrar.dll), TAR, ZIP, ArchiveAccess.DLL\n")); _tprintf (_T("Miscellaneous formats:\n")); _tprintf (_T(" RDB partition table, GZIP, XZ\n")); } return 0; }
static int unpack2 (const TCHAR *src, const TCHAR *match, int level) { struct zdirectory *h; struct zvolume *zv; int ret; uae_u8 *b; int size; TCHAR fn[MAX_DPATH]; ret = 0; zv = zfile_fopen_archive_root (src, ZFD_ALL); if (zv == NULL) { geterror(); _tprintf (_T("Couldn't open archive '%s'\n"), src); return 0; } h = zfile_opendir_archive (src); if (!h) { geterror(); _tprintf (_T("Couldn't open directory '%s'\n"), src); return 0; } while (zfile_readdir_archive (h, fn)) { TCHAR tmp[MAX_DPATH]; TCHAR *dst; struct zfile *s, *d; int isdir, flags; _tcscpy (tmp, src); _tcscat (tmp, sep); _tcscat (tmp, fn); zfile_fill_file_attrs_archive (tmp, &isdir, &flags, NULL); if (isdir) { TCHAR *p = _tcsstr (fn, _T(".DIR")); if (isdir == ZNODE_VDIR && p && _tcslen (p) == 4) { p[0] = 0; if (pattern_match (fn, match)) continue; p[0] = '.'; } unpack2 (tmp, match, 1); continue; } if (pattern_match (fn, match)) { struct mystat st; if (!zfile_stat_archive (tmp, &st)) { st.mtime.tv_sec = st.mtime.tv_usec = -1; } found = 1; dst = fn; s = zfile_open_archive (tmp, ZFD_NORECURSE); if (!s) { geterror(); _tprintf (_T("Couldn't open '%s' for reading\n"), tmp); continue; } zfile_fseek (s, 0, SEEK_END); size = zfile_ftell (s); zfile_fseek (s, 0, SEEK_SET); b = xcalloc (uae_u8, size); if (b) { if (zfile_fread (b, size, 1, s) == 1) { d = zfile_fopen (dst, _T("wb"), 0); if (d) { if (zfile_fwrite (b, size, 1, d) == 1) { ret = 1; _tprintf (_T("%s extracted, %d bytes\n"), dst, size); } zfile_fclose (d); setdate (dst, st.mtime.tv_sec); } } xfree (b); } zfile_fclose (s); } } geterror (); if (!found && !level) { _tprintf (_T("'%s' not matched\n"), match); } return ret; }
static int cli_get(int statement, int cmd) { statement_desc* s = statements.get(statement); if (s == NULL) { return cli_bad_descriptor; } if (!s->prepared) { return cli_not_fetched; } cli_request req; req.length = sizeof(cli_request); req.cmd = cmd; req.stmt_id = statement; req.pack(); if (!s->session->sock->write(&req, sizeof req)) { return cli_network_error; } int4 response; if (!s->session->sock->read(&response, sizeof response)) { return cli_network_error; } unpack4(response); if (response <= 0) { return response; } dbSmallBuffer buf(response-4); if (!s->session->sock->read(buf, response-4)) { return cli_network_error; } char* p = buf; s->oid = unpack_oid(p); if (s->oid == 0) { return cli_not_found; } p += sizeof(cli_oid_t); for (column_binding* cb = s->columns; cb != NULL; cb = cb->next) { if (cb->set_fnc != NULL) { int len = unpack4(p); p += 4; char* dst = (char*)cb->set_fnc(cb->var_type, cb->var_ptr, len); if (cb->var_type >= cli_array_of_oid) { switch (sizeof_type[cb->var_type-cli_array_of_oid]) { case 2: while (--len >= 0) { p = unpack2(dst, p); dst += 2; } break; case 4: while (--len >= 0) { p = unpack4(dst, p); dst += 4; } break; case 8: while (--len >= 0) { p = unpack8(dst, p); dst += 8; } break; default: memcpy(dst, p, len); p += len; } } else { memcpy(dst, p, len); p += len; } } else { if (cb->var_type >= cli_asciiz) { int len = unpack4(p); p += 4; char* dst = (char*)cb->var_ptr; char* src = p; int n = len; if (cb->var_len != NULL) { if (n > *cb->var_len) { n = *cb->var_len; } *cb->var_len = n; } if (cb->var_type >= cli_array_of_oid) { switch (sizeof_type[cb->var_type-cli_array_of_oid]) { case 2: while (--n >= 0) { src = unpack2(dst, src); dst += 2; } p += len*2; break; case 4: while (--n >= 0) { src = unpack4(dst, src); dst += 4; } p += len*4; break; case 8: while (--n >= 0) { src = unpack8(dst, src); dst += 8; } p += len*8; break; default: memcpy(dst, p, n); p += len; } } else { if (cb->var_type == cli_pasciiz) { dst = *(char**)dst; } memcpy(dst, p, n); p += len; } } else { switch (sizeof_type[cb->var_type]) { case 2: p = unpack2((char*)cb->var_ptr, p); break; case 4: p = unpack4((char*)cb->var_ptr, p); break; case 8: p = unpack8((char*)cb->var_ptr, p); break; default: *(char*)cb->var_ptr = *p++; } } } } return cli_ok; }
static int cli_get_fdb(int statement, int cmd, cli_oid_t value = 0) { statement_desc* s = statements.get(statement); if (s == NULL) { return cli_bad_descriptor; } if (!s->prepared) { return cli_not_fetched; } struct get_req { cli_request req; cli_oid_t value; } get; int length = sizeof(cli_request); if (cmd == cli_cmd_skip) { length += 4; pack4((char*)(&get.req+1), (int)value); } else if (cmd == cli_cmd_seek) { length += sizeof(cli_oid_t); pack_oid((char*)(&get.req+1), value); } get.req.length = length; get.req.cmd = cmd; get.req.stmt_id = statement; get.req.pack(); if (!s->session->sock->write(&get.req, length)) { return cli_network_error; } int4 response; if (!s->session->sock->read(&response, sizeof response)) { return cli_network_error; } unpack4(response); if (response <= 0) { return response; } if (s->buf_size < (size_t)response-4) { delete[] s->buf; s->buf_size = response-4 < DEFAULT_BUF_SIZE ? DEFAULT_BUF_SIZE : response-4; s->buf = new char[s->buf_size]; } char* buf = s->buf; if (!s->session->sock->read(buf, response-4)) { return cli_network_error; } char* p = buf; int result = cli_ok; if (cmd == cli_cmd_seek) { s->oid = value; result = unpack_oid(p); } else { s->oid = unpack_oid(p); if (s->oid == 0) { return cli_not_found; } } p += sizeof(cli_oid_t); for (column_binding* cb = s->columns; cb != NULL; cb = cb->next) { int type = *p++; if (cb->var_type == cli_any) { cb->var_type = type; } else { assert(cb->var_type == type); } if (cb->set_fnc != NULL) { int len = unpack4(p); p += 4; char* dst = (char*)cb->set_fnc(cb->var_type, cb->var_ptr, len, cb->name, statement, p, cb->user_data); if (dst == NULL) { continue; } if (cb->var_type == cli_array_of_string) { char** s = (char**)dst; while (--len >= 0) { *s++ = p; p += strlen(p) + 1; } } else if (cb->var_type == cli_array_of_wstring) { wchar_t** s = (wchar_t**)dst; while (--len >= 0) { *s++ = (wchar_t*)p; p += (wcslen((wchar_t*)p) + 1)*sizeof(wchar_t); } } else if (cb->var_type >= cli_array_of_oid && cb->var_type < cli_array_of_string) { switch (sizeof_type[cb->var_type-cli_array_of_oid]) { case 2: while (--len >= 0) { p = unpack2(dst, p); dst += 2; } break; case 4: while (--len >= 0) { p = unpack4(dst, p); dst += 4; } break; case 8: while (--len >= 0) { p = unpack8(dst, p); dst += 8; } break; default: memcpy(dst, p, len); p += len; } } else { memcpy(dst, p, len); p += len; } } else { if (cb->var_type >= cli_asciiz && (cb->var_type <= cli_array_of_string || cb->var_type == cli_array_of_wstring)) { int len = unpack4(p); p += 4; char* dst = (char*)cb->var_ptr; char* src = p; int n = len; if (cb->var_len != NULL) { if (n > *cb->var_len) { n = *cb->var_len; } *cb->var_len = n; } if (cb->var_type == cli_wstring || cb->var_type == cli_pwstring) { if (cb->var_type == cli_pwstring) { dst = *(char**)dst; } memcpy(dst, p, n*sizeof(wchar_t)); p += len*sizeof(wchar_t); } else if (cb->var_type >= cli_array_of_oid) { if (cb->var_type == cli_array_of_string) { char** s = (char**)dst; len -= n; while (--n >= 0) { *s++ = p; p += strlen(p) + 1; } while (--len >= 0) { p += strlen(p) + 1; } } else if (cb->var_type == cli_array_of_wstring) { wchar_t** s = (wchar_t**)dst; len -= n; while (--n >= 0) { *s++ = (wchar_t*)p; p += (wcslen((wchar_t*)p) + 1)*sizeof(wchar_t); } while (--len >= 0) { p += (wcslen((wchar_t*)p) + 1)*sizeof(wchar_t); } } else { switch (sizeof_type[cb->var_type-cli_array_of_oid]) { case 2: while (--n >= 0) { src = unpack2(dst, src); dst += 2; } p += len*2; break; case 4: while (--n >= 0) { src = unpack4(dst, src); dst += 4; } p += len*4; break; case 8: while (--n >= 0) { src = unpack8(dst, src); dst += 8; } p += len*8; break; default: memcpy(dst, p, n); p += len; } } } else { if (cb->var_type == cli_pasciiz) { dst = *(char**)dst; } memcpy(dst, p, n); p += len; } } else if (cb->var_type == cli_rectangle) { p = unpack_rectangle((cli_rectangle_t*)cb->var_ptr, p); } else { switch (sizeof_type[cb->var_type]) { case 2: p = unpack2((char*)cb->var_ptr, p); break; case 4: p = unpack4((char*)cb->var_ptr, p); break; case 8: p = unpack8((char*)cb->var_ptr, p); break; default: *(char*)cb->var_ptr = *p++; } } } } s->updated = false; return result; }