1
2
3
4
5
6
7 #ifndef MC__VFS_SHELL_DEF_H
8 #define MC__VFS_SHELL_DEF_H
9
10
11
12
13 #define VFS_SHELL_LS_DEF_CONTENT "" \
14 "export LC_TIME=C\n" \
15 "ls -Qlan \"/${SHELL_FILENAME}\" 2>/dev/null | grep '^[^cbt]' | (\n" \
16 "while read p l u g s m d y n; do\n" \
17 " echo \"P$p $u.$g\"\n" \
18 " echo \"S$s\"\n" \
19 " echo \"d$m $d $y\"\n" \
20 " echo \":$n\"\n" \
21 " echo\n" \
22 "done\n" \
23 ")\n" \
24 "ls -Qlan \"/${SHELL_FILENAME}\" 2>/dev/null | grep '^[cb]' | (\n" \
25 "while read p l u g a i m d y n; do\n" \
26 " echo \"P$p $u.$g\"\n" \
27 " echo \"E$a$i\"\n" \
28 " echo \"d$m $d $y\"\n" \
29 " echo \":$n\"\n" \
30 " echo\n" \
31 "done\n" \
32 ")\n" \
33 "echo \"### 200\"\n"
34
35
36 #define VFS_SHELL_EXISTS_DEF_CONTENT "" \
37 "ls -l \"/${SHELL_FILENAME}\" >/dev/null 2>/dev/null\n" \
38 "echo '### '$?\n"
39
40
41 #define VFS_SHELL_MKDIR_DEF_CONTENT "" \
42 "if mkdir \"/${SHELL_FILENAME}\" 2>/dev/null; then\n" \
43 " echo \"### 000\"\n" \
44 "else\n" \
45 " echo \"### 500\"\n" \
46 "fi\n"
47
48
49 #define VFS_SHELL_UNLINK_DEF_CONTENT "" \
50 "if rm -f \"/${SHELL_FILENAME}\" 2>/dev/null; then\n" \
51 " echo \"### 000\"\n" \
52 "else\n" \
53 " echo \"### 500\"\n" \
54 "fi\n"
55
56
57 #define VFS_SHELL_CHOWN_DEF_CONTENT "" \
58 "if chown ${SHELL_FILEOWNER}:${SHELL_FILEGROUP} \"/${SHELL_FILENAME}\"; then\n" \
59 " echo \"### 000\"\n" \
60 "else\n" \
61 " echo \"### 500\"\n" \
62 "fi\n"
63
64
65 #define VFS_SHELL_CHMOD_DEF_CONTENT "" \
66 "if chmod ${SHELL_FILEMODE} \"/${SHELL_FILENAME}\" 2>/dev/null; then\n" \
67 " echo \"### 000\"\n" \
68 "else\n" \
69 " echo \"### 500\"\n" \
70 "fi\n"
71
72
73 #define VFS_SHELL_UTIME_DEF_CONTENT "" \
74 "#UTIME \"$SHELL_TOUCHATIME_W_NSEC\" \"$SHELL_TOUCHMTIME_W_NSEC\" $SHELL_FILENAME\n" \
75 "if TZ=UTC touch -h -m -d \"$SHELL_TOUCHMTIME_W_NSEC\" \"/${SHELL_FILENAME}\" 2>/dev/null && \\\n" \
76 " TZ=UTC touch -h -a -d \"$SHELL_TOUCHATIME_W_NSEC\" \"/${SHELL_FILENAME}\" 2>/dev/null; then\n" \
77 " echo \"### 000\"\n" \
78 "elif TZ=UTC touch -h -m -t $SHELL_TOUCHMTIME \"/${SHELL_FILENAME}\" 2>/dev/null && \\\n" \
79 " TZ=UTC touch -h -a -t $SHELL_TOUCHATIME \"/${SHELL_FILENAME}\" 2>/dev/null; then\n" \
80 " echo \"### 000\"\n" \
81 "elif [ -n \"$SHELL_HAVE_PERL\" ] && \\\n" \
82 " perl -e 'utime '$SHELL_FILEATIME','$SHELL_FILEMTIME',@ARGV;' \"/${SHELL_FILENAME}\" 2>/dev/null; then\n" \
83 " echo \"### 000\"\n" \
84 "else\n" \
85 " echo \"### 500\"\n" \
86 "fi\n"
87
88
89 #define VFS_SHELL_RMDIR_DEF_CONTENT "" \
90 "if rmdir \"/${SHELL_FILENAME}\" 2>/dev/null; then\n" \
91 " echo \"### 000\"\n" \
92 "else\n" \
93 " echo \"### 500\"\n" \
94 "fi\n"
95
96
97 #define VFS_SHELL_LN_DEF_CONTENT "" \
98 "if ln -s \"/${SHELL_FILEFROM}\" \"/${SHELL_FILETO}\" 2>/dev/null; then\n" \
99 " echo \"### 000\"\n" \
100 "else\n" \
101 " echo \"### 500\"\n" \
102 "fi\n"
103
104
105 #define VFS_SHELL_MV_DEF_CONTENT "" \
106 "if mv \"/${SHELL_FILEFROM}\" \"/${SHELL_FILETO}\" 2>/dev/null; then\n" \
107 " echo \"### 000\"\n" \
108 "else\n" \
109 " echo \"### 500\"\n" \
110 "fi\n"
111
112
113 #define VFS_SHELL_HARDLINK_DEF_CONTENT "" \
114 "if ln \"/${SHELL_FILEFROM}\" \"/${SHELL_FILETO}\" 2>/dev/null; then\n" \
115 " echo \"### 000\"\n" \
116 "else\n" \
117 " echo \"### 500\"\n" \
118 "fi\n"
119
120
121 #define VFS_SHELL_GET_DEF_CONTENT "" \
122 "export LC_TIME=C\n" \
123 "if dd if=\"/${SHELL_FILENAME}\" of=/dev/null bs=1 count=1 2>/dev/null ; then\n" \
124 " ls -ln \"/${SHELL_FILENAME}\" 2>/dev/null | (\n" \
125 " read p l u g s r\n" \
126 " echo $s\n" \
127 " )\n" \
128 " echo \"### 100\"\n" \
129 " cat \"/${SHELL_FILENAME}\"\n" \
130 " echo \"### 200\"\n" \
131 "else\n" \
132 " echo \"### 500\"\n" \
133 "fi\n"
134
135
136 #define VFS_SHELL_SEND_DEF_CONTENT "" \
137 "FILENAME=\"/${SHELL_FILENAME}\"\n" \
138 "FILESIZE=${SHELL_FILESIZE}\n" \
139 "echo \"### 001\"\n" \
140 "{\n" \
141 " while [ $FILESIZE -gt 0 ]; do\n" \
142 " cnt=`expr \\( $FILESIZE + 255 \\) / 256`\n" \
143 " n=`dd bs=256 count=$cnt | tee -a \"${FILENAME}\" | wc -c`\n" \
144 " FILESIZE=`expr $FILESIZE - $n`\n" \
145 " done\n" \
146 "}; echo \"### 200\"\n"
147
148
149 #define VFS_SHELL_APPEND_DEF_CONTENT "" \
150 "FILENAME=\"/${SHELL_FILENAME}\"\n" \
151 "FILESIZE=${SHELL_FILESIZE}\n" \
152 "echo \"### 001\"\n" \
153 "res=`exec 3>&1\n" \
154 "(\n" \
155 " head -c $FILESIZE -q - || echo DD >&3\n" \
156 ") 2>/dev/null | (\n" \
157 " cat > \"${FILENAME}\"\n" \
158 " cat > /dev/null\n" \
159 ")`; [ \"$res\" = DD ] && {\n" \
160 " > \"${FILENAME}\"\n" \
161 " while [ $FILESIZE -gt 0 ]\n" \
162 " do\n" \
163 " cnt=`expr \\( $FILESIZE + 255 \\) / 256`\n" \
164 " n=`dd bs=256 count=$cnt | tee -a \"${FILENAME}\" | wc -c`\n" \
165 " FILESIZE=`expr $FILESIZE - $n`\n" \
166 " done\n" \
167 "}; echo \"### 200\"\n"
168
169
170 #define VFS_SHELL_INFO_DEF_CONTENT "" \
171 "export LC_TIME=C\n" \
172 "#SHELL_HAVE_HEAD 1\n" \
173 "#SHELL_HAVE_SED 2\n" \
174 "#SHELL_HAVE_AWK 4\n" \
175 "#SHELL_HAVE_PERL 8\n" \
176 "#SHELL_HAVE_LSQ 16\n" \
177 "#SHELL_HAVE_DATE_MDYT 32\n" \
178 "#SHELL_HAVE_TAIL 64\n" \
179 "res=0\n" \
180 "if `echo yes| head -c 1 > /dev/null 2>&1` ; then\n" \
181 " res=`expr $res + 1`\n" \
182 "fi\n" \
183 "if `sed --version >/dev/null 2>&1` ; then\n" \
184 " res=`expr $res + 2`\n" \
185 "fi\n" \
186 "if `awk --version > /dev/null 2>&1` ; then\n" \
187 " res=`expr $res + 4`\n" \
188 "fi\n" \
189 "if `perl -v > /dev/null 2>&1` ; then\n" \
190 " res=`expr $res + 8`\n" \
191 "fi\n" \
192 "if `ls -Q / >/dev/null 2>&1` ; then\n" \
193 " res=`expr $res + 16`\n" \
194 "fi\n" \
195 "dat=`ls -lan / 2>/dev/null | head -n 3 | tail -1 | (\n" \
196 " while read p l u g s rec; do\n" \
197 " if [ -n \"$g\" ]; then\n" \
198 " if [ -n \"$l\" ]; then\n" \
199 " echo \"$rec\"\n" \
200 " fi\n" \
201 " fi\n" \
202 " done\n" \
203 ") | cut -c1 2>/dev/null`\n" \
204 "r=`echo \"0123456789\"| grep \"$dat\"`\n" \
205 "if [ -z \"$r\" ]; then\n" \
206 " res=`expr $res + 32`\n" \
207 "fi\n" \
208 "if `echo yes| tail -c +1 - > /dev/null 2>&1` ; then\n" \
209 " res=`expr $res + 64`\n" \
210 "fi\n" \
211 "echo $res\n" \
212 "echo \"### 200\"\n"
213
214
215
216
217
218
219
220
221
222
223
224 #endif