1 | /* |
1 | /* |
2 | * Copyright (c) 2000-2003 Marc Alexander Lehmann <pcg@goof.com> |
2 | * Copyright (c) 2000-2005 Marc Alexander Lehmann <schmorp@schmorp.de> |
3 | * |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without modifica- |
4 | * Redistribution and use in source and binary forms, with or without modifica- |
5 | * tion, are permitted provided that the following conditions are met: |
5 | * tion, are permitted provided that the following conditions are met: |
6 | * |
6 | * |
7 | * 1. Redistributions of source code must retain the above copyright notice, |
7 | * 1. Redistributions of source code must retain the above copyright notice, |
… | |
… | |
38 | |
38 | |
39 | #include "config.h" |
39 | #include "config.h" |
40 | |
40 | |
41 | #include <stdio.h> |
41 | #include <stdio.h> |
42 | #include <stdlib.h> |
42 | #include <stdlib.h> |
|
|
43 | #include <string.h> |
43 | #include <assert.h> |
44 | #include <assert.h> |
44 | |
45 | |
45 | #include <unistd.h> |
46 | #include <unistd.h> |
46 | #include <getopt.h> |
47 | #include <getopt.h> |
47 | |
48 | |
… | |
… | |
52 | static void |
53 | static void |
53 | usage (int ec) |
54 | usage (int ec) |
54 | { |
55 | { |
55 | fprintf (stderr, "\n" |
56 | fprintf (stderr, "\n" |
56 | "lzf, a very lightweight compression/decompression filter\n" |
57 | "lzf, a very lightweight compression/decompression filter\n" |
57 | "written by Marc Lehmann <pcg@goof.com> You can find more info at\n" |
58 | "written by Marc Lehmann <schmorp@schmorp.de> You can find more info at\n" |
58 | "http://liblzf.plan9.de/\n" |
59 | "http://liblzf.plan9.de/\n" |
59 | "\n" |
60 | "\n" |
60 | "USAGE: lzf -c [-b blocksize] | -d\n" |
61 | "USAGE: lzf -c [-b blocksize] | -d\n" |
61 | " -c compress\n" |
62 | " -c compress\n" |
62 | " -d decompress\n" |
63 | " -d decompress\n" |
… | |
… | |
201 | { |
202 | { |
202 | int c; |
203 | int c; |
203 | unsigned int blocksize = 64*1024-1; |
204 | unsigned int blocksize = 64*1024-1; |
204 | enum { m_compress, m_decompress } mode = m_compress; |
205 | enum { m_compress, m_decompress } mode = m_compress; |
205 | |
206 | |
|
|
207 | if (!strcmp (argv[0] + strlen (argv[0] - 5), "unlzf")) |
|
|
208 | mode = m_decompress; |
|
|
209 | |
206 | while ((c = getopt (argc, argv, "cdb:h")) != -1) |
210 | while ((c = getopt (argc, argv, "cdb:h")) != -1) |
207 | switch (c) |
211 | switch (c) |
208 | { |
212 | { |
209 | case 'c': |
213 | case 'c': |
210 | mode = m_compress; |
214 | mode = m_compress; |