diff --git a/.gitignore b/.gitignore index 6f5fcdb..fdbb247 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,9 @@ /pktriggercord-cli *~ *.exe +libpktriggercord.dll /pktriggercord_commandline.html +/pktriggercord-*-win /pktriggercord-*-win.zip /pkTriggerCord-*.src.tar.gz /pktriggercord-*.rpm diff --git a/.travis.yml b/.travis.yml index 0dcd75c..93b6e26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ before_script: - make -C $HOME/astyle/build/gcc - make -C $HOME/astyle/build/gcc prefix=$HOME install script: - - if [[ -n $(make astyle | grep Formatted) ]]; then echo "Code formatting error. Please check astyle"; exit -1; fi + - if [[ -n $(make astyle | grep Formatted) ]]; then echo "Code formatting error. Please check astyle"; exit 1; fi - make android - make localwin - make srczip diff --git a/BUGS b/BUGS index 8c65790..d547437 100644 --- a/BUGS +++ b/BUGS @@ -11,9 +11,6 @@ General Taking picture restores jpeg image tone, so jpeg image tone setting is quite useless. - Setting exposure mode has no effect ( maybe it's not a bug only it's - not allowed ). - ISO table of GUI only shows the extended iso range even is base iso range is set. diff --git a/Changelog b/Changelog index aaa62ef..f774ed3 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ version 0.85.01 + RAD10 compilation (thx FrankBijnen) + Exposure mode conversion bugfix (thx blemasle) Testing status reader for KP Settings reading for K5II (thx blemasle) remote_bulb_mode_press_press setting (thx blemasle) diff --git a/Makefile b/Makefile index 23e8729..555bf06 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ MAN1DIR = $(MANDIR)/man1 LIN_CFLAGS = $(CFLAGS) LIN_LDFLAGS = $(LDFLAGS) +MAJORVERSION=0 VERSION=0.85.01 VERSIONCODE=$(shell echo $(VERSION) | sed s/\\.//g | sed s/^0// ) # variables for RPM creation @@ -40,12 +41,13 @@ LIN_GUI_CFLAGS=$(CFLAGS) $(shell pkg-config --cflags gtk+-2.0 gmodule-2.0) -DGTK default: cli pktriggercord all: srczip rpm win pktriggercord_commandline.html cli: pktriggercord-cli +lib: libpktriggercord.so.$(VERSION) MANS = pktriggercord-cli.1 pktriggercord.1 SRCOBJNAMES = pslr pslr_enum pslr_scsi pslr_lens pslr_model pktriggercord-servermode OBJS = $(SRCOBJNAMES:=.o) $(JSONDIR)/js0n.o WIN_DLLS_DIR=win_dlls -SOURCE_PACKAGE_FILES = Makefile Changelog COPYING INSTALL BUGS $(MANS) pentax_scsi_protocol.md pentax.rules samsung.rules $(SRCOBJNAMES:=.h) $(SRCOBJNAMES:=.c) pslr_scsi_linux.c pslr_scsi_win.c pslr_scsi_openbsd.c exiftool_pentax_lens.txt pktriggercord.c pktriggercord-cli.c pktriggercord.ui pentax_settings.json $(SPECFILE) android_scsi_sg.h src/ +SOURCE_PACKAGE_FILES = Makefile Changelog COPYING INSTALL BUGS $(MANS) pentax_scsi_protocol.md pentax.rules samsung.rules $(SRCOBJNAMES:=.h) $(SRCOBJNAMES:=.c) pslr_scsi_linux.c pslr_scsi_win.c pslr_scsi_openbsd.c exiftool_pentax_lens.txt pktriggercord.c pktriggercord-cli.c pktriggercord.ui pentax_settings.json $(SPECFILE) android_scsi_sg.h rad10/ src/ TARDIR = pktriggercord-$(VERSION) SRCZIP = pkTriggerCord-$(VERSION).src.tar.gz @@ -56,9 +58,16 @@ WINDIR=$(TARDIR)-win pslr.o: pslr_enum.o pslr_scsi.o pslr.c pslr.h -pktriggercord-cli: pktriggercord-cli.c $(OBJS) +pktriggercord-cli: pktriggercord-cli.c $(OBJS) libpktriggercord.o $(CC) $(LIN_CFLAGS) $^ -DVERSION='"$(VERSION)"' -o $@ $(LIN_LDFLAGS) -L. +libpktriggercord.so: libpktriggercord.so.$(VERSION) + ldconfig -v -n . + ln -s libpktriggercord.so.$(MAJORVERSION) libpktriggercord.so + +libpktriggercord.so.$(VERSION): $(OBJS) libpktriggercord.o + $(CC) $(LIN_CFLAGS) -shared -Wl,-soname,lib$(NAME).so.$(MAJORVERSION) $^ -o $@ $(LIN_LDFLAGS) -L. + pslr_scsi.o: pslr_scsi_win.c pslr_scsi_linux.c pslr_scsi_openbsd.c $(JSONDIR)/js0n.o: $(JSONDIR)/js0n.c $(JSONDIR)/js0n.h @@ -93,7 +102,7 @@ install: pktriggercord-cli pktriggercord fi clean: - rm -f pktriggercord pktriggercord-cli *.o $(JSONDIR)/*.o + rm -f pktriggercord pktriggercord-cli *.o $(JSONDIR)/*.o *.so* *.dll rm -f pktriggercord.exe pktriggercord-cli.exe rm -f *.orig @@ -200,18 +209,23 @@ winexternal: $(JSONDIR)/js0n.c $(JSONDIR)/js0n.h $(WINGCC) $(WIN_CFLAGS) -c $< -o $(JSONDIR)/js0n.o win-cli:winobjs winexternal pktriggercord-cli.c pktriggercord_commandline.html - $(WINGCC) -mms-bitfields -DVERSION='"$(VERSION)"' pktriggercord-cli.c $(OBJS) -o pktriggercord-cli.exe $(WIN_CFLAGS) -L. + $(WINGCC) -mms-bitfields -DVERSION='"$(VERSION)"' pktriggercord-cli.c libpktriggercord.c $(OBJS) -o pktriggercord-cli.exe $(WIN_CFLAGS) -L. mkdir -p $(WINDIR) cp pktriggercord-cli.exe Changelog COPYING pktriggercord_commandline.html $(WINDIR) cp $(WIN_DLLS_DIR)/*.dll $(WINDIR) +win-lib: winobjs winexternal + $(WINGCC) -mms-bitfields libpktriggercord.c $(OBJS) -shared -o libpktriggercord.dll $(WIN_CFLAGS) -L. + mkdir -p $(WINDIR) + cp libpktriggercord.dll Changelog COPYING $(WIN_DLLS_DIR)/libgcc_s_sjlj-1.dll $(WINDIR) + win-gui: winobjs $(WINGCC) -mms-bitfields -DVERSION='"$(VERSION)"' -DPKTDATADIR=\".\" pktriggercord.c $(OBJS) -o pktriggercord.exe $(WIN_GUI_CFLAGS) $(WIN_LDFLAGS) -L. mkdir -p $(WINDIR) cp pktriggercord.exe pktriggercord.ui pentax_settings.json Changelog COPYING $(WINDIR) cp $(WIN_DLLS_DIR)/*.dll $(WINDIR) -win: win-cli win-gui +win: win-cli win-gui win-lib rm -f $(WINDIR).zip zip -rj $(WINDIR).zip $(WINDIR) rm -r $(WINDIR) diff --git a/libpktriggercord.c b/libpktriggercord.c new file mode 100644 index 0000000..9518400 --- /dev/null +++ b/libpktriggercord.c @@ -0,0 +1,201 @@ +/* + pkTriggerCord + Remote control of Pentax DSLR cameras. + Copyright (C) 2011-2019 Andras Salamon + + based on: + + pslr-shoot + + Command line remote control of Pentax DSLR cameras. + Copyright (C) 2009 Ramiro Barreiro + With fragments of code from PK-Remote by Pontus Lidman. + + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU General Public License + and GNU Lesser General Public License + along with this program. If not, see . + */ + +#include "libpktriggercord.h" + +bool debug = false; +bool warnings = false; + +bool bulb_timer_before=false; +bool astrotracer_before=false; + +int save_buffer(pslr_handle_t camhandle, int bufno, int fd, pslr_status *status, user_file_format filefmt, int jpeg_stars) { + pslr_buffer_type imagetype; + uint8_t buf[65536]; + uint32_t length; + uint32_t current; + + if (filefmt == USER_FILE_FORMAT_PEF) { + imagetype = PSLR_BUF_PEF; + } else if (filefmt == USER_FILE_FORMAT_DNG) { + imagetype = PSLR_BUF_DNG; + } else { + imagetype = pslr_get_jpeg_buffer_type( camhandle, jpeg_stars ); + } + + DPRINT("get buffer %d type %d res %d\n", bufno, imagetype, status->jpeg_resolution); + + if (pslr_buffer_open(camhandle, bufno, imagetype, status->jpeg_resolution) != PSLR_OK) { + return 1; + } + + length = pslr_buffer_get_size(camhandle); + DPRINT("Buffer length: %d\n", length); + current = 0; + + while (true) { + uint32_t bytes; + bytes = pslr_buffer_read(camhandle, buf, sizeof (buf)); + if (bytes == 0) { + break; + } + ssize_t r = write(fd, buf, bytes); + if (r == 0) { + DPRINT("write(buf): Nothing has been written to buf.\n"); + } else if (r == -1) { + perror("write(buf)"); + } else if (r < bytes) { + DPRINT("write(buf): only write %zu bytes, should be %d bytes.\n", r, bytes); + } + current += bytes; + } + pslr_buffer_close(camhandle); + return 0; +} + +void save_memory(pslr_handle_t camhandle, int fd, uint32_t length) { + uint8_t buf[65536]; + uint32_t current; + + DPRINT("save memory %d\n", length); + + current = 0; + + while (current65536 ? 65536 : length-current; + bytes = pslr_fullmemory_read(camhandle, buf, current, readsize); + if (bytes == 0) { + break; + } + ssize_t r = write(fd, buf, bytes); + if (r == 0) { + DPRINT("write(buf): Nothing has been written to buf.\n"); + } else if (r == -1) { + perror("write(buf)"); + } else if (r < bytes) { + DPRINT("write(buf): only write %zu bytes, should be %d bytes.\n", r, bytes); + } + current += bytes; + } +} + +int open_file(char* output_file, int frameNo, user_file_format_t ufft) { + int ofd; + char fileName[256]; + + if (!output_file) { + ofd = 1; + } else { + char *dot = strrchr(output_file, '.'); + int prefix_length; + if (dot && !strcmp(dot+1, ufft.extension)) { + prefix_length = dot - output_file; + } else { + prefix_length = strlen(output_file); + } + snprintf(fileName, 256, "%.*s-%04d.%s", prefix_length, output_file, frameNo, ufft.extension); + ofd = open(fileName, FILE_ACCESS, 0664); + if (ofd == -1) { + fprintf(stderr, "Could not open %s\n", output_file); + return -1; + } + } + return ofd; +} + +void warning_message( const char* message, ... ) { + if ( warnings ) { + // Write to stderr + // + va_list argp; + va_start(argp, message); + vfprintf( stderr, message, argp ); + va_end(argp); + } +} + +void process_wbadj( const char* argv0, const char chr, uint32_t adj, uint32_t *wbadj_mg, uint32_t *wbadj_ba ) { + if ( chr == 'M' ) { + *wbadj_mg = 7 - adj; + } else if ( chr == 'G' ) { + *wbadj_mg = 7 + adj; + } else if ( chr == 'B' ) { + *wbadj_ba = 7 - adj; + } else if ( chr == 'A' ) { + *wbadj_ba = 7 + adj; + } else { + warning_message("%s: Invalid white_balance_adjustment\n", argv0); + } +} + +void bulb_old(pslr_handle_t camhandle, pslr_rational_t shutter_speed, struct timeval prev_time) { + DPRINT("bulb oldstyle\n"); + struct timeval current_time; + pslr_bulb( camhandle, true ); + pslr_shutter(camhandle); + gettimeofday(¤t_time, NULL); + double waitsec = 1.0 * shutter_speed.nom / shutter_speed.denom - timeval_diff_sec(¤t_time, &prev_time); + if ( waitsec < 0 ) { + waitsec = 0; + } + sleep_sec( waitsec ); + pslr_bulb( camhandle, false ); +} + +void bulb_new(pslr_handle_t camhandle, pslr_rational_t shutter_speed) { + if (pslr_has_setting_by_name(camhandle, "bulb_timer")) { + pslr_write_setting_by_name(camhandle, "bulb_timer", 1); + } else if (pslr_has_setting_by_name(camhandle, "astrotracer")) { + pslr_write_setting_by_name(camhandle, "astrotracer", 1); + } else { + fprintf(stderr, "New bulb mode is not supported for this camera model\n"); + } + int bulb_sec = (int)(shutter_speed.nom / shutter_speed.denom); + if (pslr_has_setting_by_name(camhandle, "bulb_timer_sec")) { + pslr_write_setting_by_name(camhandle, "bulb_timer_sec", bulb_sec); + } else if (pslr_has_setting_by_name(camhandle, "astrotracer_timer_sec")) { + pslr_write_setting_by_name(camhandle, "astrotracer_timer_sec", bulb_sec); + } else { + fprintf(stderr, "New bulb mode is not supported for this camera model\n"); + } + pslr_shutter(camhandle); +} + +void bulb_new_cleanup(pslr_handle_t camhandle) { + if (pslr_has_setting_by_name(camhandle, "bulb_timer")) { + if (!bulb_timer_before) { + pslr_write_setting_by_name(camhandle, "bulb_timer", bulb_timer_before); + } + } else if (pslr_has_setting_by_name(camhandle, "astrotracer")) { + if (!astrotracer_before) { + pslr_write_setting_by_name(camhandle, "astrotracer", astrotracer_before); + } + } +} diff --git a/libpktriggercord.h b/libpktriggercord.h new file mode 100644 index 0000000..7cd7102 --- /dev/null +++ b/libpktriggercord.h @@ -0,0 +1,91 @@ +/* + Header file for libpktriggercord + Shared library wrapper for pkTriggerCord + Copyright (c) 2020 Karl Rees + + for: + + pkTriggerCord + Remote control of Pentax DSLR cameras. + Copyright (C) 2011-2019 Andras Salamon + + which is based on: + + pslr-shoot + + Command line remote control of Pentax DSLR cameras. + Copyright (C) 2009 Ramiro Barreiro + With fragments of code from PK-Remote by Pontus Lidman. + + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU General Public License + and GNU Lesser General Public License + along with this program. If not, see . + */ + +#ifndef LIBPKTRIGGERCORD_H +#define LIBPKTRIGGERCORD_H + +#include +#include +#include +#include +#include +#ifdef RAD10 +#include +#include +#include "tdbtimes.h" +#include "getopt.h" +#else +#include +#include +#include +#endif +#include +#include +#include +#include +#include + +#include "pslr.h" +#include "pktriggercord-servermode.h" + +#ifdef WIN32 +#define FILE_ACCESS O_WRONLY | O_CREAT | O_TRUNC | O_BINARY +#else +#define FILE_ACCESS O_WRONLY | O_CREAT | O_TRUNC +#endif + +extern bool debug; +extern bool warnings; + +extern bool bulb_timer_before; +extern bool astrotracer_before; + + +int save_buffer(pslr_handle_t camhandle, int bufno, int fd, pslr_status *status, user_file_format filefmt, int jpeg_stars); +void save_memory(pslr_handle_t camhandle, int fd, uint32_t length); + +void print_status_info( pslr_handle_t h, pslr_status status ); +void print_settings_info( pslr_handle_t h, pslr_settings settings ); + +int open_file(char* output_file, int frameNo, user_file_format_t ufft); +void warning_message( const char* message, ... ); + +void process_wbadj( const char* argv0, const char chr, uint32_t adj, uint32_t *wbadj_mg, uint32_t *wbadj_ba ); + +void bulb_old(pslr_handle_t camhandle, pslr_rational_t shutter_speed, struct timeval prev_time); +void bulb_new(pslr_handle_t camhandle, pslr_rational_t shutter_speed); +void bulb_new_cleanup(pslr_handle_t camhandle); + +#endif \ No newline at end of file diff --git a/pktriggercord-cli.1 b/pktriggercord-cli.1 index c9fcbb1..10b3853 100644 --- a/pktriggercord-cli.1 +++ b/pktriggercord-cli.1 @@ -200,7 +200,8 @@ Turns off warning mode\. .PP \fB\-m\fR, \fB\-\-exposure_mode\fR \fIEXPOSURE_MODE\fR .RS 4 -Specify exposure mode. Does NOT work correctly. Please do not use it. +Specify exposure mode. Only works if the camera is set to user mode +(and in manual mode for some models). .RE .PP \fB\-i\fR, \fB\-\-iso\fR \fIISO\fR diff --git a/pktriggercord-cli.c b/pktriggercord-cli.c index cf803cb..7e6b5b5 100644 --- a/pktriggercord-cli.c +++ b/pktriggercord-cli.c @@ -27,41 +27,20 @@ along with this program. If not, see . */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pslr.h" -#include "pktriggercord-servermode.h" - -#ifdef WIN32 -#define FILE_ACCESS O_WRONLY | O_CREAT | O_TRUNC | O_BINARY -#else -#define FILE_ACCESS O_WRONLY | O_CREAT | O_TRUNC -#endif - -bool debug = false; -bool warnings = false; - -const char *shortopts = "m:q:a:r:d:t:o:i:F:fghvsSw"; +#include "libpktriggercord.h" -pslr_settings settings; -bool bulb_timer_before=false; -bool astrotracer_before=false; bool need_bulb_new_cleanup=false; bool need_one_push_bracketing_cleanup=false; +pslr_settings settings; + +const char *shortopts = "m:q:a:r:d:t:o:i:F:fghvsSw"; + +#ifdef RAD10 +static option const longopts[] = { +#else static struct option const longopts[] = { +#endif {"exposure_mode", required_argument, NULL, 'm'}, {"resolution", required_argument, NULL, 'r'}, {"quality", required_argument, NULL, 'q'}, @@ -110,78 +89,6 @@ static struct option const longopts[] = { { NULL, 0, NULL, 0} }; -int save_buffer(pslr_handle_t camhandle, int bufno, int fd, pslr_status *status, user_file_format filefmt, int jpeg_stars) { - pslr_buffer_type imagetype; - uint8_t buf[65536]; - uint32_t length; - uint32_t current; - - if (filefmt == USER_FILE_FORMAT_PEF) { - imagetype = PSLR_BUF_PEF; - } else if (filefmt == USER_FILE_FORMAT_DNG) { - imagetype = PSLR_BUF_DNG; - } else { - imagetype = pslr_get_jpeg_buffer_type( camhandle, jpeg_stars ); - } - - DPRINT("get buffer %d type %d res %d\n", bufno, imagetype, status->jpeg_resolution); - - if (pslr_buffer_open(camhandle, bufno, imagetype, status->jpeg_resolution) != PSLR_OK) { - return 1; - } - - length = pslr_buffer_get_size(camhandle); - DPRINT("Buffer length: %d\n", length); - current = 0; - - while (true) { - uint32_t bytes; - bytes = pslr_buffer_read(camhandle, buf, sizeof (buf)); - if (bytes == 0) { - break; - } - ssize_t r = write(fd, buf, bytes); - if (r == 0) { - DPRINT("write(buf): Nothing has been written to buf.\n"); - } else if (r == -1) { - perror("write(buf)"); - } else if (r < bytes) { - DPRINT("write(buf): only write %zu bytes, should be %d bytes.\n", r, bytes); - } - current += bytes; - } - pslr_buffer_close(camhandle); - return 0; -} - -void save_memory(pslr_handle_t camhandle, int fd, uint32_t length) { - uint8_t buf[65536]; - uint32_t current; - - DPRINT("save memory %d\n", length); - - current = 0; - - while (current65536 ? 65536 : length-current; - bytes = pslr_fullmemory_read(camhandle, buf, current, readsize); - if (bytes == 0) { - break; - } - ssize_t r = write(fd, buf, bytes); - if (r == 0) { - DPRINT("write(buf): Nothing has been written to buf.\n"); - } else if (r == -1) { - perror("write(buf)"); - } else if (r < bytes) { - DPRINT("write(buf): only write %zu bytes, should be %d bytes.\n", r, bytes); - } - current += bytes; - } -} - - void print_status_info( pslr_handle_t h, pslr_status status ) { printf("\n"); printf( "%s", collect_status_info( h, status ) ); @@ -242,55 +149,6 @@ void usage(char *name) { \n", name); } -int open_file(char* output_file, int frameNo, user_file_format_t ufft) { - int ofd; - char fileName[256]; - - if (!output_file) { - ofd = 1; - } else { - char *dot = strrchr(output_file, '.'); - int prefix_length; - if (dot && !strcmp(dot+1, ufft.extension)) { - prefix_length = dot - output_file; - } else { - prefix_length = strlen(output_file); - } - snprintf(fileName, 256, "%.*s-%04d.%s", prefix_length, output_file, frameNo, ufft.extension); - ofd = open(fileName, FILE_ACCESS, 0664); - if (ofd == -1) { - fprintf(stderr, "Could not open %s\n", output_file); - return -1; - } - } - return ofd; -} - -void warning_message( const char* message, ... ) { - if ( warnings ) { - // Write to stderr - // - va_list argp; - va_start(argp, message); - vfprintf( stderr, message, argp ); - va_end(argp); - } -} - -void process_wbadj( const char* argv0, const char chr, uint32_t adj, uint32_t *wbadj_mg, uint32_t *wbadj_ba ) { - if ( chr == 'M' ) { - *wbadj_mg = 7 - adj; - } else if ( chr == 'G' ) { - *wbadj_mg = 7 + adj; - } else if ( chr == 'B' ) { - *wbadj_ba = 7 - adj; - } else if ( chr == 'A' ) { - *wbadj_ba = 7 + adj; - } else { - warning_message("%s: Invalid white_balance_adjustment\n", argv0); - } -} - char *copyright_version(char *name, char *version) { char *ret = malloc(sizeof(char)*1024); sprintf(ret, "%s %s\n\n\%s\ @@ -315,51 +173,6 @@ char *command_line(int argc, char **argv) { return ret; } -void bulb_old(pslr_handle_t camhandle, pslr_rational_t shutter_speed, struct timeval prev_time) { - DPRINT("bulb oldstyle\n"); - struct timeval current_time; - pslr_bulb( camhandle, true ); - pslr_shutter(camhandle); - gettimeofday(¤t_time, NULL); - double waitsec = 1.0 * shutter_speed.nom / shutter_speed.denom - timeval_diff_sec(¤t_time, &prev_time); - if ( waitsec < 0 ) { - waitsec = 0; - } - sleep_sec( waitsec ); - pslr_bulb( camhandle, false ); -} - -void bulb_new(pslr_handle_t camhandle, pslr_rational_t shutter_speed) { - if (pslr_has_setting_by_name(camhandle, "bulb_timer")) { - pslr_write_setting_by_name(camhandle, "bulb_timer", 1); - } else if (pslr_has_setting_by_name(camhandle, "astrotracer")) { - pslr_write_setting_by_name(camhandle, "astrotracer", 1); - } else { - fprintf(stderr, "New bulb mode is not supported for this camera model\n"); - } - int bulb_sec = (int)(shutter_speed.nom / shutter_speed.denom); - if (pslr_has_setting_by_name(camhandle, "bulb_timer_sec")) { - pslr_write_setting_by_name(camhandle, "bulb_timer_sec", bulb_sec); - } else if (pslr_has_setting_by_name(camhandle, "astrotracer_timer_sec")) { - pslr_write_setting_by_name(camhandle, "astrotracer_timer_sec", bulb_sec); - } else { - fprintf(stderr, "New bulb mode is not supported for this camera model\n"); - } - pslr_shutter(camhandle); -} - -void bulb_new_cleanup(pslr_handle_t camhandle) { - if (pslr_has_setting_by_name(camhandle, "bulb_timer")) { - if (!bulb_timer_before) { - pslr_write_setting_by_name(camhandle, "bulb_timer", bulb_timer_before); - } - } else if (pslr_has_setting_by_name(camhandle, "astrotracer")) { - if (!astrotracer_before) { - pslr_write_setting_by_name(camhandle, "astrotracer", astrotracer_before); - } - } -} - int main(int argc, char **argv) { float F = 0; char C; diff --git a/pktriggercord-servermode.c b/pktriggercord-servermode.c index 03b762c..c3f494a 100644 --- a/pktriggercord-servermode.c +++ b/pktriggercord-servermode.c @@ -26,6 +26,14 @@ and GNU Lesser General Public License along with this program. If not, see . */ +#ifdef RAD10 +#include +#include +#include "tdbtimes.h" +#else +#include +#include +#endif #ifndef WIN32 #include #include @@ -33,10 +41,8 @@ #endif #include -#include #include -#include #include "pslr.h" #include "pslr_lens.h" diff --git a/pslr.c b/pslr.c index 8550a62..0570a6d 100644 --- a/pslr.c +++ b/pslr.c @@ -41,7 +41,13 @@ #include #include #include +#ifdef RAD10 +#include +#include +#include "tdbtime.h" +#else #include +#endif #include #include #include @@ -981,6 +987,11 @@ int pslr_set_exposure_mode(pslr_handle_t h, pslr_exposure_mode_t mode) { if (mode >= PSLR_EXPOSURE_MODE_MAX) { return PSLR_PARAM; } + + if ( p->model->need_exposure_mode_conversion ) { + mode = exposure_mode_conversion( mode ); + } + return ipslr_handle_command_x18( p, true, X18_EXPOSURE_MODE, 2, 1, mode, 0); } diff --git a/pslr_model.c b/pslr_model.c index f0bad01..4c8205c 100644 --- a/pslr_model.c +++ b/pslr_model.c @@ -39,8 +39,12 @@ #include #include #include +#ifndef RAD10 #include +#endif #include "js0n.h" +#include +#include #include "pslr_model.h" #include "pslr.h" @@ -50,6 +54,16 @@ static int first = 1; static char *jsontext=NULL; static int jsonsize; +static int dir_exists(char *dir) { + int res = 0; + struct stat info; + + if ( (stat(dir, &info) == 0) && (info.st_mode & S_IFDIR) ) { + res = 1; + } + return res; +} + static void ipslr_status_diff(uint8_t *buf) { int n; int diffs; @@ -779,7 +793,9 @@ char *read_json_file(int *jsonsize) { int jsonfd = open("pentax_settings.json", O_RDONLY); if (jsonfd == -1) { // cannot find in the current directory, also checking PKTDATADIR - jsonfd = open(PKTDATADIR "/pentax_settings.json", O_RDONLY); + if (dir_exists(PKTDATADIR)) { + jsonfd = open(PKTDATADIR "/pentax_settings.json", O_RDONLY); + } if (jsonfd == -1) { fprintf(stderr, "Cannot open pentax_settings.json file\n"); return NULL; diff --git a/pslr_scsi.c b/pslr_scsi.c index 25b48e7..7aa45c5 100644 --- a/pslr_scsi.c +++ b/pslr_scsi.c @@ -23,8 +23,7 @@ and GNU Lesser General Public License along with this program. If not, see . */ - -#ifdef WIN32 +#if defined(WIN32) || defined(RAD10) #include "pslr_scsi_win.c" #else /* Ugly hack. More generic ifs required */ diff --git a/pslr_scsi.h b/pslr_scsi.h index 3174ed4..2a1b626 100644 --- a/pslr_scsi.h +++ b/pslr_scsi.h @@ -35,6 +35,9 @@ extern bool debug; extern void write_debug( const char* message, ... ); +#ifdef RAD10 +#include +#endif #ifdef ANDROID #include #define DPRINT(...) __android_log_print(ANDROID_LOG_DEBUG, "PkTriggerCord", __VA_ARGS__) diff --git a/pslr_scsi_linux.c b/pslr_scsi_linux.c index 59d09ef..9c3e12c 100644 --- a/pslr_scsi_linux.c +++ b/pslr_scsi_linux.c @@ -81,7 +81,7 @@ char **get_drives(int *drive_num) { d = opendir(device_dirs[di]); if (d) { while ( (ent = readdir(d)) ) { - if (strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0) { + if (strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0 && strncmp(ent->d_name, "loop",4) != 0) { tmp[j] = malloc( strlen(ent->d_name)+1 ); strncpy(tmp[j], ent->d_name, strlen(ent->d_name)+1); ++j; diff --git a/pslr_scsi_win.c b/pslr_scsi_win.c index 3138631..21a4446 100644 --- a/pslr_scsi_win.c +++ b/pslr_scsi_win.c @@ -68,6 +68,21 @@ char **get_drives(int *driveNum) { int driveLetter; int j=0; for ( driveLetter = 'C'; driveLetter<='Z'; ++driveLetter ) { +#ifdef RAD10 +// These Drive types cant be a Pentax. The RAD10 debugger breaks here. + TCHAR root[4]; + snprintf(root, 4, "%c:\\", driveLetter); + switch (GetDriveType(root)) { + case DRIVE_UNKNOWN: + case DRIVE_NO_ROOT_DIR: + case DRIVE_FIXED: + case DRIVE_REMOTE: + case DRIVE_CDROM: + continue; + default: + ; + } +#endif ret[j] = malloc( 2 * sizeof (char) ); snprintf(ret[j], 2, "%c", driveLetter); ++j; diff --git a/rad10/getopt.h b/rad10/getopt.h new file mode 100644 index 0000000..3bae736 --- /dev/null +++ b/rad10/getopt.h @@ -0,0 +1,661 @@ +#ifndef __GETOPT_H__ +/** + * DISCLAIMER + * This file is part of the mingw-w64 runtime package. + * + * The mingw-w64 runtime package and its code is distributed in the hope that it + * will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR + * IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to + * warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + /* + * Copyright (c) 2002 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F39502-99-1-0512. + */ +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma warning(disable:4996); + +#define __GETOPT_H__ + +/* All the headers include this file. */ +//#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define REPLACE_GETOPT /* use this getopt as the system getopt(3) */ + +#ifdef REPLACE_GETOPT +int opterr = 1; /* if error message should be printed */ +int optind = 1; /* index into parent argv vector */ +int optopt = '?'; /* character checked for validity */ +#undef optreset /* see getopt.h */ +#define optreset __mingw_optreset +int optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ +#endif + +//extern int optind; /* index of first non-option in argv */ +//extern int optopt; /* single option character, as parsed */ +//extern int opterr; /* flag to enable built-in diagnostics... */ +// /* (user may set to zero, to suppress) */ +// +//extern char *optarg; /* pointer to argument of current option */ + +#define PRINT_ERROR ((opterr) && (*options != ':')) + +#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */ +#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */ +#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ + +/* return values */ +#define BADCH (int)'?' +#define BADARG ((*options == ':') ? (int)':' : (int)'?') +#define INORDER (int)1 + +#ifndef __CYGWIN__ +#define __progname __argv[0] +#else +extern char __declspec(dllimport) *__progname; +#endif + +#ifdef __CYGWIN__ +static char EMSG[] = ""; +#else +#define EMSG "" +#endif + +typedef struct /* specification for a long form option... */ +{ + const char *name; /* option name, without leading hyphens */ + int has_arg; /* does it take an argument? */ + int *flag; /* where to save its status, or NULL */ + int val; /* its associated status value */ +} option; + +static int getopt_internal(int, char * const *, const char *, + const option *, int *, int); +static int parse_long_options(char * const *, const char *, + const option *, int *, int); +static int gcd(int, int); +static void permute_args(int, int, int, char * const *); + +static char *place = EMSG; /* option letter processing */ + +/* XXX: set optreset to 1 rather than these two */ +static int nonopt_start = -1; /* first non option argument (for permute) */ +static int nonopt_end = -1; /* first option after non options (for permute) */ + +/* Error messages */ +static const char recargchar[] = "option requires an argument -- %c"; +static const char recargstring[] = "option requires an argument -- %s"; +static const char ambig[] = "ambiguous option -- %.*s"; +static const char noarg[] = "option doesn't take an argument -- %.*s"; +static const char illoptchar[] = "unknown option -- %c"; +static const char illoptstring[] = "unknown option -- %s"; + +static void +_vwarnx(const char *fmt,va_list ap) +{ + (void)fprintf(stderr,"%s: ",__progname); + if (fmt != NULL) + (void)vfprintf(stderr,fmt,ap); + (void)fprintf(stderr,"\n"); +} + +static void +warnx(const char *fmt,...) +{ + va_list ap; + va_start(ap,fmt); + _vwarnx(fmt,ap); + va_end(ap); +} + +/* + * Compute the greatest common divisor of a and b. + */ +static int +gcd(int a, int b) +{ + int c; + + c = a % b; + while (c != 0) { + a = b; + b = c; + c = a % b; + } + + return (b); +} + +/* + * Exchange the block from nonopt_start to nonopt_end with the block + * from nonopt_end to opt_end (keeping the same order of arguments + * in each block). + */ +static void +permute_args(int panonopt_start, int panonopt_end, int opt_end, + char * const *nargv) +{ + int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; + char *swap; + + /* + * compute lengths of blocks and number and size of cycles + */ + nnonopts = panonopt_end - panonopt_start; + nopts = opt_end - panonopt_end; + ncycle = gcd(nnonopts, nopts); + cyclelen = (opt_end - panonopt_start) / ncycle; + + for (i = 0; i < ncycle; i++) { + cstart = panonopt_end+i; + pos = cstart; + for (j = 0; j < cyclelen; j++) { + if (pos >= panonopt_end) + pos -= nnonopts; + else + pos += nopts; + swap = nargv[pos]; + /* LINTED const cast */ + ((char **) nargv)[pos] = nargv[cstart]; + /* LINTED const cast */ + ((char **)nargv)[cstart] = swap; + } + } +} + +#ifdef REPLACE_GETOPT +/* + * getopt -- + * Parse argc/argv argument vector. + * + * [eventually this will replace the BSD getopt] + */ +int +getopt(int nargc, char * const *nargv, const char *options) +{ + + /* + * We don't pass FLAG_PERMUTE to getopt_internal() since + * the BSD getopt(3) (unlike GNU) has never done this. + * + * Furthermore, since many privileged programs call getopt() + * before dropping privileges it makes sense to keep things + * as simple (and bug-free) as possible. + */ + return (getopt_internal(nargc, nargv, options, NULL, NULL, 0)); +} +#endif /* REPLACE_GETOPT */ + +//extern int getopt(int nargc, char * const *nargv, const char *options); + +#ifdef _BSD_SOURCE +/* + * BSD adds the non-standard `optreset' feature, for reinitialisation + * of `getopt' parsing. We support this feature, for applications which + * proclaim their BSD heritage, before including this header; however, + * to maintain portability, developers are advised to avoid it. + */ +# define optreset __mingw_optreset +extern int optreset; +#endif +#ifdef __cplusplus +} +#endif +/* + * POSIX requires the `getopt' API to be specified in `unistd.h'; + * thus, `unistd.h' includes this header. However, we do not want + * to expose the `getopt_long' or `getopt_long_only' APIs, when + * included in this manner. Thus, close the standard __GETOPT_H__ + * declarations block, and open an additional __GETOPT_LONG_H__ + * specific block, only when *not* __UNISTD_H_SOURCED__, in which + * to declare the extended API. + */ +#endif /* !defined(__GETOPT_H__) */ + +#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) +#define __GETOPT_LONG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +//struct option /* specification for a long form option... */ +//{ +// const char *name; /* option name, without leading hyphens */ +// int has_arg; /* does it take an argument? */ +// int *flag; /* where to save its status, or NULL */ +// int val; /* its associated status value */ +//}; + +enum /* permitted values for its `has_arg' field... */ +{ + no_argument = 0, /* option never takes an argument */ + required_argument, /* option always requires an argument */ + optional_argument /* option may take an argument */ +}; + +/* + * parse_long_options -- + * Parse long options in argc/argv argument vector. + * Returns -1 if short_too is set and the option does not match long_options. + */ +static int +parse_long_options(char * const *nargv, const char *options, + const option *long_options, int *idx, int short_too) +{ + char *current_argv, *has_equal; + size_t current_argv_len; + int i, ambiguous, match; + +#define IDENTICAL_INTERPRETATION(_x, _y) \ + (long_options[(_x)].has_arg == long_options[(_y)].has_arg && \ + long_options[(_x)].flag == long_options[(_y)].flag && \ + long_options[(_x)].val == long_options[(_y)].val) + + current_argv = place; + match = -1; + ambiguous = 0; + + optind++; + + if ((has_equal = strchr(current_argv, '=')) != NULL) { + /* argument found (--option=arg) */ + current_argv_len = has_equal - current_argv; + has_equal++; + } else + current_argv_len = strlen(current_argv); + + for (i = 0; long_options[i].name; i++) { + /* find matching long option */ + if (strncmp(current_argv, long_options[i].name, + current_argv_len)) + continue; + + if (strlen(long_options[i].name) == current_argv_len) { + /* exact match */ + match = i; + ambiguous = 0; + break; + } + /* + * If this is a known short option, don't allow + * a partial match of a single character. + */ + if (short_too && current_argv_len == 1) + continue; + + if (match == -1) /* partial match */ + match = i; + else if (!IDENTICAL_INTERPRETATION(i, match)) + ambiguous = 1; + } + if (ambiguous) { + /* ambiguous abbreviation */ + if (PRINT_ERROR) + warnx(ambig, (int)current_argv_len, + current_argv); + optopt = 0; + return (BADCH); + } + if (match != -1) { /* option found */ + if (long_options[match].has_arg == no_argument + && has_equal) { + if (PRINT_ERROR) + warnx(noarg, (int)current_argv_len, + current_argv); + /* + * XXX: GNU sets optopt to val regardless of flag + */ + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + return (BADARG); + } + if (long_options[match].has_arg == required_argument || + long_options[match].has_arg == optional_argument) { + if (has_equal) + optarg = has_equal; + else if (long_options[match].has_arg == + required_argument) { + /* + * optional argument doesn't use next nargv + */ + optarg = nargv[optind++]; + } + } + if ((long_options[match].has_arg == required_argument) + && (optarg == NULL)) { + /* + * Missing argument; leading ':' indicates no error + * should be generated. + */ + if (PRINT_ERROR) + warnx(recargstring, + current_argv); + /* + * XXX: GNU sets optopt to val regardless of flag + */ + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + --optind; + return (BADARG); + } + } else { /* unknown option */ + if (short_too) { + --optind; + return (-1); + } + if (PRINT_ERROR) + warnx(illoptstring, current_argv); + optopt = 0; + return (BADCH); + } + if (idx) + *idx = match; + if (long_options[match].flag) { + *long_options[match].flag = long_options[match].val; + return (0); + } else + return (long_options[match].val); +#undef IDENTICAL_INTERPRETATION +} + +/* + * getopt_internal -- + * Parse argc/argv argument vector. Called by user level routines. + */ +static int +getopt_internal(int nargc, char * const *nargv, const char *options, + const option *long_options, int *idx, int flags) +{ + char *oli; /* option letter list index */ + int optchar, short_too; + static int posixly_correct = -1; + + if (options == NULL) + return (-1); + + /* + * XXX Some GNU programs (like cvs) set optind to 0 instead of + * XXX using optreset. Work around this braindamage. + */ + if (optind == 0) + optind = optreset = 1; + + /* + * Disable GNU extensions if POSIXLY_CORRECT is set or options + * string begins with a '+'. + * + * CV, 2009-12-14: Check POSIXLY_CORRECT anew if optind == 0 or + * optreset != 0 for GNU compatibility. + */ + if (posixly_correct == -1 || optreset != 0) + posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); + if (*options == '-') + flags |= FLAG_ALLARGS; + else if (posixly_correct || *options == '+') + flags &= ~FLAG_PERMUTE; + if (*options == '+' || *options == '-') + options++; + + optarg = NULL; + if (optreset) + nonopt_start = nonopt_end = -1; +start: + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc) { /* end of argument vector */ + place = EMSG; + if (nonopt_end != -1) { + /* do permutation, if we have to */ + permute_args(nonopt_start, nonopt_end, + optind, nargv); + optind -= nonopt_end - nonopt_start; + } + else if (nonopt_start != -1) { + /* + * If we skipped non-options, set optind + * to the first of them. + */ + optind = nonopt_start; + } + nonopt_start = nonopt_end = -1; + return (-1); + } + if (*(place = nargv[optind]) != '-' || + (place[1] == '\0' && strchr(options, '-') == NULL)) { + place = EMSG; /* found non-option */ + if (flags & FLAG_ALLARGS) { + /* + * GNU extension: + * return non-option as argument to option 1 + */ + optarg = nargv[optind++]; + return (INORDER); + } + if (!(flags & FLAG_PERMUTE)) { + /* + * If no permutation wanted, stop parsing + * at first non-option. + */ + return (-1); + } + /* do permutation */ + if (nonopt_start == -1) + nonopt_start = optind; + else if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, + optind, nargv); + nonopt_start = optind - + (nonopt_end - nonopt_start); + nonopt_end = -1; + } + optind++; + /* process next argument */ + goto start; + } + if (nonopt_start != -1 && nonopt_end == -1) + nonopt_end = optind; + + /* + * If we have "-" do nothing, if "--" we are done. + */ + if (place[1] != '\0' && *++place == '-' && place[1] == '\0') { + optind++; + place = EMSG; + /* + * We found an option (--), so if we skipped + * non-options, we have to permute. + */ + if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, + optind, nargv); + optind -= nonopt_end - nonopt_start; + } + nonopt_start = nonopt_end = -1; + return (-1); + } + } + + /* + * Check long options if: + * 1) we were passed some + * 2) the arg is not just "-" + * 3) either the arg starts with -- we are getopt_long_only() + */ + if (long_options != NULL && place != nargv[optind] && + (*place == '-' || (flags & FLAG_LONGONLY))) { + short_too = 0; + if (*place == '-') + place++; /* --foo long option */ + else if (*place != ':' && strchr(options, *place) != NULL) + short_too = 1; /* could be short option too */ + + optchar = parse_long_options(nargv, options, long_options, + idx, short_too); + if (optchar != -1) { + place = EMSG; + return (optchar); + } + } + + if ((optchar = (int)*place++) == (int)':' || + (optchar == (int)'-' && *place != '\0') || + (oli = (char*)strchr(options, optchar)) == NULL) { + /* + * If the user specified "-" and '-' isn't listed in + * options, return -1 (non-option) as per POSIX. + * Otherwise, it is an unknown option character (or ':'). + */ + if (optchar == (int)'-' && *place == '\0') + return (-1); + if (!*place) + ++optind; + if (PRINT_ERROR) + warnx(illoptchar, optchar); + optopt = optchar; + return (BADCH); + } + if (long_options != NULL && optchar == 'W' && oli[1] == ';') { + /* -W long-option */ + if (*place) /* no space */ + /* NOTHING */; + else if (++optind >= nargc) { /* no arg */ + place = EMSG; + if (PRINT_ERROR) + warnx(recargchar, optchar); + optopt = optchar; + return (BADARG); + } else /* white space */ + place = nargv[optind]; + optchar = parse_long_options(nargv, options, long_options, + idx, 0); + place = EMSG; + return (optchar); + } + if (*++oli != ':') { /* doesn't take argument */ + if (!*place) + ++optind; + } else { /* takes (optional) argument */ + optarg = NULL; + if (*place) /* no white space */ + optarg = place; + else if (oli[1] != ':') { /* arg not optional */ + if (++optind >= nargc) { /* no arg */ + place = EMSG; + if (PRINT_ERROR) + warnx(recargchar, optchar); + optopt = optchar; + return (BADARG); + } else + optarg = nargv[optind]; + } + place = EMSG; + ++optind; + } + /* dump back option letter */ + return (optchar); +} + +/* + * getopt_long -- + * Parse argc/argv argument vector. + */ +int +getopt_long(int nargc, char * const *nargv, const char *options, + const option *long_options, int *idx) +{ + + return (getopt_internal(nargc, nargv, options, long_options, idx, + FLAG_PERMUTE)); +} + +/* + * getopt_long_only -- + * Parse argc/argv argument vector. + */ +int +getopt_long_only(int nargc, char * const *nargv, const char *options, + const option *long_options, int *idx) +{ + + return (getopt_internal(nargc, nargv, options, long_options, idx, + FLAG_PERMUTE|FLAG_LONGONLY)); +} + +//extern int getopt_long(int nargc, char * const *nargv, const char *options, +// const struct option *long_options, int *idx); +//extern int getopt_long_only(int nargc, char * const *nargv, const char *options, +// const struct option *long_options, int *idx); +/* + * Previous MinGW implementation had... + */ +#ifndef HAVE_DECL_GETOPT +/* + * ...for the long form API only; keep this for compatibility. + */ +# define HAVE_DECL_GETOPT 1 +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */ diff --git a/rad10/pktriggercord-cli.cbproj b/rad10/pktriggercord-cli.cbproj new file mode 100644 index 0000000..771af1a --- /dev/null +++ b/rad10/pktriggercord-cli.cbproj @@ -0,0 +1,879 @@ + + + {C5A9556D-7961-4B90-A14C-45819CDF248D} + 18.5 + None + True + Release + Win32 + 3 + Console + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + $(BDS)\bin\default_app.manifest + JPHNE + .\$(Platform)\$(Config) + .\$(Platform)\$(Config) + false + true + $(BDSLIB)\$(PLATFORM)\release\$(LANGDIR);$(ILINK_TranslatedLibraryPath) + CppConsoleApplication + CloudService;emsclient;emsclientfiredac;FireDAC;FireDACCommon;FireDACCommonDriver;FireDACIBDriver;FireDACSqliteDriver;inet;RESTBackendComponents;RESTComponents;soapmidas;soaprtl;soapserver;$(PackageImports) + System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) + <_TCHARMapping>char + pktriggercord-cli + VERSION="1.0";$(Defines) + 1033 + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + GNU + 6 + true + false + ..\;..\src\external\js0n\;rad10\;src\external\js0n\;$(IncludePath) + ..\;..\src\external\js0n\;rad10\;src\external\js0n\;$(ILINK_LibraryPath) + RAD10;PKTDATADIR="";$(BCC_Defines) + + + adortl;appanalytics;bcbie;bcbsmp;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindengine;CustomIPTransport;DataSnapClient;DataSnapCommon;DataSnapConnectors;DatasnapConnectorsFreePascal;DataSnapFireDAC;DataSnapIndy10ServerTransport;DataSnapNativeClient;DataSnapProviderClient;DataSnapServer;DataSnapServerMidas;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXDb2Driver;DBXFirebirdDriver;DBXInformixDriver;DBXInterBaseDriver;DBXMSSQLDriver;DBXMySQLDriver;DBXOdbcDriver;DBXOracleDriver;DBXSqliteDriver;DBXSybaseASADriver;DBXSybaseASEDriver;dsnap;dsnapcon;dsnapxml;emsedge;emshosting;FireDACADSDriver;FireDACASADriver;FireDACCommonODBC;FireDACDb2Driver;FireDACDBXDriver;FireDACDSDriver;FireDACInfxDriver;FireDACMongoDBDriver;FireDACMSAccDriver;FireDACMSSQLDriver;FireDACMySQLDriver;FireDACODBCDriver;FireDACOracleDriver;FireDACPgDriver;FireDACTDataDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;FMXTee;FmxTeeUI;ibmonitor;ibxbindings;ibxpress;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inetdb;inetdbxpress;Intraweb;rtl;svn;Tee;TeeDB;TeeUI;tethering;vcl;vclactnband;vcldb;vcldsnap;vclFireDAC;vclib;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports) + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + Debug + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png + $(BDS)\bin\cbuilder_PROJECTICON.ico + + + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + adortl;appanalytics;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindengine;CustomIPTransport;DataSnapClient;DataSnapCommon;DataSnapConnectors;DatasnapConnectorsFreePascal;DataSnapFireDAC;DataSnapIndy10ServerTransport;DataSnapNativeClient;DataSnapProviderClient;DataSnapServer;DataSnapServerMidas;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXDb2Driver;DBXFirebirdDriver;DBXInformixDriver;DBXInterBaseDriver;DBXMSSQLDriver;DBXMySQLDriver;DBXOdbcDriver;DBXOracleDriver;DBXSqliteDriver;DBXSybaseASADriver;DBXSybaseASEDriver;dsnap;dsnapcon;dsnapxml;emsedge;emshosting;FireDACADSDriver;FireDACASADriver;FireDACCommonODBC;FireDACDb2Driver;FireDACDBXDriver;FireDACDSDriver;FireDACInfxDriver;FireDACMongoDBDriver;FireDACMSAccDriver;FireDACMSSQLDriver;FireDACMySQLDriver;FireDACODBCDriver;FireDACOracleDriver;FireDACPgDriver;FireDACTDataDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;FMXTee;FmxTeeUI;ibmonitor;ibxbindings;ibxpress;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inetdb;inetdbxpress;Intraweb;rtl;Tee;TeeDB;TeeUI;tethering;vcl;vclactnband;vcldb;vcldsnap;vclFireDAC;vclib;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports) + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png + Debug + $(BDS)\bin\cbuilder_PROJECTICON.ico + + + false + true + false + true + _DEBUG;$(Defines) + false + None + DEBUG + true + true + true + true + Full + true + true + true + true + true + $(BDSLIB)\$(PLATFORM)\debug;$(ILINK_LibraryPath) + $(BDSLIB)\$(PLATFORM)\debug\$(LANGDIR);$(ILINK_TranslatedLibraryPath) + + + (None) + -o ab + false + + + NDEBUG;$(Defines) + None + + + 341 + 22 + true + CompanyName=TDBware;FileDescription=Control your Pentax camera;FileVersion=1.22.0.341;InternalName=pktriggercord-cli;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=;ProductName=Raw2Jpeg;ProductVersion=1.22;Comments= + true + None + -o ab + + + -o ab + + + + 9 + + + 9 + + + 10 + + + 9 + + + 9 + + + 10 + + + 9 + + + 9 + + + 9 + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + + + + CPlusPlusBuilder.Personality.12 + CppConsoleApplication + + + + False + True + True + True + + + DBExpress Enterprise Data Explorer Integration + Embarcadero C++Builder Office 2000 Servers Package + Embarcadero C++Builder Office XP Servers Package + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + + + true + + + + + .\ + true + + + + + + true + + + + + + .\ + true + + + + + .\ + true + + + + + .\ + true + + + + + + .\ + true + + + + + + .\ + true + + + + + .\ + true + + + + + .\ + true + + + + + + true + + + + + true + + + + + .\ + true + + + + + true + + + + + true + + + + + + true + + + + + + .\ + true + + + + + true + + + + + .\ + true + + + + + true + + + + + true + + + + + + + + true + + + + + true + + + + + + true + + + + + + pktriggercord-cli.exe + true + + + + + .\ + true + + + + + .\ + true + + + + + true + + + + + .\ + true + + + + + + true + + + + + true + + + + + + true + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + .\ + true + + + + + .\ + true + + + + + true + + + + + + true + + + + + + + true + + + + + true + + + + + pktriggercord-cli.exe + true + + + + + true + + + + + true + + + + + .\ + true + + + + + 1 + + + 0 + + + + + classes + 1 + + + + + res\xml + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\armeabi + 1 + + + + + library\lib\mips + 1 + + + + + library\lib\x86 + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + res\drawable + 1 + + + + + res\values + 1 + + + + + res\values-v21 + 1 + + + + + res\drawable + 1 + + + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-ldpi + 1 + + + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + + + res\drawable-small + 1 + + + + + res\drawable-normal + 1 + + + + + res\drawable-large + 1 + + + + + res\drawable-xlarge + 1 + + + + + 1 + + + 1 + + + 0 + + + + + 1 + .framework + + + 1 + .framework + + + 0 + + + + + 1 + .dylib + + + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 0 + .bpl + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + + + + 1 + + + 1 + + + 1 + + + + + + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 0 + + + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + + + + + + + + + + + True + True + + + 12 + + + + + diff --git a/rad10/tdbtime.h b/rad10/tdbtime.h new file mode 100644 index 0000000..8ac8de3 --- /dev/null +++ b/rad10/tdbtime.h @@ -0,0 +1,7 @@ +#pragma once + +#ifndef _TDBTIMES_H + +#include "tdbtimes.h" + +#endif diff --git a/rad10/tdbtimes.c b/rad10/tdbtimes.c new file mode 100644 index 0000000..6321e3d --- /dev/null +++ b/rad10/tdbtimes.c @@ -0,0 +1,27 @@ +#include "tdbtimes.h" +#include + +int gettimeofday(struct timeval* t,void* timezone) +{ + struct timeb timebuffer; + ftime( &timebuffer ); + t->tv_sec=timebuffer.time; + t->tv_usec=1000*timebuffer.millitm; + return 0; +} + +clock_t times (struct tms *__buffer) { + + __buffer->tms_utime = clock(); + __buffer->tms_stime = 0; + __buffer->tms_cstime = 0; + __buffer->tms_cutime = 0; + return __buffer->tms_utime; +} + +void usleep(int secs) +{ + sleep(secs / 1000000); +} + + diff --git a/rad10/tdbtimes.h b/rad10/tdbtimes.h new file mode 100644 index 0000000..d32d9bc --- /dev/null +++ b/rad10/tdbtimes.h @@ -0,0 +1,39 @@ +#ifndef _TDBTIMES_H +#define _TDBTIMES_H + +#ifdef _WIN32 +#include +#include +#include + +int gettimeofday(struct timeval* t,void* timezone); +void usleep(int secs); + +// from linux's sys/times.h + +//#include + +#define __need_clock_t +#include + + +/* Structure describing CPU time used by a process and its children. */ +struct tms + { + clock_t tms_utime; /* User CPU time. */ + clock_t tms_stime; /* System CPU time. */ + + clock_t tms_cutime; /* User CPU time of dead children. */ + clock_t tms_cstime; /* System CPU time of dead children. */ + }; + +/* Store the CPU time used by this process and all its + dead children (and their dead children) in BUFFER. + Return the elapsed real time, or (clock_t) -1 for errors. + All times are in CLK_TCKths of a second. */ +clock_t times (struct tms *__buffer); + +typedef long long suseconds_t ; + +#endif +#endif