From 3f3f0ba1d1f14bfeba26020ddbfcefe52d82b370 Mon Sep 17 00:00:00 2001 From: Ben Asselstine
Date: Sun, 18 Jan 2009 14:27:58 -0500 Subject: [PATCH] 2009-01-18 Ben Asselstine getusershell: new function: set_shells_file; new header: getusershell.h * lib/getusershell.c (set_shells_file): New function. * lib/getusershell.h: New File. * modules/getusershell (Include): Add getusershell.h. * users.txt: Add GNU Sysutils. --- lib/getusershell.c | 12 +++++++++++- lib/getusershell.h | 40 ++++++++++++++++++++++++++++++++++++++++ modules/getusershell | 2 +- users.txt | 1 + 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 lib/getusershell.h diff --git a/lib/getusershell.c b/lib/getusershell.c index bea62a0..ebad8dc 100644 --- a/lib/getusershell.c +++ b/lib/getusershell.c @@ -66,6 +66,9 @@ static size_t default_index = 0; /* Input stream from the shells file. */ static FILE *shellstream = NULL; +/* The path to the file that contains the list of shells. */ +static char const *shells_file = SHELLS_FILE; + /* Line of input from the shells file. */ static char *line = NULL; @@ -90,7 +93,7 @@ getusershell (void) if (shellstream == NULL) { - shellstream = fopen (SHELLS_FILE, "r"); + shellstream = fopen (shells_file, "r"); if (shellstream == NULL) { /* No shells file. Use the default list. */ @@ -129,6 +132,13 @@ endusershell (void) } } +/* Set the path to the file holding the list of shells. */ +void +set_shells_file (char const *filename) +{ + shells_file = filename; +} + /* Read a line from STREAM, removing any newline at the end. Place the result in *NAME, which is malloc'd and/or realloc'd as necessary and can start out NULL, diff --git a/lib/getusershell.h b/lib/getusershell.h new file mode 100644 index 0000000..81c8e0a --- /dev/null +++ b/lib/getusershell.h @@ -0,0 +1,40 @@ +/* A more useful interface to getusershell. + + Copyright (C) 2009 Free Software Foundation, Inc. + + This program 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 3 of the License, or + (at your option) any later version. + + This program 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. + + You should have received a copy of the GNU General Public License + along with this program. If not, see