1 /* xQuery.c -- Query packer properties
2 * Copyright (C) 1996-2000 authors
3 * This file is part of the xpk package.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 * USA.
19 */
20
21 /*
22 * Author: SDI (before 1.2 Urban Dominik M�ller)
23 * Written by Dirk St�cker <stoecker@amigaworld.com>
24 * UNIX version by Vesa Halttunen <vesuri@jormas.com>
25 */
26
27 #include <stdio.h>
28 #include <sys/types.h>
29 #include <xpk/xpk.h>
30 #include <xpk/amigalibs.h>
31
32 char errbuf[XPKERRMSGSIZE];
33 char line1[200], line2[200], line3[200], line4[200];
34 char line5[200], line6[200], line7[200];
35
end(const char * text)36 void end(const char *text)
37 {
38 if(text)
39 printf(text);
40
41 exit(text ? 10 : 0);
42 }
43
packerquery(unsigned int packerid)44 void packerquery(unsigned int packerid)
45 {
46 struct XpkPackerInfo xpinfo;
47 struct XpkMode xminfo;
48 unsigned int packer[2]={ packerid, 0 };
49 int mode, res;
50 char name[5];
51
52 printf("Packer : %s\n", packer);
53
54 if(res = XpkQueryTags(XPK_PackerQuery, &xpinfo, XPK_PackMethod, packer,
55 TAG_DONE))
56 return;
57
58 printf("Name : %s\n", xpinfo.xpi_LongName);
59 printf("Descr. : %s\n", xpinfo.xpi_Description);
60 printf("DefMode: %ld\t", xpinfo.xpi_DefMode);
61 printf("DefChunk: %ld Kb\t", xpinfo.xpi_DefChunk >> 10);
62 printf("MaxChunk: %ld Kb\n", xpinfo.xpi_MaxChunk >> 10);
63
64 printf(" Pack Unpack Pack Unpack\n");
65 printf("Name Mode Ratio Speed Speed Mem Mem Description\n");
66 /* FAST 99..100 99.7% 1024K/s 1040K/s 1024K 1024K Gnubbeldubbel */
67
68 memcpy(name, packer, 4); name[4] = 0;
69
70 for(mode = 0; mode < 100; mode = xminfo.xm_Upto + 1)
71 {
72 if(XpkQueryTags(XPK_ModeQuery, &xminfo,
73 XPK_PackMethod, packer,
74 XPK_PackMode, mode,
75 TAG_DONE))
76 break;
77 printf("%4.4s %2ld..%-3ld %2ld.%1ld%% %4ldK/s %4ldK/s %4ldK %4ldK %s\n",
78 name, mode, xminfo.xm_Upto, xminfo.xm_Ratio / 10, xminfo.xm_Ratio % 10,
79 xminfo.xm_PackSpeed, xminfo.xm_UnpackSpeed,
80 xminfo.xm_PackMemory >> 10, xminfo.xm_UnpackMemory >> 10,
81 xminfo.xm_Description);
82 }
83 printf("\n");
84 }
85
main(int argc,char ** argv)86 int main(int argc, char **argv)
87 {
88 struct XpkPackerList list;
89 int i;
90
91 if(XpkQueryTags(XPK_PackersQuery, &list, TAG_DONE))
92 end("Cannot get information");
93
94 if(argc == 1)
95 for(i = 0; i < list.xpl_NumPackers; i++)
96 packerquery(list.xpl_Packer[i]);
97 else
98 for(i = 1; i < argc; i++)
99 packerquery(argv[i]);
100
101 end(NULL);
102 }
103