diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-11-01 20:21:54 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:05:11 -0500 |
commit | 652b8b34f8b326f79771b03e039cfa3c6ba3427e (patch) | |
tree | 3cecbca36a8cb70b54df76c303894c06b7d63953 /source4/client | |
parent | dde06904576dfe01e9710721209650dcff228593 (diff) | |
download | samba-652b8b34f8b326f79771b03e039cfa3c6ba3427e.tar.gz samba-652b8b34f8b326f79771b03e039cfa3c6ba3427e.tar.bz2 samba-652b8b34f8b326f79771b03e039cfa3c6ba3427e.zip |
r3441: some include file cleanups and general housekeeping
(This used to be commit 73ea8ee6c268371d05cf74160f2ad451dd2ae699)
Diffstat (limited to 'source4/client')
-rw-r--r-- | source4/client/client.c | 91 | ||||
-rw-r--r-- | source4/client/clitar.c | 12 | ||||
-rw-r--r-- | source4/client/smbmount.c | 2 |
3 files changed, 91 insertions, 14 deletions
diff --git a/source4/client/client.c b/source4/client/client.c index bced80d596..4dd149796d 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -325,6 +325,29 @@ static int cmd_cd(const char **cmd_ptr) } +BOOL mask_match(struct smbcli_state *c, const char *string, char *pattern, + BOOL is_case_sensitive) +{ + fstring p2, s2; + + if (strcmp(string,"..") == 0) + string = "."; + if (strcmp(pattern,".") == 0) + return False; + + if (is_case_sensitive) + return ms_fnmatch(pattern, string, + c->transport->negotiate.protocol) == 0; + + fstrcpy(p2, pattern); + fstrcpy(s2, string); + strlower(p2); + strlower(s2); + return ms_fnmatch(p2, s2, c->transport->negotiate.protocol) == 0; +} + + + /******************************************************************* decide if a file should be operated on ********************************************************************/ @@ -714,16 +737,16 @@ static int do_get(char *rname, const char *lname, BOOL reget) handle = fileno(stdout); } else { if (reget) { - handle = sys_open(lname, O_WRONLY|O_CREAT, 0644); + handle = open(lname, O_WRONLY|O_CREAT, 0644); if (handle >= 0) { - start = sys_lseek(handle, 0, SEEK_END); + start = lseek(handle, 0, SEEK_END); if (start == -1) { d_printf("Error seeking local file\n"); return 1; } } } else { - handle = sys_open(lname, O_WRONLY|O_CREAT|O_TRUNC, 0644); + handle = open(lname, O_WRONLY|O_CREAT|O_TRUNC, 0644); } newhandle = True; } @@ -832,6 +855,22 @@ static int cmd_get(const char **cmd_ptr) return do_get(rname, lname, False); } +/**************************************************************************** + Put up a yes/no prompt. +****************************************************************************/ +static BOOL yesno(char *p) +{ + pstring ans; + printf("%s",p); + + if (!fgets(ans,sizeof(ans)-1,stdin)) + return(False); + + if (*ans == 'y' || *ans == 'Y') + return(True); + + return(False); +} /**************************************************************************** do a mget operation on one file @@ -1251,7 +1290,7 @@ static int cmd_put(const char **cmd_ptr) dos_clean_name(rname); { - SMB_STRUCT_STAT st; + struct stat st; /* allow '-' to represent stdin jdblair, 24.jun.98 */ if (!file_exist(lname,&st) && @@ -1319,6 +1358,44 @@ static int cmd_select(const char **cmd_ptr) return 0; } +/******************************************************************* + A readdir wrapper which just returns the file name. + ********************************************************************/ +static const char *readdirname(DIR *p) +{ + struct dirent *ptr; + char *dname; + + if (!p) + return(NULL); + + ptr = (struct smb_dirent *)readdir(p); + if (!ptr) + return(NULL); + + dname = ptr->d_name; + +#ifdef NEXT2 + if (telldir(p) < 0) + return(NULL); +#endif + +#ifdef HAVE_BROKEN_READDIR + /* using /usr/ucb/cc is BAD */ + dname = dname - 2; +#endif + + { + static pstring buf; + int len = NAMLEN(ptr); + memcpy(buf, dname, len); + buf[len] = 0; + dname = buf; + } + + return(dname); +} + /**************************************************************************** Recursive file matching function act as find match must be always set to True when calling this function @@ -1982,10 +2059,10 @@ static int cmd_newer(const char **cmd_ptr) { fstring buf; BOOL ok; - SMB_STRUCT_STAT sbuf; + struct stat sbuf; ok = next_token(cmd_ptr,buf,NULL,sizeof(buf)); - if (ok && (sys_stat(buf,&sbuf) == 0)) { + if (ok && (stat(buf,&sbuf) == 0)) { newer_than = sbuf.st_mtime; DEBUG(1,("Getting files newer than %s", asctime(localtime(&newer_than)))); @@ -2141,7 +2218,7 @@ static int cmd_reput(const char **cmd_ptr) pstring remote_name; fstring buf; char *p = buf; - SMB_STRUCT_STAT st; + struct stat st; pstrcpy(remote_name, cur_dir); pstrcat(remote_name, "\\"); diff --git a/source4/client/clitar.c b/source4/client/clitar.c index 7a4cea4ac7..7c19204e74 100644 --- a/source4/client/clitar.c +++ b/source4/client/clitar.c @@ -434,7 +434,7 @@ Write two zero blocks at end of file ****************************************************************************/ static void dotareof(int f) { - SMB_STRUCT_STAT stbuf; + struct stat stbuf; /* Two zero blocks at end of file, write out full buffer */ if (dry_run) @@ -443,7 +443,7 @@ static void dotareof(int f) (void) dozerobuf(f, TBLOCK); (void) dozerobuf(f, TBLOCK); - if (sys_fstat(f, &stbuf) == -1) + if (fstat(f, &stbuf) == -1) { DEBUG(0, ("Couldn't stat file handle\n")); return; @@ -1721,10 +1721,10 @@ int tar_parseargs(int argc, char *argv[], const char *Optarg, int Optind) DEBUG(0,("Option N must be followed by valid file name\n")); return 0; } else { - SMB_STRUCT_STAT stbuf; + struct stat stbuf; extern time_t newer_than; - if (sys_stat(argv[Optind], &stbuf) == 0) { + if (stat(argv[Optind], &stbuf) == 0) { newer_than = stbuf.st_mtime; DEBUG(1,("Getting files newer than %s", asctime(localtime(&newer_than)))); @@ -1879,8 +1879,8 @@ int tar_parseargs(int argc, char *argv[], const char *Optarg, int Optind) } tarhandle=-1; } else - if ((tar_type=='x' && (tarhandle = sys_open(argv[Optind], O_RDONLY, 0)) == -1) - || (tar_type=='c' && (tarhandle=sys_creat(argv[Optind], 0644)) < 0)) + if ((tar_type=='x' && (tarhandle = open(argv[Optind], O_RDONLY, 0)) == -1) + || (tar_type=='c' && (tarhandle=creat(argv[Optind], 0644)) < 0)) { DEBUG(0,("Error opening local file %s - %s\n", argv[Optind], strerror(errno))); diff --git a/source4/client/smbmount.c b/source4/client/smbmount.c index dd72672bbb..358fad6ae1 100644 --- a/source4/client/smbmount.c +++ b/source4/client/smbmount.c @@ -552,7 +552,7 @@ static void get_password_file(void) sscanf(p, "%d", &fd); close_it = False; } else if ((p = getenv("PASSWD_FILE")) != NULL) { - fd = sys_open(p, O_RDONLY, 0); + fd = open(p, O_RDONLY, 0); pstrcpy(spec, p); if (fd < 0) { fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n", |