home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c004 / 4.ddi / NETBIOS / CTNBIOS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-18  |  4.5 KB  |  232 lines

  1. /*
  2.  *    netbios version of c-tree
  3.  *    netbios functions common to server and application interface
  4.  *
  5.  *    This program is the CONFIDENTIAL and PROPRIETARY property 
  6.  *    of FairCom(R) Corporation. Any unauthorized use, reproduction or
  7.  *    transfer of this program is strictly prohibited.
  8.  *
  9.  *      Copyright (c) 1987, 1988, 1989 FairCom Corporation
  10.  *    (Subject to limited distribution and
  11.  *     restricted disclosure only.)
  12.  *    *** ALL RIGHTS RESERVED ***
  13.  *
  14.  *    4006 West Broadway
  15.  *    Columbia, MO 65203
  16.  *
  17.  *
  18.  *    c-tree(R)    Version 4.3
  19.  *            Release C
  20.  *            February 7, 1989 17:30
  21.  *
  22.  */
  23.  
  24. /*
  25.  * notes: names passed to these functions should be 16 chars long
  26.  * (except for the special name "*").
  27.  *
  28.  * do_nb() is called to actually do the int 5c.  it is implemented
  29.  * differently for server (in ctstsr) and application (ctamsg).
  30.  */
  31.  
  32. #include "ctstdr.h"
  33. #include "ctnbio.h"
  34.  
  35. extern UCOUNT far do_nb(NCB far *);
  36.  
  37. /*
  38.  * installed check
  39.  */
  40.  
  41. /* returns 0 if installed */
  42.  
  43. UCOUNT nb_install_check()
  44. {
  45.     NCB ncb;
  46.     ULONG far * bp;
  47.  
  48.     memset(&ncb,0,sizeof(NCB));
  49.     ncb.cmd = 0xff;
  50.  
  51.     bp = (ULONG far *) (0x5c * 4);
  52.     if (!*bp || NERRbadcmd != do_nb((NCB far *)&ncb))
  53.         return -1;
  54.     else
  55.         return 0;
  56. }
  57.  
  58.  
  59. /*
  60.  * adapter status
  61.  */
  62.  
  63. UCOUNT nb_adapter_stat(ncb, nowait, anr, name, buf, buflen)
  64. NCB              *ncb;
  65. UTEXT                nowait,     *name;
  66. UCOUNT                  (far *anr)();
  67. NB_ASTS                          *buf;
  68. UCOUNT                            buflen;
  69.                     
  70. {
  71.     /* name may be a "*" or NULL to get local stat */
  72.     if (!name || *name == '*')
  73.         ncb->rname[0] = '*';
  74.     else
  75.         cpybuf(ncb->rname, name, 16);
  76.     ncb->bufptr = (UTEXT far *) buf;
  77.     ncb->buflen = buflen;
  78.     ncb->anr = anr;
  79.     ncb->cmd = NCBastatus | nowait;
  80.     return(do_nb((NCB far *)ncb));
  81. }
  82.  
  83. /*
  84.  * add name
  85.  */
  86.  
  87. UCOUNT nb_addname(ncb, nowait, anr, name)
  88. NCB         *ncb;
  89. UTEXT               nowait,     *name;
  90. UCOUNT             (far *anr)();
  91. {
  92.     cpybuf(ncb->lname, name, 16);
  93.     ncb->anr = anr;
  94.     ncb->cmd = NCBaddname | nowait;
  95.     return(do_nb((NCB far *)ncb));
  96. }
  97.  
  98. /*
  99.  * delete name
  100.  */
  101.  
  102. UCOUNT nb_delname(ncb, nowait, anr, name)
  103. NCB         *ncb;
  104. UTEXT               nowait,     *name;
  105. UCOUNT             (far *anr)();
  106. {
  107.     cpybuf(ncb->lname, name, 16);
  108.     ncb->anr = anr;
  109.     ncb->cmd = NCBdelname | nowait;
  110.     return(do_nb((NCB far *)ncb));
  111. }
  112.  
  113. /*
  114.  * listen
  115.  */
  116.  
  117. UCOUNT nb_listen(ncb, nowait, anr, name,  rname, rto, sto)
  118. NCB        *ncb;
  119. UTEXT              nowait,     *name, *rname, rto, sto;
  120. UCOUNT            (far *anr)();
  121. {
  122.     cpybuf(ncb->lname, name, 16);
  123.     /* rname may be a "*" or NULL to listen for anybody */
  124.     if (!rname || *rname == '*')
  125.         ncb->rname[0] = '*';
  126.     else
  127.         cpybuf(ncb->rname, rname, 16);
  128.     ncb->rto = rto;
  129.     ncb->sto = sto;
  130.     ncb->anr = anr;
  131.     ncb->cmd = NCBlisten | nowait;
  132.     return(do_nb((NCB far *)ncb));
  133. }
  134.  
  135. /*
  136.  * call
  137.  */
  138.  
  139. UCOUNT nb_call(ncb, nowait, anr, to,  fr, rto, sto)
  140. NCB          *ncb;
  141. UTEXT            nowait,     *to, *fr, rto, sto;
  142. UCOUNT              (far *anr)();
  143. {
  144.     cpybuf(ncb->lname, fr, 16);
  145.     cpybuf(ncb->rname, to, 16);
  146.     ncb->rto = rto;
  147.     ncb->sto = sto;
  148.     ncb->anr = anr;
  149.     ncb->cmd = NCBcall | nowait;
  150.     return(do_nb((NCB far *)ncb));
  151. }
  152.  
  153.  
  154. /*
  155.  * send
  156.  */
  157.  
  158. UCOUNT nb_send(ncb, nowait, anr, lsn,  msg, msglen)
  159. NCB          *ncb;
  160. UTEXT            nowait,      lsn, *msg;
  161. UCOUNT              (far *anr)(),         msglen;
  162. {
  163.     ncb->lsn = lsn;
  164.     ncb->bufptr = (UTEXT far *) msg;
  165.     ncb->buflen = msglen;
  166.     ncb->anr = anr;
  167.     ncb->cmd = NCBsend | nowait;
  168.     return(do_nb((NCB far *)ncb));
  169. }
  170.  
  171.  
  172. /*
  173.  * receive
  174.  */
  175.  
  176. UCOUNT nb_recv(ncb, nowait, anr, lsn,  msg, maxlen)
  177. NCB          *ncb;
  178. UTEXT            nowait,      lsn, *msg;
  179. UCOUNT              (far *anr)(),         maxlen;
  180. {
  181.     ncb->lsn = lsn;
  182.     ncb->bufptr = (UTEXT far *) msg;
  183.     ncb->buflen = maxlen;
  184.     ncb->anr = anr;
  185.     ncb->cmd = NCBreceive | nowait;
  186.     return(do_nb((NCB far *)ncb));
  187. }
  188.  
  189. /*
  190.  * receive any
  191.  */
  192.  
  193. UCOUNT nb_recvany(ncb, nowait, anr, namenum,  msg, maxlen)
  194. NCB         *ncb;
  195. UTEXT               nowait,      namenum, *msg;
  196. UCOUNT             (far *anr)(),             maxlen;
  197. {
  198.     ncb->namenum = namenum;
  199.     ncb->bufptr = (UTEXT far *) msg;
  200.     ncb->buflen = maxlen;
  201.     ncb->anr = anr;
  202.     ncb->cmd = NCBrecvany | nowait;
  203.     return(do_nb((NCB far *)ncb));
  204. }
  205.  
  206. /*
  207.  * hangup
  208.  */
  209.  
  210. UCOUNT nb_hangup(ncb, nowait, anr, lsn)
  211. NCB        *ncb;
  212. UTEXT              nowait,      lsn;
  213. UCOUNT                (far *anr)();
  214. {
  215.     ncb->lsn = lsn;
  216.     ncb->anr = anr;
  217.     ncb->cmd = NCBhangup | nowait;
  218.     return(do_nb((NCB far *)ncb));
  219. }
  220.  
  221. /*
  222.  * cancel
  223.  */
  224.  
  225. UCOUNT nb_cancel(ncb,  tgtncb)
  226. NCB        *ncb, *tgtncb;
  227. {
  228.     ncb->bufptr = (UTEXT far *) tgtncb;
  229.     ncb->cmd = NCBcancel;
  230.     return(do_nb((NCB far *)ncb));
  231. }
  232.