]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/ac-power/ac-power.c
treewide: auto-convert the simple cases to log_*_errno()
[thirdparty/systemd.git] / src / ac-power / ac-power.c
CommitLineData
3d20ed6d
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3/***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
3d20ed6d
LP
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 16 Lesser General Public License for more details.
3d20ed6d 17
5430f7f2 18 You should have received a copy of the GNU Lesser General Public License
3d20ed6d
LP
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
3d20ed6d 22#include "util.h"
3d20ed6d 23
06cdd248
LP
24int main(int argc, char *argv[]) {
25 int r;
26
27 /* This is mostly intended to be used for scripts which want
28 * to detect whether AC power is plugged in or not. */
29
240dbaa4
LP
30 r = on_ac_power();
31 if (r < 0) {
0a1beeb6 32 log_error_errno(-r, "Failed to read AC status: %m");
06cdd248
LP
33 return EXIT_FAILURE;
34 }
35
240dbaa4 36 return r != 0 ? EXIT_SUCCESS : EXIT_FAILURE;
06cdd248 37}