LCOV - code coverage report
Current view: top level - lib/util - dprintf.c (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 20 20 100.0 %
Date: 2024-02-28 12:06:22 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /* 
       2             :    Unix SMB/CIFS implementation.
       3             :    display print functions
       4             :    Copyright (C) Andrew Tridgell 2001
       5             :    Copyright (C) Jelmer Vernooij 2007
       6             :    
       7             :    This program is free software; you can redistribute it and/or modify
       8             :    it under the terms of the GNU General Public License as published by
       9             :    the Free Software Foundation; either version 3 of the License, or
      10             :    (at your option) any later version.
      11             :    
      12             :    This program is distributed in the hope that it will be useful,
      13             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :    GNU General Public License for more details.
      16             :    
      17             :    You should have received a copy of the GNU General Public License
      18             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      19             : */
      20             : 
      21             : 
      22             : /*
      23             :   this module provides functions for printing internal strings in the 
      24             :   "display charset".
      25             :   
      26             :   This charset may be quite different from the chosen unix charset.
      27             : 
      28             :   Eventually these functions will need to take care of column count constraints
      29             : 
      30             :   The d_ prefix on print functions in Samba refers to the display character set
      31             :   conversion
      32             : */
      33             : 
      34             : #include "replace.h"
      35             : #include "system/locale.h"
      36             : #include "lib/util/samba_util.h"
      37             : 
      38             : static int d_vfprintf(FILE *f, const char *format, va_list ap)
      39             :                       PRINTF_ATTRIBUTE(2,0);
      40             : 
      41      384161 : static int d_vfprintf(FILE *f, const char *format, va_list ap) 
      42             : {
      43      386504 :         return vfprintf(f, format, ap);
      44             : }
      45             : 
      46             : 
      47        2787 : _PUBLIC_ int d_fprintf(FILE *f, const char *format, ...) 
      48             : {
      49          20 :         int ret;
      50          20 :         va_list ap;
      51             : 
      52        2787 :         va_start(ap, format);
      53        2787 :         ret = d_vfprintf(f, format, ap);
      54        2787 :         va_end(ap);
      55             : 
      56        2787 :         return ret;
      57             : }
      58             : 
      59             : static FILE *outfile;
      60             : 
      61      381374 : _PUBLIC_  int d_printf(const char *format, ...)
      62             : {
      63        2323 :         int ret;
      64        2323 :        va_list ap;
      65             :        
      66      381374 :        if (!outfile) outfile = stdout;
      67             :        
      68      381374 :        va_start(ap, format);
      69      381374 :        ret = d_vfprintf(outfile, format, ap);
      70      381374 :        va_end(ap);
      71             :        
      72      381374 :        return ret;
      73             : }
      74             : 
      75             : /* interactive programs need a way of tell d_*() to write to stderr instead
      76             :    of stdout */
      77          28 : void display_set_stderr(void)
      78             : {
      79          28 :         outfile = stderr;
      80          28 : }

Generated by: LCOV version 1.14