/* parse arguments of optimize command */ static int runoptimize(int argc, char **argv){ char *path = NULL; char *wstr = NULL; char *lstr = NULL; int omode = 0; for(int i = 2; i < argc; i++){ if(!path && argv[i][0] == '-'){ if(!strcmp(argv[i], "-nl")){ omode |= FDBONOLCK; } else if(!strcmp(argv[i], "-nb")){ omode |= FDBOLCKNB; } else { usage(); } } else if(!path){ path = argv[i]; } else if(!wstr){ wstr = argv[i]; } else if(!lstr){ lstr = argv[i]; } else { usage(); } } if(!path) usage(); int width = wstr ? tcatoix(wstr) : -1; int64_t limsiz = lstr ? tcatoix(lstr) : -1; int rv = procoptimize(path, width, limsiz, omode); return rv; }
/* parse arguments of optimize command */ static int runoptimize(int argc, char **argv){ char *path = NULL; char *bstr = NULL; char *astr = NULL; char *fstr = NULL; int opts = UINT8_MAX; int omode = 0; bool df = false; for(int i = 2; i < argc; i++){ if(!path && argv[i][0] == '-'){ if(!strcmp(argv[i], "-tl")){ if(opts == UINT8_MAX) opts = 0; opts |= HDBTLARGE; } else if(!strcmp(argv[i], "-td")){ if(opts == UINT8_MAX) opts = 0; opts |= HDBTDEFLATE; } else if(!strcmp(argv[i], "-tb")){ if(opts == UINT8_MAX) opts = 0; opts |= HDBTBZIP; } else if(!strcmp(argv[i], "-tt")){ if(opts == UINT8_MAX) opts = 0; opts |= HDBTTCBS; } else if(!strcmp(argv[i], "-tx")){ if(opts == UINT8_MAX) opts = 0; opts |= HDBTEXCODEC; } else if(!strcmp(argv[i], "-tz")){ if(opts == UINT8_MAX) opts = 0; } else if(!strcmp(argv[i], "-nl")){ omode |= HDBONOLCK; } else if(!strcmp(argv[i], "-nb")){ omode |= HDBOLCKNB; } else if(!strcmp(argv[i], "-df")){ df = true; } else { usage(); } } else if(!path){ path = argv[i]; } else if(!bstr){ bstr = argv[i]; } else if(!astr){ astr = argv[i]; } else if(!fstr){ fstr = argv[i]; } else { usage(); } } if(!path) usage(); int bnum = bstr ? tcatoix(bstr) : -1; int apow = astr ? tcatoix(astr) : -1; int fpow = fstr ? tcatoix(fstr) : -1; int rv = procoptimize(path, bnum, apow, fpow, opts, omode, df); return rv; }
/* parse arguments of optimize command */ static int runoptimize(int argc, char **argv){ char *name = NULL; char *params = NULL; for(int i = 2; i < argc; i++){ if(!name && argv[i][0] == '-'){ usage(); } else if(!name){ name = argv[i]; } else if(!params){ params = argv[i]; } else { usage(); } } if(!name) usage(); int rv = procoptimize(name, params); return rv; }
/* parse arguments of optimize command */ static int runoptimize(int argc, char **argv){ char *path = NULL; char *bstr = NULL; char *astr = NULL; char *fstr = NULL; int opts = UINT8_MAX; int omode = 0; for(int i = 2; i < argc; i++){ if(argv[i][0] == '-'){ if(!strcmp(argv[i], "-tl")){ if(opts == UINT8_MAX) opts = 0; opts |= HDBTLARGE; } else if(!strcmp(argv[i], "-td")){ if(opts == UINT8_MAX) opts = 0; opts |= HDBTDEFLATE; } else if(!strcmp(argv[i], "-tz")){ if(opts == UINT8_MAX) opts = 0; } else if(!strcmp(argv[i], "-nl")){ omode |= HDBONOLCK; } else if(!strcmp(argv[i], "-nb")){ omode |= HDBOLCKNB; } else { usage(); } } else if(!path){ path = argv[i]; } else if(!bstr){ bstr = argv[i]; } else if(!astr){ astr = argv[i]; } else if(!fstr){ fstr = argv[i]; } else { usage(); } } if(!path) usage(); int bnum = bstr ? atoi(bstr) : -1; int apow = astr ? atoi(astr) : -1; int fpow = fstr ? atoi(fstr) : -1; int rv = procoptimize(path, bnum, apow, fpow, opts, omode); return rv; }