10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 22*1219Sraf 230Sstevel@tonic-gate /* 24*1219Sraf * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 250Sstevel@tonic-gate * Use is subject to license terms. 26*1219Sraf */ 27*1219Sraf 28*1219Sraf /* 290Sstevel@tonic-gate * Common code and structures used by name-service-switch "files" backends. 300Sstevel@tonic-gate */ 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifndef _FILES_COMMON_H 330Sstevel@tonic-gate #define _FILES_COMMON_H 340Sstevel@tonic-gate 350Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 360Sstevel@tonic-gate 37*1219Sraf #include "c_synonyms.h" 380Sstevel@tonic-gate #include <nss_common.h> 390Sstevel@tonic-gate #include <nss_dbdefs.h> 400Sstevel@tonic-gate #include <stdio.h> 410Sstevel@tonic-gate 420Sstevel@tonic-gate #include "../../../libnsl/include/nsl_stdio_prv.h" 430Sstevel@tonic-gate 440Sstevel@tonic-gate #ifdef __cplusplus 450Sstevel@tonic-gate extern "C" { 460Sstevel@tonic-gate #endif 470Sstevel@tonic-gate 480Sstevel@tonic-gate typedef struct files_backend *files_backend_ptr_t; 490Sstevel@tonic-gate typedef nss_status_t (*files_backend_op_t)(files_backend_ptr_t, void *); 500Sstevel@tonic-gate 510Sstevel@tonic-gate typedef u_int (*files_hash_func)(nss_XbyY_args_t *, int); 520Sstevel@tonic-gate 530Sstevel@tonic-gate typedef struct files_hashent { 540Sstevel@tonic-gate struct files_hashent *h_first; 550Sstevel@tonic-gate struct files_hashent *h_next; 560Sstevel@tonic-gate u_int h_hash; 570Sstevel@tonic-gate } files_hashent_t; 580Sstevel@tonic-gate 590Sstevel@tonic-gate typedef struct { 600Sstevel@tonic-gate char *l_start; 610Sstevel@tonic-gate int l_len; 620Sstevel@tonic-gate } files_linetab_t; 630Sstevel@tonic-gate 640Sstevel@tonic-gate typedef struct { 650Sstevel@tonic-gate mutex_t fh_lock; 660Sstevel@tonic-gate int fh_resultsize; 670Sstevel@tonic-gate int fh_bufsize; 680Sstevel@tonic-gate int fh_nhtab; 690Sstevel@tonic-gate files_hash_func *fh_hash_func; 700Sstevel@tonic-gate int fh_refcnt; 710Sstevel@tonic-gate int fh_size; 720Sstevel@tonic-gate timestruc_t fh_mtime; 730Sstevel@tonic-gate char *fh_file_start; 740Sstevel@tonic-gate char *fh_file_end; 750Sstevel@tonic-gate files_linetab_t *fh_line; 760Sstevel@tonic-gate files_hashent_t *fh_table; 770Sstevel@tonic-gate } files_hash_t; 780Sstevel@tonic-gate 790Sstevel@tonic-gate struct files_backend { 800Sstevel@tonic-gate files_backend_op_t *ops; 810Sstevel@tonic-gate int n_ops; 820Sstevel@tonic-gate const char *filename; 830Sstevel@tonic-gate __NSL_FILE *f; 840Sstevel@tonic-gate int minbuf; 850Sstevel@tonic-gate char *buf; 860Sstevel@tonic-gate files_hash_t *hashinfo; 870Sstevel@tonic-gate }; 880Sstevel@tonic-gate 890Sstevel@tonic-gate /* 900Sstevel@tonic-gate * Iterator function for _nss_files_do_all(), which probably calls yp_all(). 910Sstevel@tonic-gate * NSS_NOTFOUND means "keep enumerating", NSS_SUCCESS means"return now", 920Sstevel@tonic-gate * other values don't make much sense. In other words we're abusing 930Sstevel@tonic-gate * (overloading) the meaning of nss_status_t, but hey... 940Sstevel@tonic-gate * _nss_files_XY_all() is a wrapper around _nss_files_do_all() that does the 950Sstevel@tonic-gate * generic work for nss_XbyY_args_t backends (calls cstr2ent etc). 960Sstevel@tonic-gate */ 970Sstevel@tonic-gate typedef nss_status_t (*files_do_all_func_t)(const char *, int, void *args); 980Sstevel@tonic-gate typedef int (*files_XY_check_func)(nss_XbyY_args_t *); 990Sstevel@tonic-gate 1000Sstevel@tonic-gate #if defined(__STDC__) 1010Sstevel@tonic-gate extern nss_backend_t *_nss_files_constr(files_backend_op_t *ops, 1020Sstevel@tonic-gate int n_ops, 1030Sstevel@tonic-gate const char *filename, 1040Sstevel@tonic-gate int min_bufsize, 1050Sstevel@tonic-gate files_hash_t *fhp); 1060Sstevel@tonic-gate extern nss_status_t _nss_files_destr (files_backend_ptr_t, void *dummy); 1070Sstevel@tonic-gate extern nss_status_t _nss_files_setent(files_backend_ptr_t, void *dummy); 1080Sstevel@tonic-gate extern nss_status_t _nss_files_endent(files_backend_ptr_t, void *dummy); 1090Sstevel@tonic-gate extern nss_status_t _nss_files_getent_rigid(files_backend_ptr_t, void *); 1100Sstevel@tonic-gate extern nss_status_t _nss_files_getent_netdb(files_backend_ptr_t, void *); 1110Sstevel@tonic-gate extern nss_status_t _nss_files_do_all(files_backend_ptr_t, 1120Sstevel@tonic-gate void *func_priv, 1130Sstevel@tonic-gate const char *filter, 1140Sstevel@tonic-gate files_do_all_func_t func); 1150Sstevel@tonic-gate extern nss_status_t _nss_files_XY_all(files_backend_ptr_t be, 1160Sstevel@tonic-gate nss_XbyY_args_t *args, 1170Sstevel@tonic-gate int netdb, 1180Sstevel@tonic-gate const char *filter, 1190Sstevel@tonic-gate files_XY_check_func check); 1200Sstevel@tonic-gate extern nss_status_t _nss_files_XY_hash(files_backend_ptr_t be, 1210Sstevel@tonic-gate nss_XbyY_args_t *args, 1220Sstevel@tonic-gate int netdb, 1230Sstevel@tonic-gate files_hash_t *fhp, 1240Sstevel@tonic-gate int hashop, 1250Sstevel@tonic-gate files_XY_check_func check); 1260Sstevel@tonic-gate int _nss_files_read_line(__NSL_FILE *f, char *buffer, int buflen); 1270Sstevel@tonic-gate #else 1280Sstevel@tonic-gate extern nss_backend_t *_nss_files_constr(); 1290Sstevel@tonic-gate extern nss_status_t _nss_files_destr (); 1300Sstevel@tonic-gate extern nss_status_t _nss_files_setent(); 1310Sstevel@tonic-gate extern nss_status_t _nss_files_endent(); 1320Sstevel@tonic-gate extern nss_status_t _nss_files_getent_rigid(); 1330Sstevel@tonic-gate extern nss_status_t _nss_files_getent_netdb(); 1340Sstevel@tonic-gate extern nss_status_t _nss_files_do_all(); 1350Sstevel@tonic-gate extern nss_status_t _nss_files_XY_all(); 1360Sstevel@tonic-gate extern nss_status_t _nss_files_XY_hash(); 1370Sstevel@tonic-gate #endif 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate #ifdef __cplusplus 1400Sstevel@tonic-gate } 1410Sstevel@tonic-gate #endif 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate #endif /* _FILES_COMMON_H */ 144