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 52830Sdjl * Common Development and Distribution License (the "License"). 62830Sdjl * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 222830Sdjl * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 232830Sdjl * Use is subject to license terms. 242830Sdjl */ 252830Sdjl /* 260Sstevel@tonic-gate * Common code and structures used by name-service-switch "compat" backends. 270Sstevel@tonic-gate */ 280Sstevel@tonic-gate 290Sstevel@tonic-gate #ifndef _COMPAT_COMMON_H 300Sstevel@tonic-gate #define _COMPAT_COMMON_H 310Sstevel@tonic-gate 320Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <nss_common.h> 350Sstevel@tonic-gate #include <nss_dbdefs.h> 360Sstevel@tonic-gate #include <stdio.h> 370Sstevel@tonic-gate 380Sstevel@tonic-gate #ifdef __cplusplus 390Sstevel@tonic-gate extern "C" { 400Sstevel@tonic-gate #endif 410Sstevel@tonic-gate 420Sstevel@tonic-gate typedef struct compat_backend *compat_backend_ptr_t; 430Sstevel@tonic-gate typedef nss_status_t (*compat_backend_op_t)(compat_backend_ptr_t, void *); 440Sstevel@tonic-gate 450Sstevel@tonic-gate /* 460Sstevel@tonic-gate * ===> Fix da comments (and in files_common.h too...) 470Sstevel@tonic-gate * Iterator function for _nss_files_do_all(), which probably calls yp_all(). 480Sstevel@tonic-gate * NSS_NOTFOUND means "keep enumerating", NSS_SUCCESS means"return now", 490Sstevel@tonic-gate * other values don't make much sense. In other words we're abusing 500Sstevel@tonic-gate * (overloading) the meaning of nss_status_t, but hey... 510Sstevel@tonic-gate * _nss_compat_XY_all() is a wrapper around _nss_files_do_all() that does the 520Sstevel@tonic-gate * generic work for nss_XbyY_args_t backends (calls cstr2ent etc). 530Sstevel@tonic-gate */ 540Sstevel@tonic-gate typedef nss_status_t (*files_do_all_func_t)(const char *, int, void *args); 550Sstevel@tonic-gate /* ===> ^^ nuke this line */ 560Sstevel@tonic-gate typedef int (*compat_XY_check_func)(nss_XbyY_args_t *); 570Sstevel@tonic-gate typedef const char *(*compat_get_name)(nss_XbyY_args_t *); 580Sstevel@tonic-gate typedef int (*compat_merge_func)(compat_backend_ptr_t, 590Sstevel@tonic-gate nss_XbyY_args_t *, 600Sstevel@tonic-gate const char **fields); 610Sstevel@tonic-gate 622830Sdjl typedef struct setofstrings *strset_t; 632830Sdjl 642830Sdjl struct compat_backend { 652830Sdjl compat_backend_op_t *ops; 662830Sdjl int n_ops; 672830Sdjl const char *filename; 682830Sdjl FILE *f; 692830Sdjl int minbuf; 702830Sdjl char *buf; 712830Sdjl int linelen; /* <== Explain use, lifetime */ 722830Sdjl 732830Sdjl nss_db_initf_t db_initf; 742830Sdjl nss_db_root_t *db_rootp; /* Shared between instances */ 752830Sdjl nss_getent_t db_context; /* Per-instance enumeration */ 762830Sdjl 772830Sdjl compat_get_name getnamef; 782830Sdjl compat_merge_func mergef; 792830Sdjl 802830Sdjl /* We wouldn't need all this hokey state stuff if we */ 812830Sdjl /* used another thread to implement a coroutine... */ 822830Sdjl enum { 832830Sdjl GETENT_FILE, 842830Sdjl GETENT_NETGROUP, 852830Sdjl GETENT_ATTRDB, 862830Sdjl GETENT_ALL, 872830Sdjl GETENT_DONE 882830Sdjl } state; 892830Sdjl strset_t minuses; 902830Sdjl 912830Sdjl int permit_netgroups; 922830Sdjl const char *yp_domain; 932830Sdjl nss_backend_t *getnetgrent_backend; 942830Sdjl char *netgr_buffer; 952830Sdjl int return_string_data; 96*3012Smichen int (*str2ent_save)(); 97*3012Smichen int (*str2ent_alt)(); 98*3012Smichen void *workarea; 992830Sdjl }; 1002830Sdjl 1010Sstevel@tonic-gate #if defined(__STDC__) 1020Sstevel@tonic-gate extern nss_backend_t *_nss_compat_constr(compat_backend_op_t *ops, 1030Sstevel@tonic-gate int n_ops, 1040Sstevel@tonic-gate const char *filename, 1050Sstevel@tonic-gate int min_bufsize, 1060Sstevel@tonic-gate nss_db_root_t *rootp, 1070Sstevel@tonic-gate nss_db_initf_t initf, 1080Sstevel@tonic-gate int netgroups, 1090Sstevel@tonic-gate compat_get_name getname_func, 1100Sstevel@tonic-gate compat_merge_func merge_func); 1110Sstevel@tonic-gate extern nss_status_t _nss_compat_destr(compat_backend_ptr_t, void *dummy); 1120Sstevel@tonic-gate extern nss_status_t _nss_compat_setent(compat_backend_ptr_t, void *dummy); 1130Sstevel@tonic-gate extern nss_status_t _nss_compat_endent(compat_backend_ptr_t, void *dummy); 1140Sstevel@tonic-gate extern nss_status_t _nss_compat_getent(compat_backend_ptr_t, void *); 1150Sstevel@tonic-gate extern nss_status_t _nss_compat_XY_all(compat_backend_ptr_t, 1160Sstevel@tonic-gate nss_XbyY_args_t *args, 1170Sstevel@tonic-gate compat_XY_check_func check, 1180Sstevel@tonic-gate nss_dbop_t op_num); 1190Sstevel@tonic-gate extern nss_status_t _attrdb_compat_XY_all(compat_backend_ptr_t, 1200Sstevel@tonic-gate nss_XbyY_args_t *args, 1210Sstevel@tonic-gate int netdb, 1220Sstevel@tonic-gate compat_XY_check_func check, 1230Sstevel@tonic-gate nss_dbop_t op_num); 1240Sstevel@tonic-gate #else 1250Sstevel@tonic-gate extern nss_backend_t *_nss_compat_constr(); 1260Sstevel@tonic-gate extern nss_status_t _nss_compat_destr(); 1270Sstevel@tonic-gate extern nss_status_t _nss_compat_setent(); 1280Sstevel@tonic-gate extern nss_status_t _nss_compat_endent(); 1290Sstevel@tonic-gate extern nss_status_t _nss_compat_getent(); 1300Sstevel@tonic-gate extern nss_status_t _nss_compat_XY_all(); 1310Sstevel@tonic-gate extern nss_status_t _attrdb_compat_XY_all(); 1320Sstevel@tonic-gate #endif 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate #ifdef __cplusplus 1350Sstevel@tonic-gate } 1360Sstevel@tonic-gate #endif 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate #endif /* _COMPAT_COMMON_H */ 139