Skip to content

Commit a08b1c8

Browse files
committed
update scp.c to work in mingw compiler for win32
1 parent 68677bb commit a08b1c8

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

scp.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ typedef BOOL bool;
164164
char *win32colon(char *);
165165
#define colon win32colon
166166

167+
#ifndef _SH_DENYNO
168+
#define _SH_DENYNO 0x40
169+
#endif
170+
167171
#define HAVE_UTIME_H
168172

169173
#ifdef HAVE_UTIME_H
@@ -324,25 +328,27 @@ typedef struct {
324328

325329
char * fixslashes(char * str)
326330
{
331+
int i;
327332
if (str == NULL)
328333
return str;
329334

330335
int len = (int)strlen(str);
331336

332-
for (int i = 0; i < len; i++)
337+
for (i = 0; i < len; i++)
333338
if (str[i] == '/')
334339
str[i] = '\\';
335340
return str;
336341
}
337342

338343
char * unfixslashes(char * str)
339344
{
345+
int i;
340346
if (str == NULL)
341347
return str;
342348

343349
int len = (int)strlen(str);
344350

345-
for (int i = 0; i < len; i++)
351+
for (i = 0; i < len; i++)
346352
if (str[i] == '//')
347353
str[i] = '/';
348354
return str;
@@ -351,6 +357,7 @@ char * unfixslashes(char * str)
351357
// force path separator to
352358
char * forcepathsep(char * str, char sep)
353359
{
360+
int i;
354361
// bail if str is null;
355362
if (str == NULL)
356363
return str;
@@ -367,7 +374,7 @@ char * forcepathsep(char * str, char sep)
367374

368375
int len = (int)strlen(str);
369376

370-
for (int i = 0; i < len; i++)
377+
for (i = 0; i < len; i++)
371378
if (str[i] == antisep)
372379
str[i] = sep;
373380
return str;
@@ -1023,7 +1030,12 @@ int pflag, iamremote, iamrecursive, targetshouldbedirectory;
10231030
char cmd[CMDNEEDS]; /* must hold "rcp -r -p -d\0" */
10241031

10251032
int response(void);
1033+
#ifdef WIN32_FIXME
1034+
void rsource(char *, struct _stati64 *);
1035+
#else
10261036
void rsource(char *, struct stat *);
1037+
#endif
1038+
10271039
void sink(int, char *[]);
10281040
void source(int, char *[]);
10291041
void tolocal(int, char *[]);
@@ -1503,9 +1515,7 @@ source(int argc, char *argv[])
15031515
continue;
15041516
}
15051517

1506-
15071518
if (_sopen_s(&fd, name, O_RDONLY | O_BINARY, _SH_DENYNO, 0) != 0) {
1508-
15091519
// in NT, we have to check if it is a directory
15101520
if (_stati64(name, &stb) >= 0) {
15111521
goto switchpoint;
@@ -1673,10 +1683,10 @@ next: if (fd != -1) (void)_close(fd);
16731683
}
16741684
(void)response();
16751685
}
1676-
1686+
int ii;
16771687
if (numfiles > 0)
1678-
for (int i = 0;i<numfiles;i++)
1679-
free(filenames[i]);
1688+
for (ii = 0;ii<numfiles;ii++)
1689+
free(filenames[ii]);
16801690
}
16811691

16821692
void rsource(char *name, struct _stati64 *statp)
@@ -1773,7 +1783,8 @@ void sink(int argc, char *argv[])
17731783
run_err("ambiguous target");
17741784
exit(1);
17751785
}
1776-
for (int i = 0; i<argc; i++)
1786+
int i;
1787+
for (i = 0; i<argc; i++)
17771788
{
17781789
if (i != 0)
17791790
strcat_s(aggregatePath,MAX_PATH," ");

0 commit comments

Comments
 (0)