getprinter.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "ldap_common.h"
/* printer attributes filters */
#define _F_GETPRINTERBYNAME \
"(&(objectClass=sunPrinter)(|(printer-name=%s)(printer-aliases=%s)))"
/*
* Attributes from the following classes:
* printerService
* printerAbstact
* sunPrinter
*/
/*
* Get all attributes.
*/
static const char **printer_attrs = NULL;
/*
* _nss_ldap_printers2ent is the data marshaling method for the printers
* getXbyY backend processes. This method is called after a successful
* ldap search has been performed. This method will parse the ldap search
* values into argp->buf.buffer. Three error conditions are expected and
* returned to nsswitch.
*/
static int
{
int i, j;
int nss_result;
int buflen = (int)0;
unsigned long len = 0L;
nss_result = (int)NSS_STR_PARSE_ERANGE;
goto result_printers2ent;
}
nss_result = (int)NSS_STR_PARSE_SUCCESS;
/* Make sure our buffer stays NULL terminated */
buflen--;
nss_result = (int)NSS_STR_PARSE_PARSE;
goto result_printers2ent;
}
/*
* Pick out the printer name.
*/
nss_result = (int)NSS_STR_PARSE_PARSE;
goto result_printers2ent;
}
*buffer = 0;
nss_result = (int)NSS_STR_PARSE_PARSE;
goto result_printers2ent;
}
nss_result = (int)NSS_STR_PARSE_ERANGE;
goto result_printers2ent;
}
}
}
/*
* Should never happen since it is mandatory but bail if
* we don't have a printer name.
*/
nss_result = (int)NSS_STR_PARSE_PARSE;
goto result_printers2ent;
}
/*
* Add the rest of the attributes
*/
nss_result = (int)NSS_STR_PARSE_PARSE;
goto result_printers2ent;
}
/*
* The attribute contains key=value
*/
for (j = 0; j < attr->value_count; j++) {
if (len < 1 ||
*buffer = 0;
nss_result = (int)NSS_STR_PARSE_PARSE;
goto result_printers2ent;
}
nss_result = (int)NSS_STR_PARSE_ERANGE;
goto result_printers2ent;
}
*cp = ':';
}
}
} else {
/*
* Skip the printer name
*/
continue;
}
/*
* Translate sun-printer-bsdaddr -> bsdaddr
*/
0) {
}
}
/*
* The attribute name is the key. The attribute
* data is the value.
*/
for (j = 0; j < attr->value_count; j++) {
int k;
char *kp;
if (len < 1 ||
*buffer = 0;
nss_result = (int)NSS_STR_PARSE_PARSE;
goto result_printers2ent;
}
/*
* Add extra for any colons which need to
* be backslashed plus ending ':' or ','.
*/
k = 0;
if (*kp == ':')
k++;
if (j == 0) {
}
nss_result = (int)NSS_STR_PARSE_ERANGE;
goto result_printers2ent;
}
if (j == 0) {
*cp = ':';
} else {
*cp = ',';
}
(void) append_attr(buffer,
}
}
}
}
#ifdef DEBUG
#endif
return ((int)nss_result);
}
/*
* Attributes which contain colons must be backslashed.
*/
static void
{
return;
}
if (*cp == ':') {
*bp++ = '\\';
}
}
}
/*
* getbyname gets printer attributes by printer name. This function
* constructs an ldap search filter using the printer name invocation
* parameter and the getprinterbyname search filter defined. Once the
* filter is constructed, we search for matching entries and marshal
* the data results into argp->buf.buffer for the frontend process.
* The function * _nss_ldap_printers2ent performs the data marshaling.
*/
static nss_status_t
{
char printername[BUFSIZ];
char searchfilter[SEARCHFILTERLEN];
return ((nss_status_t)NSS_NOTFOUND);
}
static ldap_backend_op_t printers_ops[] = {
};
/*
* _nss_ldap_printers_constr is where life begins. This function calls
* the generic ldap constructor function to define and build the abstract
* data types required to support ldap operations.
*/
/*ARGSUSED0*/
const char *dummy3)
{
#ifdef DEBUG
"\n[getprinterent.c: _nss_ldap_printers_constr]\n");
#endif
}