2 Unix SMB/CIFS implementation.
3 client utility routines
4 Copyright (C) Andrew Tridgell 2001
5 Copyright (C) James Myers 2003 <myersjj@samba.org>
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 2 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 /*******************************************************************
24 Functions nicked from lib/util.c needed by client.
25 *******************************************************************/
27 /* a default finfo structure to ensure all fields are sensible */
28 file_info def_finfo = {-1,0,0,0,0,0,0,"",""};
30 /*******************************************************************
31 A wrapper that handles case sensitivity and the special handling
33 *******************************************************************/
35 BOOL mask_match(struct cli_state *cli, const char *string, char *pattern, BOOL is_case_sensitive)
39 if (strcmp(string,"..") == 0)
41 if (strcmp(pattern,".") == 0)
44 if (is_case_sensitive)
45 return ms_fnmatch(pattern, string,
46 cli->transport->negotiate.protocol) == 0;
52 return ms_fnmatch(p2, s2, cli->transport->negotiate.protocol) == 0;
55 /****************************************************************************
56 Put up a yes/no prompt.
57 ****************************************************************************/
64 if (!fgets(ans,sizeof(ans)-1,stdin))
67 if (*ans == 'y' || *ans == 'Y')
73 /*******************************************************************
74 A readdir wrapper which just returns the file name.
75 ********************************************************************/
77 const char *readdirname(DIR *p)
79 struct smb_dirent *ptr;
85 ptr = (struct smb_dirent *)sys_readdir(p);
96 #ifdef HAVE_BROKEN_READDIR
97 /* using /usr/ucb/cc is BAD */
103 int len = NAMLEN(ptr);
104 memcpy(buf, dname, len);