cascade.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"
/*LINTLIBRARY*/
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <syslog.h>
#include <unistd.h>
#include <libintl.h>
#include <ns.h>
#include <job.h>
#include <list.h>
#include <misc.h>
#include <network.h>
static char *_rank_suffixes[] = {
"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"
};
static char *
rank_string(const int rank)
{
static char buf[12];
if (rank < 0)
else if (rank == 0)
else
return (buf);
}
/*
* cascade_spooler_available() always returns 0, because it is really
* used as a waiting space for contacting another spooler.
*/
int
cascade_spooler_available(const char *printer)
{
return (-1);
return (-1);
return (0);
}
/*
* cascade_client_access() always returns 0, because all requestors should
* be allowed to cascade.
*/
int
{
return (0);
}
/*
* cascade_spooler_accepting_jobs() always returns 0, because all requestors
* should be allowed to cascade.
*/
int
cascade_spooler_accepting_jobs(const char *printer)
{
return (0);
}
/*
* cascade_temp_dir() returns the directory to be used as the working
* directory for the cascaded spooler. All data files will be expected to
* be stored and retreived from this directory
*/
char *
{
return (NULL);
return (tmp);
}
/*
* cascade_restart_printer() always returns 0, because it should always be
* processing if a job is waiting to cascade.
*/
int
cascade_restart_printer(const char *printer)
{
start_daemon(1);
return (0);
}
/*
* cascade_submit_job() will save the control file data, write a binding
* file and attempt to start a transfer agent.
*/
int
char **df_list)
{
int i;
df_list);
/*
*/
return (-1);
/*
* If the first character is 'U' then make sure that the
* filename does not contain '/'
*/
} else {
}
if (s[0] == CF_USER) /* RFC-1179 User */
user = ++s;
}
/*
* When printd comes to print the request, it will have the submitting
* user's privileges so, having extracted the username from the BSD
* control file, check the user is known to locally active passwd
* databases and change ownership of the datafiles to the job owner.
*/
}
if (userid > 0)
df_list[i]);
"cascade_submit_job: chown failed");
else
"cascade_submit_job: chown succeeded");
}
/* write the control file */
df_list[0][0] = 'c';
/*
* Applying lock when bsd-gw is writing control file
*/
} else {
return (-1);
}
/* write a binding file */
df_list[0][0] = 'x';
/*
* Applying lock when bsd-gw is writing xfile
*/
} else {
df_list[0][0] = 'c';
return (-1);
}
start_daemon(1);
return (0);
}
/*
* cascade_show_queue() will relay job information from a remote spooler
* and then add any local jobs waiting to cascade to the same destination.
*/
int
const char **list)
{
int fd;
/* get the remote list first */
printer));
}
} else
/* list any "local" jobs */
int rank = 1;
if (type == 3) {
gettext("%-7.7s %8.8s %5d "
"%-32.32s %8d bytes\n"),
} else {
gettext("%-8s:%-7s\t\t\t[ job %d%s ]\n"),
}
jobs++;
}
}
return (0);
}
/*
* cascade_cancel_job() will remove any matching jobs waiting to cascade to
* the remote system, and then request the remote system to remove any
* matching jobs.
*/
int
{
int fd;
/* cancel "local" jobs */
/* ask the remote system next */
}
} else
return (0);
}