void version(void) { FILE *f = con_term; char pp[2048]; const lzo_bytep qq; char *p, *q, *s; size_t i; head(); con_fprintf(f, "lzop version: v" LZOP_VERSION_STRING ", " LZOP_VERSION_DATE "\n" "lzop build date: " LZOP_BUILD_DATE_TIME "\n"); for (i = 0, qq = lzo_copyright(); i < sizeof(pp)-1 && *qq; i++, qq++) pp[i] = (char) *qq; pp[i] = 0; p = strstr(pp,"LZO version"); if (p == NULL) return; s = strchr(p,'$'); if (s == NULL) return; for (q = s; q > p && q[-1] == '\n'; ) *--q = 0; q = strchr(s+1,'$'); if (q == NULL) return; q[1] = 0; con_fprintf(f,"\n%s\n",p); con_fprintf(f,"\n%s\n",s); }
void show_license(void) { FILE *f = con_term; show_head(); con_fprintf(f, " This program may be used freely, and you are welcome to\n" " redistribute it under certain conditions.\n" "\n" " This program is distributed in the hope that it will be useful,\n" " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" " UPX License Agreement for more details.\n" "\n" " You should have received a copy of the UPX License Agreement\n" " along with this program; see the file LICENSE.\n" " If not, visit one of the following pages:\n" "\n" ); int fg = con_fg(f,FG_CYAN); con_fprintf(f, " http://upx.sourceforge.net\n" " http://www.oberhumer.com/opensource/upx/\n" ); (void)con_fg(f,FG_ORANGE); con_fprintf(f, "\n" " Markus F.X.J. Oberhumer Laszlo Molnar\n" " <*****@*****.**> <*****@*****.**>\n" ); fg = con_fg(f,fg); UNUSED(fg); }
static void show_all_packers(FILE *f, int verbose) { options_t o; o.reset(); PackerNames pn; pn.o = &o; PackMaster::visitAllPackers(pn.visit, NULL, &o, &pn); qsort(pn.names, pn.names_count, sizeof(PackerNames::Entry), pn.cmp_fname); size_t pos = 0; for (size_t i = 0; i < pn.names_count; ++i) { const char *fn = pn.names[i].fname; const char *sn = pn.names[i].sname; if (verbose) { con_fprintf(f, " %-32s %s\n", fn, sn); } else { size_t fl = strlen(fn); if (pos == 0) { con_fprintf(f, " %s", fn); pos = 2 + fl; } else if (pos + 1 + fl > 80) { con_fprintf(f, "\n %s", fn); pos = 2 + fl; } else { con_fprintf(f, " %s", fn); pos += 1 + fl; } } } if (!verbose && pn.names_count) con_fprintf(f, "\n"); }
void help(void) { FILE *f = con_term; int fg; #ifdef OPT_NAME_DEFAULT const char *dn = ""; const char *dN = " (default)"; #else const char *dn = " (default)"; const char *dN = ""; #endif head(); usage(); con_fprintf(f,"\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Commands:\n"); fg = con_fg(f,fg); con_fprintf(f, #if defined(USE_LZO1X_1_15) && defined(USE_LZO1X_999) " -1 compress faster -9 compress better\n" #elif defined(USE_LZO1X_1_15) " -1 compress faster\n" #endif " -d decompress -x extract (same as -dPp)\n" " -l list compressed file -I display system information\n" " -t test compressed file -V display version number\n" " -h give this help -L display software license\n" ); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options:\n"); fg = con_fg(f,fg); con_fprintf(f, " -q be quiet -v be verbose\n" " -c write on standard output -oFILE write output to 'FILE'\n" " -p write output to current dir -pDIR write to path 'DIR'\n" " -f force overwrite of output files\n" " -n do not restore the original file name%s\n" " -N restore the original file name%s\n" " -P restore or save the original path and file name\n" " -S.suf use suffix .suf on compressed files\n" #if 0 " -F do *not* store or verify checksum of files (a little bit faster)\n" #endif " -U delete input files after successful operation (like gzip and bzip2)\n" " file.. files to (de)compress. If none given, try standard input.\n" , dn, dN); UNUSED(fg); }
void PackTos::fileInfo() { if (!readFileHeader()) return; con_fprintf(stdout, " text: %d, data: %d, sym: %d, bss: %d, flags=0x%x\n", (int)ih.fh_text, (int)ih.fh_data, (int)ih.fh_sym, (int)ih.fh_bss, (int)ih.fh_flag); }
void show_head(void) { FILE *f = con_term; int fg; if (head_done) return; head_done = 1; #define V(x) (strcmp(UPX_VERSION_STRING, UPX_VERSION_STRING4) ? UPX_VERSION_STRING : UPX_VERSION_STRING x) fg = con_fg(f,FG_GREEN); con_fprintf(f, " Ultimate Packer for eXecutables\n" " Copyright (C) 1996 - %s\n" "UPX %-10s Markus Oberhumer, Laszlo Molnar & John Reiser %14s\n\n", UPX_VERSION_YEAR, #if (ACC_OS_DOS16 || ACC_OS_DOS32) V("d"), #elif (ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) V("w"), #elif 0 && defined(__linux__) V("l"), #else UPX_VERSION_STRING, #endif UPX_VERSION_DATE); fg = con_fg(f,fg); #undef V UNUSED(fg); }
static void pr_print(bool c, const char *msg) { if (c && !opt->to_stdout) con_fprintf(stderr, "%s", msg); else fprintf(stderr, "%s", msg); }
void license(void) { FILE *f = con_term; head(); con_fprintf(f, " lzop and the LZO library are free software; you can redistribute them\n" " and/or modify them under the terms of the GNU General Public License as\n" " published by the Free Software Foundation; either version 2 of\n" " the License, or (at your option) any later version.\n" "\n" " This program is distributed in the hope that it will be useful,\n" " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" " GNU General Public License for more details.\n" "\n" " You should have received a copy of the GNU General Public License\n" " along with this program; see the file COPYING.\n" " If not, write to the Free Software Foundation, Inc.,\n" " 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n" "\n" " Markus F.X.J. Oberhumer\n" " <*****@*****.**>\n" " http://www.oberhumer.com/opensource/lzop/\n" ); }
static void info_print(const char *msg) { if (opt->info_mode <= 0) return; FILE *f = opt->to_stdout ? stderr : stdout; if (pr_need_nl) { printClearLine(f); con_fprintf(f,"%s\n",msg); } else if (pr_need_nl) con_fprintf(f,"\n%s\n",msg); else con_fprintf(f,"%s\n",msg); fflush(f); printSetNl(0); }
void sysinfo(void) { FILE *f = con_term; int fg = 0; const char *env = NULL; head(); #if defined(HAVE_LOCALTIME) && defined(HAVE_GMTIME) { char s[40]; time_t t; t = time(NULL); tm2str(s, sizeof(s), localtime(&t)); con_fprintf(f,"Local time is: %s\n",s); tm2str(s, sizeof(s), gmtime(&t)); con_fprintf(f,"GMT time is: %s\n\n",s); } #endif #if defined(OPTIONS_VAR) env = getenv(OPTIONS_VAR); if (env && env[0]) con_fprintf(f,"Contents of environment variable %s: '%s'\n\n", OPTIONS_VAR, env); else con_fprintf(f,"Environment variable '%s' is not set.\n\n", OPTIONS_VAR); #endif #if defined(USE_FOPEN) con_fprintf(f,"This version uses stdio for opening files.\n\n"); #endif #if defined(__DJGPP__) sysinfo_djgpp(); #endif UNUSED(env); UNUSED(fg); }
void show_usage(void) { FILE *f = con_term; con_fprintf(f,"Usage: %s [-123456789dlthVL] [-qvfk] [-o file] %sfile..\n", progname, #if defined(__DJGPP__) || defined(__EMX__) "[@]"); #else ""); #endif }
void usage(void) { FILE *f = con_term; con_fprintf(f,"Usage: %s [-dxlthIVL%s] [-qvcfFnNPkUp] [-o file] [-S suffix] [%sfile..]\n", progname, #if defined(USE_LZO1X_1_15) && defined(USE_LZO1X_999) "19", #elif defined(USE_LZO1X_1_15) "1", #else "", #endif #if defined(__DJGPP__) || defined(__EMX__) "[@]"); #else ""); #endif }
void printClearLine(FILE *f) { static char clear_line_msg[1+79+1+1]; if (!clear_line_msg[0]) { char *msg = clear_line_msg; msg[0] = '\r'; memset(msg+1,' ',79); msg[80] = '\r'; msg[81] = 0; } fflush(stdout); fflush(stderr); if (f == NULL) f = stdout; con_fprintf(f, "%s", clear_line_msg); fflush(f); printSetNl(0); }
void head(void) { FILE *f = con_term; int fg; if (head_done) return; head_done = 1; fg = con_fg(f,FG_GREEN); con_fprintf(f, " Lempel-Ziv-Oberhumer Packer\n" " Copyright (C) 1996 - 2010\n" "lzop v%-11s Markus Franz Xaver Johannes Oberhumer %20s\n" "\n", LZOP_VERSION_STRING, LZOP_VERSION_DATE); fg = con_fg(f,fg); UNUSED(fg); }
void show_head(void) { FILE *f = con_term; int fg; if (head_done) return; head_done = 1; #define V(x) (strcmp(UPX_VERSION_STRING, UPX_VERSION_STRING4) ? UPX_VERSION_STRING : UPX_VERSION_STRING x) fg = con_fg(f,FG_GREEN); con_fprintf(f, " Ultimate Packer for eXecutables\n" " Copyright (C) 1996 - " UPX_VERSION_YEAR "\n" #if defined(UPX_VERSION_GITREV) "UPX git-%6.6s%c" #else "UPX %-11s" #endif " Markus Oberhumer, Laszlo Molnar & John Reiser %14s\nBuilt with Visual Studio 2017 compiled by James34602 Build date:" BUILD_DATE "\n\n", #if defined(UPX_VERSION_GITREV) gitrev, (sizeof(gitrev)-1 > 6 && gitrev[sizeof(gitrev)-2] == '+') ? '+' : ' ', #elif (ACC_OS_DOS16 || ACC_OS_DOS32) V("d"), #elif (ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) V("w"), #else UPX_VERSION_STRING, #endif UPX_VERSION_DATE); fg = con_fg(f,fg); #undef V UNUSED(fg); }
void show_help(int verbose) { FILE *f = con_term; int fg; show_head(); show_usage(); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"\nCommands:\n"); fg = con_fg(f,fg); con_fprintf(f, " -1 compress faster -9 compress better\n" "%s" " -d decompress -l list compressed file\n" " -t test compressed file -V display version number\n" " -h give %s help -L display software license\n%s", verbose == 0 ? "" : " --best compress best (can be slow for big files)\n", verbose == 0 ? "more" : "this", verbose == 0 ? "" : "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options:\n"); fg = con_fg(f,fg); con_fprintf(f, " -q be quiet -v be verbose\n" " -oFILE write output to 'FILE'\n" //" -f force overwrite of output files and compression of suspicious files\n" " -f force compression of suspicious files\n" "%s%s" , (verbose == 0) ? " -k keep backup files\n" : "" #if 1 , (verbose > 0) ? " --no-color, --mono, --color, --no-progress change look\n" : "" #else , "" #endif ); if (verbose > 0) { fg = con_fg(f,FG_YELLOW); con_fprintf(f,"\nCompression tuning options:\n"); fg = con_fg(f,fg); con_fprintf(f, " --brute try all available compression methods & filters [slow]\n" " --ultra-brute try even more compression variants [very slow]\n" "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Backup options:\n"); fg = con_fg(f,fg); con_fprintf(f, " -k, --backup keep backup files\n" " --no-backup no backup files [default]\n" "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Overlay options:\n"); fg = con_fg(f,fg); con_fprintf(f, " --overlay=copy copy any extra data attached to the file [default]\n" " --overlay=strip strip any extra data attached to the file [DANGEROUS]\n" " --overlay=skip don't compress a file with an overlay\n" "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options for djgpp2/coff:\n"); fg = con_fg(f,fg); con_fprintf(f, " --coff produce COFF output [default: EXE]\n" "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options for dos/com:\n"); fg = con_fg(f,fg); con_fprintf(f, " --8086 make compressed com work on any 8086\n" "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options for dos/exe:\n"); fg = con_fg(f,fg); con_fprintf(f, " --8086 make compressed exe work on any 8086\n" " --no-reloc put no relocations in to the exe header\n" "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options for dos/sys:\n"); fg = con_fg(f,fg); con_fprintf(f, " --8086 make compressed sys work on any 8086\n" "\n"); #if 0 fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options for linux/386\n"); fg = con_fg(f,fg); con_fprintf(f, " --script use /usr/local/lib/upx/upx[bd] as decompressor\n" " --script=/path/upxX use path/upxX as decompressor\n" "\n"); #endif fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options for ps1/exe:\n"); fg = con_fg(f,fg); con_fprintf(f, " --8-bit uses 8 bit size compression [default: 32 bit]\n" " --8mib-ram 8 megabyte memory limit [default: 2 MiB]\n" " --boot-only disables client/host transfer compatibility\n" " --no-align don't align to 2048 bytes [enables: --console-run]\n" "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options for watcom/le:\n"); fg = con_fg(f,fg); con_fprintf(f, " --le produce LE output [default: EXE]\n" "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options for win32/pe, rtm32/pe & arm/pe:\n"); fg = con_fg(f,fg); con_fprintf(f, " --compress-exports=0 do not compress the export section\n" " --compress-exports=1 compress the export section [default]\n" " --compress-icons=0 do not compress any icons\n" " --compress-icons=1 compress all but the first icon\n" " --compress-icons=2 compress all but the first icon directory [default]\n" " --compress-icons=3 compress all icons\n" " --compress-resources=0 do not compress any resources at all\n" " --keep-resource=list do not compress resources specified by list\n" " --strip-relocs=0 do not strip relocations\n" " --strip-relocs=1 strip relocations [default]\n" "\n"); } con_fprintf(f, "file.. executables to (de)compress\n"); if (verbose > 0) { fg = con_fg(f,FG_YELLOW); con_fprintf(f,"\nThis version supports:\n"); fg = con_fg(f,fg); show_all_packers(f, verbose); } else { con_fprintf(f,"\nType '%s --help' for more detailed help.\n", progname); } con_fprintf(f,"\nUPX comes with ABSOLUTELY NO WARRANTY; for details visit http://upx.sf.net\n" // "\nUPX comes with ABSOLUTELY NO WARRANTY; for details type 'upx -L'.\n" ""); #if (DEBUG) || (TESTING) fg = con_fg(f,FG_RED); con_fprintf(f,"\nWARNING: this version is compiled with" #if (DEBUG) " -DDEBUG" #endif #if (TESTING) " -DTESTING" #endif "\n"); fg = con_fg(f,fg); #endif UNUSED(fg); }