xref: /titanic_51/usr/src/head/rpcsvc/nis_db.h (revision ba3594ba9b5dd4c846c472a8d657edcb7c8109ac)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24*ba3594baSGarrett D'Amore  *
257c478bd9Sstevel@tonic-gate  * Copyright (c) 1991,1997-1998 by Sun Microsystems, Inc.
267c478bd9Sstevel@tonic-gate  * All rights reserved.
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * This header file defines the interface to the NIS database. All
317c478bd9Sstevel@tonic-gate  * implementations of the database must export at least these routines.
327c478bd9Sstevel@tonic-gate  * They must also follow the conventions set herein. See the implementors
337c478bd9Sstevel@tonic-gate  * guide for specific semantics that are required.
347c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifndef	_RPCSVC_NIS_DB_H
377c478bd9Sstevel@tonic-gate #define	_RPCSVC_NIS_DB_H
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #include <rpc/rpc.h>
407c478bd9Sstevel@tonic-gate #include <rpcsvc/nis.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
437c478bd9Sstevel@tonic-gate extern "C" {
447c478bd9Sstevel@tonic-gate #endif
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate enum db_status {
477c478bd9Sstevel@tonic-gate 	DB_SUCCESS = 0,
487c478bd9Sstevel@tonic-gate 	DB_NOTFOUND = 1,
497c478bd9Sstevel@tonic-gate 	DB_NOTUNIQUE = 2,
507c478bd9Sstevel@tonic-gate 	DB_BADTABLE = 3,
517c478bd9Sstevel@tonic-gate 	DB_BADQUERY = 4,
527c478bd9Sstevel@tonic-gate 	DB_BADOBJECT = 5,
537c478bd9Sstevel@tonic-gate 	DB_MEMORY_LIMIT = 6,
547c478bd9Sstevel@tonic-gate 	DB_STORAGE_LIMIT = 7,
557c478bd9Sstevel@tonic-gate 	DB_INTERNAL_ERROR = 8
567c478bd9Sstevel@tonic-gate };
577c478bd9Sstevel@tonic-gate typedef enum db_status db_status;
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate enum db_action {
607c478bd9Sstevel@tonic-gate 	DB_LOOKUP = 0,
617c478bd9Sstevel@tonic-gate 	DB_REMOVE = 1,
627c478bd9Sstevel@tonic-gate 	DB_ADD = 2,
637c478bd9Sstevel@tonic-gate 	DB_FIRST = 3,
647c478bd9Sstevel@tonic-gate 	DB_NEXT = 4,
657c478bd9Sstevel@tonic-gate 	DB_ALL = 5,
667c478bd9Sstevel@tonic-gate 	DB_RESET_NEXT = 6
677c478bd9Sstevel@tonic-gate };
687c478bd9Sstevel@tonic-gate typedef enum db_action db_action;
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate typedef entry_obj *entry_object_p;
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate typedef struct {
737c478bd9Sstevel@tonic-gate 	uint_t db_next_desc_len;
747c478bd9Sstevel@tonic-gate 	char *db_next_desc_val;
757c478bd9Sstevel@tonic-gate } db_next_desc;
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate struct db_result {
787c478bd9Sstevel@tonic-gate 	db_status status;
797c478bd9Sstevel@tonic-gate 	db_next_desc nextinfo;
807c478bd9Sstevel@tonic-gate 	struct {
817c478bd9Sstevel@tonic-gate 		uint_t objects_len;
827c478bd9Sstevel@tonic-gate 		entry_object_p *objects_val;
837c478bd9Sstevel@tonic-gate 	} objects;
847c478bd9Sstevel@tonic-gate 	long ticks;
857c478bd9Sstevel@tonic-gate };
867c478bd9Sstevel@tonic-gate typedef struct db_result db_result;
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate /*
897c478bd9Sstevel@tonic-gate  * Prototypes for the database functions.
907c478bd9Sstevel@tonic-gate  */
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate extern bool_t db_initialize(char *);
937c478bd9Sstevel@tonic-gate extern db_status db_create_table(char *, table_obj *);
947c478bd9Sstevel@tonic-gate extern db_status db_destroy_table(char *);
957c478bd9Sstevel@tonic-gate extern db_result *db_first_entry(char *, int, nis_attr *);
967c478bd9Sstevel@tonic-gate extern db_result *db_next_entry(char *, db_next_desc *);
977c478bd9Sstevel@tonic-gate extern db_result *db_reset_next_entry(char *, db_next_desc *);
987c478bd9Sstevel@tonic-gate extern db_result *db_list_entries(char *, int, nis_attr *);
997c478bd9Sstevel@tonic-gate extern db_result *db_add_entry(char *, int,  nis_attr *, entry_obj *);
1007c478bd9Sstevel@tonic-gate extern db_result *db_remove_entry(char *, int, nis_attr *);
1017c478bd9Sstevel@tonic-gate extern db_status db_checkpoint(char *);
1027c478bd9Sstevel@tonic-gate extern db_status db_standby(char *);
1037c478bd9Sstevel@tonic-gate extern db_status db_table_exists(char *);
1047c478bd9Sstevel@tonic-gate extern db_status db_unload_table(char *);
1057c478bd9Sstevel@tonic-gate extern void db_free_result(db_result *);
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1087c478bd9Sstevel@tonic-gate }
1097c478bd9Sstevel@tonic-gate #endif
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate #endif	/* _RPCSVC_NIS_DB_H */
112