1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef __SHIM_H 28 #define __SHIM_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* 37 * DESCRIPTION: Shim header information not relating to hooks 38 * 39 */ 40 41 /* 42 * Structure for holding all the information relating to one map. These will 43 * probably end up in shared memory so everyone can get at them. 44 * 45 * DBM pointers are non NULL only while the file is open. 46 */ 47 typedef struct { 48 /* These are used in all modes */ 49 DBM *entries; /* NIS entry DBM file */ 50 int hash_val; /* Hash of name (to save repeated rehashing) */ 51 52 /* 53 * Names. 54 * 55 * There is some duplication of information here but this enables these 56 * strings to be worked out once (when the map_ctrl is created) rather 57 * than many times as it is used. 58 */ 59 char *map_name; /* Name of map, unqualified */ 60 char *domain; /* Domain name */ 61 char *map_path; /* Full qualified path to map */ 62 63 /* These are used only in N2L mode */ 64 DBM *ttl; /* TTL DBM file */ 65 char *ttl_path; /* Full qualified path to TTL file */ 66 char *trad_map_path; /* Equivalent qualified traditional map name */ 67 datum key_data; /* See NOTE at top of shim.c */ 68 69 /* Open parameters (in case of reopen ) */ 70 mode_t open_mode; 71 int open_flags; 72 73 int magic; /* Check that this really is a map_ctrl */ 74 75 }map_ctrl; 76 #define MAP_MAGIC 0x09876543 77 78 /* 79 * Success and failure codes the same as used by DBM 80 */ 81 typedef int suc_code; 82 #define SUCCESS 0 83 #define FAILURE -1 84 85 /* 86 * Extern defs for new DBM calls. Must have identical args to traditional 87 * version. 88 */ 89 extern void shim_dbm_close(DBM *db); 90 extern int shim_dbm_delete(DBM *db, datum key); 91 extern datum shim_dbm_fetch(DBM *db, datum key); 92 extern datum shim_dbm_fetch_noupdate(DBM *db, datum key); 93 extern datum shim_dbm_firstkey(DBM *db); 94 extern datum shim_dbm_nextkey(DBM *db); 95 extern DBM *shim_dbm_open(const char *file, int open_flags, 96 mode_t file_mode); 97 extern int shim_dbm_store(DBM *db, datum key, datum content, 98 int store_mode); 99 100 /* 101 * Other externs 102 */ 103 extern map_ctrl *get_map_ctrl(DBM *); 104 extern map_ctrl *create_map_ctrl(char *); 105 extern void free_map_ctrl(map_ctrl *); 106 extern map_ctrl *dup_map_ctrl(map_ctrl *); 107 extern void dump_map_ctrl(map_ctrl *); 108 extern suc_code map_ctrl_init(map_ctrl *map, char *name); 109 extern int lock_map_ctrl(map_ctrl *map); 110 extern int unlock_map_ctrl(map_ctrl *map); 111 112 extern int try_lock_map_update(map_ctrl *map); 113 extern suc_code lock_map_update(map_ctrl *map); 114 extern suc_code unlock_map_update(map_ctrl *map); 115 extern bool_t init_update_lock_map(); 116 117 /* 118 * Globals 119 */ 120 extern bool_t yptol_mode; 121 extern bool_t ypxfrd_flag; 122 extern int yp2ldap; 123 124 /* 125 * String extensions used in N2L 126 */ 127 128 /* Prefix used for N2L map names */ 129 #define NTOL_PREFIX "LDAP_" 130 131 /* Postfix used for TTL DBM files */ 132 #define TTL_POSTFIX "_TTL" 133 134 /* Postfix for temporary files */ 135 #define TEMP_POSTFIX "_TMP" 136 137 /* File separator character. If this is defined elsewhere can be removed */ 138 #define SEP_CHAR '/' 139 140 /* 141 * Special keys used in DBM files. No real NIS map can use these keys. 142 */ 143 #define MAP_EXPIRY_KEY "YP_EXPIRY_TIME" 144 #define MAP_OLD_MAP_DATE_KEY "YP_OLD_MAP_DATE_TIME" 145 146 /* Mmaped file used for update flags shared memory */ 147 #define SHM_FILE "/var/run/nis_shim" 148 149 #ifdef __cplusplus 150 } 151 #endif 152 153 #endif /* __SHIM_H */ 154