home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume21 / ecu / part20 < prev    next >
Text File  |  1991-08-05  |  55KB  |  1,845 lines

  1. Newsgroups: comp.sources.misc
  2. From: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
  3. Subject:  v21i072:  ecu - ECU async comm package rev 3.10, Part20/37
  4. Message-ID: <1991Aug4.162955.18462@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: ee232688f5c5c1de75c5389a2f90b4eb
  6. Date: Sun, 4 Aug 1991 16:29:55 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
  10. Posting-number: Volume 21, Issue 72
  11. Archive-name: ecu/part20
  12. Environment: SCO, XENIX, ISC
  13. Supersedes: ecu3: Volume 16, Issue 25-59
  14.  
  15. ---- Cut Here and feed the following to sh ----
  16. #!/bin/sh
  17. # this is ecu310.20 (part 20 of ecu310)
  18. # do not concatenate these parts, unpack them in order with /bin/sh
  19. # file help/ecuhelp.src continued
  20. #
  21. if touch 2>&1 | fgrep 'amc' > /dev/null
  22.  then TOUCH=touch
  23.  else TOUCH=true
  24. fi
  25. if test ! -r _shar_seq_.tmp; then
  26.     echo 'Please unpack part 1 first!'
  27.     exit 1
  28. fi
  29. (read Scheck
  30.  if test "$Scheck" != 20; then
  31.     echo Please unpack part "$Scheck" next!
  32.     exit 1
  33.  else
  34.     exit 0
  35.  fi
  36. ) < _shar_seq_.tmp || exit 1
  37. if test ! -f _shar_wnt_.tmp; then
  38.     echo 'x - still skipping help/ecuhelp.src'
  39. else
  40. echo 'x - continuing file help/ecuhelp.src'
  41. sed 's/^X//' << 'SHAR_EOF' >> 'help/ecuhelp.src' &&
  42. XUsage: parity [ None | Even | Odd ]
  43. X
  44. XThis command controls the parity of characters transmitted by the
  45. Xkeyboard.  Issuing the command with no parameter displays the current
  46. Xsetting.  When the parameter is supplied, only the first character is
  47. Xrequired.  Even or odd parity implies seven data bits; no parity implies
  48. Xeight data bits.  Parity of incoming characters is not checked.
  49. X
  50. XThe setting may be automatically changed as the result of a 'dial'
  51. Xcommand.  See also the 'baud' and 'dial' command descriptions.
  52. X#--------------------------------------------------------------------
  53. X%pid
  54. XUsage: pid
  55. X
  56. XThis command displays the process id of the ecu transmitter process, the
  57. Xecu receiver process and the process ids of ecu's parent and group.
  58. X#--------------------------------------------------------------------
  59. X%ptrace
  60. XUsage: ptrace [ 0 | 1 | on | off]
  61. X
  62. XThis command controls whether or not procedure execution is to be
  63. Xtraced.
  64. X#--------------------------------------------------------------------
  65. X%pwd
  66. XUsage: pwd
  67. X
  68. XThis command prints the current working directory of the ecu process.
  69. X#--------------------------------------------------------------------
  70. X%rk
  71. XUsage: rk
  72. X
  73. XThis command searches the PATH list for 'ckermit' (Columbia University
  74. XC-Kermit) and invokes it to receive files.  See the ecu documentation
  75. Xfor modifications necessary to ckermit for ecu operation.  The file
  76. X~/.kermrc must be set up to have any desired initialization paraeters
  77. Xyou desire.  Refer to C-Kermit documentation for more information.
  78. X#--------------------------------------------------------------------
  79. X%rs
  80. XUsage: rs
  81. X
  82. XThis command invokes a SEAlink receive protocol.
  83. X#--------------------------------------------------------------------
  84. X%redial
  85. XUsage: redial [<retry-count> [<pause-interval>]]
  86. X
  87. XThis command redials a number previously dialed with the 'dial' command.
  88. XModem status is tested and multiple retries may be made.  <retry-count>
  89. Xspecifies how many retries are to be made.  <pause-interval> specifies
  90. Xhow many seconds the program pauses after a failure to connect.  You
  91. Xmust specify <retry-count> in order to specify <pause-interval>.  The
  92. Xdefault value for <retry-count> is 10, for <pause-interval> is 60.
  93. X
  94. XYou should know that in some jurisdictions, it is ILLEGAL to dial the
  95. Xsame telephone number more than a specified number of times during some
  96. Xinterval of time.  In any case, specifying <pause-interval> less than 15
  97. Xseconds is silently changed to 15 seconds.
  98. X#--------------------------------------------------------------------
  99. X%rev
  100. XUsage: rev
  101. X
  102. XThis command displays ecu's revision, the transmitter process id and the
  103. Xdate and time ecu was made.
  104. X#--------------------------------------------------------------------
  105. X%rx
  106. XUsage: rx
  107. X
  108. XThis command invokes a modified version of Chuck Forsberg's rz program
  109. X(version 1.31) to receive files from the remote system using XMODEM/CRC.
  110. X
  111. XAfter entering the command, you are prompted as to whether or not file
  112. XCR/LF characters are to be converted to newlines.  If you are
  113. Xtransferring text files from a system which contain CR/LF line
  114. Xterminators, you must answer yes to this question.  You should answer no
  115. Xwhen transferring binary files, such as executables, .arc files and the
  116. Xlike.  File transfer progress is presented on a visual display.  To
  117. Xabort the transfer, press your interrupt key (usually DEL unless reset
  118. Xwith stty(C)).
  119. X#--------------------------------------------------------------------
  120. X%ry
  121. XUsage: ry
  122. X
  123. XThis command invokes a modified version of Chuck Forsberg's rz program
  124. X(version 1.31) to receive files from the remote system using YMODEM
  125. Xbatch with CRC-16 error correction.  The YMODEM is "true YMODEM", not
  126. XXMODEM-1k.  File transfer progress is presented on a visual display.  To
  127. Xabort the transfer, press your interrupt key (usually DEL unless reset
  128. Xwith stty(C)).
  129. X#--------------------------------------------------------------------
  130. X%rz
  131. XUsage: rz
  132. X
  133. XThis command invokes a modified version of Chuck Forsberg's rz program
  134. X(version 1.44) to receive files from the remote system using
  135. XZMODEM/CRC32.  File transfer progress is presented on a visual display.
  136. XTo abort the transfer, press your interrupt key (usually DEL unless
  137. Xreset with stty(C)).
  138. X#--------------------------------------------------------------------
  139. X%sk
  140. XUsage: sk [<file-list>]
  141. X
  142. XThis command searches the PATH list for 'ckermit' (Columbia University
  143. XC-Kermit) and invokes it to send files.  The file ~/.kermrc must be set
  144. Xup to have any desired initialization paraeters you desire.  See the ecu
  145. Xdocumentation for modifications necessary to ckermit for ecu operation.
  146. X
  147. XAfter entering the command, you are prompted as to whether or not file
  148. Xnewline characters are to be converted to CR/LF.  If you are
  149. Xtransferring text files to a system which requires CR/LF line
  150. Xterminators, you must answer yes to this question.  You should answer no
  151. Xwhen transferring binary files, such as executables, .arc files and the
  152. Xlike.  You are prompted to enter a list of files to send, which may
  153. Xcontain one or more wildcard specifications.
  154. X
  155. XThe file ~/.kermrc must be set up to have any desired initialization
  156. Xparameters you desire.  Refer to C-Kermit documentation for more
  157. Xinformation.
  158. X#--------------------------------------------------------------------
  159. X%ss
  160. XUsage: ss [<file-list>]
  161. X
  162. XThis command invokes a SEAlink file transmission protocol.
  163. X#--------------------------------------------------------------------
  164. X%stat
  165. XUsage: stat
  166. X
  167. XThis command displays statistics about ecu usage.
  168. X
  169. XExample display when not connected to a remote system:
  170. XDate/time: 06-14-1988 11:40:35 (UTC 15:40)
  171. XTotal chars transmitted: 178
  172. XTotal chars received:    3681
  173. X
  174. XDate/time: 06-14-1988 14:41:24 (UTC 18:41)
  175. XConnected to CompuHost (555-1234) at 14:40:57
  176. XParameters: 2400-N-1 Connect time: 00:01:27
  177. XTotal chars transmitted: 234 (since CONNECT 142)
  178. XTotal chars received:    2278 (since CONNECT 1478)
  179. X#--------------------------------------------------------------------
  180. X%sx
  181. XUsage: sx [<file-name>]
  182. X
  183. XThis command invokes a modified version of Chuck Forsberg's sz program
  184. X(version 1.44) to send a file to the remote system using XMODEM/CRC.
  185. X
  186. XAfter entering the command, you are prompted as to whether or not file
  187. XCR/LF characters are to be converted to newlines.  If you are
  188. Xtransferring text files from a system which contain CR/LF line termi-
  189. Xnators, you must answer yes to this question.  You should answer no when
  190. Xtransferring binary files, such as executables, .arc files and the like.
  191. X
  192. XYou are prompted to enter a filename to send.  File transfer progress is
  193. Xpresented on a visual display.  To abort the transfer, press your
  194. Xinterrupt key (usually DEL unless reset with stty(C)).
  195. X#--------------------------------------------------------------------
  196. X%sy
  197. XUsage: sy [<file-list>]
  198. X
  199. XThis command invokes a modified version of Chuck Forsberg's sz program
  200. X(version 1.44) to send file(s) to the remote system using YMODEM/CRC.
  201. X
  202. XYou are prompted to enter filename(s) to send, which may consist of one
  203. Xor more wildcard specifications.  File transfer progress is presented on
  204. Xa visual display.  To abort the transfer, press your interrupt key
  205. X(usually DEL unless reset with stty(C)).
  206. X#--------------------------------------------------------------------
  207. X%sz
  208. XUsage: sz [<file-list>]
  209. X
  210. XThis command invokes a modified version of Chuck Forsberg's sz program
  211. X(version 1.44) to send file(s) to the remote system using ZMODEM/CRC32.
  212. X
  213. XYou are prompted to enter filename(s) to send, which may consist of one
  214. Xor more wildcard specifications.  File transfer progress is presented on
  215. Xa visual display.  To abort the transfer, press your interrupt key
  216. X(usually DEL unless reset with stty(C)).
  217. X
  218. XNote: if you specify sending only newer files and the remote receiver
  219. Xdoes not support the feature, it may skip (reject) all your files.
  220. XRetry the transfer specifying 'N' to 'Transfer only newer files'.
  221. X#--------------------------------------------------------------------
  222. X%time
  223. XUsage: time
  224. X
  225. XThis command displays the local date and time as well as the current UTC.
  226. X#--------------------------------------------------------------------
  227. X%tty
  228. XUsage: tty
  229. X
  230. XThis command displays the current console tty name.
  231. X#--------------------------------------------------------------------
  232. X%exit
  233. XUsage: exit
  234. X
  235. XThis command terminates ecu promptly.  If your modem does not drop
  236. Xcarrier upon loss of Data Terminal Ready (DTR), you must use the
  237. X'hangup' command prior to issuing the 'exit' command.  It is strongly
  238. Xrecommended that you configure your modem to hang up the phone line when
  239. XDTR drops.  A shorthand version of this command exists: '.' is
  240. Xequivalent to 'exit'.
  241. X#--------------------------------------------------------------------
  242. X%xon
  243. XUsage: xon [<arg>]
  244. Xwhere <arg> is on    input and output flow control
  245. X               off   no flow control
  246. X               in    input flow control
  247. X               out   output flow control
  248. X
  249. XThis command enables or disables xon/xoff flow control.  If the
  250. Xargument is omitted, the current flow control state is displayed.
  251. X#--------------------------------------------------------------------
  252. X%!
  253. XUsage: !
  254. X       !<command>
  255. X
  256. XThe '!' command is a shell escape.  The environment variable SHELL is
  257. Xread to determine what shell program to execute (e.g., /bin/sh, etc).
  258. XIf '!' is entered by itself, an interactive shell is started; press ^D
  259. Xto exit back to ecu.  If <command> is supplied, it is executed by the
  260. Xshell with an immediate return to ecu.
  261. X
  262. XSimilarly,
  263. X  '$' causes the communications line to be stdin and stdout
  264. X      for the spawned shell
  265. X  '-' is similar to '>', except the command is executed directly
  266. X      without going through a shell.
  267. X#--------------------------------------------------------------------
  268. X%$
  269. XUsage: $
  270. X       $<command>
  271. X
  272. XThe '$' command is a shell escape causing the communications line to be
  273. Xthe stand input and output.  The environment variable SHELL is read to
  274. Xdetermine what shell program to execute (e.g., /bin/sh, etc).  If '$' is
  275. Xentered by itself, an interactive shell is started; a ^D received from
  276. Xthe communications line causes the shell to terminate and control to be
  277. Xpassed back to ecu.  If <command> is supplied, it is executed by the
  278. Xshell with an immediate return to ecu.
  279. X#--------------------------------------------------------------------
  280. X%-
  281. XUsage: -<command>
  282. X
  283. XThe '-' command causes <command> to be executed directly without
  284. Xpassing through a shell (no wildcard expansion or other shell
  285. Xprocessing occurs).  Standard input, output and error all are
  286. Xopened to the console.  In addition, all other files (including
  287. Xthe communications line) opened by ecu remain open.
  288. X#--------------------------------------------------------------------
  289. X%?
  290. XUsage: ?
  291. X
  292. XThis is an alias for the help command.
  293. X#--------------------------------------------------------------------
  294. X%clrx
  295. XUsage: clrx
  296. X
  297. XThe 'clrx' command simulates receipt of an XON by ECU.  It is useful
  298. Xin the rare circumstances that an XOFF is received by ECU from a 
  299. Xremote system and no later XON is received.
  300. X#--------------------------------------------------------------------
  301. X%pcmd
  302. XUsage: pcmd <procedure command>
  303. X
  304. XThe 'pcmd' command allows a procedure command to be issued from the
  305. Xinteractive command prompt.  It is primarily intended for debugging
  306. Xprocedure commands, but it is available for any use.
  307. X#--------------------------------------------------------------------
  308. X%plog
  309. XUsage: plog [<filename> | off | ]
  310. X
  311. XThe 'plog' command turns on or off procedure logging.  If the
  312. Xargument to the command is 'off', logging is turned off, otherwise
  313. Xlogging is started on the specified file.  If no argument is specified,
  314. Xthe status of procedure logging is displayed.
  315. X#--------------------------------------------------------------------
  316. X%rtscts
  317. XUsage: rtscts [ y | n | ]
  318. X
  319. XThis SCO-only command turns on or off the driver RTS and CTS flow
  320. Xcontrol.  As of this writing, SCO's driver does half duplex (traditional,
  321. Xbrain damaged) flow control if RTSFLOW is enabled.  FAS does hardware
  322. Xflow control based on the device magic number, but if you use a device
  323. Xnumber specifying no hardware flow control, RTSFLOW and CTSFLOW can be
  324. Xused to specify SCO-style flow control.  Advice: use rts on or off for
  325. XSCO, use appropriate magic numbered device for FAS.
  326. X
  327. Xargument | RTSFLOW | CTSFLOW   argument | RTSFLOW | CTSFLOW
  328. X---------+---------+---------  ---------+---------+---------
  329. X  off    |   0     |   0         0      |   0     |   0
  330. X  on     |   0     |   1         1      |   0     |   1
  331. X  no     |   0     |   0         2      |   1     |   0
  332. X  yes    |   1     |   1         3      |   1     |   1
  333. X#--------------------------------------------------------------------
  334. X%sdname
  335. XUsage: sdname [<filename> | ]
  336. X
  337. XThis command sets or displays the current screen dump filename.
  338. XUntil the command is issued, screen dump data is placed in
  339. X~/.ecu/screen.dump.
  340. X#--------------------------------------------------------------------
  341. X%sgr
  342. XUsage: sgr mode cmd
  343. X
  344. XThis experimental command is used to test the timed read primitive
  345. Xused by ECU.  The command <cmd> is sent to the line and a timed
  346. Xread is performed.  The data returned is displayed in hexadecimal
  347. Xformat on the console. Refer to source module ecuxenix.c, function
  348. Xsend_get_response() for details.
  349. X#--------------------------------------------------------------------
  350. X%ts
  351. XUsage: ts
  352. X
  353. XThis experimental command displays raw termio structure information
  354. Xfor the console and the tty.  It is primarily used in debugging ECU.
  355. X#--------------------------------------------------------------------
  356. X%xlog
  357. XUsage: xlog [y | n]
  358. X
  359. XThis experimental command controls exhaustive logging by the X, Y, and
  360. XZMODEM file transfer protocols to files named /tmp/szNNNNN.log or
  361. X/tmp/rzNNNNN.log where NNNNN is the process id of the transfer process.
  362. X#--------------------------------------------------------------------
  363. X%eto
  364. XUsage: eto [msec]
  365. X
  366. XThis experimental command sets or displays the "escape timeout"
  367. Xfor non-multiscreen function key detection.  Use caution: although
  368. Xthe command has a lower limit, you may set the value low enough
  369. Xnot to be able to use the HOME key!
  370. X#--------------------------------------------------------------------
  371. X%nice
  372. XUsage: nice [niceval]
  373. X
  374. XThis command sets or displays the process nice value.  The usual
  375. Xrules apply (hint: you might accidently nice4 yourself into not
  376. Xgetting enough CPU!)
  377. X#--------------------------------------------------------------------
  378. X%pushd
  379. XUsage: pushd [ | <dir> ]
  380. X
  381. XThis command either 1) pushes the current directory pathname onto
  382. Xa stack and establishes a new direcctory or 2) shows the current
  383. Xstack.  Issuing the command with no argument displays the stack.
  384. X#--------------------------------------------------------------------
  385. X%popd
  386. XUsage: pushd [ | <#> | all ]
  387. X
  388. XThis command pops one, many or all of the entries off diretory stack,
  389. Xrestoring a previous directory.  No argument results in one directory
  390. Xbeing popped.  A numeric argument pops the stack to a specified level.
  391. X'all' is equal to the numeric value 0 (and may be abbreviasted 'a').
  392. SHAR_EOF
  393. echo 'File help/ecuhelp.src is complete' &&
  394. $TOUCH -am 0725045191 'help/ecuhelp.src' &&
  395. chmod 0644 help/ecuhelp.src ||
  396. echo 'restore of help/ecuhelp.src failed'
  397. Wc_c="`wc -c < 'help/ecuhelp.src'`"
  398. test 26787 -eq "$Wc_c" ||
  399.     echo 'help/ecuhelp.src: original size 26787, current size' "$Wc_c"
  400. rm -f _shar_wnt_.tmp
  401. fi
  402. # ============= ecuungetty/ecuungetty.c ==============
  403. if test -f 'ecuungetty/ecuungetty.c' -a X"$1" != X"-c"; then
  404.     echo 'x - skipping ecuungetty/ecuungetty.c (File already exists)'
  405.     rm -f _shar_wnt_.tmp
  406. else
  407. > _shar_wnt_.tmp
  408. echo 'x - extracting ecuungetty/ecuungetty.c (Text)'
  409. sed 's/^X//' << 'SHAR_EOF' > 'ecuungetty/ecuungetty.c' &&
  410. X#ifndef lint
  411. Xchar *revision = "ecuungetty 3.10";
  412. X#endif
  413. X/*+-------------------------------------------------------------------------
  414. X    ecuungetty.c - ecu "ungetty" program
  415. X    wht@n4hgf.Mt-Park.GA.US
  416. X
  417. Xecuungetty /dev/ttyxx <bamboozle-str>
  418. Xecuungetty -t /dev/ttyxx <bamboozle-str>
  419. Xecuungetty -r /dev/ttyxx <bamboozle-str>
  420. X
  421. X  Defined functions:
  422. X    ecu_log_event(pid,logstr)
  423. X    errno_text(errnum)
  424. X    hangup()
  425. X    main(argc,argv,envp)
  426. X
  427. X--------------------------------------------------------------------------*/
  428. X/*+:EDITS:*/
  429. X/*:07-25-1991-12:57-wht@n4hgf-ECU release 3.10 */
  430. X/*:09-19-1990-19:36-wht@n4hgf-ecu_log_event now gets pid for log from caller */
  431. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  432. X
  433. X#include <stdio.h>
  434. X#include <ctype.h>
  435. X#include <fcntl.h>
  436. X#include <errno.h>
  437. X#include <signal.h>
  438. X#include <sys/types.h>
  439. X#include <sys/stat.h>
  440. X#include <utmp.h>
  441. X#include "../stdio_lint.h"
  442. X#include "../ecuungetty.h"
  443. X#include "../utmpstatus.h"
  444. X
  445. Xextern struct utmp last_utmp;
  446. X
  447. X/*+-------------------------------------------------------------------------
  448. X    ecu_log_event(pid,logstr) - dummy procedure for utmpstat.o
  449. X--------------------------------------------------------------------------*/
  450. Xvoid
  451. Xecu_log_event(pid,logstr)
  452. Xint pid;
  453. Xchar *logstr;
  454. X{
  455. X    ;
  456. X}    /* end of ecu_log_event */
  457. X
  458. X/*+-------------------------------------------------------------------------
  459. X    termecu() - "dummy" for utmpstat.c
  460. XThis particular incantation will only be called if utmp is non-existent
  461. Xor not readable.......
  462. X--------------------------------------------------------------------------*/
  463. Xtermecu()
  464. X{
  465. X    exit(UGE_NOTROOT);
  466. X}    /* end of hangup */
  467. X
  468. X/*+-------------------------------------------------------------------------
  469. X    errno_text(errnum)
  470. X--------------------------------------------------------------------------*/
  471. Xchar *
  472. Xerrno_text(errnum)
  473. Xint errnum;
  474. X{
  475. Xstatic char errstr[12];
  476. X    sprintf(errstr,"E%d\n",errnum);
  477. X    return(errstr);
  478. X}    /* end of errno_text */
  479. X
  480. X/*+-------------------------------------------------------------------------
  481. X    main(argc,argv,envp)
  482. X--------------------------------------------------------------------------*/
  483. Xmain(argc,argv,envp)
  484. Xint argc;
  485. Xchar **argv;
  486. Xchar **envp;
  487. X{
  488. Xint op = 'g';    /* assume "get" operation */
  489. Xint status;
  490. Xint itmp;
  491. Xchar *tty = argv[1];
  492. Xchar *bamboozlement = argv[2];
  493. Xchar *bamboozle();
  494. X
  495. X    if(geteuid() != 0)
  496. X        exit(UGE_NOTROOT);
  497. X
  498. X    if(*argv[1] == '-')
  499. X    {
  500. X        switch(op = *(argv[1] + 1))
  501. X        {
  502. X            case 'r':
  503. X            case 't':
  504. X                break;
  505. X            default:
  506. X                exit(UGE_BADSWITCH);
  507. X        }
  508. X        if(argc < 3)
  509. X            exit(UGE_BADARGC);
  510. X        tty = argv[2];
  511. X        bamboozlement = argv[3];
  512. X    }
  513. X    else if(argc <= 2)
  514. X        exit(UGE_BADARGC);
  515. X
  516. X    if(getuid() != 0)
  517. X    {
  518. X        if(strcmp(bamboozlement,bamboozle(getppid())))
  519. X            exit(UGE_CALLER);
  520. X    }
  521. X
  522. X    status = utmp_status(tty);
  523. X
  524. X    switch(op)
  525. X    {
  526. X        case 'g':
  527. X            switch(status)
  528. X            {
  529. X                case US_NOTFOUND:    /* not in utmp, or getty dead */
  530. X                    exit(UG_NOTENAB);
  531. X                case US_LOGIN:        /* enabled for login, idle */
  532. X                    kill(last_utmp.ut_pid,SIGUSR1);
  533. X                    nap(200L);
  534. X                    exit(UG_ENAB);
  535. X                case US_DIALOUT:    /* enabled for login, currently dialout */
  536. X                case US_LOGGEDIN:    /* enabled for login, in use */
  537. X                    exit(UG_FAIL);
  538. X            }
  539. X            break;
  540. X
  541. X        case 't':
  542. X            switch(status)
  543. X            {
  544. X                case US_NOTFOUND:    /* not in utmp, or getty dead */
  545. X                    exit(UGE_T_NOTFOUND);
  546. X                case US_LOGIN:        /* enabled for login, idle */
  547. X                    exit(UGE_T_LOGIN);
  548. X                case US_LOGGEDIN:    /* enabled for login, in use */
  549. X                    exit(UGE_T_LOGGEDIN);
  550. X                case US_DIALOUT:    /* enabled for login, currently dialout */
  551. X                    exit(UG_RESTART);
  552. X            }
  553. X            break;
  554. X
  555. X        case 'r':
  556. X            switch(status)
  557. X            {
  558. X                case US_NOTFOUND:    /* not in utmp, or getty dead */
  559. X                case US_LOGIN:        /* enabled for login, idle */
  560. X                case US_LOGGEDIN:    /* enabled for login, in use */
  561. X                    exit(0);
  562. X                case US_DIALOUT:    /* enabled for login, currently dialout */
  563. X                    itmp = 5;
  564. X                    while(itmp--)
  565. X                    {
  566. X                        if(kill(last_utmp.ut_pid,SIGUSR2))
  567. X                            break;
  568. X                        nap(100L);
  569. X                    }
  570. X                    exit(0);
  571. X            }
  572. X            break;
  573. X    }
  574. X    exit(0);
  575. X}    /* end of main */
  576. X
  577. X/* vi: set tabstop=4 shiftwidth=4: */
  578. X/* end of ecuungetty.c */
  579. SHAR_EOF
  580. $TOUCH -am 0725125791 'ecuungetty/ecuungetty.c' &&
  581. chmod 0644 ecuungetty/ecuungetty.c ||
  582. echo 'restore of ecuungetty/ecuungetty.c failed'
  583. Wc_c="`wc -c < 'ecuungetty/ecuungetty.c'`"
  584. test 4034 -eq "$Wc_c" ||
  585.     echo 'ecuungetty/ecuungetty.c: original size 4034, current size' "$Wc_c"
  586. rm -f _shar_wnt_.tmp
  587. fi
  588. # ============= z/baudtest.c ==============
  589. if test -f 'z/baudtest.c' -a X"$1" != X"-c"; then
  590.     echo 'x - skipping z/baudtest.c (File already exists)'
  591.     rm -f _shar_wnt_.tmp
  592. else
  593. > _shar_wnt_.tmp
  594. echo 'x - extracting z/baudtest.c (Text)'
  595. sed 's/^X//' << 'SHAR_EOF' > 'z/baudtest.c' &&
  596. X
  597. X/*+-------------------------------------------------------------------------
  598. X    baudtest.c
  599. X    wht@n4hgf.Mt-Park.GA.US
  600. X
  601. XAlas, on some systems, curses insists on sgtty.h inclusion
  602. Xwhich does not get aslong with termio.h AT ALL
  603. X--------------------------------------------------------------------------*/
  604. X/*+:EDITS:*/
  605. X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  606. X/*:12-04-1990-05:36-wht-creation */
  607. X
  608. X#include <stdio.h>
  609. X#include <sys/types.h>
  610. X#include <termio.h>
  611. X
  612. Xextern int iofd;
  613. Xextern int no_curses;
  614. Xextern int report_verbosity;
  615. Xextern int report_init_complete;
  616. Xextern char *numeric_revision;
  617. X
  618. X/*+-------------------------------------------------------------------------
  619. X    test_tty_and_line_baud()
  620. X
  621. X  if non-multiscreen tty baud rate not at least that
  622. X  of the attached line, use no curses, but do be a bit more
  623. X  verbose than if tty not char special
  624. X
  625. X--------------------------------------------------------------------------*/
  626. Xvoid
  627. Xtest_tty_and_line_baud()
  628. X{
  629. X    struct termio tty_termio;
  630. X    struct termio line_termio;
  631. X
  632. X    memset((char *)&tty_termio,0,sizeof(struct termio));
  633. X    memset((char *)&line_termio,0,sizeof(struct termio));
  634. X    if(ioctl(0,TCGETA,&tty_termio) || ioctl(iofd,TCGETA,&line_termio) ||
  635. X        ((tty_termio.c_cflag & CBAUD) < ((line_termio.c_cflag & CBAUD))))
  636. X    {
  637. X        fprintf(stderr,"%s %o %o\r\n",numeric_revision,
  638. X            (tty_termio.c_cflag & CBAUD), (line_termio.c_cflag & CBAUD));
  639. X        no_curses = 1;
  640. X        report_verbosity = 1;
  641. X        report_init_complete = 1;
  642. X    }
  643. X
  644. X}    /* end of test_tty_and_line_baud */
  645. X
  646. X/* vi: set tabstop=4 shiftwidth=4: */
  647. X/* end of baudtest.c */
  648. SHAR_EOF
  649. $TOUCH -am 0725125991 'z/baudtest.c' &&
  650. chmod 0644 z/baudtest.c ||
  651. echo 'restore of z/baudtest.c failed'
  652. Wc_c="`wc -c < 'z/baudtest.c'`"
  653. test 1559 -eq "$Wc_c" ||
  654.     echo 'z/baudtest.c: original size 1559, current size' "$Wc_c"
  655. rm -f _shar_wnt_.tmp
  656. fi
  657. # ============= z/ecurz.c ==============
  658. if test -f 'z/ecurz.c' -a X"$1" != X"-c"; then
  659.     echo 'x - skipping z/ecurz.c (File already exists)'
  660.     rm -f _shar_wnt_.tmp
  661. else
  662. > _shar_wnt_.tmp
  663. echo 'x - extracting z/ecurz.c (Text)'
  664. sed 's/^X//' << 'SHAR_EOF' > 'z/ecurz.c' &&
  665. Xchar *numeric_revision = "ecurz 3.13";
  666. X/*+-------------------------------------------------------------------------
  667. X    ecurz.c - X/Y/ZMODEM receive program
  668. X  Derived from public domain source by Chuck Forsberg, Omen Technologies
  669. X  Adaptation for ecu 1989 wht@n4hgf.Mt-Park.GA.US
  670. X
  671. X  Defined functions:
  672. X    SIGALRM_handler()
  673. X    arg_token(parsestr,termchars)
  674. X    bye_bye(sig)
  675. X    cancel_transaction(sig)
  676. X    close_and_report()
  677. X    flushline()
  678. X    fname_split(cmd,arg,arg_max_quan,narg_rtn)
  679. X    fname_too_long(fname)
  680. X    fname_truncated()
  681. X    getfree()
  682. X    isanylc(str)
  683. X    main(argc,argv,envp)
  684. X    make_dirs(pathname)
  685. X    mkdir(dpath,dmode)
  686. X    procheader(name)
  687. X    purgeline()
  688. X    readline(timeout)
  689. X    rzfile()
  690. X    rzfiles()
  691. X    send_ZFIN_and_exit()
  692. X    send_cancel(error)
  693. X    sendline(c)
  694. X    substr(str,token)
  695. X    sys2(shellcmd)
  696. X    tryz()
  697. X    uncaps(str)
  698. X    usage(fail_reason)
  699. X    wcgetsec(rxbuf,maxtime)
  700. X    wcreceive(argc,argp)
  701. X    wcrx()
  702. X    wcrxpn(rpn)
  703. X    write_sec_to_disk(buf,n)
  704. X    xsendline(c)
  705. X
  706. X      Usage:    ecurz -Z [-abeuy]    (ZMODEM)
  707. X                ecurz -Y [-abuy]     (YMODEM)
  708. X                ecurz -X [-abc] file (XMODEM or XMODEM-1k)
  709. X
  710. X          -a ASCII transfer (strip CR)
  711. X          -b Binary transfer for all files
  712. X          -c Use 16 bit CRC (XMODEM)
  713. X          -e Escape control characters  (ZMODEM)
  714. X          -p protect local files (ZMODEM)
  715. X          -t <tenths> rx timeout seconds
  716. X          -+ force append
  717. X          -u convert uppercase filenames to lower case
  718. X          -y Yes, clobber existing file if any
  719. X          -. line fd to use
  720. X          -, log protocol packets
  721. X
  722. X--------------------------------------------------------------------------*/
  723. X/*+:EDITS:*/
  724. X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  725. X/*:04-30-1991-18:33-wht@n4hgf-gcc version coredumping on putc(); use fputc() */
  726. X/*:03-27-1991-21:21-wht@n4hgf-dont bump error count on send ZRPOS */
  727. X/*:02-03-1991-17:27-wht@n4hgf-version number change - see zcurses.c */
  728. X/*:12-18-1990-21:26-wht@n4hgf-better output control */
  729. X/*:10-04-1990-14:01-wht@n4hgf-add file finish warning for me */
  730. X/*:09-19-1990-19:36-wht@n4hgf-ecu_log_event now gets pid for log from caller */
  731. X/*:08-23-1990-14:14-wht@n4hgf-sending ZACK was erroneously counted as error */
  732. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  733. X
  734. X#include <stdio.h>
  735. X#include <signal.h>
  736. X#include <setjmp.h>
  737. X#include <ctype.h>
  738. X#include <errno.h>
  739. X#include <fcntl.h>
  740. X#include "zmodem.h"
  741. X#include "lint_args.h"
  742. X
  743. Xchar *strrchr();
  744. X
  745. X#if defined(M_UNIX)
  746. Xchar *fname_truncated();
  747. X#endif
  748. X
  749. Xextern unsigned short crctab[];
  750. Xextern unsigned long total_data_chars_xfered; /* zcurses.c */
  751. Xextern int force_no_curses;
  752. Xextern int errno;
  753. Xextern char *sys_errlist[];
  754. Xextern char Attn[];        /* Attention string rx sends to tx on err */
  755. Xextern int Crc32;        /* Display flag indicating 32 bit CRC being received */
  756. Xextern int Rxcount;        /* Count of data bytes received */
  757. Xextern char Rxhdr[];    /* Received header */
  758. Xextern char Txhdr[];    /* Transmitted header */
  759. Xextern int Rxtimeout;    /* Tenths of seconds to wait for something */
  760. Xextern char s128[128];
  761. X
  762. X/* Max value for VMIN_COUNT is 255.  A larger value reduces system
  763. Xoverhead but may evoke kernel bugs.  133 corresponds to an XMODEM/CRC
  764. Xsector */
  765. X#if !defined(VMIN_COUNT)
  766. X#define VMIN_COUNT 133
  767. X#endif
  768. Xunsigned char vmin_count = VMIN_COUNT;
  769. Xint Readnum = VMIN_COUNT;    /* num bytes to ask for in read() from modem */
  770. X
  771. X#define DEFBYTL 2000000000L    /* default rx file size */
  772. X#define RETRYMAX 5
  773. X
  774. XFILE *fout;
  775. Xchar Lzmanag;        /* Local file management request */
  776. Xchar Pathname[PATHLEN];
  777. Xchar curr_dir[256];
  778. Xunsigned char linbuf[VMIN_COUNT];
  779. Xchar secbuf[1025];
  780. Xchar zconv;                /* ZMODEM file conversion request */
  781. Xchar zmanag;            /* ZMODEM file management request */
  782. Xchar ztrans;            /* ZMODEM file transport request */
  783. Xint Batch=0;
  784. Xint Blklen;                /* record length of received packets */
  785. Xint Crcflg;
  786. Xint Eofseen;            /* indicates cpm eof (^Z) has been received */
  787. Xint Filcnt=0;            /* count of number of files opened */
  788. Xint Filemode;            /* Unix style mode for incoming file */
  789. Xint Firstsec;
  790. Xint Lastrx;
  791. Xint Lleft=0;            /* number of characters in linbuf */
  792. Xint MakeLCPathname=1;    /* make received pathname lower case */
  793. Xint Nozmodem = 0;        /* If invoked as "rb" */
  794. Xint Rxascii=0;            /* receive files in ascii (translate) mode */
  795. Xint Rxbinary=0;            /* receive all files in bin mode */
  796. Xint Rxclob=0;            /* Clobber existing file */
  797. Xint Thisbinary;            /* current file is to be received in bin mode */
  798. Xint Twostop = 0;        /* use two stop bits */
  799. Xint Zctlesc;            /* Encode control characters */
  800. Xint Zmodem=0;            /* ZMODEM protocol requested */
  801. Xint Zrwindow = 1400;    /* RX window size (controls garbage count) */
  802. Xint ecusz_flag = 0;
  803. Xint skip_count = 0;        /* skipped files */
  804. Xint errors;
  805. Xint iofd = 0;
  806. Xint force_no_curses = 0;
  807. Xint can_on_eof = 0;
  808. Xint log_packets = 0;
  809. Xint npats = 0;
  810. Xint oldBlklen = -1;        /* last block length */
  811. Xint this_file_errors = 0;
  812. Xint tryzhdrtype=ZRINIT;    /* Header type to send corresponding to Last rx close */
  813. Xjmp_buf tohere;            /* For the interrupt on RX timeout */
  814. Xlong Bytesleft;            /* number of bytes of incoming file left */
  815. Xlong Modtime;            /* Unix style mod time for incoming file */
  816. Xlong TotalToReceive = 0L;
  817. Xlong rx_char_count = 0L;
  818. Xlong tx_char_count = 0L;
  819. Xstruct stat fout_stat;
  820. Xtime_t timep[2];
  821. Xunsigned Baudrate;
  822. Xunsigned long this_file_length;
  823. Xint required_type = 0;
  824. Xchar *bottom_label = (char *)0;
  825. Xchar *got_garbage_txt = "got garbage (0x%02x)";
  826. X
  827. X/*+-----------------------------------------------------------------------
  828. X    arg_token(parsestr,termchars)
  829. X
  830. XGet next token from string parsestr ((char *)0 on 2nd, 3rd, etc.
  831. Xcalls), where tokens are nonempty strings separated by runs of chars
  832. Xfrom termchars.  Writes nulls into parsestr to end tokens.
  833. Xtermchars need not remain constant from call to call.
  834. X
  835. XTreats multiple occurrences of a termchar as one delimiter (does not
  836. Xallow null fields).
  837. X------------------------------------------------------------------------*/
  838. X#if defined(M_UNIX)
  839. Xstatic char *arg_token_static = (char *)0;
  840. Xchar *arg_token(parsestr,termchars)
  841. Xchar *parsestr;
  842. Xchar *termchars;
  843. X{
  844. Xregister char *parseptr;
  845. Xchar *token;
  846. X
  847. X    if(parsestr == (char *)0 && arg_token_static == (char *)0)
  848. X        return((char *)0);
  849. X
  850. X    if(parsestr)
  851. X        parseptr = parsestr;
  852. X    else
  853. X       parseptr = arg_token_static;
  854. X
  855. X    while(*parseptr)
  856. X    {
  857. X        if(!strchr(termchars,*parseptr))
  858. X            break;
  859. X        parseptr++;
  860. X    }
  861. X
  862. X    if(!*parseptr)
  863. X    {
  864. X        arg_token_static = (char *)0;
  865. X        return((char *)0);
  866. X    }
  867. X
  868. X    token = parseptr;
  869. X    if(*token == '\'')
  870. X    {
  871. X        token++;
  872. X        parseptr++;
  873. X        while(*parseptr)
  874. X        {
  875. X            if(*parseptr == '\'')
  876. X            {
  877. X                arg_token_static = parseptr + 1;
  878. X                *parseptr = 0;
  879. X                return(token);
  880. X            }
  881. X            parseptr++;
  882. X        }
  883. X        arg_token_static = (char *)0;
  884. X        return(token);
  885. X    }
  886. X    while(*parseptr)
  887. X    {
  888. X        if(strchr(termchars,*parseptr))
  889. X        {
  890. X            *parseptr = 0;
  891. X            arg_token_static = parseptr + 1;
  892. X            while(*arg_token_static)
  893. X            {
  894. X                if(!strchr(termchars,*arg_token_static))
  895. X                    break;
  896. X                arg_token_static++;
  897. X            }
  898. X            return(token);
  899. X        }
  900. X        parseptr++;
  901. X    }
  902. X    arg_token_static = (char *)0;
  903. X    return(token);
  904. X}    /* end of arg_token */
  905. X#endif
  906. X
  907. X/*+-------------------------------------------------------------------------
  908. X    fname_split(cmd,arg,arg_max_quan,&narg)
  909. X--------------------------------------------------------------------------*/
  910. X#if defined(M_UNIX)
  911. Xvoid
  912. Xfname_split(cmd,arg,arg_max_quan,narg_rtn)
  913. Xchar *cmd;
  914. Xchar **arg;
  915. Xint arg_max_quan;
  916. Xint *narg_rtn;
  917. X{
  918. Xregister itmp;
  919. Xregister narg;
  920. X
  921. X    for(itmp = 0; itmp < arg_max_quan; itmp++)
  922. X        arg[itmp] = (char *)0;
  923. X    arg[0] = arg_token(cmd,"/");
  924. X
  925. X    for(narg = 1; narg < arg_max_quan; ++narg)
  926. X    {
  927. X        if((arg[narg] = arg_token((char *)0,"/")) == (char *)0) 
  928. X            break;
  929. X    }
  930. X
  931. X    *narg_rtn = narg;
  932. X
  933. X}    /* end of fname_split */
  934. X#endif
  935. X
  936. X#if defined(M_UNIX)
  937. X#define MAX_COMPONENT_LEN    14
  938. X#define MAX_PATH_COMPONENTS    16
  939. Xstatic char trunc_fname[257];
  940. Xstatic char *trunc_components[MAX_PATH_COMPONENTS];
  941. Xstatic int trunc_components_quan;
  942. Xstatic int trunc_absolute_path;
  943. X#endif
  944. X
  945. X/*+-------------------------------------------------------------------------
  946. X    fname_too_long(fname) - check for any pathname component too long
  947. X--------------------------------------------------------------------------*/
  948. X#if defined(M_UNIX)
  949. Xint
  950. Xfname_too_long(fname)
  951. Xregister char *fname;
  952. X{
  953. Xregister int itmp;
  954. Xregister char **cpptr;
  955. X
  956. X    if(trunc_absolute_path = (*fname == '/'))
  957. X        fname++;
  958. X    strncpy(trunc_fname,fname,sizeof(trunc_fname) - 1);
  959. X    fname_split(trunc_fname,trunc_components,
  960. X        MAX_PATH_COMPONENTS,&trunc_components_quan);
  961. X    itmp = trunc_components_quan;
  962. X    cpptr = trunc_components;
  963. X    while(itmp--)
  964. X    {
  965. X        if(strlen(*cpptr) > MAX_COMPONENT_LEN)
  966. X            return(1);
  967. X        cpptr++;
  968. X    }
  969. X    return(0);
  970. X}    /* end of fname_too_long */
  971. X#endif
  972. X
  973. X/*+-------------------------------------------------------------------------
  974. X    fname_truncated() - build truncated path last checked by fname_too_long
  975. X--------------------------------------------------------------------------*/
  976. X#if defined(M_UNIX)
  977. Xchar *
  978. Xfname_truncated()
  979. X{
  980. Xregister int icomp;
  981. Xchar new_fname[257];
  982. Xregister char *cptr = new_fname;
  983. X
  984. X    if(trunc_absolute_path)
  985. X    {
  986. X        *cptr = '/';
  987. X        *(cptr + 1) = 0;
  988. X    }
  989. X    else
  990. X        *cptr = 0;
  991. X    for(icomp = 0; icomp < trunc_components_quan; icomp++)
  992. X    {
  993. X        if(strlen(trunc_components[icomp]) > MAX_COMPONENT_LEN)
  994. X            *(trunc_components[icomp] + MAX_COMPONENT_LEN) = 0;
  995. X        strcat(cptr,trunc_components[icomp]);
  996. X        if(icomp < trunc_components_quan - 1)
  997. X            strcat(cptr,"/");
  998. X    }
  999. X    strcpy(trunc_fname,cptr);
  1000. X    return(trunc_fname);
  1001. X
  1002. X}    /* end of fname_truncated */
  1003. X#endif
  1004. X
  1005. X/*+-------------------------------------------------------------------------
  1006. X    substr(str,token)
  1007. X
  1008. X  searches for token in string str returns pointer to token within
  1009. X  string if found,NULL otherwise
  1010. X--------------------------------------------------------------------------*/
  1011. Xchar *
  1012. Xsubstr(str,token)
  1013. Xregister char *str,*token;
  1014. X{
  1015. Xregister char *ss,*tt;
  1016. X
  1017. X    /* search for first char of token */
  1018. X    for(ss=str; *str; str++)
  1019. X        if(*str == *token)
  1020. X            /* compare token with substring */
  1021. X            for(ss=str,tt=token; ;)
  1022. X            {
  1023. X                if(*tt == 0)
  1024. X                    return(str);
  1025. X                if(*ss++ != *tt++)
  1026. X                    break;
  1027. X            }
  1028. X    return(NULL);
  1029. X}    /* end of substr */
  1030. X
  1031. X/*+-------------------------------------------------------------------------
  1032. X    getfree()
  1033. X
  1034. X  Routine to calculate the free bytes on the current file system ~0
  1035. X  means many free bytes (unknown)
  1036. X--------------------------------------------------------------------------*/
  1037. Xlong
  1038. Xgetfree()
  1039. X{
  1040. X    return(~0L);    /* many free bytes ... */
  1041. X}    /* end of getfree */
  1042. X
  1043. X/*+-------------------------------------------------------------------------
  1044. X    usage(fail_reason)
  1045. X--------------------------------------------------------------------------*/
  1046. Xvoid
  1047. Xusage(fail_reason)
  1048. Xchar *fail_reason;
  1049. X{
  1050. X    fprintf(stderr,"%s\n",fail_reason);
  1051. X    exit(255);
  1052. X}    /* end of usage */
  1053. X
  1054. X/*+-------------------------------------------------------------------------
  1055. X    SIGALRM_handler()
  1056. X--------------------------------------------------------------------------*/
  1057. Xvoid
  1058. XSIGALRM_handler()
  1059. X{
  1060. X    report_tx_ind(0);
  1061. X    report_rx_ind(0);
  1062. X    longjmp(tohere,-1);
  1063. X}    /* end of SIGALRM_handler */
  1064. X
  1065. X/*+-------------------------------------------------------------------------
  1066. X    bye_bye(sig)
  1067. X--------------------------------------------------------------------------*/
  1068. Xvoid
  1069. Xbye_bye(sig)
  1070. Xint sig;
  1071. X{
  1072. X    exit(sig+128);
  1073. X}    /* end of bye_bye */
  1074. X
  1075. X/*+-------------------------------------------------------------------------
  1076. X    cancel_transaction(can_code)
  1077. Xcalled by signal interrupt or terminate to clean things up
  1078. X--------------------------------------------------------------------------*/
  1079. Xvoid
  1080. Xcancel_transaction(can_code)
  1081. Xint can_code;
  1082. X{
  1083. X    if(Zmodem)
  1084. X        zmputs(Attn);
  1085. X    send_cancel(1);
  1086. X    mode(0);
  1087. X    if(can_code >= 0)
  1088. X    {
  1089. X        sprintf(s128,"ecurz aborted (signal %d)",can_code);
  1090. X        report_str(s128,0);
  1091. X    }
  1092. X    report_tx_ind(0);
  1093. X    report_rx_ind(0);
  1094. X    report_uninit(0);
  1095. X    bye_bye(can_code);
  1096. X
  1097. X}    /* end of cancel_transaction */
  1098. X
  1099. X/*+-------------------------------------------------------------------------
  1100. X    sendline(c) -  send a character to DCE
  1101. X--------------------------------------------------------------------------*/
  1102. Xsendline(c)
  1103. Xchar c;
  1104. X{
  1105. X    write(iofd,&c,1);
  1106. X    ++tx_char_count;
  1107. X}    /* end of sendline */
  1108. X
  1109. X/*+-------------------------------------------------------------------------
  1110. X    xsendline(c)
  1111. X--------------------------------------------------------------------------*/
  1112. Xxsendline(c)
  1113. Xint c;
  1114. X{
  1115. X    sendline(c);
  1116. X}    /* end of xsendline */
  1117. X
  1118. X/*+-------------------------------------------------------------------------
  1119. X    flushline()
  1120. X--------------------------------------------------------------------------*/
  1121. Xflushline()
  1122. X{
  1123. X}    /* end of flushline */
  1124. X
  1125. X/*+-------------------------------------------------------------------------
  1126. X    purgeline() - purge the modem input queue of all characters
  1127. X--------------------------------------------------------------------------*/
  1128. Xpurgeline()
  1129. X{
  1130. X    Lleft = 0;
  1131. X#if defined(M_XENIX) || defined(M_UNIX)
  1132. X    ioctl(iofd,TCFLSH,0);
  1133. X#else
  1134. X    lseek(iofd,0L,2);
  1135. X#endif
  1136. X}    /* end of purgeline */
  1137. X
  1138. X/*+-------------------------------------------------------------------------
  1139. X    wcreceive(argc,argp)
  1140. X--------------------------------------------------------------------------*/
  1141. Xwcreceive(argc,argp)
  1142. Xint argc;
  1143. Xchar **argp;
  1144. X{
  1145. Xregister c;
  1146. X
  1147. X    if(Batch || argc==0)
  1148. X    {
  1149. X        Crcflg=1;
  1150. X        c=tryz();
  1151. X        if(Zmodem)
  1152. X        {
  1153. X            report_protocol_type("ZMODEM");
  1154. X            report_protocol_crc_type((Crc32) ? "/CRC32" : "/CRC16");
  1155. X        }
  1156. X        if(c)
  1157. X        {
  1158. X            if(c == ZCOMPL)
  1159. X                return(OK);
  1160. X            if(c == ERROR)
  1161. X                goto fubar;
  1162. X            c = rzfiles();
  1163. X            if(c)
  1164. X                goto fubar;
  1165. X        } else 
  1166. X        {
  1167. X            report_protocol_type("YMODEM");
  1168. X            report_protocol_crc_type((Crcflg) ? "/CRC" : "/CHK");
  1169. X            for(;;)
  1170. X            {
  1171. X                if(wcrxpn(secbuf)== ERROR)
  1172. X                    goto fubar;
  1173. X                if(secbuf[0]==0)
  1174. X                    return(OK);
  1175. X                if(procheader(secbuf) == ERROR)
  1176. X                    goto fubar;
  1177. X                report_str("Receiving data",0);
  1178. X                if(wcrx()==ERROR)
  1179. X                    goto fubar;
  1180. X            }
  1181. X        }
  1182. X    }
  1183. X    else 
  1184. X    {
  1185. X        report_protocol_type("XMODEM");
  1186. X        report_protocol_crc_type((Crcflg) ? "/CRC" : "/CHK");
  1187. X        Bytesleft = DEFBYTL;
  1188. X        Filemode = 0;
  1189. X        Modtime = 0L;
  1190. X        procheader("");
  1191. X        strcpy(Pathname,*argp);
  1192. X#if defined(M_UNIX)
  1193. X        if(fname_too_long(Pathname))
  1194. X        {
  1195. X            strcpy(s128,"truncated: ");
  1196. X            strncat(s128,Pathname,sizeof(s128) - 12);
  1197. X            ecu_log_event(getppid(),s128);
  1198. X            report_str(s128,-1);
  1199. X            strcpy(Pathname,fname_truncated());
  1200. X        }
  1201. X#endif
  1202. X        if((fout=fopen(Pathname,"w")) == NULL)
  1203. X        {
  1204. X            sprintf(s128,"%-0.35s: %-0.40s",Pathname,sys_errlist[errno]);
  1205. X            report_str(s128,1);
  1206. X            ecu_log_event(getppid(),s128);
  1207. X            goto fubar;
  1208. X        }
  1209. X
  1210. X        ++Filcnt;
  1211. X        report_file_rcv_started( Pathname,0L,Modtime,Filemode);
  1212. X        this_file_length = 0;
  1213. X        report_rxpos(0L);
  1214. X        report_str("Receiving data",0);
  1215. X        if(wcrx()==ERROR)
  1216. X            goto fubar;
  1217. X    }
  1218. X    return(OK);
  1219. Xfubar:
  1220. X    send_cancel(1);
  1221. X    if(fout)
  1222. X    {
  1223. X        fflush(fout);
  1224. X        fstat(fileno(fout),&fout_stat);
  1225. X        report_file_byte_io((long)fout_stat.st_size);
  1226. X        report_file_close(0);
  1227. X        fclose(fout);
  1228. X    }
  1229. X    return(ERROR);
  1230. X}    /* end of wcreceive */
  1231. X
  1232. X/*+-------------------------------------------------------------------------
  1233. X    wcgetsec(rxbuf,maxtime)
  1234. X
  1235. X  Wcgetsec fetches a Ward Christensen type sector.  Returns sector
  1236. X  number encountered or ERROR if valid sector not received, or CAN CAN
  1237. X  received or WCEOT if eot sector time is timeout for first char,set to
  1238. X  4 seconds thereafter. NO ACK IS SENT IF SECTOR IS RECEIVED OK. Caller
  1239. X  must do that when he is good and ready to get next sector.
  1240. X--------------------------------------------------------------------------*/
  1241. Xunsigned int
  1242. Xwcgetsec(rxbuf,maxtime)
  1243. Xchar *rxbuf;
  1244. Xint maxtime;
  1245. X{
  1246. Xregister unsigned int firstch;
  1247. Xregister unsigned short oldcrc;
  1248. Xregister unsigned char checksum;
  1249. Xregister wcj;
  1250. Xregister char *p;
  1251. Xint sectcurr;
  1252. X
  1253. X    for(Lastrx=errors=0; errors<RETRYMAX; errors++)
  1254. X    {
  1255. X
  1256. X        firstch=readline(maxtime);
  1257. X        if((firstch == STX) || (firstch == SOH))
  1258. X        {
  1259. X            oldBlklen = Blklen;
  1260. X            if(firstch == STX)
  1261. X                Blklen=1024;
  1262. X            else
  1263. X                Blklen=128;
  1264. X            if(oldBlklen != Blklen)
  1265. X                report_rxblklen(Blklen);
  1266. X
  1267. X            sectcurr=readline(1);
  1268. X            if((sectcurr + (oldcrc=readline(1))) == 0xFF)
  1269. X            {
  1270. X                oldcrc=checksum=0;
  1271. X                for(p=rxbuf,wcj=Blklen; --wcj>=0; )
  1272. X                {
  1273. X                    if((firstch=readline(1)) < 0)
  1274. X                        goto bilge;
  1275. X                    oldcrc=updcrc(firstch,oldcrc);
  1276. X                    checksum += (*p++ = firstch);
  1277. X                }
  1278. X                if((firstch=readline(1)) < 0)
  1279. X                    goto bilge;
  1280. X                if(Crcflg)
  1281. X                {
  1282. X                    oldcrc=updcrc(firstch,oldcrc);
  1283. X                    if((firstch=readline(1)) < 0)
  1284. X                        goto bilge;
  1285. X                    oldcrc=updcrc(firstch,oldcrc);
  1286. X                    if(oldcrc)
  1287. X                    {
  1288. X                        sprintf(s128,"CRC error = 0x%04x",oldcrc);
  1289. X                        report_str(s128,1);
  1290. X                    }
  1291. X                    else 
  1292. X                    {
  1293. X                        Firstsec=0;
  1294. X                        return(sectcurr);
  1295. X                    }
  1296. X                }
  1297. X                else if((checksum-firstch)==0)
  1298. X                {
  1299. X                    Firstsec=0;
  1300. X                    return(sectcurr);
  1301. X                }
  1302. X                else
  1303. X                    report_str("checksum error",1);
  1304. X            }
  1305. X            else
  1306. X            {
  1307. X                report_last_txhdr("Noise",0);
  1308. X                sprintf(s128,"Sector garbled 0x%x 0x%x",sectcurr,oldcrc);
  1309. X                report_str(s128,1);
  1310. X            }
  1311. X        }
  1312. X        /* make sure eot really is eot and not just mixmash */
  1313. X#if defined(NFGVMIN)
  1314. X        else if(firstch==EOT && readline(1)==TIMEOUT)
  1315. X            return(WCEOT);
  1316. X#else
  1317. X        else if(firstch==EOT && Lleft==0)
  1318. X            return(WCEOT);
  1319. X#endif
  1320. X        else if(firstch==EOT)
  1321. X        {
  1322. X            report_str("Noisy EOT",2);
  1323. X        }
  1324. X        else if(firstch==CAN)
  1325. X        {
  1326. X            if(Lastrx==CAN)
  1327. X            {
  1328. X                report_str("Sender CANcelled",1);
  1329. X                report_last_rxhdr("CAN",1);
  1330. X                return(ERROR);
  1331. X            } else 
  1332. X            {
  1333. X                Lastrx=CAN;
  1334. X                continue;
  1335. X            }
  1336. X        }
  1337. X        else if(firstch==TIMEOUT)
  1338. X        {
  1339. X            if(Firstsec)
  1340. X                goto humbug;
  1341. Xbilge:
  1342. X            report_str("Timeout",1);
  1343. X        }
  1344. X        else
  1345. X        {
  1346. X            sprintf(s128,"Got 0x%02x sector header",firstch);
  1347. X            report_str(s128,1);
  1348. X        }
  1349. X
  1350. Xhumbug:
  1351. X        Lastrx=0;
  1352. X        while(readline(1)!=TIMEOUT)
  1353. X            ;
  1354. X        if(Firstsec)
  1355. X        {
  1356. X            sendline(Crcflg?WANTCRC:NAK);
  1357. X            report_last_txhdr(Crcflg ? "WANTCRC" : "NAK",0);
  1358. X            Lleft=0;    /* Do read next time ... */
  1359. X        } else 
  1360. X        {
  1361. X            maxtime=40;
  1362. X            sendline(NAK);
  1363. X            report_last_txhdr("NAK",1);
  1364. X            Lleft=0;    /* Do read next time ... */
  1365. X        }
  1366. X    }
  1367. X    /* try to stop the bubble machine. */
  1368. X    send_cancel(1);
  1369. X    return(ERROR);
  1370. X}    /* end of wcgetsec */
  1371. X
  1372. X/*+-------------------------------------------------------------------------
  1373. X    wcrxpn(rpn)
  1374. X
  1375. X  Fetch a pathname from the other end.  Length is indeterminate as long
  1376. X  as less than Blklen.  During YMODEM xfers, a null string represents no
  1377. X  more files.
  1378. X--------------------------------------------------------------------------*/
  1379. Xwcrxpn(rpn)
  1380. Xchar *rpn;    /* receive a pathname */
  1381. X{
  1382. Xregister c;
  1383. X
  1384. X#if defined(NFGVMIN)
  1385. X    readline(1);
  1386. X#else
  1387. X    purgeline();
  1388. X#endif
  1389. X
  1390. Xet_tu:
  1391. X    Firstsec=1;
  1392. X    Eofseen=0;
  1393. X    sendline(Crcflg?WANTCRC:NAK);
  1394. X    report_last_txhdr(Crcflg ? "WANTCRC" : "NAK",0);
  1395. X    Lleft=0;    /* Do read next time ... */
  1396. X    while((c = wcgetsec(rpn,100)) != 0)
  1397. X    {
  1398. X        if(c == WCEOT)
  1399. X        {
  1400. X            sprintf(s128,"Pathname fetch returned %d",c);
  1401. X            report_str(s128,1);
  1402. X            sendline(ACK);
  1403. X            report_last_txhdr("ACK",0);
  1404. X            Lleft=0;    /* Do read next time ... */
  1405. X            readline(1);
  1406. X            goto et_tu;
  1407. X        }
  1408. X        return(ERROR);
  1409. X    }
  1410. X    sendline(ACK);
  1411. X    report_last_txhdr("ACK",0);
  1412. X    return(OK);
  1413. X}    /* end of wcrxpn */
  1414. X
  1415. X/*+-------------------------------------------------------------------------
  1416. X    write_sec_to_disk(buf,n)
  1417. X
  1418. X  Putsec writes the n characters of buf to receive file fout.  If not in
  1419. X  binary mode, carriage returns, and all characters starting with CPMEOF
  1420. X  are discarded.
  1421. X--------------------------------------------------------------------------*/
  1422. Xwrite_sec_to_disk(buf,n)
  1423. Xchar *buf;
  1424. Xregister n;
  1425. X{
  1426. Xregister char *p;
  1427. X
  1428. X    if(n == 0)
  1429. X        return(OK);
  1430. X    if(Thisbinary)
  1431. X    {
  1432. X        for(p=buf; --n>=0; )
  1433. X            fputc( *p++,fout);
  1434. X    }
  1435. X    else 
  1436. X    {
  1437. X        if(Eofseen)
  1438. X            return(OK);
  1439. X        for(p=buf; --n>=0; ++p )
  1440. X        {
  1441. X            if( *p == '\r')
  1442. X                continue;
  1443. X            if(*p == CPMEOF)
  1444. X            {
  1445. X                Eofseen=1;
  1446. X                fflush(fout);
  1447. X                fstat(fileno(fout),&fout_stat);
  1448. X                report_rxpos(fout_stat.st_size);
  1449. X                return(OK);
  1450. X            }
  1451. X            fputc(*p,fout);
  1452. X        }
  1453. X    }
  1454. X    fflush(fout);
  1455. X    fstat(fileno(fout),&fout_stat);
  1456. X    report_rxpos(fout_stat.st_size);
  1457. X    if(this_file_length != 0)
  1458. X    {
  1459. X    int pct;
  1460. X        sprintf(s128,"Receiving data (%u%% complete)",
  1461. X            (unsigned int)(
  1462. X            pct = ((unsigned long)fout_stat.st_size * (unsigned long)100)
  1463. X            / this_file_length));
  1464. X        report_str(s128,0);
  1465. X    }
  1466. X    return(OK);
  1467. X}    /* end of write_sec_to_disk */
  1468. X
  1469. X/*+-------------------------------------------------------------------------
  1470. X    wcrx() - receive an X/YMODEM sector
  1471. X
  1472. X  Adapted from CMODEM13.C,written by Jack M.  Wierda and Roderick W. Hart
  1473. X--------------------------------------------------------------------------*/
  1474. Xint
  1475. Xwcrx()
  1476. X{
  1477. Xregister unsigned int sectnum,sectcurr;
  1478. Xregister unsigned char sendchar;
  1479. Xint cblklen;            /* bytes to dump this block */
  1480. X
  1481. X    Firstsec=1;
  1482. X    sectnum=0;
  1483. X    Eofseen=0;
  1484. X    sendchar=Crcflg ? WANTCRC : NAK;
  1485. X    report_last_txhdr(Crcflg ? "WANTCRC" : "NAK",0);
  1486. X
  1487. X    for(;;)
  1488. X    {
  1489. X        sendline(sendchar);    /* send it now,we're ready! */
  1490. X        if(sendchar == ACK)
  1491. X            report_last_txhdr("ACK",0);
  1492. X        Lleft=0;    /* Do read next time ... */
  1493. X        sectcurr=wcgetsec(secbuf,(sectnum&0177)?50:130);
  1494. X        sprintf(s128,"Block %d received",sectnum);
  1495. X        report_last_rxhdr(s128,0);
  1496. X        fstat(fileno(fout),&fout_stat);
  1497. X        report_rxpos(fout_stat.st_size);
  1498. X        if(sectcurr == (sectnum+1 & 0xFF))
  1499. X        {
  1500. X            sectnum++;
  1501. X            cblklen = Bytesleft>Blklen ? Blklen : Bytesleft;
  1502. X            if(write_sec_to_disk(secbuf,cblklen) == ERROR)
  1503. X                return(ERROR);
  1504. X            if((Bytesleft-=cblklen) < 0)
  1505. X                Bytesleft = 0;
  1506. X            sendchar=ACK;
  1507. X        }
  1508. X        else if(sectcurr == sectnum)
  1509. X        {
  1510. X            report_str("Received duplicate Sector",-1);
  1511. X            sendchar = ACK;
  1512. X        }
  1513. X        else if(sectcurr == WCEOT)
  1514. X        {
  1515. X            if(close_and_report())
  1516. X                return(ERROR);
  1517. X            sendline(ACK);
  1518. X            report_last_txhdr("ACK",0);
  1519. X            Lleft=0;    /* Do read next time ... */
  1520. X            return(OK);
  1521. X        }
  1522. X        else if(sectcurr==ERROR)
  1523. X            return(ERROR);
  1524. X        else 
  1525. X        {
  1526. X            report_str( "Sync Error",1);
  1527. X            return(ERROR);
  1528. X        }
  1529. X    }
  1530. X}    /* end of wcrx */
  1531. X
  1532. X/*+-------------------------------------------------------------------------
  1533. X    readline(timeout)
  1534. X
  1535. X  read one or more characters timeout is in tenths of seconds
  1536. X--------------------------------------------------------------------------*/
  1537. Xreadline(timeout)
  1538. Xint timeout;
  1539. X{
  1540. XVOLATILE int n;
  1541. Xstatic unsigned char *cdq;    /* pointer for removing chars from linbuf */
  1542. X
  1543. X    if(--Lleft >= 0)
  1544. X        return(*cdq++);
  1545. X
  1546. X    n = timeout/10;
  1547. X    if(n < 2)
  1548. X        n = 3;
  1549. X    if(setjmp(tohere))
  1550. X    {
  1551. X        Lleft = 0;
  1552. X        return(TIMEOUT);
  1553. X    }
  1554. X    signal(SIGALRM,SIGALRM_handler);
  1555. X    alarm(n);
  1556. X    Lleft = read(iofd,(char *)(cdq = linbuf),Readnum);
  1557. X    alarm(0);
  1558. X    rx_char_count += Lleft;
  1559. X
  1560. X    if(Lleft < 1)
  1561. X        return(TIMEOUT);
  1562. X
  1563. X    --Lleft;
  1564. X    return(*cdq++);
  1565. X
  1566. X}    /* end of readline */
  1567. X
  1568. X/*+-------------------------------------------------------------------------
  1569. X    mkdir(dpath,dmode)
  1570. X Directory-creating routines from Public Domain TAR by John Gilmore
  1571. X Make a directory.  Compatible with the mkdir() system call on 4.2BSD.
  1572. X--------------------------------------------------------------------------*/
  1573. X#if defined(MD)
  1574. X#if (MD != 2)
  1575. X#define    TERM_SIGNAL(status)        ((status) & 0x7F)
  1576. X#define TERM_COREDUMP(status)    (((status) & 0x80) != 0)
  1577. X#define TERM_VALUE(status)        ((status) >> 8)
  1578. Xmkdir(dpath,dmode)
  1579. Xchar *dpath;
  1580. Xint dmode;
  1581. X{
  1582. Xint cpid,status;
  1583. Xstruct stat statbuf;
  1584. X
  1585. X    if(stat(dpath,&statbuf) == 0)
  1586. X    {
  1587. X        errno = EEXIST;        /* Stat worked,so it already exists */
  1588. X        return(-1);
  1589. X    }
  1590. X
  1591. X    /* If stat fails for a reason other than non-existence,return error */
  1592. X    if(errno != ENOENT)
  1593. X        return(-1);
  1594. X
  1595. X    switch(cpid = fork())
  1596. X    {
  1597. X
  1598. X    case -1:            /* Error in fork() */
  1599. X        return(-1);        /* Errno is set already */
  1600. X
  1601. X    case 0:                /* Child process */
  1602. X        /*
  1603. X         * Cheap hack to set mode of new directory.  Since this
  1604. X         * child process is going away anyway,we zap its umask.
  1605. X         * FIXME,this won't suffice to set SUID,SGID,etc. on this
  1606. X         * directory.  Does anybody care?
  1607. X         */
  1608. X        status = umask(0);    /* Get current umask */
  1609. X        status = umask(status | (0777 & ~dmode)); /* Set for mkdir */
  1610. X        execl("/bin/mkdir","mkdir",dpath,(char *)0);
  1611. X        _exit(-1);        /* Can't exec /bin/mkdir */
  1612. X
  1613. X    default:            /* Parent process */
  1614. X        while(cpid != wait(&status)) ;    /* Wait for kid to finish */
  1615. X    }
  1616. X
  1617. X    if(TERM_SIGNAL(status) != 0 || TERM_VALUE(status) != 0)
  1618. X    {
  1619. X        errno = EIO;        /* We don't know why,but */
  1620. X        return(-1);        /* /bin/mkdir failed */
  1621. X    }
  1622. X
  1623. X    return(0);
  1624. X}    /* end of mkdir */
  1625. X#endif /* MD != 2 */
  1626. X#endif /* if defined(MD) */
  1627. X
  1628. X/*+-------------------------------------------------------------------------
  1629. X    make_dirs(pathname)
  1630. X
  1631. X  Directory-creating routines from Public Domain TAR by John Gilmore
  1632. X  After a file/link/symlink/dir creation has failed, see if it's because
  1633. X  some required directory was not present, and if so, create all
  1634. X  required dirs.
  1635. X--------------------------------------------------------------------------*/
  1636. X#if defined(MD)
  1637. Xmake_dirs(pathname)
  1638. Xregister char *pathname;
  1639. X{
  1640. X    register char *p;            /* Points into path */
  1641. X    int madeone = 0;            /* Did we do anything yet? */
  1642. X    int save_errno = errno;        /* Remember caller's errno */
  1643. X
  1644. X    if(errno != ENOENT)
  1645. X        return(0);        /* Not our problem */
  1646. X
  1647. X    for(p = strchr(pathname,'/'); p != NULL; p = strchr(p+1,'/'))
  1648. X    {
  1649. X        /* Avoid mkdir of empty string,if leading or double '/' */
  1650. X        if(p == pathname || p[-1] == '/')
  1651. X            continue;
  1652. X        /* Avoid mkdir where last part of path is '.' */
  1653. X        if(p[-1] == '.' && (p == pathname+1 || p[-2] == '/'))
  1654. X            continue;
  1655. X        *p = 0;                /* Truncate the path there */
  1656. X        if( !mkdir(pathname,0777))    /* Try to create it as a dir */
  1657. X        {
  1658. X            sprintf(s128,"Made directory %s",pathname);
  1659. X            report_str(s128,-1);
  1660. X            madeone++;        /* Remember if we made one */
  1661. X            *p = '/';
  1662. X            continue;
  1663. X        }
  1664. X        *p = '/';
  1665. X        if(errno == EEXIST)        /* Directory already exists */
  1666. X            continue;
  1667. X        /*
  1668. X         * Some other error in the mkdir.  We return to the caller.
  1669. X         */
  1670. X        break;
  1671. X    }
  1672. X    errno = save_errno;        /* Restore caller's errno */
  1673. X    return(madeone);            /* Tell them to retry if we made one */
  1674. X}    /* end of make_dirs */
  1675. X#endif /* MD */
  1676. X
  1677. X/*+-------------------------------------------------------------------------
  1678. X    uncaps(str) - make string str lower case
  1679. X--------------------------------------------------------------------------*/
  1680. Xvoid
  1681. Xuncaps(str)
  1682. Xregister char *str;
  1683. X{
  1684. Xregister int itmp;
  1685. X
  1686. X    while(itmp = *str)
  1687. X    {
  1688. X        if(isupper(itmp))
  1689. X            *str = tolower(itmp);
  1690. X        str++;
  1691. X    }
  1692. X}    /* end of uncaps */
  1693. X
  1694. X/*+-------------------------------------------------------------------------
  1695. X    isanylc(str) - returns 1 if string str has any lower case letters
  1696. X--------------------------------------------------------------------------*/
  1697. Xint
  1698. Xisanylc(str)
  1699. Xregister char *str;
  1700. X{
  1701. X    while(*str)
  1702. X    {
  1703. X        if(islower(*str))
  1704. X            return(1);
  1705. X        str++;
  1706. X    }
  1707. X    return(0);
  1708. X}    /* end of isanylc */
  1709. X
  1710. X/*+-------------------------------------------------------------------------
  1711. X    procheader(name) - process incoming file information header
  1712. X--------------------------------------------------------------------------*/
  1713. Xint
  1714. Xprocheader(name)
  1715. Xchar *name;
  1716. X{
  1717. Xregister char *openmode,*p;
  1718. X
  1719. X    /* set default parameters and overrides */
  1720. X    openmode = "w";
  1721. X    Thisbinary = (!Rxascii) || Rxbinary;
  1722. X    if(Lzmanag)
  1723. X        zmanag = Lzmanag;
  1724. X
  1725. X    /*
  1726. X     *  Process ZMODEM remote file management requests
  1727. X     */
  1728. X    if(!Rxbinary && zconv == ZCNL)    /* Remote ASCII override */
  1729. X        Thisbinary = 0;
  1730. X    if(zconv == ZCBIN)    /* Remote Binary override */
  1731. X        Thisbinary = 1;
  1732. X    else if(zmanag == ZMAPND)
  1733. X        openmode = "a";
  1734. X
  1735. X    report_xfer_mode(Thisbinary ? "BINARY" : "ASCII");
  1736. X    this_file_errors = 0;
  1737. X
  1738. X    Bytesleft = DEFBYTL;
  1739. X    Filemode = 0;
  1740. X    Modtime = 0L;
  1741. X    this_file_length = 0;
  1742. X
  1743. X    if(strlen(name))
  1744. X        p = name + 1 + strlen(name);
  1745. X    else
  1746. X        p = name;
  1747. X
  1748. X#if defined(M_UNIX)
  1749. X    if(fname_too_long(name))
  1750. X    {
  1751. X        strcpy(s128,"truncated: ");
  1752. X        strncat(s128,name,sizeof(s128) - 12);
  1753. X        ecu_log_event(getppid(),s128);
  1754. X        report_str(s128,-1);
  1755. X        name = fname_truncated();
  1756. X    }
  1757. X#endif
  1758. X
  1759. X    if(*p)
  1760. X    {    /* file coming from Unix or DOS system */
  1761. X    int sscanf_count;
  1762. X    int SerialNumber;
  1763. X    int Filesleft;
  1764. X    long TotalLeft;
  1765. X
  1766. X        sscanf_count = sscanf(p,"%ld%lo%o%d&d&ld",
  1767. X            &Bytesleft,&Modtime,&Filemode,&SerialNumber,
  1768. X            &Filesleft,&TotalLeft);
  1769. X
  1770. X        switch(sscanf_count)
  1771. X        {
  1772. X        case 6:    /* TotalLeft */
  1773. X            if(!TotalToReceive)
  1774. X                TotalToReceive = TotalLeft;
  1775. X        case 5:    /* Filesleft */
  1776. X            if(!npats)
  1777. X                npats = Filesleft;
  1778. X        default:
  1779. X            break;
  1780. X        }
  1781. X
  1782. X        if((zmanag & ZMMASK) == ZMNEW)
  1783. X        {
  1784. X            if(stat(name,&fout_stat) == 0)            /* if file accessable ... */
  1785. X            {
  1786. X                if(Modtime <= fout_stat.st_mtime)    /* ... and not older */
  1787. X                {
  1788. X                    sprintf(s128,"RECEIVE skipped: %s (same or later date)",
  1789. X                        name);
  1790. X                    report_str(s128 + 8,-1);
  1791. X                    skip_count++;
  1792. X                    report_error_count();
  1793. X#if defined(LOG_SKIP)
  1794. X                    ecu_log_event(getppid(),s128);
  1795. X#endif
  1796. X                    return(ERROR);
  1797. X                }
  1798. X            }
  1799. X        }
  1800. X        /* Check for existing file */
  1801. X        else if(!Rxclob && ((zmanag & ZMMASK) != ZMCLOB) &&
  1802. X            (fout=fopen(name,"r")))
  1803. X        {
  1804. X            fclose(fout);
  1805. X            sprintf(s128,"RECEIVE skipped: %s (already exists)",name);
  1806. X            report_str(s128 + 8,-1);
  1807. X            skip_count++;
  1808. X            report_error_count();
  1809. X#if defined(LOG_SKIP)
  1810. X            ecu_log_event(getppid(),s128);
  1811. X#endif
  1812. X            return(ERROR);
  1813. X        }
  1814. X
  1815. X        if(Filemode & UNIXFILE)
  1816. X            ++Thisbinary;
  1817. X        ++Filcnt;
  1818. X
  1819. X        report_file_rcv_started( name,
  1820. X            (Bytesleft != DEFBYTL) ? Bytesleft : 0,Modtime,Filemode);
  1821. X        report_rxpos(0L);
  1822. X        report_str("",0);    /* get rid of End of File */
  1823. X        if(Bytesleft != DEFBYTL)
  1824. X        {
  1825. X            long min_100;
  1826. X            this_file_length = Bytesleft;
  1827. X            min_100 = 2L + (((Bytesleft * 11L)) * 10L) / (Baudrate * 6L);
  1828. SHAR_EOF
  1829. true || echo 'restore of z/ecurz.c failed'
  1830. fi
  1831. echo 'End of ecu310 part 20'
  1832. echo 'File z/ecurz.c is continued in part 21'
  1833. echo 21 > _shar_seq_.tmp
  1834. exit 0
  1835. --------------------------------------------------------------------
  1836. Warren Tucker, TuckerWare emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
  1837. Hacker Extraordinaire  d' async PADs,  pods,  proteins and protocols
  1838.  
  1839. exit 0 # Just in case...
  1840. -- 
  1841. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1842. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1843. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1844. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1845.