aboutsummaryrefslogtreecommitdiff
path: root/include/nss_files.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/nss_files.h')
-rw-r--r--include/nss_files.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/include/nss_files.h b/include/nss_files.h
index 6a0dcdb85b..7bf1951496 100644
--- a/include/nss_files.h
+++ b/include/nss_files.h
@@ -20,6 +20,9 @@
#define _NSS_FILES_H
#include <stdio.h>
+#if IS_IN (libc)
+#include <libc-lock.h>
+#endif
/* Open PATH for reading, as a data source for nss_files. */
FILE *__nss_files_fopen (const char *path);
@@ -47,6 +50,63 @@ int __nss_readline_seek (FILE *fp, off64_t offset) attribute_hidden;
int __nss_parse_line_result (FILE *fp, off64_t offset, int parse_line_result);
libc_hidden_proto (__nss_parse_line_result)
+/* Per-file data. Used by the *ent functions that need to preserve
+ state across calls. */
+struct nss_files_per_file_data
+{
+ FILE *stream;
+#if IS_IN (libc)
+ /* The size of locks changes between libc and nss_files, so this
+ member must be last and is only available in libc. */
+ __libc_lock_define (, lock);
+#endif
+};
+
+/* File index for __nss_files_data_get. */
+enum nss_files_file
+ {
+ nss_file_aliasent,
+ nss_file_etherent,
+ nss_file_grent,
+ nss_file_hostent,
+ nss_file_netent,
+ nss_file_protoent,
+ nss_file_pwent,
+ nss_file_rpcent,
+ nss_file_servent,
+ nss_file_sgent,
+ nss_file_spent,
+
+ nss_file_count
+ };
+
+/* Obtains a pointer to the per-file data for FILE, which is written
+ to *PDATA, and tries to open the file at PATH for it. On success,
+ returns NSS_STATUS_SUCCESS, and the caller must later call
+ __nss_files_data_put. On failure, NSS_STATUS_TRYAGAIN is returned,
+ and *ERRNOP and *HERRNOP are updated if these pointers are not
+ null. */
+enum nss_status __nss_files_data_open (struct nss_files_per_file_data **pdata,
+ enum nss_files_file file,
+ const char *path,
+ int *errnop, int *herrnop);
+libc_hidden_proto (__nss_files_data_open)
+
+/* Unlock the per-file data, previously obtained by
+ __nss_files_data_open. */
+void __nss_files_data_put (struct nss_files_per_file_data *data);
+libc_hidden_proto (__nss_files_data_put)
+
+/* Performs the set*ent operation for FILE. PATH is the file to
+ open. */
+enum nss_status __nss_files_data_setent (enum nss_files_file file,
+ const char *path);
+libc_hidden_proto (__nss_files_data_setent)
+
+/* Performs the end*ent operation for FILE. */
+enum nss_status __nss_files_data_endent (enum nss_files_file file);
+libc_hidden_proto (__nss_files_data_endent)
+
struct parser_data;
/* Instances of the parse_line function from