* 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-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
# 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 *
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
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);
endif
Include:
-"readutmp.h"
+#if HAVE_UTMPX_H || HAVE_UTMP_H
+#include "readutmp.h"
+#endif
License:
GPL