Removed wingetopt
This commit is contained in:
parent
e68b45013f
commit
5e95af46f4
|
@ -4,4 +4,5 @@ tmp/*
|
||||||
build/*
|
build/*
|
||||||
autom4te.cache
|
autom4te.cache
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
configure
|
configure
|
||||||
|
configure
|
||||||
|
|
18
README.md
18
README.md
|
@ -1,5 +1,5 @@
|
||||||
## Caesium Command Line Tools
|
## Caesium Command Line Tools
|
||||||
##### CCLT - v0.9.1-beta (build 20151012) - Copyright © Matteo Paonessa, 2015. All Rights Reserved.
|
##### CCLT - v0.9.1-beta (build 20160121) - Copyright © Matteo Paonessa, 2016. All Rights Reserved.
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
----------
|
----------
|
||||||
|
|
||||||
###### TESTED PLATFORMS
|
###### TESTED PLATFORMS
|
||||||
* MacOSX El Capitan (v. 10.11)
|
* Mac OS X El Capitan (v10.11.1)
|
||||||
* Arch Linux
|
* Arch Linux
|
||||||
* Ubuntu 14.04.2
|
* Ubuntu 14.04.2
|
||||||
|
|
||||||
|
@ -23,30 +23,26 @@ See INSTALL for more details.
|
||||||
----------
|
----------
|
||||||
|
|
||||||
###### USAGE EXAMPLES
|
###### USAGE EXAMPLES
|
||||||
|
|
||||||
|
Losslessly compress ```image1.jpg```, located in the ```home``` directory, into a folder called ```output```
|
||||||
```
|
```
|
||||||
$ caesiumclt -l -o ~/output/ ~/image.jpg
|
$ caesiumclt -l -o ~/output/ ~/image.jpg
|
||||||
```
|
```
|
||||||
Losslessly compress ```image1.jpg```, located in the ```home``` directory, into a folder called ```output```
|
|
||||||
|
|
||||||
|
Compress ```image1.jpg```, located in the ```home``` directory, into a folder called ```output``` with lossy compression and quality set to 80
|
||||||
```
|
```
|
||||||
$ caesiumclt -q 80 -o ~/output/ ~/image.jpg
|
$ caesiumclt -q 80 -o ~/output/ ~/image.jpg
|
||||||
```
|
```
|
||||||
Compress ```image1.jpg```, located in the ```home``` directory, into a folder called ```output``` with lossy compression and quality set to 80
|
|
||||||
|
|
||||||
|
Losslessly compress ```image1.jpg```, located in the ```home``` directory, into a folder called ```output``` and keeps EXIF metadata
|
||||||
```
|
```
|
||||||
$ caesiumclt -l -e -o ~/output/ ~/image.jpg
|
$ caesiumclt -l -e -o ~/output/ ~/image.jpg
|
||||||
```
|
```
|
||||||
Losslessly compress ```image1.jpg```, located in the ```home``` directory, into a folder called ```output``` and keeps EXIF metadata
|
|
||||||
|
|
||||||
|
Losslessly compress ```Pictures``` folder and subfolders, located in the ```home``` directory, into a folder called ```output```
|
||||||
```
|
```
|
||||||
$ caesiumclt -l -R -o ~/output/ ~/Pictures
|
$ caesiumclt -l -R -o ~/output/ ~/Pictures
|
||||||
```
|
```
|
||||||
Losslessly compress ```Pictures``` folder and subfolders, located in the ```home``` directory, into a folder called ```output```
|
|
||||||
|
|
||||||
```
|
|
||||||
$ caesiumclt -q 80 -s 50% -o ~/output/ ~/image1.jpg
|
|
||||||
```
|
|
||||||
Compress with quality 80 and resize at 50% ```image1.jpg```, located in the ```home``` directory, into a folder called ```output```
|
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# Guess values for system-dependent variables and create Makefiles.
|
||||||
# Generated by GNU Autoconf 2.69 for caesiumclt 1.9.9.
|
# Generated by GNU Autoconf 2.69 for caesiumclt 0.9.1-beta.
|
||||||
#
|
#
|
||||||
# Report bugs to <caesium@saerasoft.com>.
|
# Report bugs to <caesium@saerasoft.com>.
|
||||||
#
|
#
|
||||||
|
@ -580,8 +580,8 @@ MAKEFLAGS=
|
||||||
# Identity of this package.
|
# Identity of this package.
|
||||||
PACKAGE_NAME='caesiumclt'
|
PACKAGE_NAME='caesiumclt'
|
||||||
PACKAGE_TARNAME='caesiumclt'
|
PACKAGE_TARNAME='caesiumclt'
|
||||||
PACKAGE_VERSION='1.9.9'
|
PACKAGE_VERSION='0.9.1-beta'
|
||||||
PACKAGE_STRING='caesiumclt 1.9.9'
|
PACKAGE_STRING='caesiumclt 0.9.1-beta'
|
||||||
PACKAGE_BUGREPORT='caesium@saerasoft.com'
|
PACKAGE_BUGREPORT='caesium@saerasoft.com'
|
||||||
PACKAGE_URL=''
|
PACKAGE_URL=''
|
||||||
|
|
||||||
|
@ -1267,7 +1267,7 @@ if test "$ac_init_help" = "long"; then
|
||||||
# Omit some internal or obsolete options to make the list less imposing.
|
# Omit some internal or obsolete options to make the list less imposing.
|
||||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||||
cat <<_ACEOF
|
cat <<_ACEOF
|
||||||
\`configure' configures caesiumclt 1.9.9 to adapt to many kinds of systems.
|
\`configure' configures caesiumclt 0.9.1-beta to adapt to many kinds of systems.
|
||||||
|
|
||||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||||
|
|
||||||
|
@ -1333,7 +1333,7 @@ fi
|
||||||
|
|
||||||
if test -n "$ac_init_help"; then
|
if test -n "$ac_init_help"; then
|
||||||
case $ac_init_help in
|
case $ac_init_help in
|
||||||
short | recursive ) echo "Configuration of caesiumclt 1.9.9:";;
|
short | recursive ) echo "Configuration of caesiumclt 0.9.1-beta:";;
|
||||||
esac
|
esac
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
|
|
||||||
|
@ -1429,7 +1429,7 @@ fi
|
||||||
test -n "$ac_init_help" && exit $ac_status
|
test -n "$ac_init_help" && exit $ac_status
|
||||||
if $ac_init_version; then
|
if $ac_init_version; then
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
caesiumclt configure 1.9.9
|
caesiumclt configure 0.9.1-beta
|
||||||
generated by GNU Autoconf 2.69
|
generated by GNU Autoconf 2.69
|
||||||
|
|
||||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||||
|
@ -1852,7 +1852,7 @@ cat >config.log <<_ACEOF
|
||||||
This file contains any messages produced by compilers while
|
This file contains any messages produced by compilers while
|
||||||
running configure, to aid debugging if configure makes a mistake.
|
running configure, to aid debugging if configure makes a mistake.
|
||||||
|
|
||||||
It was created by caesiumclt $as_me 1.9.9, which was
|
It was created by caesiumclt $as_me 0.9.1-beta, which was
|
||||||
generated by GNU Autoconf 2.69. Invocation command line was
|
generated by GNU Autoconf 2.69. Invocation command line was
|
||||||
|
|
||||||
$ $0 $@
|
$ $0 $@
|
||||||
|
@ -2716,7 +2716,7 @@ fi
|
||||||
|
|
||||||
# Define the identity of the package.
|
# Define the identity of the package.
|
||||||
PACKAGE='caesiumclt'
|
PACKAGE='caesiumclt'
|
||||||
VERSION='1.9.9'
|
VERSION='0.9.1-beta'
|
||||||
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
@ -5130,7 +5130,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||||
# report actual input values of CONFIG_FILES etc. instead of their
|
# report actual input values of CONFIG_FILES etc. instead of their
|
||||||
# values after options handling.
|
# values after options handling.
|
||||||
ac_log="
|
ac_log="
|
||||||
This file was extended by caesiumclt $as_me 1.9.9, which was
|
This file was extended by caesiumclt $as_me 0.9.1-beta, which was
|
||||||
generated by GNU Autoconf 2.69. Invocation command line was
|
generated by GNU Autoconf 2.69. Invocation command line was
|
||||||
|
|
||||||
CONFIG_FILES = $CONFIG_FILES
|
CONFIG_FILES = $CONFIG_FILES
|
||||||
|
@ -5187,7 +5187,7 @@ _ACEOF
|
||||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||||
ac_cs_version="\\
|
ac_cs_version="\\
|
||||||
caesiumclt config.status 1.9.9
|
caesiumclt config.status 0.9.1-beta
|
||||||
configured by $0, generated by GNU Autoconf 2.69,
|
configured by $0, generated by GNU Autoconf 2.69,
|
||||||
with options \\"\$ac_cs_config\\"
|
with options \\"\$ac_cs_config\\"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
AC_INIT([caesiumclt], [1.9.9], [caesium@saerasoft.com])
|
AC_INIT([caesiumclt], [0.9.1-beta], [caesium@saerasoft.com])
|
||||||
AC_CONFIG_SRCDIR([src/])
|
AC_CONFIG_SRCDIR([src/])
|
||||||
AC_CONFIG_AUX_DIR(tools)
|
AC_CONFIG_AUX_DIR(tools)
|
||||||
AM_INIT_AUTOMAKE(-Wall -Werror foreign)
|
AM_INIT_AUTOMAKE(-Wall -Werror foreign)
|
||||||
|
@ -22,10 +22,10 @@ AC_ARG_WITH(libjpeg, [ --libjpeg=DIR libjpeg is installed in ],
|
||||||
fi
|
fi
|
||||||
if test -d "${jpeginfo_cv_libjpeg}/lib"; then
|
if test -d "${jpeginfo_cv_libjpeg}/lib"; then
|
||||||
LDFLAGS="-L${jpeginfo_cv_libjpeg}/lib $LDFLAGS"
|
LDFLAGS="-L${jpeginfo_cv_libjpeg}/lib $LDFLAGS"
|
||||||
CPPFLAGS="$CPPFLAGS -I${jpeginfo_cv_libjpeg}/include"
|
CPPFLAGS="$CPPFLAGS -I${jpeginfo_cv_libjpeg}/include"
|
||||||
else
|
else
|
||||||
LDFLAGS="-L${jpeginfo_cv_libjpeg} $LDFLAGS"
|
LDFLAGS="-L${jpeginfo_cv_libjpeg} $LDFLAGS"
|
||||||
CPPFLAGS="$CPPFLAGS -I${jpeginfo_cv_libjpeg}"
|
CPPFLAGS="$CPPFLAGS -I${jpeginfo_cv_libjpeg}"
|
||||||
fi])
|
fi])
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for libraries.
|
||||||
|
|
|
@ -6,12 +6,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <turbojpeg.h>
|
#include <turbojpeg.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include "wingetopt.h"
|
|
||||||
#else
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "jpeg.h"
|
#include "jpeg.h"
|
||||||
|
@ -93,9 +88,10 @@ cclt_compress_parameters parse_arguments(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if (isDirectory(argv[optind])) {
|
if (is_directory(argv[optind])) {
|
||||||
//TODO Works but I'd like to pass the list and return the number of files instead
|
//TODO Works but I'd like to pass the list and return the number of files instead
|
||||||
parameters.input_files = scan_folder(argv[optind], ¶meters.input_files_count, parameters.recursive);
|
parameters.input_files_count = scan_folder(parameters.input_files, argv[optind], parameters.recursive);
|
||||||
|
//parameters.input_files = scan_folder(argv[optind], ¶meters.input_files_count, parameters.recursive);
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
parameters.input_files = (char**) malloc ((argc - optind) * sizeof (char*));
|
parameters.input_files = (char**) malloc ((argc - optind) * sizeof (char*));
|
||||||
|
|
|
@ -167,7 +167,6 @@ void cclt_jpeg_compress(char* output_file, unsigned char* image_buffer, cclt_com
|
||||||
output_buffer = NULL;
|
output_buffer = NULL;
|
||||||
tjCompressHandle = tjInitCompress();
|
tjCompressHandle = tjInitCompress();
|
||||||
|
|
||||||
//TODO Scale must be a power of 2. Can we resolve it?
|
|
||||||
//TODO Error checks
|
//TODO Error checks
|
||||||
tjCompress2(tjCompressHandle,
|
tjCompress2(tjCompressHandle,
|
||||||
image_buffer,
|
image_buffer,
|
||||||
|
|
14
src/main.c
14
src/main.c
|
@ -45,9 +45,13 @@ void cclt_start(char** input_files, int n, char* output_folder, cclt_compress_pa
|
||||||
|
|
||||||
off_t i_size, o_size;
|
off_t i_size, o_size;
|
||||||
int status; //Pointer for stat() call
|
int status; //Pointer for stat() call
|
||||||
|
|
||||||
char* output_filename = (char*) malloc ((strlen(output_folder) + 1) * sizeof(char));
|
char* output_filename = (char*) malloc ((strlen(output_folder) + 1) * sizeof(char));
|
||||||
|
//CRITICAL SEGFUCKINGFAULT
|
||||||
|
//TODO input_files[i] è NULL when we pass a folder with -R
|
||||||
char* i_tmp = (char*) malloc (strlen(input_files[i]) * sizeof(char));
|
char* i_tmp = (char*) malloc (strlen(input_files[i]) * sizeof(char));
|
||||||
|
|
||||||
|
|
||||||
strcpy(i_tmp, input_files[i]);
|
strcpy(i_tmp, input_files[i]);
|
||||||
strcpy(output_filename, output_folder);
|
strcpy(output_filename, output_folder);
|
||||||
|
|
||||||
|
@ -61,9 +65,6 @@ void cclt_start(char** input_files, int n, char* output_folder, cclt_compress_pa
|
||||||
output_filename = realloc(output_filename, (strlen(output_filename) + strlen(basename(i_tmp))) * sizeof(char));
|
output_filename = realloc(output_filename, (strlen(output_filename) + strlen(basename(i_tmp))) * sizeof(char));
|
||||||
output_filename = strcat(output_filename, basename(i_tmp));
|
output_filename = strcat(output_filename, basename(i_tmp));
|
||||||
|
|
||||||
//TODO OVERALL progress update?
|
|
||||||
//print_progress(i + 1, pars.input_files_count, "Progress: ");
|
|
||||||
|
|
||||||
//Get input stats
|
//Get input stats
|
||||||
status = stat(input_files[i], &st_buf);
|
status = stat(input_files[i], &st_buf);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
|
@ -73,7 +74,7 @@ void cclt_start(char** input_files, int n, char* output_folder, cclt_compress_pa
|
||||||
|
|
||||||
//Check if we ran into a folder
|
//Check if we ran into a folder
|
||||||
//TODO Check symlinks too
|
//TODO Check symlinks too
|
||||||
if (isDirectory(input_files[i])) {
|
if (is_directory(input_files[i])) {
|
||||||
//Folder found, but we don't need it here
|
//Folder found, but we don't need it here
|
||||||
printf("Folder found\n");
|
printf("Folder found\n");
|
||||||
i++;
|
i++;
|
||||||
|
@ -161,6 +162,9 @@ int main (int argc, char *argv[]) {
|
||||||
clock_t start = clock(), diff;
|
clock_t start = clock(), diff;
|
||||||
//We need the file list right here
|
//We need the file list right here
|
||||||
cclt_start(pars.input_files, pars.input_files_count, pars.output_folder, &pars, &i_t_size, &o_t_size);
|
cclt_start(pars.input_files, pars.input_files_count, pars.output_folder, &pars, &i_t_size, &o_t_size);
|
||||||
|
/*for (int i = 0; i < pars.input_files_count; i++) {
|
||||||
|
printf("FILE %d: %s\n", i, pars.input_files[i]);
|
||||||
|
}*/
|
||||||
diff = clock() - start;
|
diff = clock() - start;
|
||||||
|
|
||||||
fprintf(stdout, "-------------------------------\nCompression completed in %lum%lus\n%s -> %s [%.2f%% | %s]\n",
|
fprintf(stdout, "-------------------------------\nCompression completed in %lum%lus\n%s -> %s [%.2f%% | %s]\n",
|
||||||
|
@ -171,5 +175,5 @@ int main (int argc, char *argv[]) {
|
||||||
((float) o_t_size - i_t_size) * 100 / i_t_size,
|
((float) o_t_size - i_t_size) * 100 / i_t_size,
|
||||||
get_human_size(((long) o_t_size - i_t_size)));
|
get_human_size(((long) o_t_size - i_t_size)));
|
||||||
|
|
||||||
exit(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
25
src/utils.c
25
src/utils.c
|
@ -51,7 +51,6 @@ void print_help() {
|
||||||
"\t-e\tkeeps EXIF info during compression\n"
|
"\t-e\tkeeps EXIF info during compression\n"
|
||||||
"\t-o\tcompress to custom folder\n"
|
"\t-o\tcompress to custom folder\n"
|
||||||
"\t-l\tuse lossless optimization\n"
|
"\t-l\tuse lossless optimization\n"
|
||||||
"\t-s\tscale to value, expressed as percentage (e.g. 20%%) [Only 1/2^n allowed]\n"
|
|
||||||
"\t-R\tif input is a folder, scan subfolders too\n"
|
"\t-R\tif input is a folder, scan subfolders too\n"
|
||||||
//TODO Remove this warning
|
//TODO Remove this warning
|
||||||
"\t-S\tkeep the folder structure [Not active yet]\n"
|
"\t-S\tkeep the folder structure [Not active yet]\n"
|
||||||
|
@ -60,14 +59,6 @@ void print_help() {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_progress(int current, int max, char* message) {
|
|
||||||
fprintf(stdout, "\e[?25l");
|
|
||||||
fprintf(stdout, "\r%s[%d%%]", message, current * 100 / max);
|
|
||||||
if (current == max) {
|
|
||||||
fprintf(stdout, "\e[?25h\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO Recheck
|
//TODO Recheck
|
||||||
int mkpath(const char *pathname, mode_t mode) {
|
int mkpath(const char *pathname, mode_t mode) {
|
||||||
|
|
||||||
|
@ -76,7 +67,7 @@ int mkpath(const char *pathname, mode_t mode) {
|
||||||
/* make a parent directory path */
|
/* make a parent directory path */
|
||||||
strncpy(parent, pathname, sizeof(parent));
|
strncpy(parent, pathname, sizeof(parent));
|
||||||
parent[sizeof(parent) - 1] = '\0';
|
parent[sizeof(parent) - 1] = '\0';
|
||||||
for(p = parent + strlen(parent); *p != '/' && p != parent; p--);
|
for (p = parent + strlen(parent); *p != '/' && p != parent; p--);
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
/* try make parent directory */
|
/* try make parent directory */
|
||||||
if(p != parent && mkpath(parent, mode) != 0) {
|
if(p != parent && mkpath(parent, mode) != 0) {
|
||||||
|
@ -93,19 +84,18 @@ int mkpath(const char *pathname, mode_t mode) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char** scan_folder(char* basedir, int* n, int recur) {
|
int scan_folder(char** fileList, char* basedir, int recur) {
|
||||||
|
//TODO CRITIAL Pass list as 1st parameter
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
char* entpath = NULL;
|
char* entpath = NULL;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
int indexes = 0;
|
int indexes = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char** fileList = NULL;
|
|
||||||
|
|
||||||
char absolute_path[PATH_MAX];
|
char absolute_path[PATH_MAX];
|
||||||
char* ptr = realpath(basedir, absolute_path);
|
char* ptr = realpath(basedir, absolute_path);
|
||||||
|
|
||||||
|
|
||||||
dir = opendir(ptr);
|
dir = opendir(ptr);
|
||||||
|
|
||||||
if (dir != NULL) {
|
if (dir != NULL) {
|
||||||
|
@ -130,7 +120,7 @@ char** scan_folder(char* basedir, int* n, int recur) {
|
||||||
if (S_ISDIR(s.st_mode)) {
|
if (S_ISDIR(s.st_mode)) {
|
||||||
// Directory, walk it if recursive is set
|
// Directory, walk it if recursive is set
|
||||||
if (recur != 0) {
|
if (recur != 0) {
|
||||||
fileList = scan_folder(entpath, n, recur);
|
scan_folder(fileList, entpath, recur);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//File, add to the list
|
//File, add to the list
|
||||||
|
@ -142,6 +132,7 @@ char** scan_folder(char* basedir, int* n, int recur) {
|
||||||
fileList[i] = (char*) malloc(strlen(entpath) * sizeof(char));
|
fileList[i] = (char*) malloc(strlen(entpath) * sizeof(char));
|
||||||
//Copy the file path in the array
|
//Copy the file path in the array
|
||||||
fileList[i] = strcpy(fileList[i], entpath);
|
fileList[i] = strcpy(fileList[i], entpath);
|
||||||
|
printf("%s\n", fileList[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,8 +142,8 @@ char** scan_folder(char* basedir, int* n, int recur) {
|
||||||
exit(-19);
|
exit(-19);
|
||||||
}
|
}
|
||||||
free(entpath);
|
free(entpath);
|
||||||
*n = i;
|
|
||||||
return fileList;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum image_type detect_image_type(char* path) {
|
enum image_type detect_image_type(char* path) {
|
||||||
|
@ -187,7 +178,7 @@ enum image_type detect_image_type(char* path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int isDirectory(const char *file_path) {
|
int is_directory(const char *file_path) {
|
||||||
struct stat s;
|
struct stat s;
|
||||||
stat(file_path, &s);
|
stat(file_path, &s);
|
||||||
return S_ISDIR(s.st_mode);
|
return S_ISDIR(s.st_mode);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#define APP_VERSION "0.9.1-beta"
|
#define APP_VERSION "0.9.1-beta"
|
||||||
#define BUILD 20150921
|
#define BUILD 20160116
|
||||||
|
|
||||||
typedef struct cclt_compress_parameters {
|
typedef struct cclt_compress_parameters {
|
||||||
int quality;
|
int quality;
|
||||||
|
@ -32,11 +32,10 @@ enum image_type {
|
||||||
|
|
||||||
int string_to_int(char* in_string);
|
int string_to_int(char* in_string);
|
||||||
void print_help();
|
void print_help();
|
||||||
void print_progress(int current, int max, char* message);
|
|
||||||
int mkpath(const char *pathname, mode_t mode);
|
int mkpath(const char *pathname, mode_t mode);
|
||||||
enum image_type detect_image_type(char* path);
|
enum image_type detect_image_type(char* path);
|
||||||
int isDirectory(const char *file_path);
|
int is_directory(const char *file_path);
|
||||||
char** scan_folder(char* basedir, int* n, int recur);
|
int scan_folder(char** fileList, char* basedir, int recur);
|
||||||
char* get_human_size(long size);
|
char* get_human_size(long size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
#ifndef __GNUC__
|
|
||||||
|
|
||||||
#include "wingetopt.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define NULL 0
|
|
||||||
#define EOF (-1)
|
|
||||||
#define ERR(s, c) if(opterr){\
|
|
||||||
char errbuf[2];\
|
|
||||||
errbuf[0] = c; errbuf[1] = '\n';\
|
|
||||||
fputs(argv[0], stderr);\
|
|
||||||
fputs(s, stderr);\
|
|
||||||
fputc(c, stderr);}
|
|
||||||
//(void) write(2, argv[0], (unsigned)strlen(argv[0]));\
|
|
||||||
//(void) write(2, s, (unsigned)strlen(s));\
|
|
||||||
//(void) write(2, errbuf, 2);}
|
|
||||||
|
|
||||||
int opterr = 1;
|
|
||||||
int optind = 1;
|
|
||||||
int optopt;
|
|
||||||
char *optarg;
|
|
||||||
|
|
||||||
int
|
|
||||||
getopt(argc, argv, opts)
|
|
||||||
int argc;
|
|
||||||
char **argv, *opts;
|
|
||||||
{
|
|
||||||
static int sp = 1;
|
|
||||||
register int c;
|
|
||||||
register char *cp;
|
|
||||||
|
|
||||||
if(sp == 1)
|
|
||||||
if(optind >= argc ||
|
|
||||||
argv[optind][0] != '-' || argv[optind][1] == '\0')
|
|
||||||
return(EOF);
|
|
||||||
else if(strcmp(argv[optind], "--") == NULL) {
|
|
||||||
optind++;
|
|
||||||
return(EOF);
|
|
||||||
}
|
|
||||||
optopt = c = argv[optind][sp];
|
|
||||||
if(c == ':' || (cp=strchr(opts, c)) == NULL) {
|
|
||||||
ERR(": illegal option -- ", c);
|
|
||||||
if(argv[optind][++sp] == '\0') {
|
|
||||||
optind++;
|
|
||||||
sp = 1;
|
|
||||||
}
|
|
||||||
return('?');
|
|
||||||
}
|
|
||||||
if(*++cp == ':') {
|
|
||||||
if(argv[optind][sp+1] != '\0')
|
|
||||||
optarg = &argv[optind++][sp+1];
|
|
||||||
else if(++optind >= argc) {
|
|
||||||
ERR(": option requires an argument -- ", c);
|
|
||||||
sp = 1;
|
|
||||||
return('?');
|
|
||||||
} else
|
|
||||||
optarg = argv[optind++];
|
|
||||||
sp = 1;
|
|
||||||
} else {
|
|
||||||
if(argv[optind][++sp] == '\0') {
|
|
||||||
sp = 1;
|
|
||||||
optind++;
|
|
||||||
}
|
|
||||||
optarg = NULL;
|
|
||||||
}
|
|
||||||
return(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __GNUC__ */
|
|
|
@ -1,24 +0,0 @@
|
||||||
#ifdef __GNUC__
|
|
||||||
#include <getopt.h>
|
|
||||||
#endif
|
|
||||||
#ifndef __GNUC__
|
|
||||||
|
|
||||||
#ifndef _WINGETOPT_H_
|
|
||||||
#define _WINGETOPT_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern int opterr;
|
|
||||||
extern int optind;
|
|
||||||
extern int optopt;
|
|
||||||
extern char *optarg;
|
|
||||||
extern int getopt(int argc, char **argv, char *opts);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _GETOPT_H_ */
|
|
||||||
#endif /* __GNUC__ */
|
|
Loading…
Reference in New Issue