home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8708 / 19 < prev    next >
Encoding:
Internet Message Format  |  1990-07-13  |  18.5 KB

  1. From: Stuart.Lynne@van-bc.UUCP (Stuart Lynne)
  2. Newsgroups: comp.sources.misc
  3. Subject: uupc.mac.8.4
  4. Message-ID: <4197@ncoast.UUCP>
  5. Date: 17 Aug 87 01:14:52 GMT
  6. Sender: allbery@ncoast.UUCP
  7. Lines: 904
  8. Approved: allbery@ncoast.UUCP
  9. X-Archive: comp.sources.misc/8708/19
  10.  
  11. >From uucp Wed Aug 12 02:43 PDT 1987
  12. >From slynne  Wed Aug 12 02:42:15 1987 remote from slmac
  13. Received: by van-bc.uucp (smail2.3)
  14.     id AA17598; 12 Aug 87 02:42:15 PDT (Wed)
  15. Received: by slmac.vnet.van-bc.uucp (pcmail) Wed Aug 12 02:37:52 1987
  16. Date: Wed Aug 12 02:37:52 1987
  17. From: Stuart Lynne - test a mac <slynne@slmac.vnet.van-bc.uucp>
  18. Message-ID: <149@slmac.vnet.van-bc.uucp>
  19. To: sl@van-bc
  20. Subject: shar/uupc.mac.8.4
  21.  
  22. #! /bin/sh
  23. # This is a shell archive, meaning:
  24. # 1. Remove everything above the #! /bin/sh line.
  25. # 2. Save the resulting text in a file.
  26. # 3. Execute the file with /bin/sh (not csh) to create the files:
  27. #    mac/README.MAC
  28. #    mac/Makefile.mac
  29. #    mac/host.c
  30. #    mac/host.h
  31. #    mac/mlib.c
  32. #    mac/ulib.c
  33. #    mac/profile
  34. #    mac/ndir.h
  35. # This archive created: Wed Aug 12 02:02:50 1987
  36. # By:    Stuart Lynne - test a mac ()
  37. export PATH; PATH=/bin:$PATH
  38. if test -f 'mac/README.MAC'
  39. then
  40.        echo shar: will not over-write existing file "'mac/README.MAC'"
  41. else
  42. cat << \SHAR_EOF > 'mac/README.MAC'
  43. mac             June 8, 1987        Stuart Lynne
  44.  
  45. For Beta implementors only.
  46.  
  47. uupc incorporates a streamlined version of dcp to implement a uucp mail
  48. and news delivery system. 
  49.  
  50. See README.DCP for dcp info.
  51. See README.UU for overview of this version.
  52.  
  53. This directory implements the macintosh version of host support routines. 
  54. It runs under the Aztec Shell environment.
  55.  
  56. By moving the host dependant code into one file the other four dcp files can 
  57. hopefully be maintained easily. It should be possible to maintain one version
  58. of them which compiles and runs on all machines without conditional compilation
  59. flags.
  60.  
  61. To simplify things for other systems (Atari) use of -D in the cc command is
  62. not used. Instead various small files are used to set flags and then include
  63. a common file.
  64.  
  65. host.h             - include <host/host.h>
  66. mailhost.c        - define MAIN mailmain; include <host/host.h>
  67. mlib.c            - include <host/mlib.c>
  68. ulib.c            - include <host/ulib.c>
  69. uuhost.c        - define MAIN mailmain; include <host/host.h>
  70.  
  71. mac/host.c         - generic macintosh host, calls MAIN
  72. mac/host.h         - macintosh host header file
  73. mac/mlib.c         - mail library
  74. mac/ulib.c         - uupc library
  75.  
  76. mac/profile        - a sample aztec profile file to set environment varialbes
  77.  
  78. There is actually fairly little code here. I have a separate set of library 
  79. routines for doing the standard things like directory support. See 
  80. the shar file for the Macintosh library (maclib.shar).
  81.  
  82. A separate uux command is included in uupc for the Macintosh (not finished yet).
  83. Called macbin it copies a MacBinary image from stdin to a Macintosh file.
  84. This allows macintosh files, including both forks and the finder info to be
  85. stored in a single file on the remote system. It can then be retrieved by:
  86.  
  87.     uux macfile > remotemac!macbin
  88.  
  89. A standalone macbin will be available to convert a Macintosh file into a
  90. flat file with the MacBinary image.
  91.  
  92. For more information, bug fixes, more commands etc:
  93.  
  94.         Stuart.Lynne@van-bc.uucp
  95.         604-937-7532
  96.  
  97.  
  98.  
  99. PS. July 29/87
  100.  
  101. See the Amiga version for a genv.c that gets environment var's from
  102. a profile file directly. I havn't had time to try on mac yet. 
  103.  
  104. I have made a VERY PRELIMINARY start at a standalone version, but have
  105. not completed it yet. I hope to get more time to work on this early
  106. in the fall. In the meantime anyone who could get this running as a Mac
  107. application.... please feel free. And send me the changes.
  108.  
  109. sl
  110.  
  111. SHAR_EOF
  112. chmod +x 'mac/README.MAC'
  113. fi # end of overwriting check
  114. if test -f 'mac/Makefile.mac'
  115. then
  116.        echo shar: will not over-write existing file "'mac/Makefile.mac'"
  117. else
  118. cat << \SHAR_EOF > 'mac/Makefile.mac'
  119. #        Makefile for uupc/dcp with Macintosh Aztec C
  120. #
  121. #        Stuart Lynne
  122. #        May/87
  123. #
  124.  
  125.  
  126. .c.o:
  127.     cc $(CFLAGS) $*.c
  128.  
  129. #LFLAGS= -M -lx /usr/lib/mixcroot.o -lc
  130. #CFLAGS= -E200 -DSTANDALONE
  131. LFLAGS= -lx -lc
  132. CFLAGS= -E200 -Y200
  133. LIBS=
  134.  
  135. OFILES= dcp.o dcpsys.o dcpxfer.o dcpgpkt.o rmail.o \
  136.           lib.o
  137.  
  138.  
  139. all:     uupc mail
  140.     echo uupc & mail done
  141.  
  142. #
  143. # .o dependicies
  144. #
  145. dcp.o: dcp.c dcp.h local/host.h
  146. dcpsys.o: dcpsys.c dcp.h local/host.h
  147. dcpxfer.o: dcpxfer.c dcp.h local/host.h
  148. dcpgpkt.o: dcpgpkt.c dcp.h local/host.h
  149. lib.o: lib.c local/host.h
  150. lmail.o: pcmail.c lmail.c local/host.h
  151. mailhost.o: local/host.c local/host.h
  152. mail.o: local/host.h
  153. mlib.o: local/mlib.c local/host.h
  154. ulib.o: local/ulib.c local/host.h
  155. uuhost.o: local/host.c local/host.h
  156.  
  157. #
  158. # mail
  159. #
  160. mail: lmail.o mailhost.o mail.o mlib.o lib.o Makefile
  161.     ln mailhost.o mail.o lmail.o mlib.o lib.o $(LIBS) $(LFLAGS) -o mail
  162.  
  163. #
  164. # uupc
  165. #
  166. uupc:    uuhost.o $(OFILES) ulib.o lib.o Makefile
  167.     ln uuhost.o ulib.o $(OFILES) $(LIBS) $(LFLAGS) -o uupc
  168.  
  169. #
  170. # simple shar constructing
  171. #
  172. SDCP     =  dcp.c dcp.h dcpgpkt.c dcpsys.c dcpxfer.c
  173.  
  174. SUU        = host.h lib.c lmail.c mail.c mailhost.c mlib.c \
  175.         ndir.h pcmail.c rmail.c ulib.c uuhost.c systems
  176.  
  177. SREAD    = README.DCP README.UUPC README.PORT README.INFO  
  178.  
  179. SMAC    = mac/README.MAC mac/Makefile.mac\
  180.         mac/host.c mac/host.h mac/mlib.c mac/ulib.c mac/profile \
  181.         mac/ndir.h
  182.  
  183. SST        = st/README.ST \
  184.         st/host.c st/host.h  \
  185.         st/c.mm st/cu.mm st/dirsubs.c st/dmymath.c st/env.mm \
  186.         st/fgets.c st/genv.c st/getargs.c st/getenv.c \
  187.         st/getone.c st/host.c st/host.h \
  188.         st/inoutpth.c st/ldcp.mm \
  189.         st/l.mm st/l1.mm st/ldcp.mm st/lmail.mm \
  190.         st/ndir.c st/ndir.h st/printmsg.c st/readme.st st/shell.c \
  191.         st/startup.mm st/time.c st/utar.mm st/uu.mm st/uuar.mm \
  192.         st/uusup.c  st/zdcp.h st/zgenv.h st/zzgenv.h \
  193.         st/zhost.h st/zzhost.h st/zmailhos.c st/zzmailhost.c \
  194.         st/zndir.h st/zzndir.h st/zztime.h st/zuuhost.c 
  195.  
  196.  
  197. SAMI    = amiga/README.Amiga amiga/Makefile.ami amiga/Makefile \
  198.         amiga/chdir.c amiga/genv.c amiga/genv.dyna \
  199.         amiga/genv.h amiga/getcwd.c amiga/host.c amiga/host.h \
  200.         amiga/mkdir.c amiga/mlib.c \
  201.         amiga/ndir.c amiga/ndir.h \
  202.         amiga/SerialIO.c amiga/sio.c \
  203.         amiga/sleep.c amiga/Timer.c amiga/ulib.c
  204.  
  205. SDOS    = dos/README.DOS dos/Makefile.dos \
  206.         dos/comm.asm dos/comm.h \
  207.         dos/host.c dos/host.h \
  208.         dos/mlib.c dos/ndir.c dos/ndir.h \
  209.         dos/setup.bat dos/ulib.c
  210.  
  211. shar: shar/uupc.dcp.8.3 shar/uupc.uu.8.2 shar/uupc.read.8.1 \
  212.         shar/uupc.mac.8.4 shar/uupc.st.8.5 shar/uupc.ami.8.6 \
  213.         shar/uupc.dos.8.7
  214.  
  215. shar/uupc.read.8.1: $(SUU)
  216.     shar $(SREAD) > shar/uupc.read.8.1
  217. shar/uupc.uu.8.2: $(SUU)
  218.     shar $(SUU) > shar/uupc.uu.8.2
  219. shar/uupc.dcp.8.3: $(SDCP)
  220.     shar  $(SDCP) > shar/uupc.dcp.8.3
  221. shar/uupc.mac.8.4: $(SMAC)
  222.     cp Makefile mac/Makefile.mac
  223.     shar $(SMAC) > shar/uupc.mac.8.4
  224. shar/uupc.st.8.5: $(SST)
  225.     shar $(SST) > shar/uupc.st.8.5
  226. shar/uupc.ami.8.6: $(SAMI)
  227.     shar $(SAMI) > shar/uupc.ami.8.6
  228. shar/uupc.dos.8.7: $(SDOS)
  229.     shar $(SDOS) > shar/uupc.dos.8.7
  230.  
  231. clean:
  232.     rm *.o *.bak CC.TMP
  233.  
  234.  
  235. SHAR_EOF
  236. chmod +x 'mac/Makefile.mac'
  237. fi # end of overwriting check
  238. if test -f 'mac/host.c'
  239. then
  240.        echo shar: will not over-write existing file "'mac/host.c'"
  241. else
  242. cat << \SHAR_EOF > 'mac/host.c'
  243. /*        mac.c
  244.  
  245.         macintosh host 
  246.  
  247. */
  248.  
  249. #include <stdio.h>
  250. #include "host.h"
  251.  
  252. #include <ctype.h>
  253. #include <setjmp.h>
  254. #include <errno.h>
  255.  
  256. char *curdir;
  257. char * getcwd();
  258. FILE * FOPEN();
  259.  
  260. int CHDIR();
  261. int    debuglevel;        /* debugging level */
  262.  
  263. #ifdef STANDALONE
  264. char *flds[10];
  265. char line[128];
  266.  
  267. #define DMAILBOX    "mailbox"
  268. #define    DNAME        ""
  269. #define DHOME        "/usr/guest"
  270. #define    DDOMAIN        "pc.uucp"
  271. #define    DMAILDIR    "/usr/mail"
  272. #define    DCONFDIR    "/usr/lib/uucp"
  273. #define    DSPOOLDIR    "/usr/spool/uucp"
  274. #define DPUBDIR        "/usr/spool/uucppublic"
  275. #define    DMAILSERVICE    "host"
  276. #define    DNODENAME    ""
  277. #define    DDEVICE        ".a"
  278. #define    DSPEED        "1200"
  279. #define    DTEMPDIR    "/tmp"
  280.  
  281. FILE *fe;
  282.  
  283. void sgenv(thename, envname, dflt)
  284. char **thename;
  285. char *envname;
  286. char *dflt;
  287. {
  288.     char line[BUFSIZ];
  289.  
  290.     fprintf( stderr, "genv: %s %s\n", envname, dflt ); /**/
  291.     
  292.     if (fgets( line, BUFSIZ, fe ) == NULL) {
  293.         fprintf( stderr, "genv: %s not found, using %s\n", envname, dflt ); /* */
  294.         strcpy( *thename, dflt);
  295.     }
  296.     else {
  297.         strcpy( *thename, line);
  298.         fprintf( stderr, "genv: %s %s\n", envname, *thename ); /**/
  299.     }
  300. }
  301.  
  302. void sloadenv()
  303. {
  304.     fprintf( stderr, "sloadenv\n" );
  305.     if ( (fe = FOPEN( "/usr/lib/uucp/defaults", "r" )) == (FILE *) NULL ) {
  306.         fprintf( stderr, "can't open /usr/lib/uucp/defaults  %d\n", errno );
  307.         exit( -1 );
  308.     }
  309.     fprintf( stderr, "sloadenv - fopened\n" );
  310.     /* get environment var's */
  311.     sgenv( &name, NAME, DNAME );
  312.     sgenv( &mailbox, MAILBOX, DMAILBOX );
  313.     sgenv( &nodename, NODENAME, DNODENAME );
  314.     sgenv( &home, HOME, DHOME );
  315.     sgenv( &domain, DOMAIN, DDOMAIN );
  316.     sgenv( &maildir, MAILDIR, DMAILDIR );
  317.     sgenv( &confdir, CONFDIR, DCONFDIR );
  318.     sgenv( &spooldir, SPOOLDIR, DSPOOLDIR );
  319.     sgenv( &pubdir, PUBDIR, DPUBDIR );
  320.     sgenv( &mailserv, MAILSERVICE, DMAILSERVICE );
  321.     sgenv( &device, DEVICE, DDEVICE );
  322.     sgenv( &speed, SPEED, DSPEED );
  323.     sgenv( &tempdir, TEMPDIR, DTEMPDIR );
  324. }
  325. #endif
  326.  
  327. jmp_buf    dcpexit;
  328.  
  329. char *gets();
  330.  
  331. main( argc, argv )
  332. int    argc;
  333. char *argv[];
  334. {
  335.  
  336.     macinit();
  337.  
  338. #ifdef STANDALONE
  339.     fprintf( stderr, "Please enter parameters: " );
  340.     if ( gets( line ) == (char *) NULL )
  341.         exit( -1 );
  342.     getargs( line, flds );
  343.     argv = flds;
  344.     /* mac specific prolog */
  345.     sloadenv();
  346. #else
  347.     /* mac specific prolog */
  348.     loadenv();
  349. #endif
  350.     
  351.     
  352.     curdir = getcwd( NULL, 0 );
  353.  
  354. #ifdef CWDSPOOL
  355.     CHDIR( spooldir );
  356. #endif
  357.  
  358.     /* setup longjmp for error exit's */
  359.     if ( setjmp( dcpexit ) == 0 ) {
  360.  
  361.         MAIN( argc, argv );
  362.  
  363.     }
  364.     
  365.  
  366.     /* mac specific epilog */
  367.     chdir( curdir );
  368.  
  369. }
  370.  
  371.  
  372. /* canonical name conversio routines
  373.  
  374.     importpath    canonical -> host
  375.     exportpath    host -> canonical
  376.  
  377.     host        your local pathname format
  378.     canonical    unix style
  379. */
  380.  
  381. importpath( host, canon )
  382. char * host;
  383. char * canon;
  384. {
  385.     sprintf( host, "%s", canon );
  386. }
  387.  
  388. exportpath( canon, host )
  389. char * host;
  390. char * canon;
  391. {
  392.  
  393.  
  394. }
  395.  
  396.  
  397.  
  398. SHAR_EOF
  399. chmod +x 'mac/host.c'
  400. fi # end of overwriting check
  401. if test -f 'mac/host.h'
  402. then
  403.        echo shar: will not over-write existing file "'mac/host.h'"
  404. else
  405. cat << \SHAR_EOF > 'mac/host.h'
  406.  /*        mac.h
  407.  
  408.         Macintosh version
  409.  
  410. */
  411.  
  412. /*#include <local/genv.h>*/
  413. #include <genv.h>
  414. #include <time.h>
  415. #include <errno.h>
  416. #include <ctype.h>
  417.  
  418. #define SAME     0
  419. #define    FALSE    0
  420. #define    TRUE    1
  421.  
  422. #define    TFILENAME    "tmpfile.%.7d"
  423. #define    SFILENAME    "SEQF"
  424.  
  425. #define SEPCHAR        '/'    /* path separater character        */
  426. #define SIGFILE        ".signature"    /* file containing signature    */
  427. #define COPYFILE    "Mail/mail.sent"    /* copy of sent mail    */
  428. #define NEWSDIR        "/usr/spool/rnews/%02d%02d%02d%02d%02d%02d.%03d"
  429.  
  430. #define HOSTINIT    macinit()    /* name of function used to initialize    */
  431.  
  432. #define FILEMODE(f)
  433.  
  434. #define    CALLFILE    "C."
  435. #define    XQTFILE        "X."
  436.  
  437. #include <local/genv.h>
  438. extern    char * fgets();
  439. extern    char * index();
  440.  
  441. extern     int    debuglevel;                  /* debuglevelging level */
  442.  
  443.  
  444. SHAR_EOF
  445. chmod +x 'mac/host.h'
  446. fi # end of overwriting check
  447. if test -f 'mac/mlib.c'
  448. then
  449.        echo shar: will not over-write existing file "'mac/mlib.c'"
  450. else
  451. cat << \SHAR_EOF > 'mac/mlib.c'
  452. /*        lib.c
  453.  
  454.  
  455.         macintosh library
  456.         
  457.  
  458.     Things to do in uu host
  459.  
  460.         serial I/O
  461.         
  462.         directory stuff
  463.             opendir, readdir, closedir
  464.  
  465.         prolog and epilog
  466.  
  467.         system call
  468.  
  469. */
  470.  
  471. #include <stdio.h>
  472. #include "host.h"
  473. #include <sgtty.h>
  474.  
  475. int get_one()
  476. {
  477.     char c;
  478.     
  479.     struct sgttyb stty, sttyo;
  480.     ioctl( 0, TIOCGETP, &stty );
  481.     sttyo = stty;
  482.     stty.sg_flags |= CBREAK;
  483.     stty.sg_flags &= ~ ECHO;
  484.     ioctl( 0, TIOCSETP, &stty );
  485.     c = fgetc( stdin );
  486.     ioctl( 0, TIOCSETP, &sttyo );
  487.     return( c );
  488. }
  489.  
  490.  
  491.  
  492. SHAR_EOF
  493. chmod +x 'mac/mlib.c'
  494. fi # end of overwriting check
  495. if test -f 'mac/ulib.c'
  496. then
  497.        echo shar: will not over-write existing file "'mac/ulib.c'"
  498. else
  499. cat << \SHAR_EOF > 'mac/ulib.c'
  500. /*        ulib.c
  501.  
  502.  
  503.         macintosh library
  504.         
  505.  
  506.     Things to do in uu host
  507.  
  508.         serial I/O
  509.         
  510.         directory stuff
  511.             opendir, readdir, closedir
  512.  
  513.         prolog and epilog
  514.  
  515.         system call
  516.  
  517. */
  518.  
  519. #include <stdio.h>
  520. #include "host.h"
  521. #include <sgtty.h>
  522.  
  523.  
  524.  
  525. /* */
  526. /*
  527.  *
  528.  *      login (for slave in PC mode)
  529.  * Real dumb login handshake
  530. */
  531. login()
  532. {
  533.     char    logmsg[132];
  534. #ifdef PC
  535. lretry:
  536.     msgtime = 9999;
  537.     rmsg(logmsg, 0); /* wait for a <CR> or <NL> */
  538.     msgtime = 2 * MSGTIME;
  539.     wmsg("Username:", 0);
  540.     rmsg(logmsg, 0);
  541.     printmsg( 0, "Username = %s", logmsg );
  542.     wmsg("Password:", 0);
  543.     rmsg(logmsg, 0);
  544.     printmsg( 14, "Password = %s", logmsg );
  545.     if (strcmp(logmsg, "uucp") != 0) 
  546.         goto lretry;
  547. #endif
  548.     return('I');
  549. }
  550.  
  551.  
  552. char inbuf[BUFSIZ];
  553. char outbuf[BUFSIZ];
  554.  
  555. swrite(data, num)
  556. int    num;
  557. char    *data;
  558. {
  559.  
  560.     int test;
  561.     unsigned char * cp;
  562.  
  563.     if (debuglevel > 14)
  564.         fputc( '{', stderr );
  565.     if (debuglevel > 14) {
  566.         test = num;
  567.         cp = data;
  568.         while (test--)
  569.             fprintf( stderr, isprint(*cp)? "{%c}":"{%02x}", *cp++ );
  570.     }
  571.     test = SIOWrite( data, num );
  572.     if (debuglevel > 14)
  573.         fputc( '}', stderr );
  574.     return( test );
  575.  
  576. }
  577.  
  578. /* non-blocking read essential to "g" protocol */
  579. /* see "dcpgpkt.c" for description */
  580. /* This all changes in a mtask systems. Requests for */
  581. /* I/O should get qued and an event flag given. Then the */
  582. /* requesting process (e.g.gmachine()) waits for the event */
  583. /* flag to fire processing either a read or a write. */
  584. /* Could be implemented on VAX/VMS or DG but not MS-DOS */
  585. sread(buf, num, timeout)
  586. char    *buf;
  587. int    num, timeout;
  588. {
  589. /*
  590.     return( SIORead( buf, num, num, timeout*10 ) );
  591. */
  592.     int count;
  593.     int test;
  594.     unsigned char * cp;
  595.  
  596.     if (debuglevel > 13)
  597.         fputc( '[', stderr );
  598.     printmsg( 15, "sread: num: %d  timeout: %d", num, timeout );
  599.         
  600.     count = SIORead( buf, num, num, timeout*10 );
  601.     printmsg( 15, "sread: read: %d ", count );
  602.  
  603.     if (debuglevel > 13 && count > 0) {
  604.         test = count;
  605.         cp = buf;
  606.         while (test--)
  607.             fprintf( stderr, isprint(*cp)? "[%c]":"[%02x]", *cp++ );
  608.     }
  609.         
  610.     if (debuglevel > 13)
  611.         fputc( ']', stderr );
  612.     return( count );    
  613.     
  614. }
  615.  
  616.  
  617.  
  618. openline(name, baud)
  619. char    *name, *baud;
  620. {
  621.  
  622.     printmsg( 3, "openline: name: \"%s\"  baud: \"%s\"", name, baud );
  623.     SIOInit( name, baud );
  624.     SIOInBuffer( inbuf, BUFSIZ );
  625.     SIOOutBuffer( outbuf, BUFSIZ );
  626.     return( 0 );
  627. }
  628.  
  629.  
  630. closeline()
  631. {
  632.     SIOClose( 1 );
  633. }
  634.  
  635.  
  636. nodot(string)
  637. {
  638. }
  639.  
  640.  
  641.  
  642. notimp( argc, argv )
  643. char *argv[];
  644. {
  645.     /*debuglevelMsg("\Pcheck argc (08) and argv (0a) ");*/
  646.     fprintf( stderr, "shell: %s not implemented\n", *argv );
  647. }
  648.  
  649. /*         shell
  650.  
  651.  
  652. */
  653.  
  654. char * getcwd();
  655.  
  656. shell( command, inname, outname, errname )
  657. char * command;
  658. char * inname;
  659. char * outname;
  660. {
  661.  
  662.     char    * argvec[50];
  663.  
  664.     int rmail();
  665.     int rnews();
  666.     int macbin();
  667.     
  668.     int     argcp;
  669.  
  670.     char **argvp;
  671.     char args;
  672.     
  673.  
  674.     int    (*proto)();
  675.     
  676.     argcp = 0;
  677.  
  678.     argcp = getargs( command, argvec );
  679.  
  680.     argvp = argvec;
  681.     args = argcp;
  682.  
  683.     if ( debuglevel > 5 ) {
  684.         while ( args ) 
  685.             fprintf( stderr, "arg: %d  %s\n", args--, *argvp++ );
  686.         argvp = argvec;
  687.         args = argcp;
  688.     }
  689.     /* */
  690.     
  691.     proto = notimp;
  692.  
  693.     if ( strcmp( *argvp, "rmail" ) == SAME )
  694.         proto = rmail;
  695.  
  696.     else if ( strcmp( *argvp, "rnews" ) == SAME ) 
  697.         proto = rnews;
  698.     
  699.     else if ( strcmp( *argvp, "macbin" ) == SAME ) 
  700.         proto = macbin;
  701.     
  702.         
  703.     if ( *inname != '\0' ) {
  704.         /* fprintf( stderr, "reopening stdin as %s\n", inname );
  705.         fprintf( stderr, "curdir: %s\n", getcwd(NULL, 0)); /* */
  706.         if ( freopen( inname, "r", stdin ) == NULL ) 
  707.             fprintf( stderr, "Couldn't open %s, %d\n", inname, errno );
  708.     }
  709.     (proto)( argcp, argvp );
  710.  
  711.     freopen( ".console", "r", stdin );
  712.  
  713. }
  714.  
  715.  
  716. /*
  717.     macbin
  718.  
  719.     copy a macbinary image from stdin into a macintosh file
  720.  
  721.         128 bytes of header information
  722.         (n+128)/128*128 bytes of data fork data
  723.         (n+128)/128*128 bytes of resource fork data
  724.  
  725.     The name is derived from the header information
  726.  
  727.     The directory is given as an arguement
  728.  
  729.  
  730.     on remote system use:
  731.  
  732.         uux macfile.mb > remotemac!macbin /usr/sl
  733.  
  734.  
  735. */
  736.  
  737. #undef TRUE
  738.  
  739. #include <types.h>
  740. #include <pb.h>
  741.  
  742. /* #include <stdio.h> */
  743.  
  744. typedef struct {
  745.     /*
  746.     char                blknum;
  747.     char                mblknum;
  748.     */
  749.     char                dummy;
  750.  
  751.     char                version;
  752.  
  753.     char                fName[64];
  754.     FInfo                finderInfo;            /* check - starts on odd byte boundary */
  755.     char                protected;
  756.     char                ckZero1;
  757.     long                dfLength;
  758.     long                rfLength;
  759.     long                crDat;
  760.     long                mdDat;
  761.     char                fill1[27];
  762.     char                computer;
  763.     char                os;
  764.     } MacBinHeader;
  765.  
  766.  
  767.  
  768. int macbin( argc, argv )
  769. int argc;
  770. char *argv[];
  771. {
  772. #ifdef TESTETEST
  773.     char    filename[132];
  774.     char    buf[BUFSIZ];
  775.     MacBinHeader mbh;
  776.     long    count, size;
  777.     int        i;
  778.  
  779.     HPrmBlkRec    pbr;
  780.  
  781.     /* get the header */
  782.     fread( &mbh.version, 1, 128, stdin );
  783.  
  784.  
  785.     /* create and open the file */
  786.     strncpy( pbr.ioNamePtr, mbh.fName, 64 );
  787.     pbr.ioVRefNum = 0;
  788.     pbr.u.hfp.ioFVersNum = 0;
  789.     PBCreate( &pbr, FALSE );
  790.  
  791.  
  792.     /* get finder info */
  793.     pbr.u.hfp.ioFDirIndex = 0;
  794.     pbr.u.hfp.ioDirID = 0L;
  795.     PBGetInfo( &pbr, FALSE );
  796.     
  797.     /* set finder info */
  798.     pbr.u.hfp.ioFlFndrInfo.fdFldr = 0;
  799.     pbr.u.hfp.ioFlCrDat = mbh.crDat;
  800.     pbr.u.hfp.ioFlMdDat = mbh.mdDat;
  801.     pbr.u.hfp.ioFlFndrInfo = mbh.finderInfo;
  802.     PBSetInfo( &pbr, FALSE );
  803.  
  804.     /* get and write out the fork */
  805.     pbr.u.iop.ioPermssn = 0;
  806.     pbr.u.iop.ioMisc = 0L;
  807.     for ( i = 1; i > 0 ; i-- ) {
  808.         if (i == 1 ) {
  809.             PBOpen( &pbr, FALSE );
  810.             size = (mbh.dfLength + 127) & 0xffffff80;
  811.         }
  812.         else {
  813.             PBROpen( &pbr, FALSE );
  814.             size = (mbh.rfLength + 127) & 0xffffff80;
  815.         }
  816.         while ( size > 0 )
  817.             if ( (count = fread( buf, 1, BUFSIZ, stdin )) != 0 ) {
  818.                 size -= count;
  819.                 pbr.u.iop.ioBuffer = buf;
  820.                 pbr.u.iop.ioReqCount = count;
  821.                 PBWrite ( &pbr, FALSE);
  822.             }
  823.         PBClose( &pbr, FALSE );
  824.     }
  825. #endif
  826. }
  827.  
  828.  
  829.  
  830. SHAR_EOF
  831. chmod +x 'mac/ulib.c'
  832. fi # end of overwriting check
  833. if test -f 'mac/profile'
  834. then
  835.        echo shar: will not over-write existing file "'mac/profile'"
  836. else
  837. cat << \SHAR_EOF > 'mac/profile'
  838.  
  839. set NAME="Stuart Lynne - test a mac"
  840. set MAILBOX=slynne
  841. set HOME=/usr/sl
  842.  
  843. set DOMAIN="slmac.vcr.bc.can"
  844. set MAILSERVICE="van-bc"
  845. set NODENAME=slmac
  846.  
  847.  
  848. SHAR_EOF
  849. chmod +x 'mac/profile'
  850. fi # end of overwriting check
  851. if test -f 'mac/ndir.h'
  852. then
  853.        echo shar: will not over-write existing file "'mac/ndir.h'"
  854. else
  855. cat << \SHAR_EOF > 'mac/ndir.h'
  856. /* @(#)ndir.h    1.4    4/16/85 */
  857. #ifndef DEV_BSIZE
  858. #define    DEV_BSIZE    512
  859. #endif
  860. #define DIRBLKSIZ    DEV_BSIZE
  861. #define    MAXNAMLEN    255
  862.  
  863. struct    direct {
  864.     long    d_ino;            /* inode number of entry */
  865.     short    d_reclen;        /* length of this record */ 
  866.     short    d_namlen;        /* length of string in d_name */
  867.     char    d_name[MAXNAMLEN + 1];    /* name must be no longer than this */
  868. };
  869.  
  870. /*
  871.  * The DIRSIZ macro gives the minimum record length which will hold
  872.  * the directory entry.  This requires the amount of space in struct direct
  873.  * without the d_name field, plus enough space for the name with a terminating
  874.  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  875.  */
  876.  
  877. #ifdef DIRSIZ
  878. #undef DIRSIZ
  879. #endif /* DIRSIZ */
  880. #define DIRSIZ(dp) \
  881.     ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
  882.  
  883. /*
  884.  * Definitions for library routines operating on directories.
  885.  */
  886. /*
  887. typedef struct _dirdesc {
  888.     int    dd_fd;
  889.     long    dd_loc;
  890.     long    dd_size;
  891.     char    dd_buf[DIRBLKSIZ];
  892. } DIR;
  893. */
  894. typedef struct _dirdesc {
  895.     int     ioVRefNum;
  896.     long    ioDrDirID;
  897.     int        ioFDirIndex;
  898. } DIR;
  899. #ifndef NULL
  900. #define NULL 0L
  901. #endif
  902. extern    DIR *opendir();
  903. extern    struct direct *readdir();
  904. extern    void closedir();
  905. extern char * getcwd();
  906.  
  907. SHAR_EOF
  908. chmod +x 'mac/ndir.h'
  909. fi # end of overwriting check
  910. #    End of shell archive
  911. exit 0
  912.  
  913. --
  914. {ubc-vision,uunet}!van-bc!sl                Stuart.Lynne@van-bc.uucp
  915.