VirtualBox

Changeset 1183 in kBuild for trunk/src/kmk/kmkbuiltin/install.c


Ignore:
Timestamp:
Oct 5, 2007 10:16:46 PM (17 years ago)
Author:
bird
Message:

Added --version and --help to all builtins.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/install.c

    r942 r1183  
    8181#endif
    8282
     83#include "kmkbuiltin.h"
     84
     85
    8386extern void * setmode(const char *p);
    8487extern mode_t getmode(const void *bbox, mode_t omode);
     
    117120static mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
    118121static const char *suffix = BACKUP_SUFFIX;
     122
     123static struct option long_options[] =
     124{
     125    { "help",                                           no_argument, 0, 261 },
     126    { "version",                                        no_argument, 0, 262 },
     127    { 0, 0,     0, 0 },
     128};
     129
    119130
    120131static int      copy(int, const char *, int, const char *, off_t);
     
    129140static int      trymmap(int);
    130141#endif
    131 static int      usage(void);
     142static int      usage(FILE *);
    132143
    133144int
    134 kmk_builtin_install(int argc, char *argv[])
     145kmk_builtin_install(int argc, char *argv[], char **envp)
    135146{
    136147        struct stat from_sb, to_sb;
     
    158169        iflags = 0;
    159170        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)
    161172                switch((char)ch) {
    162173                case 'B':
     
    217228                        verbose = 1;
    218229                        break;
     230                case 261:
     231                        usage(stdout);
     232                        return 0;
     233                case 262:
     234                        return kbuild_version(argv[0]);
    219235                case '?':
    220236                default:
    221                         return usage();
     237                        return usage(stderr);
    222238                }
    223239        argc -= optind;
     
    227243        if (dostrip && dodir) {
    228244                warnx("-d and -s may not be specified together");
    229                 return usage();
     245                return usage(stderr);
    230246        }
    231247
    232248        /* must have at least two arguments, except when creating directories */
    233249        if (argc == 0 || (argc == 1 && !dodir))
    234                 return usage();
     250                return usage(stderr);
    235251
    236252        /* need to make a temp copy so we can compare stripped version */
     
    292308        if (argc != 2) {
    293309                warnx("wrong number or types of arguments");
    294                 return usage();
     310                return usage(stderr);
    295311        }
    296312
     
    927943 */
    928944static 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");
     945usage(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);
    937956        return EX_USAGE;
    938957}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette