apps/examples/lzf: unlzf and lzcat are not supported.
This commit is contained in:
parent
7c70ca5006
commit
177cc93051
@ -66,7 +66,7 @@ static off_t g_nread;
|
|||||||
static off_t g_nwritten;
|
static off_t g_nwritten;
|
||||||
|
|
||||||
static FAR const char *g_imagename;
|
static FAR const char *g_imagename;
|
||||||
static enum { COMPRESS, UNCOMPRESS, LZCAT } g_mode = COMPRESS;
|
static enum { COMPRESS, UNCOMPRESS } g_mode = COMPRESS;
|
||||||
static bool g_verbose = false;
|
static bool g_verbose = false;
|
||||||
static bool g_force = 0;
|
static bool g_force = 0;
|
||||||
static long blocksize = BLOCKSIZE;
|
static long blocksize = BLOCKSIZE;
|
||||||
@ -93,8 +93,6 @@ static void usage(int ret)
|
|||||||
"http://liblzf.plan9.de/\n"
|
"http://liblzf.plan9.de/\n"
|
||||||
"\n"
|
"\n"
|
||||||
"usage: lzf [-dufhvb] [file ...]\n"
|
"usage: lzf [-dufhvb] [file ...]\n"
|
||||||
" unlzf [file ...]\n"
|
|
||||||
" lzcat [file ...]\n"
|
|
||||||
"\n%s",
|
"\n%s",
|
||||||
opt);
|
opt);
|
||||||
|
|
||||||
@ -382,12 +380,9 @@ static int run_file(const char *fname)
|
|||||||
struct stat mystat;
|
struct stat mystat;
|
||||||
char oname[PATH_MAX + 1];
|
char oname[PATH_MAX + 1];
|
||||||
|
|
||||||
if (g_mode != LZCAT)
|
if (compose_name(fname, oname))
|
||||||
{
|
{
|
||||||
if (compose_name(fname, oname))
|
return -1;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = stat(fname, &mystat);
|
ret = stat(fname, &mystat);
|
||||||
@ -406,13 +401,6 @@ static int run_file(const char *fname)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_mode == LZCAT)
|
|
||||||
{
|
|
||||||
ret = uncompress_fd(fd, 1);
|
|
||||||
close(fd);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
fd2 = open_out(oname);
|
fd2 = open_out(oname);
|
||||||
if (fd2 == -1)
|
if (fd2 == -1)
|
||||||
{
|
{
|
||||||
@ -468,6 +456,8 @@ int lzf_main(int argc, FAR char *argv[])
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_ENVIRON
|
#ifndef CONFIG_DISABLE_ENVIRON
|
||||||
|
/* Block size may be specified as an environment variable */
|
||||||
|
|
||||||
p = getenv("LZF_BLOCKSIZE");
|
p = getenv("LZF_BLOCKSIZE");
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
@ -479,18 +469,16 @@ int lzf_main(int argc, FAR char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Get the program name sans path */
|
||||||
|
|
||||||
p = strrchr(argv[0], '/');
|
p = strrchr(argv[0], '/');
|
||||||
g_imagename = p ? ++p : argv[0];
|
g_imagename = p ? ++p : argv[0];
|
||||||
|
|
||||||
if (!strncmp(g_imagename, "un", 2) || !strncmp(g_imagename, "de", 2))
|
/* Assume compression mode */
|
||||||
{
|
|
||||||
g_mode = UNCOMPRESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strstr(g_imagename, "cat"))
|
g_mode = COMPRESS;
|
||||||
{
|
|
||||||
g_mode = LZCAT;
|
/* Handle command line options */
|
||||||
}
|
|
||||||
|
|
||||||
while ((optc = getopt(argc, argv, "cdfhvb:")) != -1)
|
while ((optc = getopt(argc, argv, "cdfhvb:")) != -1)
|
||||||
{
|
{
|
||||||
@ -517,9 +505,8 @@ int lzf_main(int argc, FAR char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
errno = 0;
|
|
||||||
blocksize = strtoul(optarg, 0, 0);
|
blocksize = strtoul(optarg, 0, 0);
|
||||||
if (errno || !blocksize || blocksize > MAX_BLOCKSIZE)
|
if (!blocksize || blocksize > MAX_BLOCKSIZE)
|
||||||
{
|
{
|
||||||
blocksize = BLOCKSIZE;
|
blocksize = BLOCKSIZE;
|
||||||
}
|
}
|
||||||
@ -539,7 +526,7 @@ int lzf_main(int argc, FAR char *argv[])
|
|||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
#ifdef CONFIG_SERIAL_TERMIOS
|
||||||
if (!g_force)
|
if (!g_force)
|
||||||
{
|
{
|
||||||
if ((g_mode == UNCOMPRESS || g_mode == LZCAT) && isatty(0))
|
if ((g_mode == UNCOMPRESS) && isatty(0))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: compressed data not read from a terminal. "
|
fprintf(stderr, "%s: compressed data not read from a terminal. "
|
||||||
"Use -f to force decompression.\n", g_imagename);
|
"Use -f to force decompression.\n", g_imagename);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user