2 Copyright (C) 2015-2018 IoT.bzh
4 author: José Bollo <jose.bollo@iot.bzh>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
27 #include <libxml/tree.h>
30 #include "wgtpkg-workdir.h"
31 #include "wgtpkg-files.h"
32 #include "wgtpkg-zip.h"
33 #include "wgtpkg-digsig.h"
34 #include "wgtpkg-xmlsec.h"
38 static const char appname[] = "wgtpkg-info";
40 static void show(const char *wgtfile);
46 " %s version="AFM_VERSION"\n"
48 " Copyright (C) 2015, 2016, 2017 \"IoT.bzh\"\n"
49 " AFB comes with ABSOLUTELY NO WARRANTY.\n"
59 "usage: %s [-q] [-v] wgtfile...\n"
69 static struct option options[] = {
70 { "help", no_argument, NULL, 'h' },
71 { "quiet", no_argument, NULL, 'q' },
72 { "verbose", no_argument, NULL, 'v' },
73 { "version", no_argument, NULL, 'V' },
77 /* info the widgets of the list */
78 int main(int ac, char **av)
88 i = getopt_long(ac, av, "hqvV", options, NULL);
106 ERROR("missing argument value");
109 ERROR("unrecognized option");
114 /* canonic names for files */
116 for (i = 0 ; av[i] != NULL ; i++) {
117 wpath = realpath(av[i], NULL);
119 ERROR("error while getting realpath of %dth widget: %s", i+1, av[i]);
132 static int check_and_show()
134 struct wgt_info *ifo;
136 ifo = wgt_info_createat(workdirfd, NULL, 1, 1, 1);
139 wgt_info_dump(ifo, 1, "");
144 /* install the widget of the file */
145 static void show(const char *wgtfile)
147 NOTICE("-- INFO for widget %s --", wgtfile);
150 if (make_workdir("/tmp", "UNPACK", 0)) {
151 ERROR("failed to create a working directory");
155 if (zread(wgtfile, 0))
158 if (check_all_signatures(1)) /* info even on WGT without signature */