From 489de1005c94bda6ea2d3f8d0b8535be191cf16e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 29 Oct 2014 19:06:17 +0100 Subject: more code reuse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/log-login-btmp.c | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) (limited to 'src/log-login-btmp.c') diff --git a/src/log-login-btmp.c b/src/log-login-btmp.c index 35b2b31..6d4ae18 100644 --- a/src/log-login-btmp.c +++ b/src/log-login-btmp.c @@ -17,42 +17,16 @@ * along with this program. If not, see . */ #include "common.h" - #include - -#define X(A) static const char* A = NULL; - LIST_ARGUMENTS -#undef X - - -static int log_action(void); - - -int main(int argc, char** argv) +int do_log(void) { - int i; - - for (i = 1; i < argc; i++) - { -#define X(A) if (strstr(argv[i], "--" #A "=")) A = strchr(argv[i], '=') + 1; - LIST_ARGUMENTS -#undef X - } + struct utmp ut; - if (!streq(action, "failed")) return 0; - if (NULL == username) return 1; - if (NULL == ttyname) return 1; - if (NULL == pid) return 1; + if (!streq(action, "failed")) + return 0; - return -log_action(); -} - - -static int log_action(void) -{ - struct utmp ut; memset(&ut, 0, sizeof(struct utmp)); ut.ut_type = LOGIN_PROCESS; -- cgit v1.2.3-70-g09d2