LCOV - code coverage report
Current view: top level - src/base - pdf-stm-f-null.c (source / functions) Hit Total Coverage
Test: libgnupdf.info Lines: 13 13 100.0 %
Date: 2011-12-09 Functions: 2 2 100.0 %
Branches: 5 8 62.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- mode: C -*-
       2                 :            :  *
       3                 :            :  *       File:         pdf-stm-f-null.c
       4                 :            :  *       Date:         Mon Jul  9 22:01:41 2007
       5                 :            :  *
       6                 :            :  *       GNU PDF Library - NULL stream filter
       7                 :            :  *
       8                 :            :  */
       9                 :            : 
      10                 :            : /* Copyright (C) 2007-2011 Free Software Foundation, Inc. */
      11                 :            : 
      12                 :            : /* This program is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU General Public License as published by
      14                 :            :  * the Free Software Foundation, either version 3 of the License, or
      15                 :            :  * (at your option) any later version.
      16                 :            :  *
      17                 :            :  * This program is distributed in the hope that it will be useful,
      18                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      19                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      20                 :            :  * GNU General Public License for more details.
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU General Public License
      23                 :            :  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
      24                 :            :  */
      25                 :            : 
      26                 :            : #include <config.h>
      27                 :            : 
      28                 :            : #include <string.h>
      29                 :            : 
      30                 :            : #include <pdf-types.h>
      31                 :            : #include <pdf-types-buffer.h>
      32                 :            : #include <pdf-stm-f-null.h>
      33                 :            : #include <pdf-hash.h>
      34                 :            : 
      35                 :            : /* Define NULL filter */
      36                 :       1343 : PDF_STM_FILTER_DEFINE_STATELESS (pdf_stm_f_null_get,
      37                 :            :                                  stm_f_null_apply);
      38                 :            : 
      39                 :            : static enum pdf_stm_filter_apply_status_e
      40                 :       4810 : stm_f_null_apply (void          *state,
      41                 :            :                   pdf_buffer_t  *in,
      42                 :            :                   pdf_buffer_t  *out,
      43                 :            :                   pdf_bool_t     finish,
      44                 :            :                   pdf_error_t  **error)
      45                 :            : {
      46                 :            :   pdf_size_t in_size;
      47                 :            :   pdf_size_t out_size;
      48                 :            :   pdf_size_t bytes_to_copy;
      49                 :            : 
      50                 :            :   /* Fill the output buffer with the contents of the input buffer, but
      51                 :            :    * note that the second may be bigger than the former */
      52         [ -  + ]:       4810 :   PDF_ASSERT (in->wp >= in->rp);
      53         [ -  + ]:       4810 :   PDF_ASSERT (out->size >= out->wp);
      54                 :       4810 :   in_size = in->wp - in->rp;
      55                 :       4810 :   out_size = out->size - out->wp;
      56                 :            : 
      57                 :       4810 :   bytes_to_copy = PDF_MIN (out_size, in_size);
      58         [ +  + ]:       4810 :   if (bytes_to_copy != 0)
      59                 :            :     {
      60                 :       1380 :       memcpy (out->data,
      61                 :       1380 :               in->data,
      62                 :            :               bytes_to_copy);
      63                 :            : 
      64                 :       1380 :       in->rp += bytes_to_copy;
      65                 :       1380 :       out->wp += bytes_to_copy;
      66                 :            :     }
      67                 :            : 
      68         [ -  + ]:       4810 :   return (in_size > out_size ?
      69                 :            :           PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT :
      70                 :            :           PDF_STM_FILTER_APPLY_STATUS_NO_INPUT);
      71                 :            : }
      72                 :            : 
      73                 :            : /* End of pdf_stm_f_null.c */

Generated by: LCOV version 1.8