xref: /titanic_51/usr/src/lib/print/libprint/common/llib-lprint (revision 1e49577a7fcde812700ded04431b49d67cc57d6d)
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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26/* LINTLIBRARY */
27/* PROTOLIB1 */
28
29#pragma ident	"%Z%%M%	%I%	%E% SMI"
30
31#include <arpa/inet.h>
32#include <dirent.h>
33#include <dlfcn.h>
34#include <errno.h>
35#include <fcntl.h>
36#include <libintl.h>
37#include <netdb.h>
38#include <netinet/in.h>
39#include <pwd.h>
40#include <rpc/rpc.h>
41#include <rpcsvc/yp_prot.h>
42#include <rpcsvc/ypclnt.h>
43#include <signal.h>
44#include <stdarg.h>
45#include <stdio.h>
46#include <stdlib.h>
47#include <string.h>
48#include <sys/mman.h>
49#include <sys/socket.h>
50#include <sys/stat.h>
51#include <sys/systeminfo.h>
52#include <sys/types.h>
53#include <syslog.h>
54#include <unistd.h>
55
56void **list_append(void **, void *);
57void **list_append_unique(void **, void *, int (*)(void *, void*));
58void **list_concatenate(void **, void **);
59void * list_locate(void **, int (*)(void *, void *), void *);
60int list_iterate(void **, int (*)(void *, __va_list), ...);
61
62void	*dynamic_function(const char *, const char *);
63
64struct ns_bsd_addr {
65	char	*server;	/* server name */
66	char	*printer;	/* printer name or NULL */
67	char	*extension;	/* RFC-1179 conformance */
68	char  *pname;		/* Local printer name */
69};
70typedef struct ns_bsd_addr ns_bsd_addr_t;
71
72/* Key/Value pair structure */
73struct ns_kvp {
74	char *key;		/* key */
75	char *value;		/* value string */
76};
77typedef struct ns_kvp ns_kvp_t;
78
79/* Printer Object structure */
80struct ns_printer {
81	char		*name;			/* primary name of printer */
82	char		**aliases;		/* aliases for printer */
83	char		*source;		/* name service derived from */
84	ns_kvp_t	**attributes;		/* key/value pairs. */
85};
86typedef struct ns_printer ns_printer_t;
87
88/* functions to get/put printer objects */
89ns_printer_t *ns_printer_create(char *, char **, char *, ns_kvp_t **);
90ns_printer_t *ns_printer_get_name(const char *, const char *);
91ns_printer_t **ns_printer_get_list(const char *);
92int	ns_printer_put(const ns_printer_t *);
93void	ns_printer_destroy(ns_printer_t *);
94
95/* functions to manipulate key/value pairs */
96void	*ns_get_value(const char *, const ns_printer_t *);
97char	*ns_get_value_string(const char *, const ns_printer_t *);
98int	ns_set_value(const char *, const void *, ns_printer_t *);
99int	ns_set_value_from_string(const char *, const char *,
100						ns_printer_t *);
101ns_kvp_t	*ns_kvp_create(const char *, const char *);
102
103/* for BSD bindings only */
104ns_bsd_addr_t *ns_bsd_addr_get_default(void);
105ns_bsd_addr_t *ns_bsd_addr_get_name(char *name);
106ns_bsd_addr_t **ns_bsd_addr_get_all(int);
107ns_bsd_addr_t **ns_bsd_addr_get_list(int);
108
109/* others */
110ns_printer_t *posix_name(const char *);
111int ns_printer_match_name(ns_printer_t *, const char *);
112char *ns_printer_name_list(const ns_printer_t *);
113char *value_to_string(const char *, void *);
114void *string_to_value(const char *, char *);
115
116
117ns_printer_t *_cvt_pconf_entry_to_printer(char *, char *);
118char *_cvt_printer_to_pconf_entry(ns_printer_t *);
119
120ns_printer_t *_cvt_user_string_to_printer(char *, char *);
121char *_cvt_printer_to_user_string(ns_printer_t *);
122
123
124ns_printer_t *_file_get_name(const char *, const char *,
125    ns_printer_t *(*)(char *, char *), char *);
126
127ns_printer_t **_file_get_list(const char *,
128    ns_printer_t *(*)(char *, char *), char *);
129
130int _file_put_printer(const char *, const ns_printer_t *,
131    ns_printer_t *(*)(char *, char *), char *, char *(*)(ns_printer_t *));
132
133
134ns_printer_t *_nis_get_name(const char *, const char *,
135    ns_printer_t *(*)(char *, char *), char *);
136
137ns_printer_t **_nis_get_list(const char *,
138    ns_printer_t *(*)(char *, char *), char *);
139
140int _nis_put_printer(const char *, const ns_printer_t *,
141    ns_printer_t *(*)(char *, char *), char *, char *(*)(ns_printer_t *));
142