Skip to content

Commit c7323fe

Browse files
FrankBijnenasalamon74
authored andcommitted
Make pktriggercord-cli compile on Windows using RAD Studio 10.3 (asalamon74#47)
1 parent f9e23ed commit c7323fe

14 files changed

+1677
-7
lines changed

Changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
version 0.85.01
2+
RAD10 compilation (thx FrankBijnen)
23
Exposure mode conversion bugfix (thx blemasle)
34
Testing status reader for KP
45
Settings reading for K5II (thx blemasle)

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ MANS = pktriggercord-cli.1 pktriggercord.1
4545
SRCOBJNAMES = pslr pslr_enum pslr_scsi pslr_lens pslr_model pktriggercord-servermode
4646
OBJS = $(SRCOBJNAMES:=.o) $(JSONDIR)/js0n.o
4747
WIN_DLLS_DIR=win_dlls
48-
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/
48+
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/
4949
TARDIR = pktriggercord-$(VERSION)
5050
SRCZIP = pkTriggerCord-$(VERSION).src.tar.gz
5151

pktriggercord-cli.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,21 @@
3232
#include <stdlib.h>
3333
#include <stdint.h>
3434
#include <stdio.h>
35+
#ifdef RAD10
36+
#include <utime.h>
37+
#include <io.h>
38+
#include "tdbtimes.h"
39+
#include "getopt.h"
40+
#else
3541
#include <unistd.h>
3642
#include <getopt.h>
43+
#include <sys/time.h>
44+
#endif
3745
#include <fcntl.h>
3846
#include <ctype.h>
3947
#include <time.h>
4048
#include <stdarg.h>
4149
#include <math.h>
42-
#include <sys/time.h>
4350

4451
#include "pslr.h"
4552
#include "pktriggercord-servermode.h"
@@ -61,7 +68,11 @@ bool astrotracer_before=false;
6168
bool need_bulb_new_cleanup=false;
6269
bool need_one_push_bracketing_cleanup=false;
6370

71+
#ifdef RAD10
72+
static option const longopts[] = {
73+
#else
6474
static struct option const longopts[] = {
75+
#endif
6576
{"exposure_mode", required_argument, NULL, 'm'},
6677
{"resolution", required_argument, NULL, 'r'},
6778
{"quality", required_argument, NULL, 'q'},

pktriggercord-servermode.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,23 @@
2626
and GNU Lesser General Public License
2727
along with this program. If not, see <http://www.gnu.org/licenses/>.
2828
*/
29+
#ifdef RAD10
30+
#include <windows.h>
31+
#include <utime.h>
32+
#include "tdbtimes.h"
33+
#else
34+
#include <sys/time.h>
35+
#include <unistd.h>
36+
#endif
2937
#ifndef WIN32
3038
#include <sys/socket.h>
3139
#include <arpa/inet.h>
3240
#include <netinet/in.h>
3341
#endif
3442

3543
#include <stdio.h>
36-
#include <sys/time.h>
3744
#include <stdlib.h>
3845

39-
#include <unistd.h>
4046

4147
#include "pslr.h"
4248
#include "pslr_lens.h"

pslr.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@
4141
#include <fcntl.h>
4242
#include <stdlib.h>
4343
#include <signal.h>
44+
#ifdef RAD10
45+
#include <windows.h>
46+
#include <utime.h>
47+
#include "tdbtime.h"
48+
#else
4449
#include <unistd.h>
50+
#endif
4551
#include <stdbool.h>
4652
#include <stdarg.h>
4753
#include <dirent.h>

pslr_model.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@
3939
#include <string.h>
4040
#include <stdbool.h>
4141
#include <fcntl.h>
42+
#ifndef RAD10
4243
#include <unistd.h>
44+
#endif
4345
#include "js0n.h"
46+
#include <sys/types.h>
47+
#include <sys/stat.h>
4448

4549
#include "pslr_model.h"
4650
#include "pslr.h"
@@ -50,6 +54,16 @@ static int first = 1;
5054
static char *jsontext=NULL;
5155
static int jsonsize;
5256

57+
static int dir_exists(char *dir) {
58+
int res = 0;
59+
struct stat info;
60+
61+
if ( (stat(dir, &info) == 0) && (info.st_mode & S_IFDIR) ) {
62+
res = 1;
63+
}
64+
return res;
65+
}
66+
5367
static void ipslr_status_diff(uint8_t *buf) {
5468
int n;
5569
int diffs;
@@ -779,7 +793,9 @@ char *read_json_file(int *jsonsize) {
779793
int jsonfd = open("pentax_settings.json", O_RDONLY);
780794
if (jsonfd == -1) {
781795
// cannot find in the current directory, also checking PKTDATADIR
782-
jsonfd = open(PKTDATADIR "/pentax_settings.json", O_RDONLY);
796+
if (dir_exists(PKTDATADIR)) {
797+
jsonfd = open(PKTDATADIR "/pentax_settings.json", O_RDONLY);
798+
}
783799
if (jsonfd == -1) {
784800
fprintf(stderr, "Cannot open pentax_settings.json file\n");
785801
return NULL;

pslr_scsi.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
and GNU Lesser General Public License
2424
along with this program. If not, see <http://www.gnu.org/licenses/>.
2525
*/
26-
27-
#ifdef WIN32
26+
#if defined(WIN32) || defined(RAD10)
2827
#include "pslr_scsi_win.c"
2928
#else
3029
/* Ugly hack. More generic ifs required */

pslr_scsi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
extern bool debug;
3636
extern void write_debug( const char* message, ... );
3737

38+
#ifdef RAD10
39+
#include <windows.h>
40+
#endif
3841
#ifdef ANDROID
3942
#include <android/log.h>
4043
#define DPRINT(...) __android_log_print(ANDROID_LOG_DEBUG, "PkTriggerCord", __VA_ARGS__)

pslr_scsi_win.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ char **get_drives(int *driveNum) {
6868
int driveLetter;
6969
int j=0;
7070
for ( driveLetter = 'C'; driveLetter<='Z'; ++driveLetter ) {
71+
#ifdef RAD10
72+
// These Drive types cant be a Pentax. The RAD10 debugger breaks here.
73+
TCHAR root[4];
74+
snprintf(root, 4, "%c:\\", driveLetter);
75+
switch (GetDriveType(root)) {
76+
case DRIVE_UNKNOWN:
77+
case DRIVE_NO_ROOT_DIR:
78+
case DRIVE_FIXED:
79+
case DRIVE_REMOTE:
80+
case DRIVE_CDROM:
81+
continue;
82+
default:
83+
;
84+
}
85+
#endif
7186
ret[j] = malloc( 2 * sizeof (char) );
7287
snprintf(ret[j], 2, "%c", driveLetter);
7388
++j;

0 commit comments

Comments
 (0)