Library
Module
Module type
Parameter
Class
Class type
LPD protocol server library (RFC 1179 compliant).
type file_type =
| Text of int * int
Text(indent, number_of_columns)
: print as a text file, providing page breaks as necessary. According to the RFC, any ASCII control chars other than '\b', '\t', '\n', '\012', '\r' should be discarded -- it is your task to do so as you know better how to deal with them (accented letters,...) especially when you know PDF files may be sent using that type!
| Bin
Binary file to be printed as is (including control chars).
*)| PS
PostScript file.
*)| DVI
TeX DVI file.
*)| Troff of string * string * string * string
Troff(R font, I font, B font, S font)
: troff output file.
| Ditroff
ditroff (device independent troff) output.
*)| CIF
CalTech Intermediate Form graphics language.
*)| Plot
Output from the Berkeley Unix plot library.
*)| Pr of string * int
Pr(title, number_of_columns)
: print with a heading, page numbers, and pagination. The heading should include the date and time that printing was started, the title
, and a page number identifier followed by the page number.
| Fortran
Print interpreting the first column of each line as FORTRAN carriage control.
*)| Raster
Sun raster format file.
*)Information on the type of the file to be printed.
type file = {
name : string;
Name of the file on the client machine. ""
means standard input.
size : int;
Size in bytes of the file.
*)nbcopies : int;
Number of copies requested.
*)storage : string;
Local file on the disk holding the data.
*)of_type : file_type;
Type of the file.
*)}
type job = {
number : int;
Three digits job number. A negative number indicates that the client did not send a correct job number.
*)user : string;
User identification of the entity requesting the printing job.
*)host : string;
Host which is to be treated as the source of the print job. This is not necessarily the same as the machine which connected this server -- the job may have been routed through several computers.
*)mailto : string;
If different from ""
, request that a mail be sent to the given address when the printing operation ends (successfully or unsuccessfully). There is no guarantee that the email address is even well formed (e.g. it may only be the login name).
files : file list;
List of files of this job. The files will be removed after the job handling function on_reception
return. If you want to keep them longer, rename them or (better) move them to another directory.
addr : Unix.sockaddr;
Address of the machine which connected to this server.
*)}
type queue_actions = {
print : unit -> unit;
Function executed when it is requested to start the printing process (if not already running).
*)on_reception : job -> unit;
Handler for each job received.
*)send_queue : jobref list -> Socket.out_channel -> unit;
Handler for sending a queue state in short form.
*)send_queue_long : jobref list -> Socket.out_channel -> unit;
Handler for sending a queue state in long form.
*)remove : string -> Unix.sockaddr -> jobref list -> unit;
Handler for removing jobs. The string
is the user name (the agent) requesting the removal and Unix.sockaddr
is the address of the machine which connected the server (to enable security checks). lprm -
, requesting to remove all the jobs that the user owns, gives as a list of jobs: [User "-"]
.
}
Functions to be executed on queue events.
module type CONFIG = sig ... end
string_of_current_time()
returns the current date and time.
header_of_job queue
returns a string suitable as a header for Lpd.string_of_job
. If queue = ""
, the mention of the queue is omitted.
val string_of_job : int -> job -> string
string_of_job rank job
returns a one line string describing the job
. A job with an empty list of files is considered to have been canceled. The rank
is a positive number giving the rank of the job in the queue. A rank
if 0
means that the job is in the printing stage. string_of_job
is a helper function to design a send_queue
callback (see Lpd.queue_actions
).
val long_string_of_job : int -> job -> string
long_string_of_job rank job
does the same as Lpd.string_of_job
except that the description is in long format (multi-lines). It is suitable to write send_queue_long
callback (see Lpd.queue_actions
).
val any_host : Unix.sockaddr -> bool
any_host addr
accepts any Internet host which can be found in the DNS.
val these_hosts : ?file:string -> string list -> Unix.sockaddr -> bool
these_hosts ?file hosts adrr
accepts connections from Internet hosts or IP addresses listed in the file or in the list hosts
.