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 51914Scasper * Common Development and Distribution License (the "License"). 61914Scasper * 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 */ 211219Sraf 220Sstevel@tonic-gate /* 23*6812Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 251219Sraf */ 261219Sraf 271219Sraf /* 280Sstevel@tonic-gate * Common code and structures used by name-service-switch "user" backends. 290Sstevel@tonic-gate */ 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifndef _USER_COMMON_H 320Sstevel@tonic-gate #define _USER_COMMON_H 330Sstevel@tonic-gate 340Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 350Sstevel@tonic-gate 360Sstevel@tonic-gate #include <nss_common.h> 370Sstevel@tonic-gate #include <nss_dbdefs.h> 380Sstevel@tonic-gate #include <stdio.h> 390Sstevel@tonic-gate 400Sstevel@tonic-gate #ifdef __cplusplus 410Sstevel@tonic-gate extern "C" { 420Sstevel@tonic-gate #endif 430Sstevel@tonic-gate 440Sstevel@tonic-gate typedef struct user_backend *user_backend_ptr_t; 450Sstevel@tonic-gate typedef nss_status_t (*user_backend_op_t)(user_backend_ptr_t, void *); 460Sstevel@tonic-gate 470Sstevel@tonic-gate 480Sstevel@tonic-gate 490Sstevel@tonic-gate struct user_backend { 500Sstevel@tonic-gate user_backend_op_t *ops; 510Sstevel@tonic-gate int n_ops; 520Sstevel@tonic-gate const char *filename; 531914Scasper FILE *f; 540Sstevel@tonic-gate int minbuf; 550Sstevel@tonic-gate char *buf; 560Sstevel@tonic-gate }; 570Sstevel@tonic-gate 580Sstevel@tonic-gate /* 590Sstevel@tonic-gate * Iterator function for _nss_user_do_all() 600Sstevel@tonic-gate * NSS_NOTFOUND means "keep enumerating", NSS_SUCCESS means"return now", 610Sstevel@tonic-gate * other values don't make much sense. In other words we're abusing 620Sstevel@tonic-gate * (overloading) the meaning of nss_status_t, but hey... 630Sstevel@tonic-gate * _nss_user_XY_all() is a wrapper around _nss_user_do_all() that does the 640Sstevel@tonic-gate * generic work for nss_XbyY_args_t backends (calls cstr2ent etc). 650Sstevel@tonic-gate */ 660Sstevel@tonic-gate typedef nss_status_t (*user_do_all_func_t)(const char *, int, void *args); 670Sstevel@tonic-gate typedef int (*user_XY_check_func)(nss_XbyY_args_t *); 680Sstevel@tonic-gate 690Sstevel@tonic-gate #if defined(__STDC__) 700Sstevel@tonic-gate extern nss_backend_t *_nss_user_constr(user_backend_op_t *ops, 710Sstevel@tonic-gate int n_ops, 720Sstevel@tonic-gate const char *filename, 730Sstevel@tonic-gate int min_bufsize); 741914Scasper extern nss_status_t _nss_user_destr(user_backend_ptr_t, void *dummy); 750Sstevel@tonic-gate extern nss_status_t _nss_user_setent(user_backend_ptr_t, void *dummy); 760Sstevel@tonic-gate extern nss_status_t _nss_user_endent(user_backend_ptr_t, void *dummy); 770Sstevel@tonic-gate extern nss_status_t _nss_user_do_all(user_backend_ptr_t, 780Sstevel@tonic-gate void *func_priv, 790Sstevel@tonic-gate const char *filter, 800Sstevel@tonic-gate user_do_all_func_t func); 810Sstevel@tonic-gate extern nss_status_t _nss_user_XY_all(user_backend_ptr_t be, 820Sstevel@tonic-gate nss_XbyY_args_t *args, 830Sstevel@tonic-gate int netdb, 840Sstevel@tonic-gate const char *filter, 850Sstevel@tonic-gate user_XY_check_func check); 861914Scasper extern int _nss_user_read_line(FILE *f, 870Sstevel@tonic-gate char *buffer, 880Sstevel@tonic-gate int buflen); 890Sstevel@tonic-gate #else 900Sstevel@tonic-gate extern nss_backend_t *_nss_user_constr(); 911914Scasper extern nss_status_t _nss_user_destr(); 920Sstevel@tonic-gate extern nss_status_t _nss_user_setent(); 930Sstevel@tonic-gate extern nss_status_t _nss_user_endent(); 940Sstevel@tonic-gate extern nss_status_t _nss_user_do_all(); 950Sstevel@tonic-gate extern nss_status_t _nss_user_XY_all(); 960Sstevel@tonic-gate extern int _nss_user_read_line(); 970Sstevel@tonic-gate #endif 980Sstevel@tonic-gate 990Sstevel@tonic-gate #ifdef __cplusplus 1000Sstevel@tonic-gate } 1010Sstevel@tonic-gate #endif 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate #endif /* _USER_COMMON_H */ 104