Changeset 1183 in kBuild for trunk/src/kmk/kmkbuiltin/install.c
- Timestamp:
- Oct 5, 2007 10:16:46 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/install.c
r942 r1183 81 81 #endif 82 82 83 #include "kmkbuiltin.h" 84 85 83 86 extern void * setmode(const char *p); 84 87 extern mode_t getmode(const void *bbox, mode_t omode); … … 117 120 static mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; 118 121 static const char *suffix = BACKUP_SUFFIX; 122 123 static struct option long_options[] = 124 { 125 { "help", no_argument, 0, 261 }, 126 { "version", no_argument, 0, 262 }, 127 { 0, 0, 0, 0 }, 128 }; 129 119 130 120 131 static int copy(int, const char *, int, const char *, off_t); … … 129 140 static int trymmap(int); 130 141 #endif 131 static int usage( void);142 static int usage(FILE *); 132 143 133 144 int 134 kmk_builtin_install(int argc, char *argv[] )145 kmk_builtin_install(int argc, char *argv[], char **envp) 135 146 { 136 147 struct stat from_sb, to_sb; … … 158 169 iflags = 0; 159 170 group = owner = NULL; 160 while ((ch = getopt (argc, argv, "B:bCcdf:g:Mm:o:pSsv")) != -1)171 while ((ch = getopt_long(argc, argv, "B:bCcdf:g:Mm:o:pSsv", long_options, NULL)) != -1) 161 172 switch((char)ch) { 162 173 case 'B': … … 217 228 verbose = 1; 218 229 break; 230 case 261: 231 usage(stdout); 232 return 0; 233 case 262: 234 return kbuild_version(argv[0]); 219 235 case '?': 220 236 default: 221 return usage( );237 return usage(stderr); 222 238 } 223 239 argc -= optind; … … 227 243 if (dostrip && dodir) { 228 244 warnx("-d and -s may not be specified together"); 229 return usage( );245 return usage(stderr); 230 246 } 231 247 232 248 /* must have at least two arguments, except when creating directories */ 233 249 if (argc == 0 || (argc == 1 && !dodir)) 234 return usage( );250 return usage(stderr); 235 251 236 252 /* need to make a temp copy so we can compare stripped version */ … … 292 308 if (argc != 2) { 293 309 warnx("wrong number or types of arguments"); 294 return usage( );310 return usage(stderr); 295 311 } 296 312 … … 927 943 */ 928 944 static int 929 usage() 930 { 931 (void)fprintf(stderr, 932 "usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n" 933 " [-o owner] file1 file2\n" 934 " install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n" 935 " [-o owner] file1 ... fileN directory\n" 936 " install -d [-v] [-g group] [-m mode] [-o owner] directory ...\n"); 945 usage(FILE *pf) 946 { 947 fprintf(stderr, 948 "usage: %s [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n" 949 " [-o owner] file1 file2\n" 950 " or: %s [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n" 951 " [-o owner] file1 ... fileN directory\n" 952 " or: %s -d [-v] [-g group] [-m mode] [-o owner] directory ...\n" 953 " or: %s --help\n" 954 " or: %s --version\n", 955 g_progname, g_progname, g_progname, g_progname, g_progname); 937 956 return EX_USAGE; 938 957 }
Note:
See TracChangeset
for help on using the changeset viewer.