LCOV - code coverage report
Current view: top level - source3/lib - fstring.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 14 15 93.3 %
Date: 2024-04-21 15:09:00 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    fixed string functions
       5             : 
       6             :    Copyright (C) Igor Vergeichik <iverg@mail.ru> 2001
       7             :    Copyright (C) Andrew Tridgell 2001
       8             :    Copyright (C) Simo Sorce 2001
       9             :    Copyright (C) Martin Pool 2003
      10             : 
      11             :    This program is free software; you can redistribute it and/or modify
      12             :    it under the terms of the GNU General Public License as published by
      13             :    the Free Software Foundation; either version 3 of the License, or
      14             :    (at your option) any later version.
      15             : 
      16             :    This program is distributed in the hope that it will be useful,
      17             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             :    GNU General Public License for more details.
      20             : 
      21             :    You should have received a copy of the GNU General Public License
      22             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      23             : 
      24             : */
      25             : 
      26             : #include "includes.h"
      27             : 
      28        9162 : size_t push_ascii_fstring(void *dest, const char *src)
      29             : {
      30        9162 :         return push_ascii(dest, src, sizeof(fstring), STR_TERMINATE);
      31             : }
      32             : 
      33             : /********************************************************************
      34             :  Push an nstring (a netbios string)
      35             :  this function uses convert_string_error() to avoid common debug
      36             :  warnings where is unable to convert strings to CH_DOS. The target
      37             :  string is truncated at the first character that cannot be converted
      38             :  The target is always null terminated.
      39             : ********************************************************************/
      40             : 
      41       82417 : size_t push_ascii_nstring(void *dest, const char *src)
      42             : {
      43       82417 :         size_t converted_size = 0;
      44        1276 :         bool ret;
      45             : 
      46       82417 :         errno = 0;
      47       82417 :         ret = convert_string_error(CH_UNIX, CH_DOS, src, -1, dest, sizeof(nstring), &converted_size);
      48       82417 :         if (ret || errno == E2BIG) {
      49       82417 :                 SCVAL(dest, sizeof(nstring)-1, 0);
      50             :         } else {
      51           0 :                 SCVAL(dest, 0, 0);
      52             :         }
      53       82417 :         return ret ? converted_size : (size_t)-1;
      54             : }
      55             : 
      56        6750 : size_t pull_ascii_fstring(char *dest, const void *src)
      57             : {
      58        6750 :         return pull_ascii(dest, src, sizeof(fstring), -1, STR_TERMINATE);
      59             : }
      60             : 
      61             : /* When pulling an nstring it can expand into a larger size (dos cp -> utf8). Cope with this. */
      62             : 
      63       26716 : size_t pull_ascii_nstring(char *dest, size_t dest_len, const void *src)
      64             : {
      65       26716 :         return pull_ascii(dest, src, dest_len, sizeof(nstring), STR_TERMINATE);
      66             : }
      67             : 

Generated by: LCOV version 1.14