line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "ftpparse.h" |
2
|
|
|
|
|
|
|
#include "EXTERN.h" |
3
|
|
|
|
|
|
|
#include "perl.h" |
4
|
|
|
|
|
|
|
#include "XSUB.h" |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#include "ppport.h" |
7
|
|
|
|
|
|
|
#include |
8
|
|
|
|
|
|
|
#define MATH_INT64_NATIVE_IF_AVAILABLE |
9
|
|
|
|
|
|
|
#include "perl_math_int64.h" |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
MODULE = File::Listing::Ftpcopy PACKAGE = File::Listing::Ftpcopy |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BOOT: |
14
|
11
|
50
|
|
|
|
|
PERL_MATH_INT64_LOAD_OR_CROAK; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
SV * |
17
|
|
|
|
|
|
|
ftpparse(line) |
18
|
|
|
|
|
|
|
char *line; |
19
|
|
|
|
|
|
|
INIT: |
20
|
|
|
|
|
|
|
HV * result; |
21
|
|
|
|
|
|
|
struct ftpparse fp; |
22
|
|
|
|
|
|
|
int val; |
23
|
|
|
|
|
|
|
CODE: |
24
|
6
|
|
|
|
|
|
val = ftpparse(&fp, line, strlen(line), 0); |
25
|
6
|
100
|
|
|
|
|
if(val) |
26
|
|
|
|
|
|
|
{ |
27
|
5
|
|
|
|
|
|
result = newHV(); |
28
|
5
|
|
|
|
|
|
hv_store(result, "name", 4, newSVpv(fp.name,fp.namelen), 0); |
29
|
5
|
|
|
|
|
|
hv_store(result, "flagtrycwd", 10, newSViv(fp.flagtrycwd), 0); |
30
|
5
|
|
|
|
|
|
hv_store(result, "flagtryretr", 11, newSViv(fp.flagtryretr), 0); |
31
|
5
|
|
|
|
|
|
hv_store(result, "sizetype", 8, newSViv(fp.sizetype), 0); |
32
|
|
|
|
|
|
|
/* |
33
|
|
|
|
|
|
|
* If UV is 64 bit then store size as a UV, |
34
|
|
|
|
|
|
|
* otherwise use sprintf and store it as a string. |
35
|
|
|
|
|
|
|
* use PRIu64 which is c99, otherwise try %llu |
36
|
|
|
|
|
|
|
* and cross fingers that it is supported. |
37
|
|
|
|
|
|
|
*/ |
38
|
5
|
|
|
|
|
|
hv_store(result, "size", 4, newSVu64(fp.size), 0); |
39
|
5
|
|
|
|
|
|
hv_store(result, "mtimetype", 9, newSViv(fp.mtimetype), 0); |
40
|
|
|
|
|
|
|
/* |
41
|
|
|
|
|
|
|
* okay this is slightly silly, the TAI implementation |
42
|
|
|
|
|
|
|
* with ftpparse is converting from UNIX time to TAI but |
43
|
|
|
|
|
|
|
* it isn't consulting any leap second tables or anything |
44
|
|
|
|
|
|
|
* like that so it is sort of pointless. Since most Perl |
45
|
|
|
|
|
|
|
* programmers are likely to be dealing with the UNIX time |
46
|
|
|
|
|
|
|
* scale we will just quietly convert it back to UNIX time |
47
|
|
|
|
|
|
|
* (at least in so far as it was converted to TAI in the |
48
|
|
|
|
|
|
|
* first place). |
49
|
|
|
|
|
|
|
*/ |
50
|
5
|
|
|
|
|
|
hv_store(result, "mtime", 5, newSVu64(fp.mtime.x-4611686018427387914ULL), 0); |
51
|
5
|
|
|
|
|
|
hv_store(result, "idtype", 6, newSViv(fp.idtype), 0); |
52
|
5
|
|
|
|
|
|
hv_store(result, "id", 2, newSVpv(fp.id, fp.idlen), 0); |
53
|
5
|
|
|
|
|
|
hv_store(result, "format", 6, newSViv(fp.format), 0); |
54
|
5
|
|
|
|
|
|
hv_store(result, "flagbrokenmlsx", 14, newSViv(fp.flagbrokenmlsx), 0); |
55
|
5
|
100
|
|
|
|
|
if(fp.symlink != NULL) |
56
|
|
|
|
|
|
|
{ |
57
|
1
|
|
|
|
|
|
hv_store(result, "symlink", 7, newSVpv(fp.symlink, fp.symlinklen), 0); |
58
|
|
|
|
|
|
|
} |
59
|
5
|
|
|
|
|
|
RETVAL = newRV_noinc((SV*)result); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else |
62
|
|
|
|
|
|
|
{ |
63
|
1
|
|
|
|
|
|
XSRETURN_EMPTY; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
OUTPUT: |
66
|
|
|
|
|
|
|
RETVAL |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
SV * |
70
|
|
|
|
|
|
|
_parse_dir(line) |
71
|
|
|
|
|
|
|
char * line |
72
|
|
|
|
|
|
|
INIT: |
73
|
|
|
|
|
|
|
struct ftpparse fp; |
74
|
|
|
|
|
|
|
int val; |
75
|
|
|
|
|
|
|
AV * result; |
76
|
|
|
|
|
|
|
char *type; |
77
|
|
|
|
|
|
|
SV * size; |
78
|
|
|
|
|
|
|
SV * mtime; |
79
|
|
|
|
|
|
|
CODE: |
80
|
53
|
|
|
|
|
|
val = ftpparse(&fp, line, strlen(line), 0); |
81
|
53
|
100
|
|
|
|
|
if(val && !(fp.namelen == 1 && fp.name[0] == '.') && !(fp.namelen == 2 && fp.name[0] == '.' && fp.name[1] == '.')) |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
82
|
|
|
|
|
|
|
{ |
83
|
34
|
|
|
|
|
|
result = newAV(); |
84
|
34
|
|
|
|
|
|
av_push(result, newSVpv(fp.name,fp.namelen)); |
85
|
34
|
50
|
|
|
|
|
if(fp.symlink != NULL) |
86
|
|
|
|
|
|
|
type = "l"; |
87
|
34
|
100
|
|
|
|
|
else if(fp.flagtrycwd && !fp.flagtryretr) |
|
|
50
|
|
|
|
|
|
88
|
|
|
|
|
|
|
type = "d"; |
89
|
26
|
50
|
|
|
|
|
else if(!fp.flagtrycwd && fp.flagtryretr) |
|
|
50
|
|
|
|
|
|
90
|
|
|
|
|
|
|
type = "f"; |
91
|
|
|
|
|
|
|
else |
92
|
|
|
|
|
|
|
type = "?"; |
93
|
34
|
|
|
|
|
|
av_push(result, newSVpv(type, 1)); |
94
|
34
|
100
|
|
|
|
|
if(fp.sizetype == FTPPARSE_SIZE_UNKNOWN) |
95
|
|
|
|
|
|
|
{ |
96
|
4
|
|
|
|
|
|
size = newSV(0); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
else |
99
|
|
|
|
|
|
|
{ |
100
|
30
|
|
|
|
|
|
size = newSVu64(fp.size); |
101
|
|
|
|
|
|
|
} |
102
|
34
|
|
|
|
|
|
av_push(result, size); |
103
|
34
|
50
|
|
|
|
|
if(fp.mtimetype == FTPPARSE_MTIME_UNKNOWN) |
104
|
|
|
|
|
|
|
{ |
105
|
0
|
|
|
|
|
|
mtime = newSV(0); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
else |
108
|
|
|
|
|
|
|
{ |
109
|
34
|
|
|
|
|
|
mtime = newSVu64(fp.mtime.x-4611686018427387914ULL); |
110
|
|
|
|
|
|
|
} |
111
|
34
|
|
|
|
|
|
av_push(result, mtime); |
112
|
34
|
|
|
|
|
|
av_push(result, newSV(0)); |
113
|
34
|
|
|
|
|
|
av_push(result, newSViv(fp.mtimetype)); |
114
|
34
|
|
|
|
|
|
RETVAL = newRV_noinc((SV*)result); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
else |
117
|
|
|
|
|
|
|
{ |
118
|
19
|
|
|
|
|
|
XSRETURN_EMPTY; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
OUTPUT: |
121
|
|
|
|
|
|
|
RETVAL |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
int |
125
|
|
|
|
|
|
|
_return42() |
126
|
|
|
|
|
|
|
CODE: |
127
|
|
|
|
|
|
|
RETVAL = (10*4+2); |
128
|
|
|
|
|
|
|
OUTPUT: |
129
|
|
|
|
|
|
|
RETVAL |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
int |
132
|
|
|
|
|
|
|
_size_of_UV() |
133
|
|
|
|
|
|
|
CODE: |
134
|
|
|
|
|
|
|
RETVAL = sizeof(UV); |
135
|
|
|
|
|
|
|
OUTPUT: |
136
|
|
|
|
|
|
|
RETVAL |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
int |
139
|
|
|
|
|
|
|
_constant(name) |
140
|
|
|
|
|
|
|
char *name |
141
|
|
|
|
|
|
|
CODE: |
142
|
27
|
100
|
|
|
|
|
if(!strcmp(name, "FORMAT_EPLF")) |
143
|
|
|
|
|
|
|
RETVAL = FTPPARSE_FORMAT_EPLF; |
144
|
26
|
100
|
|
|
|
|
else if(!strcmp(name, "FORMAT_LS")) |
145
|
|
|
|
|
|
|
RETVAL = FTPPARSE_FORMAT_LS; |
146
|
25
|
100
|
|
|
|
|
else if(!strcmp(name, "FORMAT_MLSX")) |
147
|
|
|
|
|
|
|
RETVAL = FTPPARSE_FORMAT_MLSX; |
148
|
24
|
100
|
|
|
|
|
else if(!strcmp(name, "FORMAT_UNKNOWN")) |
149
|
|
|
|
|
|
|
RETVAL = FTPPARSE_FORMAT_UNKNOWN; |
150
|
23
|
100
|
|
|
|
|
else if(!strcmp(name, "ID_FULL")) |
151
|
|
|
|
|
|
|
RETVAL = FTPPARSE_ID_FULL; |
152
|
22
|
100
|
|
|
|
|
else if(!strcmp(name, "ID_UNKNOWN")) |
153
|
|
|
|
|
|
|
RETVAL = FTPPARSE_ID_UNKNOWN; |
154
|
21
|
100
|
|
|
|
|
else if(!strcmp(name, "MTIME_LOCAL")) |
155
|
|
|
|
|
|
|
RETVAL = FTPPARSE_MTIME_LOCAL; |
156
|
15
|
100
|
|
|
|
|
else if(!strcmp(name, "MTIME_REMOTEDAY")) |
157
|
|
|
|
|
|
|
RETVAL = FTPPARSE_MTIME_REMOTEDAY; |
158
|
13
|
100
|
|
|
|
|
else if(!strcmp(name, "MTIME_REMOTEMINUTE")) |
159
|
|
|
|
|
|
|
RETVAL = FTPPARSE_MTIME_REMOTEMINUTE; |
160
|
7
|
100
|
|
|
|
|
else if(!strcmp(name, "MTIME_REMOTESECOND")) |
161
|
|
|
|
|
|
|
RETVAL = FTPPARSE_MTIME_REMOTESECOND; |
162
|
6
|
100
|
|
|
|
|
else if(!strcmp(name, "MTIME_UNKNOWN")) |
163
|
|
|
|
|
|
|
RETVAL = FTPPARSE_MTIME_UNKNOWN; |
164
|
5
|
100
|
|
|
|
|
else if(!strcmp(name, "SIZE_ASCII")) |
165
|
|
|
|
|
|
|
RETVAL = FTPPARSE_SIZE_ASCII; |
166
|
4
|
100
|
|
|
|
|
else if(!strcmp(name, "SIZE_BINARY")) |
167
|
|
|
|
|
|
|
RETVAL = FTPPARSE_SIZE_BINARY; |
168
|
2
|
50
|
|
|
|
|
else if(!strcmp(name, "SIZE_UNKNOWN")) |
169
|
|
|
|
|
|
|
RETVAL = FTPPARSE_SIZE_UNKNOWN; |
170
|
|
|
|
|
|
|
else |
171
|
|
|
|
|
|
|
RETVAL = -1; |
172
|
|
|
|
|
|
|
OUTPUT: |
173
|
|
|
|
|
|
|
RETVAL |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
SV * |
177
|
|
|
|
|
|
|
_tai_now() |
178
|
|
|
|
|
|
|
INIT: |
179
|
|
|
|
|
|
|
SV *result; |
180
|
|
|
|
|
|
|
struct tai to; |
181
|
|
|
|
|
|
|
char b[21]; |
182
|
|
|
|
|
|
|
CODE: |
183
|
0
|
|
|
|
|
|
tai_now(&to); |
184
|
|
|
|
|
|
|
#ifdef PRIu64 |
185
|
0
|
|
|
|
|
|
sprintf(b, "%"PRIu64,to.x); |
186
|
|
|
|
|
|
|
#else |
187
|
|
|
|
|
|
|
sprintf(b, "%llu",to.x); |
188
|
|
|
|
|
|
|
#endif |
189
|
0
|
|
|
|
|
|
result = newSVpv(b,0); |
190
|
0
|
|
|
|
|
|
RETVAL = newRV_noinc(result); |
191
|
|
|
|
|
|
|
OUTPUT: |
192
|
|
|
|
|
|
|
RETVAL |
193
|
|
|
|
|
|
|
|