1 /* help.c --
2
3 This file is part of the lzop file compressor.
4
5 Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
6 All Rights Reserved.
7
8 lzop and the LZO library are free software; you can redistribute them
9 and/or modify them under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING.
20 If not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
23 Markus F.X.J. Oberhumer
24 <markus@oberhumer.com>
25 http://www.oberhumer.com/opensource/lzop/
26 */
27
28
29 #include "conf.h"
30 #include "version.h"
31
32
33 /*************************************************************************
34 //
35 **************************************************************************/
36
37 static lzo_bool head_done = 0;
38
head(void)39 void head(void)
40 {
41 FILE *f = con_term;
42 int fg;
43
44 if (head_done)
45 return;
46 head_done = 1;
47
48 fg = con_fg(f,FG_GREEN);
49 con_fprintf(f,
50 " Lempel-Ziv-Oberhumer Packer\n"
51 " Copyright (C) 1996 - 2017\n"
52 "lzop v%-11s Markus Franz Xaver Johannes Oberhumer %20s\n"
53 "\n",
54 LZOP_VERSION_STRING, LZOP_VERSION_DATE);
55 fg = con_fg(f,fg);
56 UNUSED(fg);
57 }
58
59
60 /*************************************************************************
61 //
62 **************************************************************************/
63
usage(void)64 void usage(void)
65 {
66 FILE *f = con_term;
67
68 con_fprintf(f,"Usage: %s [-dxlthIVL%s] [-qvcfFnNPkUp] [-o file] [-S suffix] [%sfile..]\n", progname,
69 #if defined(USE_LZO1X_1_15) && defined(USE_LZO1X_999)
70 "19",
71 #elif defined(USE_LZO1X_1_15)
72 "1",
73 #else
74 "",
75 #endif
76 #if defined(__DJGPP__) || defined(__EMX__)
77 "[@]");
78 #else
79 "");
80 #endif
81 }
82
83
84 /*************************************************************************
85 //
86 **************************************************************************/
87
help(void)88 void help(void)
89 {
90 FILE *f = con_term;
91 int fg;
92
93 #ifdef OPT_NAME_DEFAULT
94 const char *dn = "";
95 const char *dN = " (default)";
96 #else
97 const char *dn = " (default)";
98 const char *dN = "";
99 #endif
100
101 head();
102 usage();
103
104 con_fprintf(f,"\n");
105 fg = con_fg(f,FG_YELLOW);
106 con_fprintf(f,"Commands:\n");
107 fg = con_fg(f,fg);
108 con_fprintf(f,
109 #if defined(USE_LZO1X_1_15) && defined(USE_LZO1X_999)
110 " -1 compress faster -9 compress better\n"
111 #elif defined(USE_LZO1X_1_15)
112 " -1 compress faster\n"
113 #endif
114 " -d decompress -x extract (same as -dPp)\n"
115 " -l list compressed file -I display system information\n"
116 " -t test compressed file -V display version number\n"
117 " -h give this help -L display software license\n"
118 );
119
120 fg = con_fg(f,FG_YELLOW);
121 con_fprintf(f,"Options:\n");
122 fg = con_fg(f,fg);
123
124 con_fprintf(f,
125 " -q be quiet -v be verbose\n"
126 " -c write on standard output -oFILE write output to 'FILE'\n"
127 " -p write output to current dir -pDIR write to path 'DIR'\n"
128 " -f force overwrite of output files\n"
129 " -n do not restore the original file name%s\n"
130 " -N restore the original file name%s\n"
131 " -P restore or save the original path and file name\n"
132 " -S.suf use suffix .suf on compressed files\n"
133 #if 0
134 " -F do *not* store or verify checksum of files (a little bit faster)\n"
135 #endif
136 " -U delete input files after successful operation (like gzip and bzip2)\n"
137 " file.. files to (de)compress. If none given, try standard input.\n"
138 , dn, dN);
139
140 UNUSED(fg);
141 }
142
143
144 /*************************************************************************
145 //
146 **************************************************************************/
147
license(void)148 void license(void)
149 {
150 FILE *f = con_term;
151
152 head();
153
154 con_fprintf(f,
155 " lzop and the LZO library are free software; you can redistribute them\n"
156 " and/or modify them under the terms of the GNU General Public License as\n"
157 " published by the Free Software Foundation; either version 2 of\n"
158 " the License, or (at your option) any later version.\n"
159 "\n"
160 " This program is distributed in the hope that it will be useful,\n"
161 " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
162 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
163 " GNU General Public License for more details.\n"
164 "\n"
165 " You should have received a copy of the GNU General Public License\n"
166 " along with this program; see the file COPYING.\n"
167 " If not, write to the Free Software Foundation, Inc.,\n"
168 " 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n"
169 "\n"
170 " Markus F.X.J. Oberhumer\n"
171 " <markus@oberhumer.com>\n"
172 " http://www.oberhumer.com/opensource/lzop/\n"
173 );
174 }
175
176
177 /*************************************************************************
178 //
179 **************************************************************************/
180
181 #ifndef LZOP_BUILD_DATE_TIME
182 #define LZOP_BUILD_DATE_TIME __DATE__ " " __TIME__
183 #endif
184
185 const char lzop_rcsid[] =
186 "\n$" "Id: lzop " LZOP_VERSION_STRING " built " LZOP_BUILD_DATE_TIME " $\n";
187
188 LZO_EXTERN(const lzo_bytep) lzo_copyright(void);
189
version(void)190 void version(void)
191 {
192 FILE *f = con_term;
193 char pp[2048];
194 const lzo_bytep qq;
195 char *p, *q, *s;
196 size_t i;
197
198 head();
199
200 con_fprintf(f,
201 "lzop version: v" LZOP_VERSION_STRING ", " LZOP_VERSION_DATE "\n"
202 "lzop build date: " LZOP_BUILD_DATE_TIME "\n");
203
204 for (i = 0, qq = lzo_copyright(); i < sizeof(pp)-1 && *qq; i++, qq++)
205 pp[i] = (char) *qq;
206 pp[i] = 0;
207 p = strstr(pp,"LZO version");
208 if (p == NULL)
209 return;
210 s = strchr(p,'$');
211 if (s == NULL)
212 return;
213 for (q = s; q > p && q[-1] == '\n'; )
214 *--q = 0;
215 q = strchr(s+1,'$');
216 if (q == NULL)
217 return;
218 q[1] = 0;
219 con_fprintf(f,"\n%s\n",p);
220 con_fprintf(f,"\n%s\n",s);
221 }
222
223
224 /*************************************************************************
225 //
226 **************************************************************************/
227
sysinfo(void)228 void sysinfo(void)
229 {
230 FILE *f = con_term;
231 int fg = 0;
232 const char *env = NULL;
233
234 head();
235
236 #if defined(HAVE_LOCALTIME) && defined(HAVE_GMTIME)
237 {
238 char s[40];
239 time_t t;
240
241 t = time(NULL);
242 tm2str(s, sizeof(s), localtime(&t));
243 con_fprintf(f,"Local time is: %s\n",s);
244 tm2str(s, sizeof(s), gmtime(&t));
245 con_fprintf(f,"GMT time is: %s\n\n",s);
246 }
247 #endif
248
249 #if defined(OPTIONS_VAR)
250 env = getenv(OPTIONS_VAR);
251 if (env && env[0])
252 con_fprintf(f,"Contents of environment variable %s: '%s'\n\n",
253 OPTIONS_VAR, env);
254 else
255 con_fprintf(f,"Environment variable '%s' is not set.\n\n",
256 OPTIONS_VAR);
257 #endif
258
259 #if defined(USE_FOPEN)
260 con_fprintf(f,"This version uses stdio for opening files.\n\n");
261 #endif
262
263 #if defined(__DJGPP__)
264 sysinfo_djgpp();
265 #endif
266
267 UNUSED(env);
268 UNUSED(fg);
269 }
270
271
272 /* vim:set ts=4 sw=4 et: */
273