pike.git / lib / modules / Protocols.pmod / LPD.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/LPD.pmod:1: - // - // LPD.pmod: an implementation of the BSD lpd protocol (RFC 1179). - // This is a module for pike. + //! + //! An implementation of the BSD lpd protocol (@rfc{1179@}). + //!   // 3 July 1998 <hww3@riverweb.com> Bill Welliver   // 2 August 2012 <bill@welliver.org> Bill Welliver>   //      #pike __REAL_VERSION__      //! A client for communicating with printers and print spoolers that - //! support the BSD lpd protocol (RFC 1179). + //! support the BSD lpd protocol (@rfc{1179@}).   class client {    string host;    int port;    private Stdio.File conn;    int jobnum;    string jobtype;    string jobname;    -  static int connect(string host, int port) +  protected int connect(string host, int port)    {    int a=random(10);    // try to open one of the "official" local socket ports.    // not having one doesn't seem to be a problem with most LPD    // servers, but we should at least try. will probably fail    // if two try to open the same local port at once. ymmv.    int res=conn->open_socket(721 + a);       return conn->connect(host, port);    }    -  static void send(string s, mixed ... args) +  protected void send(string s, mixed ... args)   {   #ifdef LPD_DEBUG    werror("LPD: sending %O\n", s);   #endif    conn->write(s, @args);   }      //! @decl int set_job_type(string type)   //! Set the type of job to be sent to the printer to @i{type@}.   //! Valid types are: text, postscript and raw.
pike.git/lib/modules/Protocols.pmod/LPD.pmod:85:    return 0;       send("%c%s\n", 01, queue);    string resp= conn->read();    conn->close();    int res;    sscanf(resp, "%c", res);    return res;    }    - static string make_control(int jn) + protected string make_control(int jn)   {    String.Buffer control = String.Buffer();       control->add("H", gethostname(), "\n");   #if constant(getuid) && constant(getpwuid)    control->add("P", getpwuid(getuid())[0]||"nobody", "\n");   #else    control->add("P-1\n");   #endif    control->sprintf("%sdfA%03d%s\n", (jobtype||"l"), jn, gethostname());
pike.git/lib/modules/Protocols.pmod/LPD.pmod:232:    conn->close();    return resp;    }      //! Create a new LPD client connection.   //! @param hostname   //! Contains the hostname or ipaddress of the print host.   //! if not provided, defaults to @i{localhost@}.   //! @param portnum   //! Contains the port the print host is listening on. - //! if not provided, defaults to port @i{515@}, the RFC 1179 standard. + //! if not provided, defaults to port @i{515@}, the @rfc{1179@} standard.    void create(string|void hostname, int|void portnum)    {    host=hostname || "localhost";    port=portnum || 515;    conn=Stdio.File();    jobnum=1;    }   }