144746Smarkm/* 250476Speter * ------+---------+---------+---------+---------+---------+---------+---------* 344746Smarkm * Copyright (c) 2002 - Garance Alistair Drosehn <gad@FreeBSD.org>. 444746Smarkm * All rights reserved. 544746Smarkm * 644746Smarkm * Redistribution and use in source and binary forms, with or without 744746Smarkm * modification, are permitted provided that the following conditions 857171Sshin * are met: 996462Sru * 1. Redistributions of source code must retain the above copyright 1074870Sru * notice, this list of conditions and the following disclaimer. 1174870Sru * 2. Redistributions in binary form must reproduce the above copyright 12114962Shmp * notice, this list of conditions and the following disclaimer in the 13114962Shmp * documentation and/or other materials provided with the distribution. 1444746Smarkm * 1544746Smarkm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1644746Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1744746Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1844746Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1944746Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2044746Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2165240Sache * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2259266Ssteve * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2359266Ssteve * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2459266Ssteve * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2544746Smarkm * SUCH DAMAGE. 2644746Smarkm * 2744746Smarkm * The views and conclusions contained in the software and documentation 2844746Smarkm * are those of the authors and should not be interpreted as representing 2945255Sache * official policies, either expressed or implied, of the FreeBSD Project 3044746Smarkm * or FreeBSD, Inc. 3144746Smarkm * 32 * ------+---------+---------+---------+---------+---------+---------+---------* 33 * $FreeBSD: releng/10.3/usr.sbin/lpr/common_source/matchjobs.h 117541 2003-07-14 05:15:21Z gad $ 34 * ------+---------+---------+---------+---------+---------+---------+---------* 35 */ 36 37#include <sys/queue.h> 38 39/* 40 * The "matcheduser" field is *only* valid during the call to the 41 * given "doentry()" routine, and is only set if the specification 42 * included a userid. 43 */ 44struct jobspec { 45 STAILQ_ENTRY(jobspec) nextjs; 46 char *wantedhost; 47 char *wanteduser; 48 char *matcheduser; /* only valid for "doentry()" */ 49 char *fmtoutput; /* set by format_jobspec() */ 50 long startnum; 51 long endrange; 52 int pluralfmt; /* boolean set by format_jobspec() */ 53 uint matchcnt; 54}; 55STAILQ_HEAD(jobspec_hdr, jobspec); 56 57/* 58 * Format options for format_jobspec. 59 */ 60#define FMTJS_TERSE 1 /* user:jobrange@host */ 61#define FMTJS_VERBOSE 2 /* jobrange from user@host */ 62 63/* 64 * Options for scanq_jobspec. 65 * 66 * The caller must choose the order that entries should be scanned: 67 * 1) JSORDER: Matched jobs are processed (by calling the "doentry()" 68 * routine) in the order that the user specified those jobs. 69 * 2) QORDER: Matched jobs are processed in the order that the jobs are 70 * listed the queue. This guarantees that the "doentry()" routine 71 * will be called only once per job. 72 * 73 * There is a "job_matched" variable in struct jobqueue, which is used 74 * to make sure that the "doentry()" will only be called once for any 75 * given job in JSORDER processing. The "doentry()" routine can turn 76 * that off, if it does want to be called multiple times when the job 77 * is matched by multiple specifiers. 78 * 79 * The JSORDER processing will also call the "doentry()" routine once 80 * after each scan of the queue, with the jobqueue set to null. This 81 * provides a way for the caller to print out a summary message for 82 * each jobspec that was given. 83 */ 84#define SCQ_JSORDER 0x0001 /* follow the user-specified order */ 85#define SCQ_QORDER 0x0002 /* the order of jobs in the queue */ 86 87#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */ 88 89__BEGIN_DECLS 90struct jobqueue; 91 92typedef int process_jqe(void *_myinfo, struct jobqueue *_jq, 93 struct jobspec *_jspec); 94 95void format_jobspec(struct jobspec *_jspec, int _fmt_wanted); 96void free_jobspec(struct jobspec_hdr *_js_hdr); 97int scanq_jobspec(int _qitems, struct jobqueue **_squeue, int _sopts, 98 struct jobspec_hdr *_js_hdr, process_jqe _doentry, 99 void *_doentryinfo); 100int parse_jobspec(char *_jobstr, struct jobspec_hdr *_js_hdr); 101__END_DECLS 102 103