Changed interface of function mc_symlink()
[midnight-commander.git] / src / vfs / fish / fishdef.h
blobc9761e3635b60e7aceb288d06850fb577cb48554
2 /**
3 * \file
4 * \brief Header: FISH script defaults
5 */
7 #ifndef MC__FISH_DEF_H
8 #define MC__FISH_DEF_H
10 /*** typedefs(not structures) and defined constants **********************************************/
12 /* default 'ls' script */
13 #define FISH_LS_DEF_CONTENT "" \
14 "#LIST /${FISH_FILENAME}\n" \
15 "export LC_TIME=C\n" \
16 "ls -Qlan \"/${FISH_FILENAME}\" 2>/dev/null | grep '^[^cbt]' | (\n" \
17 "while read p l u g s m d y n; do\n" \
18 " echo \"P$p $u.$g\"\n" \
19 " echo \"S$s\"\n" \
20 " echo \"d$m $d $y\"\n" \
21 " echo \":$n\"\n" \
22 " echo\n" \
23 "done\n" \
24 ")\n" \
25 "ls -Qlan \"/${FISH_FILENAME}\" 2>/dev/null | grep '^[cb]' | (\n" \
26 "while read p l u g a i m d y n; do\n" \
27 " echo \"P$p $u.$g\"\n" \
28 " echo \"E$a$i\"\n" \
29 " echo \"d$m $d $y\"\n" \
30 " echo \":$n\"\n" \
31 " echo\n" \
32 "done\n" \
33 ")\n" \
34 "echo \"### 200\"\n"
36 /* default file exisits script */
37 #define FISH_EXISTS_DEF_CONTENT "" \
38 "#ISEXISTS $FISH_FILENAME\n" \
39 "ls -l \"/${FISH_FILENAME}\" >/dev/null 2>/dev/null\n" \
40 "echo '### '$?\n"
42 /* default 'mkdir' script */
43 #define FISH_MKDIR_DEF_CONTENT "" \
44 "#MKD $FISH_FILENAME\n" \
45 "if mkdir \"/${FISH_FILENAME}\" 2>/dev/null; then\n" \
46 " echo \"### 000\"\n" \
47 "else\n" \
48 " echo \"### 500\"\n" \
49 "fi\n"
51 /* default 'unlink' script */
52 #define FISH_UNLINK_DEF_CONTENT "" \
53 "#DELE $FISH_FILENAME\n" \
54 "if rm -f \"/${FISH_FILENAME}\" 2>/dev/null; then\n" \
55 " echo \"### 000\"\n" \
56 "else\n" \
57 " echo \"### 500\"\n" \
58 "fi\n"
59 /* default 'chown' script */
60 #define FISH_CHOWN_DEF_CONTENT "" \
61 "#CHOWN $FISH_FILEOWNER:$FISH_FILEGROUP $FISH_FILENAME\n" \
62 "if chown ${FISH_FILEOWNER}:${FISH_FILEGROUP} \"/${FISH_FILENAME}\"; then\n"\
63 " echo \"### 000\"\n" \
64 "else\n" \
65 " echo \"### 500\"\n" \
66 "fi\n"
68 /* default 'chmod' script */
69 #define FISH_CHMOD_DEF_CONTENT "" \
70 "#CHMOD $FISH_FILEMODE $FISH_FILENAME\n" \
71 "if chmod ${FISH_FILEMODE} \"/${FISH_FILENAME}\" 2>/dev/null; then\n" \
72 " echo \"### 000\"\n" \
73 "else\n" \
74 " echo \"### 500\"\n" \
75 "fi\n"
77 /* default 'utime' script */
78 #define FISH_UTIME_DEF_CONTENT "" \
79 "#UTIME $FISH_FILEATIME $FISH_FILEMTIME $FISH_FILENAME\n" \
80 "if [ -n \"$FISH_HAVE_PERL\" ] && \\\n" \
81 " perl -e 'utime '$FISH_FILEATIME','$FISH_FILEMTIME',@ARGV;' \"/${FISH_FILENAME}\" 2>/dev/null; then\n" \
82 " echo \"### 000\"\n" \
83 "elif TZ=UTC touch -m -t $FISH_TOUCHMTIME \"/${FISH_FILENAME}\" 2>/dev/null && \\\n" \
84 " TZ=UTC touch -a -t $FISH_TOUCHATIME \"/${FISH_FILENAME}\" 2>/dev/null; then\n" \
85 " echo \"### 000\"\n" \
86 "else\n" \
87 " echo \"### 500\"\n" \
88 "fi\n"
90 /* default 'rmdir' script */
91 #define FISH_RMDIR_DEF_CONTENT "" \
92 "#RMD $FISH_FILENAME\n" \
93 "if rmdir \"/${FISH_FILENAME}\" 2>/dev/null; then\n" \
94 " echo \"### 000\"\n" \
95 "else\n" \
96 " echo \"### 500\"\n" \
97 "fi\n"
99 /* default 'ln -s' symlink script */
100 #define FISH_LN_DEF_CONTENT "" \
101 "#SYMLINK $FISH_FILEFROM $FISH_FILETO\n" \
102 "if ln -s \"/${FISH_FILEFROM}\" \"/${FISH_FILETO}\" 2>/dev/null; then\n" \
103 " echo \"### 000\"\n" \
104 "else\n" \
105 " echo \"### 500\"\n" \
106 "fi\n"
108 /* default 'mv' script */
109 #define FISH_MV_DEF_CONTENT "" \
110 "#RENAME $FISH_FILEFROM $FISH_FILETO\n" \
111 "if mv \"/${FISH_FILEFROM}\" \"/${FISH_FILETO}\" 2>/dev/null; then\n" \
112 " echo \"### 000\"\n" \
113 "else\n" \
114 " echo \"### 500\"\n" \
115 "fi\n"
117 /* default 'ln' hardlink script */
118 #define FISH_HARDLINK_DEF_CONTENT "" \
119 "#LINK $FISH_FILEFROM $FISH_FILETO\n" \
120 "if ln \"/${FISH_FILEFROM}\" \"/${FISH_FILETO}\" 2>/dev/null; then\n" \
121 " echo \"### 000\"\n" \
122 "else\n" \
123 " echo \"### 500\"\n" \
124 "fi\n"
126 /* default 'retr' script */
127 #define FISH_GET_DEF_CONTENT "" \
128 "export LC_TIME=C\n" \
129 "#RETR $FISH_FILENAME\n" \
130 "if dd if=\"/${FISH_FILENAME}\" of=/dev/null bs=1 count=1 2>/dev/null ; then\n" \
131 " ls -ln \"/${FISH_FILENAME}\" 2>/dev/null | (\n" \
132 " read p l u g s r\n" \
133 " echo $s\n" \
134 " )\n" \
135 " echo \"### 100\"\n" \
136 " cat \"/${FISH_FILENAME}\"\n" \
137 " echo \"### 200\"\n" \
138 "else\n" \
139 " echo \"### 500\"\n" \
140 "fi\n"
142 /* default 'stor' script */
143 #define FISH_SEND_DEF_CONTENT "" \
144 "FILENAME=\"/${FISH_FILENAME}\"\n" \
145 "FILESIZE=${FISH_FILESIZE}\n" \
146 "#STOR $FILESIZE $FILENAME\n" \
147 "echo \"### 001\"\n" \
148 "{\n" \
149 " while [ $FILESIZE -gt 0 ]; do\n" \
150 " cnt=`expr \\( $FILESIZE + 255 \\) / 256`\n" \
151 " n=`dd bs=256 count=$cnt | tee -a \"${FILENAME}\" | wc -c`\n" \
152 " FILESIZE=`expr $FILESIZE - $n`\n" \
153 " done\n" \
154 "}; echo \"### 200\"\n"
156 /* default 'appe' script */
157 #define FISH_APPEND_DEF_CONTENT "" \
158 "FILENAME=\"/${FISH_FILENAME}\"\n" \
159 "FILESIZE=${FISH_FILESIZE}\n" \
160 "#APPE $FILESIZE $FILENAME\n" \
161 "echo \"### 001\"\n" \
162 "res=`exec 3>&1\n" \
163 "(\n" \
164 " head -c $FILESIZE -q - || echo DD >&3\n" \
165 ") 2>/dev/null | (\n" \
166 " cat > \"${FILENAME}\"\n" \
167 " cat > /dev/null\n" \
168 ")`; [ \"$res\" = DD ] && {\n" \
169 " > \"${FILENAME}\"\n" \
170 " while [ $FILESIZE -gt 0 ]\n" \
171 " do\n" \
172 " cnt=`expr \\( $FILESIZE + 255 \\) / 256`\n" \
173 " n=`dd bs=256 count=$cnt | tee -a \"${FILENAME}\" | wc -c`\n" \
174 " FILESIZE=`expr $FILESIZE - $n`\n" \
175 " done\n" \
176 "}; echo \"### 200\"\n"
178 /* default 'info' script */
179 #define FISH_INFO_DEF_CONTENT "" \
180 "export LC_TIME=C\n" \
181 "#FISH_HAVE_HEAD 1\n" \
182 "#FISH_HAVE_SED 2\n" \
183 "#FISH_HAVE_AWK 4\n" \
184 "#FISH_HAVE_PERL 8\n" \
185 "#FISH_HAVE_LSQ 16\n" \
186 "#FISH_HAVE_DATE_MDYT 32\n" \
187 "#FISH_HAVE_TAIL 64\n" \
188 "res=0\n" \
189 "if `echo yes| head -c 1 > /dev/null 2>&1` ; then\n" \
190 " res=`expr $res + 1`\n" \
191 "fi\n" \
192 "if `sed --version >/dev/null 2>&1` ; then\n" \
193 " res=`expr $res + 2`\n" \
194 "fi\n" \
195 "if `awk --version > /dev/null 2>&1` ; then\n" \
196 " res=`expr $res + 4`\n" \
197 "fi\n" \
198 "if `perl -v > /dev/null 2>&1` ; then\n" \
199 " res=`expr $res + 8`\n" \
200 "fi\n" \
201 "if `ls -Q / >/dev/null 2>&1` ; then\n" \
202 " res=`expr $res + 16`\n" \
203 "fi\n" \
204 "dat=`ls -lan / 2>/dev/null | head -n 3 | tail -n 1 | (\n" \
205 " while read p l u g s rec; do\n" \
206 " if [ -n \"$g\" ]; then\n" \
207 " if [ -n \"$l\" ]; then\n" \
208 " echo \"$rec\"\n" \
209 " fi\n" \
210 " fi\n" \
211 " done\n" \
212 ") | cut -c1 2>/dev/null`\n" \
213 "r=`echo \"0123456789\"| grep \"$dat\"`\n" \
214 "if [ -z \"$r\" ]; then\n" \
215 " res=`expr $res + 32`\n" \
216 "fi\n" \
217 "if `echo yes| tail -c +1 - > /dev/null 2>&1` ; then\n" \
218 " res=`expr $res + 64`\n" \
219 "fi\n" \
220 "echo $res\n" \
221 "echo \"### 200\"\n"
223 /*** enums ***************************************************************************************/
225 /*** structures declarations (and typedefs of structures)*****************************************/
227 /*** global variables defined in .c file *********************************************************/
229 /*** declarations of public functions ************************************************************/
231 /*** inline functions ****************************************************************************/
232 #endif