]> Savannah Git Hosting - gnulib.git/commitdiff
readutmp: Improve comments. Fix module description.
authorBruno Haible <bruno@clisp.org>
Sun, 30 Jul 2023 13:08:59 +0000 (15:08 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 16 Aug 2023 16:50:58 +0000 (18:50 +0200)
* lib/readutmp.h (extract_trimmed_name): Add specification comment.
(read_utmp): Move specification comment from lib/readutmp.c to here.
Mention also UTMP_FILE and READ_UTMP_USER_PROCESS.
* lib/readutmp.c (extract_trimmed_name): Fix comment.
* modules/readutmp (Include): Only include the .h file if
HAVE_UTMPX_H || HAVE_UTMP_H.

ChangeLog
lib/readutmp.c
lib/readutmp.h
modules/readutmp

index ddb24f6284b986aa9704f591d76a0ad876fcee1a..526f6b8cbc2f853f73be90eed75860efe354d77c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-07-30  Bruno Haible  <bruno@clisp.org>
+
+       readutmp: Improve comments. Fix module description.
+       * lib/readutmp.h (extract_trimmed_name): Add specification comment.
+       (read_utmp): Move specification comment from lib/readutmp.c to here.
+       Mention also UTMP_FILE and READ_UTMP_USER_PROCESS.
+       * lib/readutmp.c (extract_trimmed_name): Fix comment.
+       * modules/readutmp (Include): Only include the .h file if
+       HAVE_UTMPX_H || HAVE_UTMP_H.
+
 2023-07-29  Paul Eggert  <eggert@cs.ucla.edu>
 
        readutmp: work around glibc utmpx bug
index cfc8b69c038b9163c9f6f033597f6ab74bc52cbb..acffe1000e91c878d3f1603dcecd8b8269b94019 100644 (file)
@@ -40,7 +40,7 @@
 # pragma GCC diagnostic ignored "-Wsizeof-pointer-memaccess"
 #endif
 
-/* Copy UT->ut_name into storage obtained from malloc.  Then remove any
+/* Copy UT_USER (UT) into storage obtained from malloc.  Then remove any
    trailing spaces from the copy, NUL terminate it, and return the copy.  */
 
 char *
@@ -77,13 +77,6 @@ desirable_utmp_entry (STRUCT_UTMP const *u, int options)
   return true;
 }
 
-/* Read the utmp entries corresponding to file FILE into freshly-
-   malloc'd storage, set *UTMP_BUF to that pointer, set *N_ENTRIES to
-   the number of entries, and return zero.  If there is any error,
-   return -1, setting errno, and don't modify the parameters.
-   If OPTIONS & READ_UTMP_CHECK_PIDS is nonzero, omit entries whose
-   process-IDs do not currently exist.  */
-
 #ifdef UTMP_NAME_FUNCTION
 
 static void
index 097dca6024eb121cc5e92a10db9c0fc0c6dd2fb9..7d2a6281353f44289fec7011560ab149ec79bf60 100644 (file)
@@ -219,10 +219,21 @@ enum
     READ_UTMP_USER_PROCESS = 2
   };
 
+/* Return a copy of UT_USER (UT), without trailing spaces,
+   as a freshly allocated string.  */
 char *extract_trimmed_name (const STRUCT_UTMP *ut)
   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
   _GL_ATTRIBUTE_RETURNS_NONNULL;
 
+/* Read the utmp entries corresponding to file FILE into freshly-
+   malloc'd storage, set *UTMP_BUF to that pointer, set *N_ENTRIES to
+   the number of entries, and return zero.  If there is any error,
+   return -1, setting errno, and don't modify the parameters.
+   A good candidate for FILE is UTMP_FILE.
+   If OPTIONS & READ_UTMP_CHECK_PIDS is nonzero, omit entries whose
+   process-IDs do not currently exist.
+   If OPTIONS & READ_UTMP_USER_PROCESS is nonzero, omit entries which
+   do not correspond to a user process.  */
 /* FIXME: This header should use idx_t, not size_t.  */
 int read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf,
                int options);
index 2a4a4ffc6839f6f84edd8bbb9f687263c4df7f3a..7f84f189eaa6aa02663980be28376eb7c58dc345 100644 (file)
@@ -25,7 +25,9 @@ lib_SOURCES += readutmp.c
 endif
 
 Include:
-"readutmp.h"
+#if HAVE_UTMPX_H || HAVE_UTMP_H
+#include "readutmp.h"
+#endif
 
 License:
 GPL