fishdef.h 13 KB

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