X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fac-power.c;h=37313cf144d2051c8d250de9824d068bf0eb33c2;hb=68fb08920b2162b48cf0fa8dd98b021327b42896;hp=a30216ffb3451582f52b4a858f5af0d7d7083844;hpb=3d20ed6d51e38968cd646e2b3b24f36673408024;p=elogind.git diff --git a/src/ac-power.c b/src/ac-power.c index a30216ffb..37313cf14 100644 --- a/src/ac-power.c +++ b/src/ac-power.c @@ -6,16 +6,16 @@ Copyright 2010 Lennart Poettering systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. systemd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ @@ -26,9 +26,8 @@ #include #include "util.h" -#include "ac-power.h" -int on_ac_power(void) { +static int on_ac_power(void) { int r; struct udev *udev; @@ -96,3 +95,17 @@ finish: return r; } + +int main(int argc, char *argv[]) { + int r; + + /* This is mostly intended to be used for scripts which want + * to detect whether AC power is plugged in or not. */ + + if ((r = on_ac_power()) < 0) { + log_error("Failed to read AC status: %s", strerror(-r)); + return EXIT_FAILURE; + } + + return r == 0; +}