home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Commun⁄Network / Telnet 2.5.src.ThinkC / source / NCSA Driver / atalk.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-14  |  3.9 KB  |  161 lines  |  [TEXT/MPS ]

  1. #ifndef lint
  2. static char *SCCSid = "%W%    (NCSA)    %G%";
  3. #endif
  4. /*
  5. *    atalk.c
  6. *     by Gaige B. Paulsen
  7. ****************************************************************************
  8. *                                                                          *
  9. *      Uses    :                                                               *
  10. *      TCP/IP kernel for NCSA Telnet                                       *
  11. *      by Tim Krauskopf                                                    *
  12. *       with Macintosh code by Gaige B. Paulsen                                 *
  13. *                                                                          *
  14. *      National Center for Supercomputing Applications                     *
  15. *      152 Computing Applications Building                                 *
  16. *      605 E. Springfield Ave.                                             *
  17. *      Champaign, IL  61820                                                *
  18. *                                                                          *
  19. *                                                                          *
  20. ****************************************************************************
  21. *
  22. *    Appletalk init and shutdown (and utility) procs.    
  23. *
  24. *    Called by:
  25. *        dlayer.c
  26. *        mactools.c
  27. *        macutil.c
  28. */
  29.  
  30. #include <stdio.h>
  31.  
  32. #include <AppleTalk.h>
  33. #include <Dialogs.h>
  34. #include <Devices.h>
  35.  
  36. #include "protocol.h"
  37. #include "configrec.h"
  38. #include "data.h"
  39. #include "croft.h"
  40.  
  41. #include "mpw.h"
  42. #include "maclook.h"
  43. #include "menu.h"
  44.  
  45. typedef struct {
  46.     char    node[26];
  47.     char    net[2];
  48. } ABusVarStruct, *ABusVarPtr, **ABusVarPtrPtr;
  49.  
  50. extern Listen();
  51. extern char *KIPnameptr;
  52. extern int EtherNet;            /* BYU 2.4.15 */
  53.  
  54. void getATaddress
  55.   (
  56.     int *hi,
  57.     int *low,
  58.     int *node
  59.   )
  60. {
  61.     ABusVarPtr ABusVars;
  62.     ABusVarPtrPtr ABusPtrPtr = (ABusVarPtrPtr) 0x2d8L;
  63.  
  64.     ABusVars = *ABusPtrPtr;
  65.     *hi = ABusVars->net[0];
  66.     *low = ABusVars->net[1];
  67.     *node = ABusVars->node[0];
  68.  
  69. }
  70.  
  71. int atopen
  72.   (
  73.     void
  74.   )
  75. {
  76.     short err;
  77.     short socket=72, refnum, item;
  78.     ABusVarPtr ABusVars;
  79.     ABusVarPtrPtr ABusPtrPtr = (ABusVarPtrPtr) 0x2d8L;
  80.     char buffr[100];
  81.     DialogPtr dtemp;
  82.     MPPParamBlock pb;
  83.  
  84.     err = 0;
  85.  
  86. #ifndef MPW
  87.     err = OpenDriver("\P.MPP",&refnum);            /* BYU 2.4.8 */
  88. #else
  89.     err = OpenDriver("\P.MPP",&refnum);
  90. #endif MPW
  91.  
  92.     if (err == 0)
  93.       {
  94.         pb.DDPlistener = (Ptr) Listen;
  95.         pb.DDPsocket = socket;
  96.         err=POpenSkt(&pb, FALSE);
  97.       }
  98.     if (err != 0)
  99.       { 
  100.         sprintf(buffr,"Failed Appletalk initialization (%d)\015",err);    /* BYU 2.4.18 - changed \n to \015 */
  101.         putln(buffr);
  102. #ifndef MPW
  103.         if (err == -91)
  104.             ParamText(0L, 0L, 0L, "\PCouldn't install Listener");
  105.         else if (err == -97 || err == -98)
  106.             ParamText(0L, 0L, 0L,
  107.                 "\PYou forgot to turn on AppleTalk in the Chooser");
  108.         else if (err == -192)
  109.             ParamText(0L, 0L, 0L, "\PCouldn’t find ‘atpl’ resource");
  110.         else
  111.             ParamText(0L, 0L, 0L, "\PUnknown Error");
  112. #else
  113.         if (err == -91)
  114.             paramtext(0L, 0L, 0L, "Couldn't install Listener");
  115.         else if (err == -97 || err == -98)
  116.             paramtext(0L, 0L, 0L,
  117.                 "You forgot to turn on AppleTalk in the Chooser");
  118.         else if (err == -192)
  119.             paramtext(0L, 0L, 0L, "Couldn’t find ‘atpl’ resource");
  120.         else
  121.             paramtext(0L, 0L, 0L, "Unknown Error");
  122. #endif MPW
  123.         dtemp = GetNewDialog(302, (Ptr) 0L, (WindowPtr) -1L);
  124. #if 1                                                            /* BYU 2.4.15 */
  125.         DrawDialog(dtemp);                                        /* BYU 2.4.15 */
  126.         WaitSeconds(5);                                            /* BYU 2.4.15 */
  127.         EtherNet = -100;                                        /* BYU 2.4.15 */
  128. #else                                                            /* BYU 2.4.15 */
  129.         ModalDialog(0L,&item);
  130. #endif                                                            /* BYU 2.4.15 */
  131.         DisposDialog(dtemp);
  132. /*        quit();                                                    /* BYU 2.4.15 */
  133.       }
  134.  
  135.     ABusVars = *ABusPtrPtr;
  136.     nnmyaddr[0] = ABusVars->net[0];
  137.     nnmyaddr[1] = ABusVars->net[1];
  138.     nnmyaddr[2] = ABusVars->node[0];
  139.     nnmyaddr[3] = 72;
  140.  
  141.     sprintf(buffr,"Net : %d,  Node : %d",*((unsigned short *)(&(ABusVars->net[0]))),(int)(ABusVars->node[0]));
  142.     putln(buffr);
  143.     return(0);
  144. }
  145.  
  146. int atclose
  147.   (
  148.     void
  149.   )
  150. {
  151.     MPPParamBlock pb;
  152.  
  153.     pb.DDPsocket=72;
  154.     PCloseSkt(&pb, FALSE);
  155.  
  156.     if (KIPnameptr)
  157.         KIPunregister();
  158.  
  159.     return(0);
  160. }
  161.