From 2bcb0db75e5a0ce3c33600a8c8680adcc298bf80 Mon Sep 17 00:00:00 2001 From: hsn <> Date: Sat, 27 Sep 2003 11:06:46 +0000 Subject: [PATCH] Initial revision --- clients/fstatcmd.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++ man/fstatcmd.1 | 46 ++++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 clients/fstatcmd.c create mode 100644 man/fstatcmd.1 diff --git a/clients/fstatcmd.c b/clients/fstatcmd.c new file mode 100644 index 0000000..39962c0 --- /dev/null +++ b/clients/fstatcmd.c @@ -0,0 +1,97 @@ + /*********************************************************************\ + * Copyright (c) 2003 by Radim Kolar (hsn@cybermail.net) * + * Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu) * + * * + * You may copy or modify this file in any manner you wish, provided * + * that this notice is always included, and that you hold the author * + * harmless for any loss or damage resulting from the installation or * + * use of this software. * + \*********************************************************************/ + +#include "tweak.h" +#include "client_def.h" +#include "c_extern.h" +#include "bsd_extern.h" +#include "co_extern.h" +#ifdef STDC_HEADERS +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#include "my-string.h" + +static void stat_file PROTO1(const char *,fname) +{ + struct stat sb; + struct tm *ftime; + char buf[35]; + + if(util_stat(fname,&sb)) + { + printf("%s: stat error\n",fname); + } else + { + if(S_ISREG(sb.st_mode)) + printf("File"); + else + if(S_ISDIR(sb.st_mode)) + printf("Directory"); + + ftime=localtime(&sb.st_mtime); + strftime(buf,35,"%Y-%m-%d %H:%M:%S",ftime); +#ifdef NATIVE_LARGEFILES +#define SFORM "%llu" +#else +#define SFORM "%lu" +#endif + printf(": %s Size: "SFORM" Time: %s\n",fname,sb.st_size,buf); + } + + +} + +int main PROTO2(int, argc, char **, argv) +{ + char n[1024]; + int prompt; + char **av, *av2[2]; + + env_client(); + + if(argc>1) + { + for( optind=1; argc>optind ; optind++) + { + if(!(av = glob(argv[optind]))) + { + av = av2; + av2[0] = argv[optind]; + av2[1] = 0; + } + while(*av) + stat_file(*av++); + } + } else { + prompt = isatty(0); + while(1) { + if(prompt) { + fputs("fstat: ",stdout); + fflush(stdout); + } + if(!getsl(n,1024)) break; + if(!*n) break; + if(!(av = glob(n))) { + av = av2; + av2[0] = n; + av2[1] = 0; + } + while(*av) + stat_file(*av++); + } + } + + client_done(); + + exit(0); +} diff --git a/man/fstatcmd.1 b/man/fstatcmd.1 new file mode 100644 index 0000000..68bff1b --- /dev/null +++ b/man/fstatcmd.1 @@ -0,0 +1,46 @@ +.TH FSTAT 1 "23 September 2003" FSP + +.SH NAME +fstatcmd, fstat displays information on remote files and directories + +.SH SYNOPSIS +.B fstatcmd +.I filename ... +.LP +.B fstat +.I filename ... + +.SH DESCRIPTION +.LP +.B fstatcmd +will display the type (file or directory), name, size in bytes and +creation time of the given remote file. The time and date of creation will +be displayed in ISO format. +.LP +Since user's command shells generally cannot do the proper globbing for +this program, it is recommended that user defines a shell alias or +function to turn off command shell globbing before running this program. +.LP +.B csh +example: +.LP +.nf +alias fstat \e(set noglob\e; exec fstatcmd \e!\e*\e) +.fi +.LP +.B bash +example: +.LP +.nf +_fstat() { fstatcmd "$@" ;set +f;} +alias fstat='set -f;_fstat' +.fi + +.SH ENVIRONMEN +See fsp_env(7) for list of used environment variables. + +.SH "SEE ALSO" +.PD +fcatcmd(1), fcdcmd(1), fgetcmd(1), fgrabcmd(1), flscmd(1), fmkdir(1), +fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fducmd(1), +fhostcmd(1), fspd(1), fsp_prof(5), ffindcmd(1), fsp_env(7)