30 lines
645 B
C
30 lines
645 B
C
|
#include <stdio.h> /* fprintf(3), stderr, NULL */
|
||
|
#if !defined EX_OK || !defined EX_USAGE
|
||
|
# include <sysexits.h>
|
||
|
#endif
|
||
|
#include <unistd.h> /* getopt(3) */
|
||
|
#include "libfileis.h" /* f_executable(3), f_exists(3), f_readable(3),
|
||
|
* f_writeable(3) */
|
||
|
|
||
|
static char *program_name = "fileis";
|
||
|
|
||
|
int main(int argc, char *argv[]){
|
||
|
int c;
|
||
|
|
||
|
if(argc < 2)
|
||
|
goto usage;
|
||
|
|
||
|
while((c = getopt(argc, argv, "erwx")) != -1)
|
||
|
switch(c){
|
||
|
default: goto usage;
|
||
|
}
|
||
|
|
||
|
if(optind == argc){
|
||
|
usage: fprintf(stderr, "Usage: %s (-ehrwx) [file]\n",
|
||
|
argv[0] == NULL ? program_name : argv[0]);
|
||
|
return EX_USAGE;
|
||
|
}
|
||
|
|
||
|
return !f(argv[optind]);
|
||
|
}
|