/* WARNING: This file was generated by dkct. Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: printqd.ctr */ /* Copyright (C) 2016-2017, Dirk Krause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above opyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PRINTQD_H_INCLUDED /** Avoid multiple inclusions. */ #define PRINTQD_H_INCLUDED 1 #line 10 "printqd.ctr" /* CORRECT NEXT LINE AFTER REPLACING PRINTQD */ /** @file printqd.h Definitions for printqd. */ #ifndef DK4CONF_H_INCLUDED #include "dk4conf.h" #endif #ifndef DK4TYPES_H_INCLUDED #include "dk4types.h" #endif #ifndef DK4STO_H_INCLUDED #include "dk4sto.h" #endif #ifndef DK4SOCK_H_INCLUDED #include "dk4sock.h" #endif /** Limit for one user or group. */ typedef struct { char *name; /**< User or group name */ dk4_um_t limit; /**< Page limit. */ } pqd_limit_t; /** Printer class (may contain multiple printers). */ typedef struct { char *name; /**< Class name. */ dk4_sto_t *s_u; /**< User limits storage. */ dk4_sto_it_t *i_u; /**< User limits storage iterator. */ dk4_sto_t *s_g; /**< Group limits storage. */ dk4_sto_it_t *i_g; /**< Group limits storage iterator. */ dk4_um_t dl; /**< Default limit. */ int da; /**< Deny action: 1=hold, 0=remove. */ int hdl; /**< Flag: Have default limit. */ } pqd_class_t; /** Printer. */ typedef struct { char *name; /**< Printer name. */ pqd_class_t *cl; /**< Printer class. */ } pqd_printer_t; /* In service the class is not NULL. If no class is configured for a printer, the program complains and exits. */ /** Printer alias. */ typedef struct { char *name; /**< Alias name. */ pqd_printer_t *pr; /**< The real printer. */ } pqd_printer_alias_t; /** Printqd configuration. */ typedef struct { char *sname; /**< UNIX domain socket file name. */ char *dname; /**< Database name (including type). */ char *lname; /**< Log file name. */ dk4_sto_t *s_c; /**< Storage for classes. */ dk4_sto_it_t *i_c; /**< Iterator for class storage. */ dk4_sto_t *s_p; /**< Storage for printers. */ dk4_sto_it_t *i_p; /**< Iterator for printers storage. */ dk4_sto_t *s_a; /**< Storage for aliases. */ dk4_sto_it_t *i_a; /**< Iterator for aliases storage. */ dk4_sto_t *s_ai; /**< Storage for peers allowed info rq. */ dk4_sto_it_t *i_ai; /**< Iterator for info peers storage. */ dk4_sto_t *s_ad; /**< Storage for peers allowed data rq. */ dk4_sto_it_t *i_ad; /**< Iterator for data peers storage. */ dk4_sto_t *s_aa; /**< Storage for peers allowed admin rq. */ dk4_sto_it_t *i_aa; /**< Iterator for admin peers storage. */ size_t m_loc; /**< Maximum number of local connections. */ size_t m_tcp; /**< Maximum number of TCP connections. */ uid_t uid; /**< Run as specified user. */ uid_t suid; /**< Local socket owner UID. */ gid_t gid; /**< Run as specified group. */ gid_t sgid; /**< Local socket owner GID. */ int slbl; /**< Backlog for local socket. */ int snbl; /**< Backlog for network socket. */ int iglo; /**< Flag: Globally allow info requests. */ int dglo; /**< Flag: Globally allow data requests. */ int aglo; /**< Flag: Globally allow admin requests. */ int linf; /**< Flag: Log info requests. */ int ldb; /**< Flag: Log database modifications. */ unsigned short ptcp; /**< TCP port (info, data, admin), host repr. */ unsigned short pudp; /**< UDP port (info only), host represent. */ } pqd_conf_t; /** Connection record for local socket. */ typedef struct { dk4_socket_t sock; /**< Socket. */ } pqd_l_conn_t; /** Connection record for network socket. */ typedef struct { dk4_sockaddr_storage_t raddr; /**< Remote address. */ dk4_socket_t sock; /**< Socket. */ int pqdpl; /**< Printqd protocol level. */ } pqd_n_conn_t; /** One request to process. */ typedef struct { void *connptr; /**< Connection record for socket. */ dk4_sto_t *sto; /**< Container for conn records. */ struct sockaddr *soa; /**< Remote address, only UDP. */ size_t *pnconn; /**< Addr of variable, NULL for UDP. */ char *cmdptr; /**< Start of command. */ char *argptr; /**< Command arguments. */ size_t szsoa; /**< Size of rem address, only UDP. */ dk4_socket_t sock; /**< Socket to use for response. */ int protlev; /**< Protocol level. */ int action; /**< Action to take. */ int logthis; /**< Flag: Log request and response. */ } pqd_rq_t; /** Data for one user in a class. */ typedef struct { dk4_um_t limit; /**< Limit (maximum page number). */ dk4_um_t used; /**< Number of pages used within limit. */ dk4_um_t account; /**< Remaining pages personal print account. */ int da; /**< Deny action: 0=remove, 1=hold. */ } pqd_account_t; /** Information from one LPRng accounting line. */ typedef struct { char *username; /**< User name. */ char *queuename; /**< Print queue name. */ char *jobtitle; /**< Print job title. */ char *pagecount; /**< Pagecount reported in line. */ } lprng_info_t; /** Printqd protocol levels. */ enum { PQD_PROTO_NONE = 0 , /**< No requests allowed. */ PQD_PROTO_INFO = 1 , /**< Info requests only. */ PQD_PROTO_DATA = 2 , /**< Info and data requests. */ PQD_PROTO_ADMIN = 3 /**< Info, data and admin requests. */ }; /** Commands in the printqd protocol. */ enum { PQD_CMD_NONE = -1 , /**< Illegal command. */ PQD_CMD_JOBSTART = 0 , /**< Start of print job, response required. */ PQD_CMD_JOBEND = 1 , /**< End of print job. */ PQD_CMD_START = 2 , /**< Start of printing (ignored). */ PQD_CMD_END = 3 , /**< End of printing (ignored). */ PQD_CMD_FILESTART = 4 , /**< Start of file printing (pc). */ PQD_CMD_FILEEND = 5 , /**< End of file printing (pc). */ PQD_CMD_INFO = 6 , /**< Information, response required. */ PQD_CMD_ACCT_CHECK = 7 , /**< Check permission, response required. */ PQD_CMD_ACCT_START = 8 , /**< Start of file printing (pc). */ PQD_CMD_ACCT_END = 9 , /**< End of file printing (pc). */ PQD_CMD_ACCT_CHARGE = 10 , /**< Summary for file printing (pc). */ PQD_CMD_CONTROL = 11 /**< Control request. */ }; #endif