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

WERROR cli_spoolss_enum_printers ( struct cli_state *  cli,
TALLOC_CTX mem_ctx,
uint32  offered,
uint32 *  needed,
uint32  flags,
uint32  level,
uint32 *  num_printers,
PRINTER_INFO_CTR *  ctr 
)

Enumerate printers 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.
flags Selected from PRINTER_ENUM_* flags.
level Request information level.
num_printers Pointer to number of printers returned. May be NULL.
ctr Return structure for printer information. May be NULL.

Definition at line 409 of file cli_spoolss.c.

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

      ZERO_STRUCT(q);
      ZERO_STRUCT(r);

      fstrcpy (server, 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_enumprinters(&q, flags, server, level, &buffer, 
                            offered);

            /* Marshall data and send request */

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

            /* Unmarshall response */

            if (spoolss_io_r_enumprinters("", &r, &rbuf, 0)) {
            if (needed)
                  *needed = r.needed;
            }
            
      result = r.status;
            
      /* Return output parameters */

      if (!W_ERROR_IS_OK(r.status))
                  goto done;
      
      if (num_printers)
            *num_printers = r.returned;

      if (!ctr)
            goto done;

                  switch (level) {
                  case 0:
                        decode_printer_info_0(mem_ctx, r.buffer, r.returned, 
                                          &ctr->printers_0);
                        break;
                  case 1:
                        decode_printer_info_1(mem_ctx, r.buffer, r.returned, 
                                          &ctr->printers_1);
                        break;
                  case 2:
                        decode_printer_info_2(mem_ctx, r.buffer, r.returned, 
                                          &ctr->printers_2);
                        break;
                  case 3:
                        decode_printer_info_3(mem_ctx, r.buffer, r.returned, 
                                          &ctr->printers_3);
                        break;
                  }                 

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

      return result;    
}


Generated by  Doxygen 1.6.0   Back to index