Logo Search packages:      
Sourcecode: samba-doc-ja version File versions

WERROR cli_spoolss_enum_ports ( struct cli_state *  cli,
TALLOC_CTX mem_ctx,
uint32  offered,
uint32 *  needed,
uint32  level,
int *  num_ports,
PORT_INFO_CTR *  ctr 
)

Enumerate printer ports on a print server.

Parameters:
cli Pointer to client state structure which is open on the SPOOLSS pipe.
mem_ctx Pointer to an initialised talloc context.
offered Buffer size offered in the request.
needed Number of bytes needed to complete the request. May be NULL.
level Requested information level.
num_ports Pointer to number of ports returned. May be NULL.
ctr Pointer to structure holding port information. May be NULL.

Definition at line 509 of file cli_spoolss.c.

{
      prs_struct qbuf, rbuf;
      SPOOL_Q_ENUMPORTS q;
        SPOOL_R_ENUMPORTS r;
      NEW_BUFFER buffer;
      WERROR result = W_ERROR(ERRgeneral);
      fstring server;

      ZERO_STRUCT(q);
      ZERO_STRUCT(r);

        slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
        strupper (server);

            /* Initialise input parameters */

      init_buffer(&buffer, offered, mem_ctx);

            prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
            prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);

      make_spoolss_q_enumports(&q, server, level, &buffer, offered);

            /* Marshall data and send request */

            if (!spoolss_io_q_enumports("", &q, &qbuf, 0) ||
          !rpc_api_pipe_req(cli, SPOOLSS_ENUMPORTS, &qbuf, &rbuf))
                  goto done;

            /* Unmarshall response */

            if (spoolss_io_r_enumports("", &r, &rbuf, 0)) {
            if (needed)
                  *needed = r.needed;
            }
            
      result = r.status;

            /* Return output parameters */

      if (!W_ERROR_IS_OK(result))
            goto done;

      if (num_ports)
            *num_ports = r.returned;

      if (!ctr)
            goto done;

                  switch (level) {
                  case 1:
                        decode_port_info_1(mem_ctx, r.buffer, r.returned, 
                                       &ctr->port.info_1);
                        break;
                  case 2:
                        decode_port_info_2(mem_ctx, r.buffer, r.returned, 
                                       &ctr->port.info_2);
                        break;
                  }                 

      done:
            prs_mem_free(&qbuf);
            prs_mem_free(&rbuf);

      return result;    
}


Generated by  Doxygen 1.6.0   Back to index