xref: /onnv-gate/usr/src/lib/print/libprint/common/llib-lprint (revision 7253:39650c3caeca)
12264Sjacobs/*
22264Sjacobs * CDDL HEADER START
32264Sjacobs *
42264Sjacobs * The contents of this file are subject to the terms of the
52264Sjacobs * Common Development and Distribution License (the "License").
62264Sjacobs * You may not use this file except in compliance with the License.
72264Sjacobs *
82264Sjacobs * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92264Sjacobs * or http://www.opensolaris.org/os/licensing.
102264Sjacobs * See the License for the specific language governing permissions
112264Sjacobs * and limitations under the License.
122264Sjacobs *
132264Sjacobs * When distributing Covered Code, include this CDDL HEADER in each
142264Sjacobs * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152264Sjacobs * If applicable, add the following below this CDDL HEADER, with the
162264Sjacobs * fields enclosed by brackets "[]" replaced with your own identifying
172264Sjacobs * information: Portions Copyright [yyyy] [name of copyright owner]
182264Sjacobs *
192264Sjacobs * CDDL HEADER END
202264Sjacobs */
212264Sjacobs/*
22*7253Sjacobs * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
232264Sjacobs * Use is subject to license terms.
242264Sjacobs */
252264Sjacobs
262264Sjacobs/* LINTLIBRARY */
272264Sjacobs/* PROTOLIB1 */
282264Sjacobs
292264Sjacobs#pragma ident	"%Z%%M%	%I%	%E% SMI"
302264Sjacobs
312264Sjacobs#include <arpa/inet.h>
322264Sjacobs#include <dirent.h>
332264Sjacobs#include <dlfcn.h>
342264Sjacobs#include <errno.h>
352264Sjacobs#include <fcntl.h>
362264Sjacobs#include <libintl.h>
372264Sjacobs#include <netdb.h>
382264Sjacobs#include <netinet/in.h>
392264Sjacobs#include <pwd.h>
402264Sjacobs#include <rpc/rpc.h>
412264Sjacobs#include <rpcsvc/yp_prot.h>
422264Sjacobs#include <rpcsvc/ypclnt.h>
432264Sjacobs#include <signal.h>
442264Sjacobs#include <stdarg.h>
452264Sjacobs#include <stdio.h>
462264Sjacobs#include <stdlib.h>
472264Sjacobs#include <string.h>
482264Sjacobs#include <sys/mman.h>
492264Sjacobs#include <sys/socket.h>
502264Sjacobs#include <sys/stat.h>
512264Sjacobs#include <sys/systeminfo.h>
522264Sjacobs#include <sys/types.h>
532264Sjacobs#include <syslog.h>
542264Sjacobs#include <unistd.h>
552264Sjacobs
562264Sjacobsvoid **list_append(void **, void *);
572264Sjacobsvoid **list_append_unique(void **, void *, int (*)(void *, void*));
582264Sjacobsvoid **list_concatenate(void **, void **);
592264Sjacobsvoid * list_locate(void **, int (*)(void *, void *), void *);
602264Sjacobsint list_iterate(void **, int (*)(void *, __va_list), ...);
612264Sjacobs
622264Sjacobsvoid	*dynamic_function(const char *, const char *);
632264Sjacobs
642264Sjacobsstruct ns_bsd_addr {
652264Sjacobs	char	*server;	/* server name */
662264Sjacobs	char	*printer;	/* printer name or NULL */
672264Sjacobs	char	*extension;	/* RFC-1179 conformance */
682264Sjacobs	char  *pname;		/* Local printer name */
692264Sjacobs};
702264Sjacobstypedef struct ns_bsd_addr ns_bsd_addr_t;
712264Sjacobs
722264Sjacobs/* Key/Value pair structure */
732264Sjacobsstruct ns_kvp {
742264Sjacobs	char *key;		/* key */
752264Sjacobs	char *value;		/* value string */
762264Sjacobs};
772264Sjacobstypedef struct ns_kvp ns_kvp_t;
782264Sjacobs
792264Sjacobs/* Printer Object structure */
802264Sjacobsstruct ns_printer {
812264Sjacobs	char		*name;			/* primary name of printer */
822264Sjacobs	char		**aliases;		/* aliases for printer */
832264Sjacobs	char		*source;		/* name service derived from */
842264Sjacobs	ns_kvp_t	**attributes;		/* key/value pairs. */
852264Sjacobs};
862264Sjacobstypedef struct ns_printer ns_printer_t;
872264Sjacobs
882264Sjacobs/* functions to get/put printer objects */
892264Sjacobsns_printer_t *ns_printer_create(char *, char **, char *, ns_kvp_t **);
902264Sjacobsns_printer_t *ns_printer_get_name(const char *, const char *);
912264Sjacobsns_printer_t **ns_printer_get_list(const char *);
922264Sjacobsint	ns_printer_put(const ns_printer_t *);
932264Sjacobsvoid	ns_printer_destroy(ns_printer_t *);
942264Sjacobs
952264Sjacobs/* functions to manipulate key/value pairs */
962264Sjacobsvoid	*ns_get_value(const char *, const ns_printer_t *);
972264Sjacobschar	*ns_get_value_string(const char *, const ns_printer_t *);
982264Sjacobsint	ns_set_value(const char *, const void *, ns_printer_t *);
992264Sjacobsint	ns_set_value_from_string(const char *, const char *,
1002264Sjacobs						ns_printer_t *);
1012264Sjacobsns_kvp_t	*ns_kvp_create(const char *, const char *);
1022264Sjacobs
1032264Sjacobs/* for BSD bindings only */
1042264Sjacobsns_bsd_addr_t *ns_bsd_addr_get_default(void);
1052264Sjacobsns_bsd_addr_t *ns_bsd_addr_get_name(char *name);
1062264Sjacobsns_bsd_addr_t **ns_bsd_addr_get_all(int);
1072264Sjacobsns_bsd_addr_t **ns_bsd_addr_get_list(int);
1082264Sjacobs
1092264Sjacobs/* others */
1102264Sjacobsns_printer_t *posix_name(const char *);
1112264Sjacobsint ns_printer_match_name(ns_printer_t *, const char *);
1122264Sjacobschar *ns_printer_name_list(const ns_printer_t *);
1132264Sjacobschar *value_to_string(const char *, void *);
1142264Sjacobsvoid *string_to_value(const char *, char *);
1152264Sjacobs
1162264Sjacobs
1172264Sjacobsns_printer_t *_cvt_pconf_entry_to_printer(char *, char *);
1182264Sjacobschar *_cvt_printer_to_pconf_entry(ns_printer_t *);
1192264Sjacobs
1202264Sjacobsns_printer_t *_cvt_user_string_to_printer(char *, char *);
1212264Sjacobschar *_cvt_printer_to_user_string(ns_printer_t *);
1222264Sjacobs
1232264Sjacobs
1242264Sjacobsns_printer_t *_file_get_name(const char *, const char *,
1252264Sjacobs    ns_printer_t *(*)(char *, char *), char *);
1262264Sjacobs
1272264Sjacobsns_printer_t **_file_get_list(const char *,
1282264Sjacobs    ns_printer_t *(*)(char *, char *), char *);
1292264Sjacobs
1302264Sjacobsint _file_put_printer(const char *, const ns_printer_t *,
1312264Sjacobs    ns_printer_t *(*)(char *, char *), char *, char *(*)(ns_printer_t *));
1322264Sjacobs
1332264Sjacobs
1342264Sjacobsns_printer_t *_nis_get_name(const char *, const char *,
1352264Sjacobs    ns_printer_t *(*)(char *, char *), char *);
1362264Sjacobs
1372264Sjacobsns_printer_t **_nis_get_list(const char *,
1382264Sjacobs    ns_printer_t *(*)(char *, char *), char *);
1392264Sjacobs
1402264Sjacobsint _nis_put_printer(const char *, const ns_printer_t *,
1412264Sjacobs    ns_printer_t *(*)(char *, char *), char *, char *(*)(ns_printer_t *));
142