adaptor.c revision 355b4669e025ff377602b6fc7caaf30dbc218371
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <dlfcn.h>
#include <sys/systeminfo.h>
#include <syslog.h>
#include <adaptor.h>
#include <ns.h>
#ifndef RTLD_GLOBAL /* for OSF/1 */
#define RTLD_GLOBAL 0
#endif
/*
* This file contains the implementation of the API used by the front half
* of the BSD Print protocol adaptor to select and glue in the back half of
* the print protocol adaptor dynamically. Most of the functions in this
* file are hollow shells that pick a back end, load it, and call the "real"
* function from the loaded object, with the arguments passed in. The loaded
* functions have the naming convention {paradigm}_{function}.
* These functions are in NO WAY MT-Safe. They are intended to be used by
*/
static void *paradigm_handle = NULL;
static char *paradigm_name = NULL;
static int paradigm_version = -1;
static char *primary_name = NULL;
static int
is_localhost(char *name)
{
return (0);
return (0);
}
int
{
register char *p;
return (0);
return (0);
for (p = (char *)str; *p; p++)
return (0);
return (1);
}
/*
* A hack for performance. This will look for a local LP based printer in
* the most efficient manner. If found, it will circumvent all future
* adaptor resolution and load the default lpsched translation module.
*/
static int
lpsched_adaptor_available(const char *printer)
{
return (-1);
"in.lpd:lpsched_adaptor_available: printer is %s\n",
printer);
return (-1);
"in.lpd:lpsched_adaptor_available: printer %s local\n",
printer);
if (paradigm_handle == NULL)
return (-1);
return (0);
}
/*
* adaptor_avaliable() takes in the name of a printer, looks it up in the
* name service, and dynamically loads backend support for the print paradigm
* the printer is defined in. If the printer is undefined, UNDEFINED is
* returned. If the spooling paradigm is not defined, and the printer is
* remote, a "cascade" capability is loaded.
*/
int
adaptor_available(const char *printer)
{
char *path,
*dir,
*tmp,
*tmp_path;
/*
* for performance, check lpsched first and foremost. This will
* hide any NS information if there is an LP configuration, valid
* or not.
*/
if (lpsched_adaptor_available(printer) == 0)
return (0);
errno = 0;
NS_SVC_ETC)) == NULL) &&
(endprinterentry() == 0) &&
return (-1);
}
printer_object)) == NULL) {
else
}
}
== NULL)
path = ADAPTOR_PATH;
if (paradigm_version < 0)
dir, paradigm_name);
else
!= NULL)
break;
#ifdef DEBUG
#endif
}
return (paradigm_handle == NULL);
}
static void *
{
char name[128];
if (paradigm_handle == NULL)
return (NULL);
return (fpt);
}
int
adaptor_spooler_available(const char *printer)
{
"spooler_available")) != NULL))
/*
* in the case of cascading,
* use the local name of the printer
*/
else
return ((int)(fpt)
return (-1);
}
int
adaptor_spooler_accepting_jobs(const char *printer)
{
"spooler_accepting_jobs")) != NULL))
return (-1);
}
int
{
"client_access")) != NULL))
return (-1);
}
int
adaptor_restart_printer(const char *printer)
{
/* need a cast */
"restart_printer")) != NULL))
return (-1);
}
char *
{
/* need a cast */
"temp_dir")) != NULL))
host));
return (NULL);
}
int
char **df_list)
{
/* need a cast */
"submit_job")) != NULL))
return (-1);
}
int
char **list)
{
/* need a cast */
"show_queue")) != NULL))
return (-1);
}
int
{
/* need a cast */
"cancel_job")) != NULL))
return (-1);
}