Code Review
/
src
/
app-framework-main.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Revert "afm-unit: add autoapi in required-api feature""
[src/app-framework-main.git]
/
src
/
wgtpkg-installer.c
diff --git
a/src/wgtpkg-installer.c
b/src/wgtpkg-installer.c
index
62807aa
..
e8b693d
100644
(file)
--- a/
src/wgtpkg-installer.c
+++ b/
src/wgtpkg-installer.c
@@
-1,5
+1,7
@@
/*
/*
- Copyright 2015 IoT.bzh
+ Copyright (C) 2015-2018 IoT.bzh
+
+ author: José Bollo <jose.bollo@iot.bzh>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@
-23,16
+25,34
@@
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
-#include <syslog.h>
#include <getopt.h>
#include <getopt.h>
+#include <libxml/tree.h>
+
#include "verbose.h"
#include "verbose.h"
-#include "wgtpkg.h"
+#include "wgtpkg-permissions.h"
+#include "wgtpkg-xmlsec.h"
+#include "wgt-info.h"
+#include "wgtpkg-install.h"
-static const char appname[] = "wgtpkg-install";
+static const char appname[] = "wgtpkg-install
er
";
static const char *root;
static int force;
static const char *root;
static int force;
+static void version()
+{
+ printf(
+ "\n"
+ " %s version="AFM_VERSION"\n"
+ "\n"
+ " Copyright (C) 2015, 2016, 2017 \"IoT.bzh\"\n"
+ " AFB comes with ABSOLUTELY NO WARRANTY.\n"
+ " Licence Apache 2\n"
+ "\n",
+ appname
+ );
+}
+
static void usage()
{
printf(
static void usage()
{
printf(
@@
-43,6
+63,7
@@
static void usage()
" -f force overwriting\n"
" -q quiet\n"
" -v verbose\n"
" -f force overwriting\n"
" -q quiet\n"
" -v verbose\n"
+ " -V version\n"
"\n",
appname
);
"\n",
appname
);
@@
-54,22
+75,23
@@
static struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
+ { "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
};
/* install the widgets of the list */
int main(int ac, char **av)
{
{ NULL, 0, NULL, 0 }
};
/* install the widgets of the list */
int main(int ac, char **av)
{
- int i;
-
char *wpath
;
+ int i
, rc
;
+
struct wgt_info *ifo
;
-
openlog(appname, LOG_PERROR, LOG_AUTH
);
+
LOGAUTH(appname
);
xmlsec_init();
force = 0;
for (;;) {
xmlsec_init();
force = 0;
for (;;) {
- i = getopt_long(ac, av, "hfqvp:", options, NULL);
+ i = getopt_long(ac, av, "hfqv
V
p:", options, NULL);
if (i < 0)
break;
switch (i) {
if (i < 0)
break;
switch (i) {
@@
-86,8
+108,15
@@
int main(int ac, char **av)
case 'v':
verbosity++;
break;
case 'v':
verbosity++;
break;
+ case 'V':
+ version();
+ return 0;
case 'p':
case 'p':
- grant_permission_list(optarg);
+ rc = grant_permission_list(optarg);
+ if (rc < 0) {
+ ERROR("Can't set granted permission list");
+ exit(1);
+ }
break;
case ':':
ERROR("missing argument value");
break;
case ':':
ERROR("missing argument value");
@@
-104,21
+133,14
@@
int main(int ac, char **av)
return 1;
}
return 1;
}
- /*
canonic names for file
s */
+ /*
install widget
s */
av += optind;
av += optind;
- for (i = 0 ; av[i] != NULL ; i++) {
- wpath = realpath(av[i], NULL);
- if (wpath == NULL) {
- ERROR("error while getting realpath of %dth widget: %s", i+1, av[i]);
- return 1;
- }
- av[i] = wpath;
- }
root = *av++;
root = *av++;
-
- /* install widgets */
- for ( ; *av ; av++)
- install_widget(*av, root, force);
+ for ( ; *av ; av++) {
+ ifo = install_widget(*av, root, force);
+ if (ifo)
+ wgt_info_unref(ifo);
+ }
return 0;
}
return 0;
}