home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / ckc190.zip / ckonbi.c < prev    next >
C/C++ Source or Header  |  1994-09-03  |  33KB  |  1,134 lines

  1. char *ckonbiv = "OS/2 NetBios support, 5A(008) 22 Jul 94";
  2.  
  3. /*  C K O N B I  --  OS/2-specific NetBios support  */
  4.  
  5. /*
  6.   COPYRIGHT NOTICE:
  7.  
  8.   Copyright (C) 1985, 1994, Trustees of Columbia University in the City of New
  9.   York.  The C-Kermit software may not be, in whole or in part, licensed or
  10.   sold for profit as a software product itself, nor may it be included in or
  11.   distributed with commercial products or otherwise distributed by commercial
  12.   concerns to their clients or customers without written permission of the
  13.   Office of Kermit Development and Distribution, Columbia University.  This
  14.   copyright notice must not be removed, altered, or obscured.
  15. */
  16.  
  17. /*
  18.    developed by Jeffrey Altman <p00118@psilink.com>  
  19.    
  20.    Supports:
  21.       Traditional NetBios interface:
  22.          IBM Lan Adapter and Protocol Support
  23.          IBM OS/2 Extended Services
  24.          IBM Communication Manager/2
  25.  
  26.       Newer Netbeui Interface:
  27.          Microsoft LAN Manager Requester
  28.          IBM LAN Server Requester
  29.          Novell Netware Requester
  30. */
  31.  
  32. #ifndef __32BIT__
  33. #ifdef CK_NETBIOS
  34. #undef CK_NETBIOS
  35. #endif /* CK_NETBIOS */
  36. #endif /* __32BIT__ */
  37.  
  38. #ifdef CK_NETBIOS
  39. #define    INCL_NOPM
  40. #define    INCL_DOSPROCESS
  41. #define    INCL_DOSMODULEMGR
  42. #define  INCL_ERRORS
  43. #define  INCL_DOSSEMAPHORES
  44. #include <os2.h>
  45. #undef COMMENT
  46.  
  47. #include "ckcdeb.h"
  48. #include "ckcker.h"
  49. #include "ckonbi.h"
  50.  
  51. #define No 0
  52. #define Yes 1
  53.  
  54. #ifdef _loadds
  55. #undef _loadds
  56. #define _loadds
  57. #endif 
  58.  
  59. static APIRET16 (* APIENTRY16 netbios)(PNCB)=NULL;
  60. static APIRET16 (* APIENTRY16 netbios_Submit)(USHORT, USHORT, PNCB)=NULL;
  61. static APIRET16 (* APIENTRY16 netbios_Close)(USHORT, USHORT)=NULL;
  62. static APIRET16 (* APIENTRY16 netbios_Open)(PSZ, PSZ, USHORT, PUSHORT);
  63. static APIRET16 (* APIENTRY16 netbios_Enum)(PSZ, USHORT, PBYTE,USHORT,
  64.    PUSHORT,PUSHORT)=NULL;
  65.  
  66. static USHORT Netbeui_Handle[NB_ADAPTERS]={0,0,0,0};
  67. static PNETINFO1 pNetinfo=NULL;
  68. static USHORT Netentries=0;
  69.  
  70. extern int pid ;
  71. extern int ttyfd ;
  72. extern USHORT netbiosAvail ;
  73. extern BOOL NetbeuiAPI = 0 ;
  74.  
  75. UCHAR  NetBiosRemote[NETBIOS_NAME_LEN+1] = "                \0" ;
  76. UCHAR  NetBiosName[NETBIOS_NAME_LEN+1] = "                \0" ;
  77. UCHAR  NetBiosAdapter = 0 ;
  78. BYTE   NetBiosLSN = 0 ;
  79. HEV    hevNetBiosLSN = 0 ;
  80. PNCB   pWorkNCB = 0 ;
  81. PNCB   pListenNCB = 0 ;
  82. PNCB   pRecvNCB = 0 ;
  83. PNCB   pSendNCB[MAXWS] ;
  84. TID    ListenThreadID = -1 ;
  85. BYTE   NetBiosRecvBuf[MAXRP] ;
  86. BYTE*  NetBiosSendBuf[MAXWS] ;
  87. USHORT MaxCmds,MaxSess,MaxNames ;
  88.  
  89. void
  90. os2_netbiosinit( void ) {
  91.    int rc = 1, i ;
  92.  
  93.    /* Initialize Send NCBs to zero */
  94.    for ( i=0; i<MAXWS ; i++ )
  95.       {
  96.       pSendNCB[i] = 0 ;
  97.       NetBiosSendBuf[i] = malloc( MAXSP ) ;
  98.       }
  99.  
  100.    if (deblog)
  101.       {
  102.       printf( "  NetBIOS support..." ) ;
  103.       debug(F100,"NetBIOS support...","",0);
  104.       }
  105.    rc = netbios_avail( NetbeuiAPI=0 ) ;  /* ACSNETB.DLL - NTS/2 */
  106.  
  107.    if ( rc )
  108.    rc = netbios_avail( NetbeuiAPI=1 ) ;  /* NETAPI.DLL - Lan Manager,
  109.                                                          Lan Server 2.x,
  110.                                                          Novell Requester */
  111.  
  112.    if ( !rc ) {
  113.       char semname[19] ;
  114.  
  115.       if ( NetbeuiAPI )
  116.          if (deblog)
  117.             {
  118.             printf( "NETAPI.DLL loaded OK\n") ;
  119.             debug(F100,"NETAPI.DLL loaded OK","",0);
  120.             }
  121.       else
  122.          if (deblog)
  123.          {
  124.          printf( "ACSNETB.DLL loaded OK\n") ;
  125.          debug(F100,"ACSNETB.DLL loaded OK","",0);
  126.          }
  127.  
  128.       DosCreateEventSem( NULL, &hevNetBiosLSN, 0, 0 );
  129.  
  130.       sprintf(semname,"\\SEM\\%#6.6X.CK%s",pid,"W");
  131.       if ( pWorkNCB = (PNCB) malloc( NCBSIZE ) )
  132.          rc = Dos16CreateSem( DC_SEM_SHARED,
  133.             (PHSEM16) &(pWorkNCB->basic_ncb.ncb_semaphore),
  134.             semname ) ;
  135.  
  136.       sprintf(semname,"\\SEM\\%#6.6X.CK%s",pid,"L");
  137.       if ( pListenNCB = (PNCB) malloc( NCBSIZE ) )
  138.          rc = Dos16CreateSem( DC_SEM_SHARED,
  139.             (PHSEM16) &(pListenNCB->basic_ncb.ncb_semaphore),
  140.             semname ) ;
  141.  
  142.       sprintf(semname,"\\SEM\\%#6.6X.CK%s",pid,"R");
  143.       if ( pRecvNCB = (PNCB) malloc( NCBSIZE ) )
  144.          rc = Dos16CreateSem( DC_SEM_SHARED,
  145.             (PHSEM16) &(pRecvNCB->basic_ncb.ncb_semaphore),
  146.             semname ) ;
  147.  
  148.      for ( i=0 ; i < MAXWS ; i++ ) {
  149.       sprintf(semname,"\\SEM\\%#6.6X.%s%2d",pid,"S",i);
  150.       if ( pSendNCB[i] = (PNCB) malloc( NCBSIZE ) )
  151.          rc = Dos16CreateSem( DC_SEM_SHARED,
  152.             (PHSEM16) &(pSendNCB[i]->basic_ncb.ncb_semaphore),
  153.             semname ) ;
  154.        }
  155.  
  156.       GetNCBConfig( NetbeuiAPI, NetBiosAdapter, &MaxSess,
  157.                    &MaxCmds, &MaxNames ) ;
  158.       debug( F101,"MaxSess","",MaxSess ) ;
  159.       debug( F101, "MaxCmds", "", MaxCmds ) ;
  160.       debug( F101, "MaxNames", "", MaxNames ) ;
  161.  
  162.       if ( NB_LSN < MaxSess ) MaxSess = NB_LSN ;
  163.       if ( NB_NCB < MaxCmds ) MaxCmds = NB_NCB ;
  164.       if ( MAXWS  < MaxCmds ) MaxCmds = MAXWS  ;
  165.       if ( NB_NAMES < MaxNames ) MaxNames = NB_NAMES ;
  166.       
  167.       rc = NCBReset( NetbeuiAPI, pWorkNCB, NetBiosAdapter,
  168.          MaxSess, MaxCmds, MaxNames ) ;
  169.  
  170.  
  171.       if ( rc ) {
  172.          if (deblog)
  173.             {
  174.             printf( "NetBIOS Adapter Reset failed\n" ) ;
  175.             debug(F100,"NetBIOS Adapter Reset failed","",0);
  176.             }
  177.          }
  178.       else {
  179.          netbiosAvail = 1 ;
  180.          if (deblog)
  181.             {
  182.             printf( "NetBIOS Adapter Reset successful\n" ) ;
  183.             debug(F100,"NetBIOS Adapter Reset successful","",0);
  184.             }
  185.          }
  186.       }
  187.    else if (deblog)
  188.       {
  189.       printf( "Not installed\n" ) ;
  190.       debug(F100,"Not installed","",0);
  191.       }
  192.    }
  193.  
  194. void
  195. os2_netbioscleanup( void ) {
  196.    if ( netbiosAvail )
  197.       {
  198.       int i ;
  199.  
  200.       if (strcmp( NetBiosName, "                " ) )
  201.          NCBDeleteName( NetbeuiAPI, pWorkNCB, NetBiosAdapter, NetBiosName ) ;
  202.  
  203.       NCBClose( NetbeuiAPI, pWorkNCB, NetBiosAdapter ) ;
  204.  
  205.       if ( pWorkNCB )
  206.          {
  207.          Dos16CloseSem( pWorkNCB->basic_ncb.ncb_semaphore ) ;
  208.          free( pWorkNCB ) ;
  209.          pWorkNCB = 0 ;
  210.          }
  211.  
  212.       if ( pListenNCB )
  213.          {
  214.          Dos16CloseSem( pListenNCB->basic_ncb.ncb_semaphore ) ;
  215.          free( pListenNCB ) ;
  216.          pListenNCB = 0 ;
  217.          }
  218.  
  219.       if ( pRecvNCB )
  220.          {
  221.          Dos16CloseSem( pRecvNCB->basic_ncb.ncb_semaphore ) ;
  222.          free( pRecvNCB ) ;
  223.          pRecvNCB = 0 ;
  224.          }
  225.  
  226.       for ( i=0 ; i<MAXWS ; i++ ) {
  227.          if ( pSendNCB[i] )
  228.          {
  229.          Dos16CloseSem( pSendNCB[i]->basic_ncb.ncb_semaphore ) ;
  230.          free( pSendNCB[i] ) ;
  231.          pSendNCB[i] = 0 ;
  232.  
  233.          if ( NetBiosSendBuf[i] )
  234.             {
  235.             free( NetBiosSendBuf[i] ) ;
  236.             NetBiosSendBuf[i] = 0 ;
  237.             }
  238.          }
  239.       }
  240.  
  241.       DosCloseEventSem( hevNetBiosLSN );
  242.       }
  243.    }
  244.  
  245. USHORT loadapi(PSZ module, PSZ proc, PFN FAR *addr)
  246. {
  247. int rc,rc1;
  248. HMODULE mh;
  249.        rc1=0;                         /* load adapter processor */
  250.        rc=DosQueryModuleHandle(module,&mh);
  251.        if(rc==0)
  252.          {                            /* loaded, check for this process */
  253.          rc1=DosQueryProcAddr(mh,0,proc,addr);
  254.          }
  255.        if(rc || rc1)   /* either not loaded, or not loaded for this process */
  256.          {                            /* so load it */
  257.          rc=DosLoadModule(NULL,0,module,&mh);
  258.          rc1=1;                       /* force getprocaddr */
  259.          }
  260.        if(rc==0)
  261.          {                            /* loaded ok? */
  262.          if(rc1)                      /* no address to call, so get it */
  263.            rc=DosQueryProcAddr(mh,0,proc,addr); /* get entry */
  264.          }
  265.        return rc;
  266. }
  267.  
  268. USHORT netbios_avail(BOOL Netbeui)
  269. {
  270. int rc=0;
  271.         if(!Netbeui)
  272.           {
  273.           if(!netbios)
  274.             rc=loadapi("ACSNETB","NETBIOS",(PFN *)&netbios);
  275.           } /* end if */
  276.         else
  277.           {
  278.          if(!netbios_Submit)
  279.             {
  280.             rc|=loadapi("NETAPI","NETBIOSSUBMIT",(PFN *) &netbios_Submit);
  281.             rc|=loadapi("NETAPI","NETBIOSCLOSE", (PFN *) &netbios_Close );
  282.             rc|=loadapi("NETAPI","NETBIOSOPEN",  (PFN *) &netbios_Open  );
  283.             rc|=loadapi("NETAPI","NETBIOSENUM",  (PFN *) &netbios_Enum  );
  284.             } /* end if */
  285.          } /* end else */
  286.         return rc;
  287. }
  288.  
  289. GetNCBConfig(BOOL Netbeui,USHORT Adapter,PUSHORT S,PUSHORT C, PUSHORT N)
  290. {
  291. NCB WorkNcb;
  292.       NCBConfig(Netbeui,&WorkNcb,Adapter,S,C,N);
  293. }
  294.  
  295. #pragma stack16(256)
  296. VOID CDECL16 ncbpost(USHORT Junk, PNCB16 NcbPointer)
  297. {
  298.    APIRET rc = 0 ;
  299.    NCB ncb = *NcbPointer ;
  300.    rc = Dos16SemClear(NcbPointer->basic_ncb.ncb_semaphore);
  301.  
  302. }
  303.  
  304. static USHORT NetbeuiConfig(USHORT lana, PUSHORT sessions, PUSHORT commands,
  305.    PUSHORT names)
  306. {
  307. USHORT rc=NB_INADEQUATE_RESOURCES,blen,MaxEntries,i;
  308. PNETINFO1 temp=NULL;
  309.  
  310.         if(netbios_Enum)
  311.           {
  312.           if(!pNetinfo)
  313.             {
  314.             if(pNetinfo=(PNETINFO1)malloc(blen=sizeof(NETINFO1)*NB_ADAPTERS))
  315.               {
  316.               if(rc=(*netbios_Enum)(NULL,1,(PBYTE)pNetinfo,blen,&Netentries,
  317.                   &MaxEntries))
  318.                 {
  319.                 free(pNetinfo);
  320.                 pNetinfo=NULL;
  321.                 }
  322.               } /* end if */
  323.             }
  324.           if(pNetinfo)
  325.             {
  326.             if(lana<=Netentries)
  327.               {
  328.               *sessions=pNetinfo[lana].nb1_max_sess;
  329.               *commands=pNetinfo[lana].nb1_max_ncbs;
  330.               *names=   pNetinfo[lana].nb1_max_names;
  331.               rc=NB_COMMAND_SUCCESSFUL;
  332.               } /* end if */
  333.             else
  334.               {
  335.               rc=NB_INVALID_ADAPTER;
  336.               } /* end else */
  337.             } /* end if */
  338.           } /* end if */
  339.         return rc;
  340. }
  341.  
  342.  
  343. USHORT  NCBConfig(BOOL Netbeui, PNCB Ncb, USHORT lana, PUSHORT sessions,
  344.    PUSHORT commands, PUSHORT names )
  345. {
  346. SHORT rc;
  347.  
  348.         if(!Netbeui)
  349.           {
  350.           rc=NCBReset(Netbeui, Ncb, lana, 255, 255,255 );
  351.           *sessions=Ncb->basic_ncb.bncb.ncb_name[0];
  352.           *commands=Ncb->basic_ncb.bncb.ncb_name[1];
  353.           *names=   Ncb->basic_ncb.bncb.ncb_name[2];
  354.           NCBClose(Netbeui,Ncb,lana);
  355.           } /* end if */
  356.         else
  357.           {
  358.           memset( Ncb, 0, BNCBSIZE ) ;
  359.           if(!(rc=NetbeuiConfig(lana,sessions,commands,names)))
  360.             {
  361.             Ncb->basic_ncb.bncb.ncb_name[8]=*sessions;
  362.             Ncb->basic_ncb.bncb.ncb_name[9]=*commands;
  363.             Ncb->basic_ncb.bncb.ncb_name[10]=*names;
  364.             }
  365.           } /* end else */
  366.  
  367.         return rc;
  368. }
  369. USHORT  NCBClose( BOOL Netbeui, PNCB Ncb, USHORT lana)
  370. {
  371. USHORT rc;
  372.         if(!Netbeui)
  373.           {
  374.           memset( Ncb, 0, BNCBSIZE ) ;
  375.           Ncb->reset.ncb_command  = NB_RESET_WAIT;
  376.           Ncb->reset.ncb_lsn=255;
  377.           Ncb->reset.ncb_lana_num = lana;
  378.           rc=(*netbios)(Ncb);
  379.           } /* end if */
  380.         else
  381.           {
  382.           if(Netbeui_Handle[lana])
  383.             {
  384.             rc=(*netbios_Close)(Netbeui_Handle[lana],0);
  385.             } /* end if */
  386.           else
  387.             {
  388.             rc=NB_ENVIRONMENT_NOT_DEFINED;
  389.             } /* end else */
  390.           } /* end else */
  391.         return rc;
  392. }
  393. USHORT  NCBReset( BOOL Netbeui, PNCB Ncb, USHORT lana,USHORT  sessions,
  394.    USHORT  commands,USHORT names )
  395. {
  396. int i,rc=NB_INADEQUATE_RESOURCES;
  397.         if(!Netbeui)
  398.           {
  399.           memset( Ncb, 0, BNCBSIZE ) ;
  400.           Ncb->reset.ncb_command  = NB_RESET_WAIT;
  401.           Ncb->reset.ncb_lana_num = lana;
  402.           Ncb->reset.req_sessions = sessions;
  403.           Ncb->reset.req_commands = commands;
  404.           Ncb->reset.req_names = names;
  405.  
  406.           (*netbios)(Ncb );
  407.  
  408.           rc=Ncb->reset.ncb_retcode;
  409.           } /* end if */
  410.         else
  411.           {
  412.           if(!pNetinfo)
  413.             {
  414.             rc=NetbeuiConfig(lana,&sessions,&commands,&names);
  415.             } /* end if */
  416.           if(pNetinfo)
  417.             {
  418.             if(lana<=Netentries)
  419.               {
  420.               if(pNetinfo[lana].nb1_max_sess>=sessions &&
  421.                  pNetinfo[lana].nb1_max_ncbs>=commands &&
  422.                  pNetinfo[lana].nb1_max_names>=names)
  423.                  rc=(*netbios_Open)(pNetinfo[lana].nb1_net_name,NULL,1,
  424.                      &Netbeui_Handle[lana]);
  425.               } /* end if */
  426.             else
  427.               {
  428.               rc=NB_INVALID_ADAPTER;
  429.               } /* end else */
  430.             } /* end if */
  431.           } /* end else */
  432.         return rc;
  433. }
  434. USHORT NCBAddName( BOOL Netbeui, PNCB Ncb,USHORT lana, PBYTE name )
  435. {
  436.  
  437.         memset( Ncb, 0, BNCBSIZE ) ;
  438.         Ncb->basic_ncb.bncb.ncb_command  = NB_ADD_NAME_WAIT;
  439.         Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  440.         strncpy( Ncb->basic_ncb.bncb.ncb_name, name, NETBIOS_NAME_LEN );
  441.         if(Netbeui)
  442.           {
  443.           (*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  444.           } /* end if */
  445.         else
  446.           {
  447.           (*netbios)(Ncb );
  448.           } /* end else */
  449.  
  450.         return (Ncb->basic_ncb.bncb.ncb_retcode);
  451. }
  452. USHORT NCBDeleteName(BOOL Netbeui, PNCB Ncb,USHORT lana, PBYTE name )
  453. {
  454.  
  455.         memset( Ncb, 0, BNCBSIZE ) ;
  456.         Ncb->basic_ncb.bncb.ncb_command  = NB_DELETE_NAME_WAIT;
  457.         Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  458.         strncpy( Ncb->basic_ncb.bncb.ncb_name, name, NETBIOS_NAME_LEN );
  459.  
  460.         if(Netbeui)
  461.           {
  462.           (*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  463.           } /* end if */
  464.         else
  465.           {
  466.           (*netbios)(Ncb );
  467.           }
  468.  
  469.         return (Ncb->basic_ncb.bncb.ncb_retcode);
  470. }
  471. USHORT NCBAddGroupName(BOOL Netbeui, PNCB Ncb,USHORT lana, PBYTE name )
  472. {
  473.  
  474.         memset( Ncb, 0, BNCBSIZE ) ;
  475.         Ncb->basic_ncb.bncb.ncb_command  = NB_ADD_GROUP_NAME_WAIT;
  476.         Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  477.         strncpy( Ncb->basic_ncb.bncb.ncb_name, name, NETBIOS_NAME_LEN );
  478.  
  479.         if(Netbeui)
  480.           {
  481.           (*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  482.           } /* end if */
  483.         else
  484.           {
  485.           (*netbios)(Ncb );
  486.           }
  487.  
  488.         return (Ncb->basic_ncb.bncb.ncb_retcode);
  489. }
  490. USHORT  NCBCall(BOOL Netbeui, PNCB  Ncb, USHORT lana, PBYTE lclname,
  491.    PBYTE rmtname,USHORT recv_timeout,USHORT send_timeout,BOOL wait)
  492. {
  493.    int rc;
  494.     ;
  495.  
  496.    memset( Ncb, 0, BNCBSIZE ) ;
  497.    Ncb->basic_ncb.bncb.ncb_command  = (wait)?NB_CALL_WAIT:NB_CALL;
  498.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  499.    Ncb->basic_ncb.bncb.ncb_rto      = recv_timeout*2;  /* times 2 since in   */
  500.    Ncb->basic_ncb.bncb.ncb_sto      = send_timeout*2;  /* steps of 500 msecs */
  501.  
  502.    if ( Netbeui )
  503.    {
  504.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  505.           ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L); 
  506.    } else {
  507.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  508.          (address)((!wait)?ncbpost:NULL);
  509.    }
  510.  
  511.    strncpy( Ncb->basic_ncb.bncb.ncb_name, lclname, NETBIOS_NAME_LEN );
  512.    strncpy( Ncb->basic_ncb.bncb.ncb_callname, rmtname, NETBIOS_NAME_LEN );
  513.    if(!wait)
  514.      rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore);
  515.  
  516.    if(Netbeui)
  517.      {
  518.      rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  519.      } /* end if */
  520.    else
  521.      {
  522.      rc=(*netbios)(Ncb );
  523.      }
  524.  
  525.    return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  526. }
  527.  
  528. USHORT NCBListen(BOOL Netbeui, PNCB  Ncb, USHORT lana, PBYTE lclname,
  529.    PBYTE rmtname,USHORT recv_timeout,USHORT send_timeout,BOOL wait)
  530. {
  531. int rc;
  532.  ;
  533.    memset( Ncb, 0, BNCBSIZE ) ;
  534.    Ncb->basic_ncb.bncb.ncb_command  = (wait)?NB_LISTEN_WAIT:NB_LISTEN;
  535.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  536.    Ncb->basic_ncb.bncb.ncb_rto      = recv_timeout*2; /* times 2 since in   */
  537.    Ncb->basic_ncb.bncb.ncb_sto      = send_timeout*2; /* steps of 500 msecs */
  538.  
  539.    if ( Netbeui )
  540.    {
  541.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  542.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  543.    } else {
  544.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  545.          (address)((!wait)?ncbpost:NULL);
  546.    }
  547.  
  548.    strncpy( Ncb->basic_ncb.bncb.ncb_name, lclname, NETBIOS_NAME_LEN );
  549.    strncpy( Ncb->basic_ncb.bncb.ncb_callname, rmtname, NETBIOS_NAME_LEN );
  550.    if(!wait)
  551.      {
  552.      rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore);
  553.      }
  554.  
  555.    if(Netbeui)
  556.      {
  557.      rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  558.      } /* end if */
  559.    else
  560.      {
  561.      rc=(*netbios)(Ncb );
  562.      }
  563.  
  564.    return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  565. }
  566.  
  567. /**********************************************************************/
  568. /*
  569. ** NCBSend      Sends data to the session partner as defined by the
  570. **              session number in the NCB.LSN field.  The data to send
  571. **              is in the buffer pointed to by the NCB.BUFFER field.
  572. **
  573. **              Accepts the adapter number, the session number,
  574. **              the char array holding the message to be sent, and
  575. **              the length of the message in that array.
  576. **
  577. **              Returns the NCB return code.
  578. */
  579.  
  580. USHORT  NCBSend(BOOL Netbeui, PNCB  Ncb, USHORT lana, USHORT lsn,
  581.    PBYTE message, word length,BOOL wait)
  582. {
  583. int rc;
  584.  ;
  585.    memset( Ncb, 0, BNCBSIZE ) ;
  586.    Ncb->basic_ncb.bncb.ncb_command  = (wait)?NB_SEND_WAIT:NB_SEND;
  587.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  588.    Ncb->basic_ncb.bncb.ncb_lsn      = lsn;
  589.    Ncb->basic_ncb.bncb.ncb_buffer_address = message;
  590.    Ncb->basic_ncb.bncb.ncb_length   = length;
  591.  
  592.    if ( Netbeui )
  593.    {
  594.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  595.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  596.    } else {
  597.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  598.          (address)((!wait)?ncbpost:NULL);
  599.    }
  600.  
  601.    if(!wait)
  602.      rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore);
  603.  
  604.    if(Netbeui)
  605.      {
  606.      rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  607.      } /* end if */
  608.    else
  609.      {
  610.      rc=(*netbios)(Ncb );
  611.      }
  612.  
  613.    return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  614. }
  615.  
  616. USHORT NCBSendDatagram(BOOL Netbeui, PNCB  Ncb, USHORT lana, USHORT lsn,
  617.    PSZ rmtname, PBYTE message, word length,BOOL wait)
  618. {
  619. int rc;
  620.  ;
  621.    memset( Ncb, 0, BNCBSIZE ) ;
  622.    Ncb->basic_ncb.bncb.ncb_command  =
  623.                      (wait)?NB_SEND_DATAGRAM_WAIT:NB_SEND_DATAGRAM;
  624.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  625.    Ncb->basic_ncb.bncb.ncb_num      = lsn;
  626.    Ncb->basic_ncb.bncb.ncb_buffer_address = message;
  627.    Ncb->basic_ncb.bncb.ncb_length   = length;
  628.  
  629.    if ( Netbeui )
  630.    {
  631.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  632.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  633.    } else {
  634.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  635.          (address)((!wait)?ncbpost:NULL);
  636.    }
  637.  
  638.     strncpy( Ncb->basic_ncb.bncb.ncb_callname, rmtname, NETBIOS_NAME_LEN );
  639.     if(!wait)
  640.       rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore );
  641.  
  642.     if(Netbeui)
  643.       {
  644.       rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  645.       } /* end if */
  646.     else
  647.       {
  648.       rc=(*netbios)(Ncb );
  649.       }
  650.  
  651.     return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  652. }
  653. USHORT  NCBSendBroadcast(BOOL Netbeui, PNCB  Ncb, USHORT lana, USHORT lsn,
  654.    PBYTE message, word length,BOOL wait)
  655. {
  656. int rc;
  657.  ;
  658.    memset( Ncb, 0, BNCBSIZE ) ;
  659.    Ncb->basic_ncb.bncb.ncb_command  =
  660.          (wait)?NB_SEND_BROADCAST_DATAGRAM_WAIT:NB_SEND_BROADCAST_DATAGRAM;
  661.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  662.    Ncb->basic_ncb.bncb.ncb_num      = lsn;
  663.    Ncb->basic_ncb.bncb.ncb_buffer_address = message;
  664.    Ncb->basic_ncb.bncb.ncb_length   = length;
  665.  
  666.    if ( Netbeui )
  667.    {
  668.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  669.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  670.    } else {
  671.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  672.          (address)((!wait)?ncbpost:NULL);
  673.    }
  674.  
  675.    if(!wait)
  676.      rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore );
  677.  
  678.    if(Netbeui)
  679.      {
  680.      rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  681.      } /* end if */
  682.    else
  683.      {
  684.      rc=(*netbios)(Ncb );
  685.      }
  686.  
  687.    return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  688. }
  689.  
  690. USHORT  NCBSendNoAck(BOOL Netbeui, PNCB  Ncb, USHORT lana, USHORT lsn,
  691.    PBYTE message, word length,BOOL wait)
  692. {
  693. int rc;
  694.  ;
  695.    memset( Ncb, 0, BNCBSIZE ) ;
  696.    Ncb->basic_ncb.bncb.ncb_command  =
  697.                         (wait)?NB_SEND_NO_ACK_WAIT:NB_SEND_NO_ACK;
  698.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  699.    Ncb->basic_ncb.bncb.ncb_lsn      = lsn;
  700.    Ncb->basic_ncb.bncb.ncb_buffer_address = message;
  701.    Ncb->basic_ncb.bncb.ncb_length   = length;
  702.  
  703.    if ( Netbeui )
  704.    {
  705.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  706.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  707.    } else {
  708.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  709.          (address)((!wait)?ncbpost:NULL);
  710.    }
  711.  
  712.   if(!wait)
  713.     rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore);
  714.  
  715.   if(Netbeui)
  716.     {
  717.     rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  718.     } /* end if */
  719.   else
  720.     {
  721.     rc=(*netbios)(Ncb );
  722.     }
  723.  
  724.   return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  725. }
  726. /**********************************************************************/
  727. /*
  728. ** NCBChainSend      Sends data to the session partner as defined by the
  729. **              session number in the NCB.LSN field.  The data to send
  730. **              is in the buffer pointed to by the NCB.BUFFER field.
  731. **
  732. **              Accepts the adapter number, the session number,
  733. **              the char array holding the message to be sent, and
  734. **              the length of the message in that array.
  735. **
  736. **              Returns the NCB return code.
  737. */
  738.  
  739. USHORT  NCBChainSend(BOOL Netbeui, PNCB  Ncb, USHORT lana, USHORT lsn,
  740.    PBYTE  message, word length, PBYTE Buffer2, word Length2,BOOL wait)
  741. {
  742. int rc;
  743. PBuf2 b2;
  744.  ;
  745.    memset( Ncb, 0, BNCBSIZE ) ;
  746.    b2=(PBuf2)&Ncb->basic_ncb.bncb.ncb_callname;
  747.    Ncb->basic_ncb.bncb.ncb_command  =
  748.                              (wait)?NB_CHAIN_SEND_WAIT:NB_CHAIN_SEND;
  749.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  750.    Ncb->basic_ncb.bncb.ncb_lsn      = lsn;
  751.    Ncb->basic_ncb.bncb.ncb_buffer_address = message;
  752.    Ncb->basic_ncb.bncb.ncb_length   = length;
  753.  
  754.    if ( Netbeui )
  755.    {
  756.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  757.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  758.    } else {
  759.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  760.          (address)((!wait)?ncbpost:NULL);
  761.    }
  762.  
  763.    b2->Length=Length2;
  764.    b2->Buffer=Buffer2;
  765.    if(!wait)
  766.      rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore);
  767.  
  768.    if(Netbeui)
  769.      {
  770.      rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  771.      } /* end if */
  772.    else
  773.      {
  774.      rc=(*netbios)(Ncb );
  775.      }
  776.  
  777.    return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  778. }
  779. USHORT  NCBChainSendNoAck(BOOL Netbeui, PNCB  Ncb, USHORT lana, USHORT lsn,
  780.    PBYTE message, word length, PBYTE Buffer2, word Length2,BOOL wait)
  781. {
  782. int rc;
  783. PBuf2 b2;
  784.  ;
  785.    memset( Ncb, 0, BNCBSIZE ) ;
  786.    b2=(PBuf2)&Ncb->basic_ncb.bncb.ncb_callname;
  787.    Ncb->basic_ncb.bncb.ncb_command  =
  788.                   (wait)?NB_CHAIN_SEND_NO_ACK_WAIT:NB_CHAIN_SEND_NO_ACK;
  789.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  790.    Ncb->basic_ncb.bncb.ncb_lsn      = lsn;
  791.    Ncb->basic_ncb.bncb.ncb_buffer_address = message;
  792.    Ncb->basic_ncb.bncb.ncb_length   = length;
  793.  
  794.    if ( Netbeui )
  795.    {
  796.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  797.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  798.    } else {
  799.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  800.          (address)((!wait)?ncbpost:NULL);
  801.    }
  802.  
  803.    b2->Length=Length2;
  804.    b2->Buffer=Buffer2;
  805.    if(!wait)
  806.      rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore);
  807.  
  808.    if(Netbeui)
  809.      {
  810.      rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  811.      } /* end if */
  812.    else
  813.      {
  814.      rc=(*netbios)(Ncb );
  815.      }
  816.  
  817.    return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  818. }
  819.  
  820. /**********************************************************************/
  821. /*
  822. ** NCBReceive   Receives data from the session partner that sends data
  823. **              to this station.
  824. **
  825. **              Accepts the adapter number, the session number,
  826. **              the char array to hold the message received, and
  827. **              the maximum length the message may occupy in that
  828. **              array.
  829. **
  830. **              Returns the NCB return code and, if successful,
  831. **              the received data in the buffer.
  832. */
  833.  
  834. USHORT NCBReceive(BOOL Netbeui, PNCB  Ncb, USHORT lana, USHORT lsn,
  835.    PBYTE buffer, word length, BOOL wait )
  836. {
  837. int rc;
  838.  ;
  839.    memset( Ncb, 0, BNCBSIZE ) ;
  840.    Ncb->basic_ncb.bncb.ncb_command  = (wait)?NB_RECEIVE_WAIT:NB_RECEIVE;
  841.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  842.    Ncb->basic_ncb.bncb.ncb_lsn      = lsn;
  843.    Ncb->basic_ncb.bncb.ncb_buffer_address = buffer;
  844.    Ncb->basic_ncb.bncb.ncb_length   = length;
  845.  
  846.    if ( Netbeui )
  847.    {
  848.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  849.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  850.    } else {
  851.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  852.          (address)((!wait)?ncbpost:NULL);
  853.    }
  854.  
  855.    if(!wait)
  856.      rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore);
  857.  
  858.    if(Netbeui)
  859.      {
  860.      rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  861.      } /* end if */
  862.    else
  863.      {
  864.      rc=(*netbios)(Ncb );
  865.      }
  866.  
  867.    return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  868. }
  869. /**********************************************************************/
  870. /*
  871. ** NCBReceiveAny Receives data from the session partner that sends data
  872. **              to this station.
  873. **
  874. **              Accepts the adapter number, the session number,
  875. **              the char array to hold the message received, and
  876. **              the maximum length the message may occupy in that
  877. **              array.
  878. **
  879. **              Returns the NCB return code and, if successful,
  880. **              the received data in the buffer.
  881. */
  882.  
  883. USHORT NCBReceiveAny(BOOL Netbeui, PNCB  Ncb, USHORT lana, USHORT lsn,
  884.    PBYTE buffer, word length,BOOL wait )
  885. {
  886. int rc;
  887.  ;
  888.    memset( Ncb, 0, BNCBSIZE ) ;
  889.    Ncb->basic_ncb.bncb.ncb_command  =
  890.                            (wait)?NB_RECEIVE_ANY_WAIT:NB_RECEIVE_ANY;
  891.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  892.    Ncb->basic_ncb.bncb.ncb_num      = lsn;
  893.    Ncb->basic_ncb.bncb.ncb_buffer_address = buffer;
  894.    Ncb->basic_ncb.bncb.ncb_length   = length;
  895.  
  896.    if ( Netbeui )
  897.    {
  898.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  899.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  900.    } else {
  901.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  902.          (address)((!wait)?ncbpost:NULL);
  903.    }
  904.  
  905.    if(!wait)
  906.      rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore );
  907.  
  908.    if(Netbeui)
  909.      {
  910.      rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  911.      } /* end if */
  912.    else
  913.      {
  914.      rc=(*netbios)(Ncb );
  915.      }
  916.  
  917.    return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  918. }
  919.  
  920. USHORT NCBReceiveDatagram(BOOL Netbeui, PNCB  Ncb, USHORT lana, USHORT lsn,
  921.    PBYTE buffer, word length,BOOL wait )
  922. {
  923. int rc;
  924.  ;
  925.    memset( Ncb, 0, BNCBSIZE ) ;
  926.    Ncb->basic_ncb.bncb.ncb_command  =
  927.                (wait)?NB_RECEIVE_DATAGRAM_WAIT:NB_RECEIVE_DATAGRAM;
  928.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  929.    Ncb->basic_ncb.bncb.ncb_num      = lsn;
  930.    Ncb->basic_ncb.bncb.ncb_buffer_address = buffer;
  931.    Ncb->basic_ncb.bncb.ncb_length   = length;
  932.  
  933.    if ( Netbeui )
  934.    {
  935.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  936.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  937.    } else {
  938.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  939.          (address)((!wait)?ncbpost:NULL);
  940.    }
  941.  
  942.    if(!wait)
  943.      rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore );
  944.  
  945.    if(Netbeui)
  946.      {
  947.      rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  948.      } /* end if */
  949.    else
  950.      {
  951.      rc=(*netbios)(Ncb );
  952.      }
  953.  
  954.    return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  955. }
  956.  
  957. USHORT NCBReceiveBroadcast(BOOL Netbeui, PNCB  Ncb,USHORT  lana, USHORT lsn,
  958.    PBYTE buffer, word length,BOOL wait )
  959. {
  960. int rc;
  961.  ;
  962.    memset( Ncb, 0, BNCBSIZE ) ;
  963.    Ncb->basic_ncb.bncb.ncb_command  =
  964.        (wait)?NB_RECEIVE_BROADCAST_DATAGRAM_W:NB_RECEIVE_BROADCAST_DATAGRAM;
  965.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  966.    Ncb->basic_ncb.bncb.ncb_num      = lsn;
  967.    Ncb->basic_ncb.bncb.ncb_buffer_address = buffer;
  968.    Ncb->basic_ncb.bncb.ncb_length   = length;
  969.  
  970.    if ( Netbeui )
  971.    {
  972.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  973.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  974.    } else {
  975.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  976.          (address)((!wait)?ncbpost:NULL);
  977.    }
  978.  
  979.    if(!wait)
  980.      rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore );
  981.  
  982.    if(Netbeui)
  983.      {
  984.      rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  985.      } /* end if */
  986.    else
  987.      {
  988.      rc=(*netbios)(Ncb );
  989.      }
  990.  
  991.    return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  992. }
  993.  
  994. /**********************************************************************/
  995. /*
  996. ** NCBHangup    Closes the session with another name on the network
  997. **              specified by the session number.
  998. **
  999. **              Accepts the adapter number and session number.
  1000. **
  1001. **              Returns the NCB return code.
  1002. */
  1003.  
  1004. USHORT  NCBHangup(BOOL Netbeui, PNCB  Ncb, USHORT lana, USHORT lsn )
  1005. {
  1006.    memset( Ncb, 0, BNCBSIZE ) ;
  1007.    Ncb->basic_ncb.bncb.ncb_command  = NB_HANG_UP_WAIT;
  1008.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  1009.    Ncb->basic_ncb.bncb.ncb_lsn      = lsn;
  1010.  
  1011.    if(Netbeui)
  1012.      {
  1013.      (*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  1014.      } /* end if */
  1015.    else
  1016.      {
  1017.      (*netbios)(Ncb );
  1018.      }
  1019.  
  1020.    return (Ncb->basic_ncb.bncb.ncb_retcode);
  1021. }
  1022.  
  1023. /**********************************************************************/
  1024. /*
  1025. ** NCBCancel    Cancels a previously issued NCB if possible.
  1026. **
  1027. **              Accepts the adapter number and a ptr to the NCB to cancel.
  1028. **
  1029. **              Returns the NCB return code.
  1030. */
  1031.  
  1032. USHORT  NCBCancel(BOOL Netbeui, PNCB  Ncb, USHORT lana, PNCB NcbToCancel)
  1033. {
  1034.    memset( Ncb, 0, BNCBSIZE ) ;
  1035.    Ncb->basic_ncb.bncb.ncb_command  = NB_CANCEL_WAIT;
  1036.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  1037.    Ncb->basic_ncb.bncb.ncb_buffer_address = (address)NcbToCancel;
  1038.  
  1039.    if(Netbeui)
  1040.      {
  1041.      (*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  1042.      } /* end if */
  1043.    else
  1044.      {
  1045.      (*netbios)(Ncb );
  1046.      }
  1047.  
  1048.    return (Ncb->basic_ncb.bncb.ncb_retcode);
  1049. }
  1050.  
  1051. /**********************************************************************/
  1052. /*
  1053. ** NCBStatus  
  1054. **
  1055. **              Accepts the adapter number and a ptr to the NCB to cancel.
  1056. **
  1057. **              Returns the NCB return code.
  1058. */
  1059.  
  1060. USHORT NCBStatus(BOOL Netbeui, PNCB Ncb, USHORT lana, PBYTE callname,
  1061.    PSTATUSINFO pInfo, word length, BOOL wait )
  1062. {
  1063. int rc;
  1064.  ;
  1065.    memset( Ncb, 0, BNCBSIZE ) ;
  1066.    Ncb->basic_ncb.bncb.ncb_command  = (wait)?NB_STATUS_WAIT:NB_STATUS;
  1067.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  1068.    strncpy( Ncb->basic_ncb.bncb.ncb_callname, callname, NETBIOS_NAME_LEN );
  1069.    Ncb->basic_ncb.bncb.ncb_buffer_address = (PBYTE) pInfo;
  1070.    Ncb->basic_ncb.bncb.ncb_length   = length;
  1071.  
  1072.    if ( Netbeui )
  1073.    {
  1074.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  1075.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  1076.    } else {
  1077.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  1078.          (address)((!wait)?ncbpost:NULL);
  1079.    }
  1080.  
  1081.    if(!wait)
  1082.      rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore);
  1083.  
  1084.    if(Netbeui)
  1085.      {
  1086.      rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  1087.      } /* end if */
  1088.    else
  1089.      {
  1090.      rc=(*netbios)(Ncb );
  1091.      }
  1092.  
  1093.    return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  1094. }
  1095.  
  1096. USHORT NCBSessionStatus(BOOL Netbeui, PNCB Ncb, USHORT lana, PBYTE lclname,
  1097.    PSESSIONINFO pInfo, word length, BOOL wait )
  1098. {
  1099. int rc;
  1100.  ;
  1101.    memset( Ncb, 0, BNCBSIZE ) ;
  1102.    Ncb->basic_ncb.bncb.ncb_command  =
  1103.                      (wait)?NB_SESSION_STATUS_WAIT:NB_SESSION_STATUS;
  1104.    Ncb->basic_ncb.bncb.ncb_lana_num = lana;
  1105.    strncpy( Ncb->basic_ncb.bncb.ncb_name, lclname, NETBIOS_NAME_LEN );
  1106.    Ncb->basic_ncb.bncb.ncb_buffer_address = (PBYTE) pInfo;
  1107.    Ncb->basic_ncb.bncb.ncb_length   = length;
  1108.  
  1109.    if ( Netbeui )
  1110.    {
  1111.       Ncb->basic_ncb.bncb.off44.ncb_post_handle=
  1112.          ((!wait)?Ncb->basic_ncb.ncb_semaphore:0L);
  1113.    } else {
  1114.       Ncb->basic_ncb.bncb.off44.ncb_post_address=
  1115.          (address)((!wait)?ncbpost:NULL);
  1116.    }
  1117.  
  1118.    if(!wait)
  1119.      rc= Dos16SemSet(Ncb->basic_ncb.ncb_semaphore);
  1120.  
  1121.    if(Netbeui)
  1122.      {
  1123.      rc=(*netbios_Submit)(Netbeui_Handle[lana],0,Ncb);
  1124.      } /* end if */
  1125.    else
  1126.      {
  1127.      rc=(*netbios)(Ncb );
  1128.      }
  1129.  
  1130.    return (wait)?Ncb->basic_ncb.bncb.ncb_retcode:rc;
  1131. }
  1132.  
  1133. #endif /* CK_NETBIOS */
  1134.