LCOV - code coverage report
Current view: top level - librpc/ndr - ndr_ntprinting.c (source / functions) Hit Total Coverage
Test: coverage report for vadcx-master-patch-75612 fe003de8 Lines: 41 44 93.2 %
Date: 2024-02-29 22:57:05 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    routines for marshalling/unmarshalling special ntprinting structures
       5             : 
       6             :    Copyright (C) Guenther Deschner 2010
       7             : 
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             : 
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             : 
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : #include "includes.h"
      23             : #include "../librpc/gen_ndr/ndr_ntprinting.h"
      24             : 
      25         140 : _PUBLIC_ libndr_flags ndr_ntprinting_string_flags(libndr_flags string_flags)
      26             : {
      27         140 :         libndr_flags flags = LIBNDR_FLAG_STR_NULLTERM;
      28             : 
      29         140 :         if (string_flags & LIBNDR_FLAG_STR_ASCII) {
      30           0 :                 flags |= LIBNDR_FLAG_STR_ASCII;
      31          96 :         } else if (string_flags & LIBNDR_FLAG_STR_RAW8) {
      32           0 :                 flags |= LIBNDR_FLAG_STR_RAW8;
      33             :         } else {
      34          96 :                 flags |= LIBNDR_FLAG_STR_UTF8;
      35             :         }
      36             : 
      37         140 :         return flags;
      38             : }
      39             : 
      40           4 : _PUBLIC_ enum ndr_err_code ndr_pull_ntprinting_printer(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct ntprinting_printer *r)
      41             : {
      42           4 :         uint32_t _ptr_devmode;
      43           4 :         TALLOC_CTX *_mem_save_devmode_0;
      44             :         {
      45           4 :                 libndr_flags _flags_save_STRUCT = ndr->flags;
      46           4 :                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
      47           4 :                 if (ndr_flags & NDR_SCALARS) {
      48           4 :                         NDR_CHECK(ndr_pull_align(ndr, 5));
      49           4 :                         NDR_CHECK(ndr_pull_ntprinting_printer_info(ndr, NDR_SCALARS, &r->info));
      50           4 :                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_devmode));
      51           4 :                         if (_ptr_devmode) {
      52           4 :                                 NDR_PULL_ALLOC(ndr, r->devmode);
      53             :                         } else {
      54           0 :                                 r->devmode = NULL;
      55             :                         }
      56             :                 }
      57           4 :                 if (ndr_flags & NDR_BUFFERS) {
      58           4 :                         if (r->devmode) {
      59           4 :                                 _mem_save_devmode_0 = NDR_PULL_GET_MEM_CTX(ndr);
      60           4 :                                 NDR_PULL_SET_MEM_CTX(ndr, r->devmode, 0);
      61           4 :                                 r->devmode->string_flags = r->info.string_flags;
      62           4 :                                 NDR_CHECK(ndr_pull_ntprinting_devicemode(ndr, NDR_SCALARS|NDR_BUFFERS, r->devmode));
      63           4 :                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_devmode_0, 0);
      64             :                         }
      65             :                 }
      66           4 :                 if (ndr_flags & NDR_SCALARS) {
      67           4 :                         r->count = 0;
      68           4 :                         NDR_PULL_ALLOC_N(ndr, r->printer_data, r->count);
      69          44 :                         while (ndr->offset + 4 <= ndr->data_size) {
      70          44 :                                 uint32_t ptr = 0;
      71          44 :                                 ptr = IVAL(ndr->data, ndr->offset);
      72          44 :                                 if (ptr == 0) {
      73           4 :                                         ndr->offset = ndr->offset + 4;
      74           4 :                                         break;
      75             :                                 }
      76          40 :                                 r->printer_data = talloc_realloc(ndr, r->printer_data, struct ntprinting_printer_data, r->count + 1);
      77          40 :                                 NDR_ERR_HAVE_NO_MEMORY(r->printer_data);
      78          40 :                                 r->printer_data[r->count].string_flags = r->info.string_flags;
      79          40 :                                 NDR_CHECK(ndr_pull_ntprinting_printer_data(ndr, NDR_SCALARS, &r->printer_data[r->count]));
      80          40 :                                 r->count++;
      81             :                         }
      82           4 :                         NDR_CHECK(ndr_pull_trailer_align(ndr, 5));
      83             :                 }
      84           4 :                 ndr->flags = _flags_save_STRUCT;
      85             :         }
      86           4 :         return NDR_ERR_SUCCESS;
      87             : }

Generated by: LCOV version 1.14