2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef __SHIM_H
2N/A#define __SHIM_H
2N/A
2N/A#include <paths.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/*
2N/A * DESCRIPTION: Shim header information not relating to hooks
2N/A *
2N/A */
2N/A
2N/A/*
2N/A * Structure for holding all the information relating to one map. These will
2N/A * probably end up in shared memory so everyone can get at them.
2N/A *
2N/A * DBM pointers are non NULL only while the file is open.
2N/A */
2N/Atypedef struct {
2N/A /* These are used in all modes */
2N/A DBM *entries; /* NIS entry DBM file */
2N/A int hash_val; /* Hash of name (to save repeated rehashing) */
2N/A
2N/A /*
2N/A * Names.
2N/A *
2N/A * There is some duplication of information here but this enables these
2N/A * strings to be worked out once (when the map_ctrl is created) rather
2N/A * than many times as it is used.
2N/A */
2N/A char *map_name; /* Name of map, unqualified */
2N/A char *domain; /* Domain name */
2N/A char *map_path; /* Full qualified path to map */
2N/A
2N/A /* These are used only in N2L mode */
2N/A DBM *ttl; /* TTL DBM file */
2N/A char *ttl_path; /* Full qualified path to TTL file */
2N/A char *trad_map_path; /* Equivalent qualified traditional map name */
2N/A datum key_data; /* See NOTE at top of shim.c */
2N/A
2N/A /* Open parameters (in case of reopen ) */
2N/A mode_t open_mode;
2N/A int open_flags;
2N/A
2N/A int magic; /* Check that this really is a map_ctrl */
2N/A
2N/A}map_ctrl;
2N/A#define MAP_MAGIC 0x09876543
2N/A
2N/A/*
2N/A * Structure for holding unique map IDs.
2N/A * Used for locking purposes, in N2L mode only.
2N/A */
2N/Atypedef struct map_id_elt {
2N/A char *map_name;
2N/A int map_id;
2N/A struct map_id_elt *next;
2N/A} map_id_elt_t;
2N/A
2N/A/*
2N/A * Success and failure codes the same as used by DBM
2N/A */
2N/Atypedef int suc_code;
2N/A#define SUCCESS 0
2N/A#define FAILURE -1
2N/A
2N/A/*
2N/A * Extern defs for new DBM calls. Must have identical args to traditional
2N/A * version.
2N/A */
2N/Aextern void shim_dbm_close(DBM *db);
2N/Aextern int shim_dbm_delete(DBM *db, datum key);
2N/Aextern datum shim_dbm_fetch(DBM *db, datum key);
2N/Aextern datum shim_dbm_fetch_noupdate(DBM *db, datum key);
2N/Aextern datum shim_dbm_firstkey(DBM *db);
2N/Aextern datum shim_dbm_nextkey(DBM *db);
2N/Aextern DBM *shim_dbm_open(const char *file, int open_flags,
2N/A mode_t file_mode);
2N/Aextern int shim_dbm_store(DBM *db, datum key, datum content,
2N/A int store_mode);
2N/A
2N/A/*
2N/A * Other externs
2N/A */
2N/Aextern map_ctrl *get_map_ctrl(DBM *);
2N/Aextern map_ctrl *create_map_ctrl(char *);
2N/Aextern void free_map_ctrl(map_ctrl *);
2N/Aextern map_ctrl *dup_map_ctrl(map_ctrl *);
2N/Aextern void dump_map_ctrl(map_ctrl *);
2N/Aextern suc_code map_ctrl_init(map_ctrl *map, char *name);
2N/Aextern int lock_map_ctrl(map_ctrl *map);
2N/Aextern int unlock_map_ctrl(map_ctrl *map);
2N/Aextern int map_id_list_init();
2N/Aextern void get_list_max(map_id_elt_t ***list, int *max);
2N/A
2N/Aextern int try_lock_map_update(map_ctrl *map);
2N/Aextern suc_code lock_map_update(map_ctrl *map);
2N/Aextern suc_code unlock_map_update(map_ctrl *map);
2N/Aextern bool_t init_update_lock_map();
2N/A
2N/A/*
2N/A * Globals
2N/A */
2N/Aextern bool_t yptol_mode;
2N/Aextern bool_t yptol_newlock;
2N/Aextern bool_t ypxfrd_flag;
2N/Aextern int yp2ldap;
2N/A
2N/A/*
2N/A * String extensions used in N2L
2N/A */
2N/A
2N/A/* Prefix used for N2L map names */
2N/A#define NTOL_PREFIX "LDAP_"
2N/A
2N/A/* Postfix used for TTL DBM files */
2N/A#define TTL_POSTFIX "_TTL"
2N/A
2N/A/* Postfix for temporary files */
2N/A#define TEMP_POSTFIX "_TMP"
2N/A
2N/A/* File separator character. If this is defined elsewhere can be removed */
2N/A#define SEP_CHAR '/'
2N/A
2N/A/*
2N/A * Special keys used in DBM files. No real NIS map can use these keys.
2N/A */
2N/A#define MAP_EXPIRY_KEY "YP_EXPIRY_TIME"
2N/A#define MAP_OLD_MAP_DATE_KEY "YP_OLD_MAP_DATE_TIME"
2N/A
2N/A/* Mmaped file used for update flags shared memory */
2N/A#define SHM_FILE _PATH_SYSVOL "/nis_shim"
2N/A
2N/A/* used for map arrays reallocation purposes */
2N/A#define ARRAY_CHUNK 10
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* __SHIM_H */